gpt4 book ai didi

org.apache.zookeeper.server.ZooKeeperServer.closeSession()方法的使用及代码示例

转载 作者:知者 更新时间:2024-03-17 05:02:40 27 4
gpt4 key购买 nike

本文整理了Java中org.apache.zookeeper.server.ZooKeeperServer.closeSession()方法的一些代码示例,展示了ZooKeeperServer.closeSession()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZooKeeperServer.closeSession()方法的具体详情如下:
包路径:org.apache.zookeeper.server.ZooKeeperServer
类名称:ZooKeeperServer
方法名:closeSession

ZooKeeperServer.closeSession介绍

暂无

代码示例

代码示例来源:origin: apache/zookeeper

public void terminateSession() {
  try {
    zk.closeSession(sessionId);
  } catch (Exception e) {
    LOG.warn("Unable to closeSession() for session: 0x" 
        + getSessionId(), e);
  }
}

代码示例来源:origin: apache/zookeeper

public void closeSession(ServerCnxn cnxn, RequestHeader requestHeader) {
  closeSession(cnxn.getSessionId());
}

代码示例来源:origin: org.apache.zookeeper/zookeeper

public void terminateSession() {
  try {
    zk.closeSession(sessionId);
  } catch (Exception e) {
    LOG.warn("Unable to closeSession() for session: 0x" 
        + getSessionId(), e);
  }
}

代码示例来源:origin: org.apache.zookeeper/zookeeper

public void closeSession(ServerCnxn cnxn, RequestHeader requestHeader) {
  closeSession(cnxn.getSessionId());
}

代码示例来源:origin: apache/hbase

@Test
public void testSessionExpire() throws Exception {
 assertArrayEquals(DATA, RO_ZK.get(PATH).get());
 ZooKeeper zk = RO_ZK.zookeeper;
 long sessionId = zk.getSessionId();
 UTIL.getZkCluster().getZooKeeperServers().get(0).closeSession(sessionId);
 // should not reach keep alive so still the same instance
 assertSame(zk, RO_ZK.zookeeper);
 byte[] got = RO_ZK.get(PATH).get();
 assertArrayEquals(DATA, got);
 assertNotNull(RO_ZK.zookeeper);
 assertNotSame(zk, RO_ZK.zookeeper);
 assertNotEquals(sessionId, RO_ZK.zookeeper.getSessionId());
}

代码示例来源:origin: LiveRamp/hank

public static void expireSession(long sessionId){
 server.closeSession(sessionId);
}

代码示例来源:origin: org.apache.hadoop/zookeeper

public void terminateSession() {
  try {
    zk.closeSession(sessionId);
  } catch (Exception e) {
    LOG.warn("Unable to closeSession() for session: 0x" 
        + getSessionId(), e);
  }
}

代码示例来源:origin: org.apache.hadoop/zookeeper

public void closeSession(ServerCnxn cnxn, RequestHeader requestHeader) {
  closeSession(cnxn.getSessionId());
}

代码示例来源:origin: com.twitter.common/zookeeper-testing

/**
 * Expires the active session for the given client.  The client should be one returned from
 * {@link #createClient}.
 *
 * @param zkClient the client to expire
 * @throws ZooKeeperClient.ZooKeeperConnectionException if a problem is encountered connecting to
 *    the local zk server while trying to expire the session
 * @throws InterruptedException if interrupted while requesting expiration
 */
public final void expireClientSession(ZooKeeperClient zkClient)
  throws ZooKeeperClient.ZooKeeperConnectionException, InterruptedException {
 zooKeeperServer.closeSession(zkClient.get().getSessionId());
}

代码示例来源:origin: ch.cern.hadoop/hadoop-common

/**
 * Expire the ZK session of the given service. This requires
 * (and asserts) that the given service be the current active.
 * @throws NoNodeException if no service holds the lock
 */
public void expireActiveLockHolder(int idx)
  throws NoNodeException {
 Stat stat = new Stat();
 byte[] data = zks.getZKDatabase().getData(
   DummyZKFC.LOCK_ZNODE, stat, null);
 
 assertArrayEquals(Ints.toByteArray(svcs[idx].index), data);
 long session = stat.getEphemeralOwner();
 LOG.info("Expiring svc " + idx + "'s zookeeper session " + session);
 zks.closeSession(session);
}

代码示例来源:origin: com.github.jiayuhan-it/hadoop-common

/**
 * Expire the ZK session of the given service. This requires
 * (and asserts) that the given service be the current active.
 * @throws NoNodeException if no service holds the lock
 */
public void expireActiveLockHolder(int idx)
  throws NoNodeException {
 Stat stat = new Stat();
 byte[] data = zks.getZKDatabase().getData(
   DummyZKFC.LOCK_ZNODE, stat, null);
 
 assertArrayEquals(Ints.toByteArray(svcs[idx].index), data);
 long session = stat.getEphemeralOwner();
 LOG.info("Expiring svc " + idx + "'s zookeeper session " + session);
 zks.closeSession(session);
}

