client.waitUntilConnected(10L, TimeUnit.SECONDS); client.close();
public DynamicBrokerSelector(String zkServers) { ZkClient zkClient = new ZkClient(zkServers); zkClient.setZkSerializer(new BytesPushThroughSerializer()); zkClient.waitUntilConnected(60, TimeUnit.SECONDS); zkClient.subscribeDataChanges(ExternalViewReader.BROKER_EXTERNAL_VIEW_PATH, this); evReader = new ExternalViewReader(zkClient); refresh(); }
client.waitUntilConnected(10L, TimeUnit.SECONDS); client.close();
private void waitForRetry() { if (_operationRetryTimeoutInMillis < 0) { waitUntilConnected(); return; } waitUntilConnected(_operationRetryTimeoutInMillis, TimeUnit.MILLISECONDS); }
public void waitUntilConnected() throws ZkInterruptedException { waitUntilConnected(Integer.MAX_VALUE, TimeUnit.MILLISECONDS); }
public void waitUntilConnected() throws ZkInterruptedException { waitUntilConnected(Integer.MAX_VALUE, TimeUnit.MILLISECONDS); }
/** * {@inheritDoc} */ @Override public void init() { zkClient.waitUntilConnected(zkConfig.getZkConnectionTimeoutMs(), TimeUnit.MILLISECONDS); }
/** * {@inheritDoc} */ @Override public void init() { zkClient.waitUntilConnected(zkConfig.getZkConnectionTimeoutMs(), TimeUnit.MILLISECONDS); }
public void connect() throws ZkInterruptedException { boolean isConnected = zkClient.waitUntilConnected(connectionTimeoutMs, TimeUnit.MILLISECONDS); if (!isConnected) { metrics.zkConnectionError.inc(); throw new RuntimeException("Unable to connect to Zookeeper within connectionTimeout " + connectionTimeoutMs + "ms. Shutting down!"); } }
/** * {@inheritDoc} */ @Override public void init() { zkClient.waitUntilConnected(zkConfig.getZkConnectionTimeoutMs(), TimeUnit.MILLISECONDS); }
public void connect() throws ZkInterruptedException { boolean isConnected = zkClient.waitUntilConnected(connectionTimeoutMs, TimeUnit.MILLISECONDS); if (!isConnected) { metrics.zkConnectionError.inc(); throw new RuntimeException("Unable to connect to Zookeeper within connectionTimeout " + connectionTimeoutMs + "ms. Shutting down!"); } }
public void connect() throws ZkInterruptedException { boolean isConnected = zkClient.waitUntilConnected(connectionTimeoutMs, TimeUnit.MILLISECONDS); if (!isConnected) { metrics.zkConnectionError.inc(); throw new RuntimeException("Unable to connect to Zookeeper within connectionTimeout " + connectionTimeoutMs + "ms. Shutting down!"); } }
/** * {@inheritDoc} */ @Override public void init() { zkClient.waitUntilConnected(zkConfig.getZkConnectionTimeoutMs(), TimeUnit.MILLISECONDS); }
/** * {@inheritDoc} */ @Override public void init() { zkClient.waitUntilConnected(zkConfig.getZkConnectionTimeoutMs(), TimeUnit.MILLISECONDS); }
public void connect() throws ZkInterruptedException { boolean isConnected = zkClient.waitUntilConnected(connectionTimeoutMs, TimeUnit.MILLISECONDS); if (!isConnected) { metrics.zkConnectionError.inc(); throw new RuntimeException("Unable to connect to Zookeeper within connectionTimeout " + connectionTimeoutMs + "ms. Shutting down!"); } }
public void connect() throws ZkInterruptedException { boolean isConnected = zkClient.waitUntilConnected(connectionTimeoutMs, TimeUnit.MILLISECONDS); if (!isConnected) { metrics.zkConnectionError.inc(); throw new RuntimeException("Unable to connect to Zookeeper within connectionTimeout " + connectionTimeoutMs + "ms. Shutting down!"); } }
@Override public boolean validateObject(String key, PooledObject<ZkClient> pooledObject) { return pooledObject.getObject().waitUntilConnected(ZKPOOL_KEEPSTATE_TIME, TimeUnit.MILLISECONDS); }
private static ZkClient fromCurator(CuratorFramework curatorFramework) { // Note: You must initialize the ZkClient with ZKStringSerializer. If you don't, then // createTopic() will only seem to work (it will return without error). The topic will exist in // only ZooKeeper and will be returned when listing topics, but Kafka itself does not create the topic. ZkClient zkClient = new ZkClient(curatorFramework.getZookeeperClient().getCurrentConnectionString(), sessionTimeOutInMs, connectionTimeOutInMs, ZKStringSerializer$.MODULE$); zkClient.waitUntilConnected(); return zkClient; }
@Test public void testSimpleScenario() throws Exception { String connectionString; String host; int port; try (EmbeddedZookeeper zk = new EmbeddedZookeeper()) { connectionString = zk.getConnectionString(); host = zk.getHostAddress(); port = zk.getPort(); Assert.assertEquals(host + ":" + port, connectionString); ZkClient client = new ZkClient(connectionString); try { String path = "/" + UUID.randomUUID().toString(); client.waitUntilConnected(5, TimeUnit.SECONDS); client.create(path, "payload", CreateMode.PERSISTENT); Assert.assertEquals("payload", client.readData(path)); } finally { client.close(); } } //now verify shut down try { new Socket(host, port); Assert.fail("expected to fail"); } catch (ConnectException ignored) { } } }
if (!waitUntilConnected(maxMsToWaitUntilConnected, TimeUnit.MILLISECONDS)) { throw new ZkTimeoutException("Unable to connect to zookeeper server within timeout: " + maxMsToWaitUntilConnected);