public long getSessionTimeout() { ZooKeeper current = zk; if (current != null) { return current.getSessionTimeout(); } return -1; }
public long getSessionTimeout() { ZooKeeper current = zk; if (current != null) { return current.getSessionTimeout(); } return -1; }
private void verifySessionTimeOut(int sessionTimeout, int expectedSessionTimeout, String HOSTPORT) throws IOException, KeeperException, InterruptedException { clientConnected = new CountDownLatch(1); ZooKeeper zk = new ZooKeeper(HOSTPORT, sessionTimeout, this); Assert.assertTrue("Failed to establish zkclient connection!", clientConnected.await(sessionTimeout, TimeUnit.MILLISECONDS)); Assert.assertEquals("Not able to configure the sessionTimeout values", expectedSessionTimeout, zk.getSessionTimeout()); zk.close(); }
/** * String representation of this ZooKeeper client. Suitable for things * like logging. * * Do NOT count on the format of this string, it may change without * warning. * * @since 3.3.0 */ @Override public String toString() { States state = getState(); return ("State:" + state.toString() + (state.isConnected() ? " Timeout:" + getSessionTimeout() + " " : " ") + cnxn); }
/** * String representation of this ZooKeeper client. Suitable for things * like logging. * * Do NOT count on the format of this string, it may change without * warning. * * @since 3.3.0 */ @Override public String toString() { States state = getState(); return ("State:" + state.toString() + (state.isConnected() ? " Timeout:" + getSessionTimeout() + " " : " ") + cnxn); }
@Override public int getNegotiatedSessionTimeoutMs() { return (zooKeeperHandle != null) ? zooKeeperHandle.getSessionTimeout() : 0; } };
public long getSessionTimeout() { ZooKeeper current = zk; if (current != null) { return current.getSessionTimeout(); } return -1; }
@Override public int getSessionTimeout() { return delegate.getSessionTimeout(); }
@Override public int getSessionTimeout() { return _zk.getSessionTimeout(); }
@Override public int getSessionTimeout() { return delegate.getSessionTimeout(); }
@Override public int getSessionTimeout() { return delegate.getSessionTimeout(); }
public int getSessionTimeout() { return zooKeeper.getSessionTimeout(); }
@Override public int getSessionTimeout() { ZooKeeper zkHandle = zk.get(); if (null == zkHandle) { return super.getSessionTimeout(); } return zkHandle.getSessionTimeout(); }
@Override public int getSessionTimeout() { ZooKeeper zkHandle = zk.get(); if (null == zkHandle) { return super.getSessionTimeout(); } return zkHandle.getSessionTimeout(); }
@Override public int getSessionTimeout() { return getZk().getSessionTimeout(); }
@Override public int getSessionTimeout() { return getDelegate().getSessionTimeout(); }
/** * String representation of this ZooKeeper client. Suitable for things * like logging. * * Do NOT count on the format of this string, it may change without * warning. * * @since 3.3.0 */ @Override public String toString() { States state = getState(); return ("State:" + state.toString() + (state == States.CONNECTED ? " Timeout:" + getSessionTimeout() + " " : " ") + cnxn); }
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(); }
/** * expire zk session asynchronously * @param client * @throws Exception */ public static void asyncExpireSession(HelixZkClient client) throws Exception { final ZkClient zkClient = (ZkClient) client; ZkConnection connection = ((ZkConnection) zkClient.getConnection()); ZooKeeper curZookeeper = connection.getZookeeper(); LOG.info("Before expiry. sessionId: " + Long.toHexString(curZookeeper.getSessionId())); Watcher watcher = new Watcher() { @Override public void process(WatchedEvent event) { LOG.info("Process watchEvent: " + event); } }; final ZooKeeper dupZookeeper = new ZooKeeper(connection.getServers(), curZookeeper.getSessionTimeout(), watcher, curZookeeper.getSessionId(), curZookeeper.getSessionPasswd()); // wait until connected, then close while (dupZookeeper.getState() != States.CONNECTED) { Thread.sleep(10); } dupZookeeper.close(); connection = (ZkConnection) zkClient.getConnection(); curZookeeper = connection.getZookeeper(); // System.err.println("zk: " + oldZookeeper); LOG.info("After expiry. sessionId: " + Long.toHexString(curZookeeper.getSessionId())); }