public synchronized byte[] getSessionPasswd() { return zk == null ? null : zk.getSessionPasswd(); }
private void expireZooKeeperSession(ZooKeeper zk, int timeout) throws IOException, InterruptedException, KeeperException { final CountDownLatch latch = new CountDownLatch(1); ZooKeeper newZk = new ZooKeeper(zkServers, timeout, new Watcher() { @Override public void process(WatchedEvent event) { if (event.getType() == EventType.None && event.getState() == KeeperState.SyncConnected) { latch.countDown(); } }}, zk.getSessionId(), zk.getSessionPasswd()); if (!latch.await(timeout, TimeUnit.MILLISECONDS)) { throw KeeperException.create(KeeperException.Code.CONNECTIONLOSS); } newZk.close(); }
}, oldZk.getSessionId(), oldZk.getSessionPasswd()); if (!latch.await(timeout, TimeUnit.MILLISECONDS)) { throw KeeperException.create(KeeperException.Code.CONNECTIONLOSS);
String quorumServers = ZKConfig.getZKQuorumServersString(c); ZooKeeper zk = nodeZK.getRecoverableZooKeeper().getZooKeeper(); byte[] password = zk.getSessionPasswd(); long sessionID = zk.getSessionId();
@Override public byte[] getSessionPasswd() { return delegate.getSessionPasswd(); }
@Override public byte[] getSessionPasswd() { return _zk.getSessionPasswd(); }
@Override public byte[] getSessionPasswd() { return delegate.getSessionPasswd(); }
@Override public byte[] getSessionPasswd() { return delegate.getSessionPasswd(); }
public byte[] getSessionPasswd() { return zk.getSessionPasswd(); }
public byte[] getSessionPasswd() { return zooKeeper.getSessionPasswd(); }
public synchronized byte[] getSessionPasswd() { return zk == null ? null : zk.getSessionPasswd(); }
public synchronized byte[] getSessionPasswd() { return zk == null ? null : zk.getSessionPasswd(); }
public synchronized byte[] getSessionPasswd() { return zk == null ? null : zk.getSessionPasswd(); }
public byte[] getSessionPasswd() { return zk.getSessionPasswd(); }
@Override public byte[] getSessionPasswd() { ZooKeeper zkHandle = zk.get(); if (null == zkHandle) { return super.getSessionPasswd(); } return zkHandle.getSessionPasswd(); }
@Override public byte[] getSessionPasswd() { ZooKeeper zkHandle = zk.get(); if (null == zkHandle) { return super.getSessionPasswd(); } return zkHandle.getSessionPasswd(); }
@Override public byte[] getSessionPasswd() { return getDelegate().getSessionPasswd(); }
@Override public byte[] getSessionPasswd() { return getZk().getSessionPasswd(); }
protected void simulateSessionExpiry(ZkConnection zkConnection) throws IOException, InterruptedException { ZooKeeper oldZookeeper = zkConnection.getZookeeper(); LOG.info("Old sessionId = " + oldZookeeper.getSessionId()); Watcher watcher = new Watcher() { @Override public void process(WatchedEvent event) { LOG.info("In New connection, process event:" + event); } }; ZooKeeper newZookeeper = new ZooKeeper(zkConnection.getServers(), oldZookeeper.getSessionTimeout(), watcher, oldZookeeper.getSessionId(), oldZookeeper.getSessionPasswd()); LOG.info("New sessionId = " + newZookeeper.getSessionId()); // Thread.sleep(3000); newZookeeper.close(); Thread.sleep(10000); oldZookeeper = zkConnection.getZookeeper(); LOG.info("After session expiry sessionId = " + oldZookeeper.getSessionId()); }
private void expireZkSession(ZKClientService zkClientService) throws Exception { ZooKeeper zooKeeper = zkClientService.getZooKeeperSupplier().get(); final SettableFuture<?> connectFuture = SettableFuture.create(); Watcher watcher = new Watcher() { @Override public void process(WatchedEvent event) { if (event.getState() == Event.KeeperState.SyncConnected) { connectFuture.set(null); } } }; // Create another Zookeeper session with the same sessionId so that the original one expires. final ZooKeeper dupZookeeper = new ZooKeeper(zkClientService.getConnectString(), zooKeeper.getSessionTimeout(), watcher, zooKeeper.getSessionId(), zooKeeper.getSessionPasswd()); connectFuture.get(30, TimeUnit.SECONDS); Assert.assertEquals("Failed to re-create current session", dupZookeeper.getState(), ZooKeeper.States.CONNECTED); dupZookeeper.close(); }