public static ZookeeperClient newInstance(String zkConnString, RetryPolicy retryPolicy) { return new ZookeeperClient(zkConnString, retryPolicy, CuratorFrameworkFactory.newClient(zkConnString, retryPolicy)); }
@Override public void close() throws Exception { zkCli.close(); }
public static ZookeeperClient newInstance(String zkConnString) { return newInstance(zkConnString, DEFAULT_RETRY_POLICY); }
public KafkaBrokersInfo<String> getBrokerInfoFromZk() throws ZookeeperClientException, IOException { final String brokerIdsZkPath = kafkaZkConnection.buildZkRootPath(ZK_RELATIVE_PATH_KAFKA_BROKERS_IDS); final List<String> brokerIds = zkCli.getChildren(brokerIdsZkPath); List<String> brokerInfo = null; if (brokerIds != null) { brokerInfo = new ArrayList<>(); for (String bkId : brokerIds) { final byte[] bytes = zkCli.getData(brokerIdsZkPath + "/" + bkId); brokerInfo.add(new String(bytes, "UTF-8")); } } return KafkaBrokersInfo.fromZk(brokerInfo, getSecurity(), getKafkaBrokerListeners()); }
/** * Creates and starts a {@link ZookeeperClient} connection as part of the object construction process. * The connection must be closed. See {@link KafkaMetadataService} */ public static KafkaMetadataService newInstance( EnvironmentService environmentService, Long clusterId, SecurityContext securityContext) throws ServiceConfigurationNotFoundException, IOException, ServiceNotFoundException, ServiceComponentNotFoundException { final KafkaZkConnection kafkaZkConnection = KafkaZkConnection.newInstance( getZkStringRaw(environmentService, clusterId, AMBARI_JSON_CONFIG_KAFKA_BROKER)); final ZookeeperClient zkCli = ZookeeperClient.newInstance(kafkaZkConnection); zkCli.start(); return new KafkaMetadataService(zkCli, kafkaZkConnection, securityContext, getKafkaBrokerComponent(environmentService, clusterId), getKafkaBrokers(environmentService, clusterId), getServiceConfig(environmentService, clusterId, AMBARI_JSON_CONFIG_KAFKA_BROKER), getServiceConfig(environmentService, clusterId, AMBARI_JSON_CONFIG_KAFKA_ENV)); }
public List<String> getChildren(ZkPathFactory zkPathFactory) throws ZookeeperClientException { return getChildren(zkPathFactory.createPath()); }
public Stat setData(ZkPathFactory zkPathFactory, byte[] data) throws ZookeeperClientException { return setData(zkPathFactory.createPath(), data); }
public String createPath(ZkPathFactory zkPathFactory) throws ZookeeperClientException { return createPath(zkPathFactory.createPath()); }
public byte[] getData(ZkPathFactory zkPathFactory) throws ZookeeperClientException { return getData(zkPathFactory.createPath()); }
public KafkaTopics getTopicsFromZk() throws ZookeeperClientException, IOException { final Security security = getSecurity(); final List<String> topics = zkCli.getChildren(kafkaZkConnection.buildZkRootPath(ZK_RELATIVE_PATH_KAFKA_TOPICS)); return topics == null ? new KafkaTopics(Collections.emptyList(), security) : new KafkaTopics(topics, security); }
public KafkaBrokersInfo<KafkaBrokersInfo.BrokerId> getBrokerIdsFromZk() throws ZookeeperClientException, IOException { final List<String> brokerIds = zkCli.getChildren(kafkaZkConnection.buildZkRootPath(ZK_RELATIVE_PATH_KAFKA_BROKERS_IDS)); return KafkaBrokersInfo.brokerIds(brokerIds, getSecurity(), getKafkaBrokerListeners()); }
public static ZookeeperClient newInstance(ZkConnectionStringFactory zkConnStrFactory) { return newInstance(zkConnStrFactory.createZkConnString(), DEFAULT_RETRY_POLICY); }
public static ZookeeperClient newInstance(ZkConnectionStringFactory zkConnStrFactory, RetryPolicy retryPolicy) { return newInstance(zkConnStrFactory.createZkConnString(), retryPolicy); }