代码示例来源:origin: ch.cern.hadoop/hadoop-common

/**
 * Randomly expire the ZK sessions of the two ZKFCs. This differs
 * from the above test in that it is not a controlled failover -
 * we just do random expirations and expect neither one to ever
 * generate fatal exceptions.
 */
@Test(timeout=(STRESS_RUNTIME_SECS + EXTRA_TIMEOUT_SECS) * 1000)
public void testRandomExpirations() throws Exception {
 cluster.start();
 long st = Time.now();
 long runFor = STRESS_RUNTIME_SECS * 1000;
 Random r = new Random();
 while (Time.now() - st < runFor) {
  cluster.getTestContext().checkException();
  int targetIdx = r.nextInt(2);
  ActiveStandbyElector target = cluster.getElector(targetIdx);
  long sessId = target.getZKSessionIdForTests();
  if (sessId != -1) {
   LOG.info(String.format("Expiring session %x for svc %d",
     sessId, targetIdx));
   getServer(serverFactory).closeSession(sessId);
  }
  Thread.sleep(r.nextInt(300));
 }
}

代码示例来源:origin: com.github.jiayuhan-it/hadoop-common

/**
 * Randomly expire the ZK sessions of the two ZKFCs. This differs
 * from the above test in that it is not a controlled failover -
 * we just do random expirations and expect neither one to ever
 * generate fatal exceptions.
 */
@Test(timeout=(STRESS_RUNTIME_SECS + EXTRA_TIMEOUT_SECS) * 1000)
public void testRandomExpirations() throws Exception {
 cluster.start();
 long st = Time.now();
 long runFor = STRESS_RUNTIME_SECS * 1000;
 Random r = new Random();
 while (Time.now() - st < runFor) {
  cluster.getTestContext().checkException();
  int targetIdx = r.nextInt(2);
  ActiveStandbyElector target = cluster.getElector(targetIdx);
  long sessId = target.getZKSessionIdForTests();
  if (sessId != -1) {
   LOG.info(String.format("Expiring session %x for svc %d",
     sessId, targetIdx));
   getServer(serverFactory).closeSession(sessId);
  }
  Thread.sleep(r.nextInt(300));
 }
}

代码示例来源:origin: com.aliyun.hbase/alihbase-zookeeper

@Test
public void testSessionExpire() throws Exception {
 assertArrayEquals(DATA, RO_ZK.get(PATH).get());
 ZooKeeper zk = RO_ZK.zookeeper;
 long sessionId = zk.getSessionId();
 UTIL.getZkCluster().getZooKeeperServers().get(0).closeSession(sessionId);
 // should not reach keep alive so still the same instance
 assertSame(zk, RO_ZK.zookeeper);
 byte[] got = RO_ZK.get(PATH).get();
 assertArrayEquals(DATA, got);
 assertNotNull(RO_ZK.zookeeper);
 assertNotSame(zk, RO_ZK.zookeeper);
 assertNotEquals(sessionId, RO_ZK.zookeeper.getSessionId());
}

代码示例来源:origin: org.apache.hbase/hbase-zookeeper

@Test
public void testSessionExpire() throws Exception {
 assertArrayEquals(DATA, RO_ZK.get(PATH).get());
 ZooKeeper zk = RO_ZK.zookeeper;
 long sessionId = zk.getSessionId();
 UTIL.getZkCluster().getZooKeeperServers().get(0).closeSession(sessionId);
 // should not reach keep alive so still the same instance
 assertSame(zk, RO_ZK.zookeeper);
 byte[] got = RO_ZK.get(PATH).get();
 assertArrayEquals(DATA, got);
 assertNotNull(RO_ZK.zookeeper);
 assertNotSame(zk, RO_ZK.zookeeper);
 assertNotEquals(sessionId, RO_ZK.zookeeper.getSessionId());
}

代码示例来源:origin: ch.cern.hadoop/hadoop-common

zks.closeSession(elector.getZKSessionIdForTests());

代码示例来源:origin: com.github.jiayuhan-it/hadoop-common

zks.closeSession(elector.getZKSessionIdForTests());

代码示例来源:origin: ch.cern.hadoop/hadoop-common

zks.closeSession(electors[1].getZKSessionIdForTests());

代码示例来源:origin: com.github.jiayuhan-it/hadoop-common

zks.closeSession(electors[1].getZKSessionIdForTests());

代码示例来源:origin: ch.cern.hadoop/hadoop-common

zkServer.closeSession(electors[1].getZKSessionIdForTests());
zkServer.closeSession(electors[0].getZKSessionIdForTests());

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com