Java Code Examples for kafka.utils.ZkUtils#createZkClientAndConnection()

The following examples show how to use kafka.utils.ZkUtils#createZkClientAndConnection() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AtlasTopicCreator.java    From atlas with Apache License 2.0 5 votes vote down vote up
@VisibleForTesting
protected ZkUtils createZkUtils(Configuration atlasProperties) {
    String zkConnect = atlasProperties.getString("atlas.kafka.zookeeper.connect");
    int sessionTimeout = atlasProperties.getInt("atlas.kafka.zookeeper.session.timeout.ms", 400);
    int connectionTimeout = atlasProperties.getInt("atlas.kafka.zookeeper.connection.timeout.ms", 200);
    Tuple2<ZkClient, ZkConnection> zkClientAndConnection = ZkUtils.createZkClientAndConnection(
            zkConnect, sessionTimeout, connectionTimeout);
    return new ZkUtils(zkClientAndConnection._1(), zkClientAndConnection._2(), false);
}
 
Example 2
Source File: OperatorUtil.java    From doctorkafka with Apache License 2.0 5 votes vote down vote up
public static ZkUtils getZkUtils(String zkUrl) {
  if (!zkUtilsMap.containsKey(zkUrl)) {
    Tuple2<ZkClient, ZkConnection> zkClientAndConnection =
        ZkUtils.createZkClientAndConnection(zkUrl, 30000, 3000000);

    ZkUtils zkUtils = new ZkUtils(zkClientAndConnection._1(), zkClientAndConnection._2(), true);
    zkUtilsMap.put(zkUrl, zkUtils);
  }
  return zkUtilsMap.get(zkUrl);
}
 
Example 3
Source File: KafkaUtils.java    From doctorkafka with Apache License 2.0 5 votes vote down vote up
public static ZkUtils getZkUtils(String zkUrl) {
  if (!zkUtilsMap.containsKey(zkUrl)) {
    Tuple2<ZkClient, ZkConnection> zkClientAndConnection =
        ZkUtils.createZkClientAndConnection(zkUrl, 30000, 3000000);

    ZkUtils zkUtils = new ZkUtils(zkClientAndConnection._1(), zkClientAndConnection._2(), true);
    zkUtilsMap.put(zkUrl, zkUtils);
  }
  return zkUtilsMap.get(zkUrl);
}
 
Example 4
Source File: AtlasTopicCreator.java    From incubator-atlas with Apache License 2.0 5 votes vote down vote up
@VisibleForTesting
protected ZkUtils createZkUtils(Configuration atlasProperties) {
    String zkConnect = atlasProperties.getString("atlas.kafka.zookeeper.connect");
    int sessionTimeout = atlasProperties.getInt("atlas.kafka.zookeeper.session.timeout.ms", 400);
    int connectionTimeout = atlasProperties.getInt("atlas.kafka.zookeeper.connection.timeout.ms", 200);
    Tuple2<ZkClient, ZkConnection> zkClientAndConnection = ZkUtils.createZkClientAndConnection(
            zkConnect, sessionTimeout, connectionTimeout);
    return new ZkUtils(zkClientAndConnection._1(), zkClientAndConnection._2(), false);
}
 
Example 5
Source File: TestKafkaBroker.java    From ignite with Apache License 2.0 5 votes vote down vote up
/**
 * Sets up ZooKeeper test server.
 *
 * @throws Exception If failed.
 */
private void setupZooKeeper() throws Exception {
    zkServer = new TestingServer(ZK_PORT, true);

    Tuple2<ZkClient, ZkConnection> zkTuple = ZkUtils.createZkClientAndConnection(zkServer.getConnectString(),
        ZK_SESSION_TIMEOUT, ZK_CONNECTION_TIMEOUT);

    zkUtils = new ZkUtils(zkTuple._1(), zkTuple._2(), false);
}