use of org.I0Itec.zkclient.ZkClient in project motan by weibocom.
the class ZkRegistryServiceTest method setUp.
@Before
public void setUp() throws Exception {
Properties properties = new Properties();
InputStream in = EmbeddedZookeeper.class.getResourceAsStream("/zoo.cfg");
properties.load(in);
int port = Integer.parseInt(properties.getProperty("clientPort"));
in.close();
URL zkUrl = new URL("zookeeper", "127.0.0.1", port, "com.weibo.api.motan.registry.RegistryService");
URL clientUrl = new URL(MotanConstants.PROTOCOL_MOTAN, "127.0.0.1", 0, "com.weibo.motan.demoService");
URL url1 = new URL(MotanConstants.PROTOCOL_MOTAN, "127.0.0.1", 8001, service1);
URL url2 = new URL(MotanConstants.PROTOCOL_MOTAN, "127.0.0.1", 8002, service1);
URL url3 = new URL(MotanConstants.PROTOCOL_MOTAN, "127.0.0.1", 8003, service2);
embeddedZookeeper = new EmbeddedZookeeper();
embeddedZookeeper.start();
zkClient = new ZkClient("127.0.0.1:" + port, 5000);
ZookeeperRegistry registry = new ZookeeperRegistry(zkUrl, zkClient);
registry.register(url1);
registry.register(url2);
registry.register(url3);
registry.subscribe(clientUrl, null);
registryService = new ZookeeperRegistryService(zkClient);
}
use of org.I0Itec.zkclient.ZkClient in project opennms by OpenNMS.
the class JUnitKafkaServer method getBrokerMetadatas.
private List<BrokerMetadata> getBrokerMetadatas() {
ZkClient zkClient = new ZkClient(getZookeeperConnectString(), 1000, 1000, ZKStringSerializer$.MODULE$);
ZkUtils zkUtils = new ZkUtils(zkClient, new ZkConnection(getZookeeperConnectString()), false);
return JavaConversions.asJavaList(AdminUtils.getBrokerMetadatas(zkUtils, Enforced$.MODULE$, Option.empty()));
}
use of org.I0Itec.zkclient.ZkClient in project flink by apache.
the class KafkaTestEnvironmentImpl method deleteTestTopic.
@Override
public void deleteTestTopic(String topic) {
ZkUtils zkUtils = getZkUtils();
try {
LOG.info("Deleting topic {}", topic);
ZkClient zk = new ZkClient(zookeeperConnectionString, Integer.valueOf(standardProps.getProperty("zookeeper.session.timeout.ms")), Integer.valueOf(standardProps.getProperty("zookeeper.connection.timeout.ms")), new ZooKeeperStringSerializer());
AdminUtils.deleteTopic(zkUtils, topic);
zk.close();
} finally {
zkUtils.close();
}
}
use of org.I0Itec.zkclient.ZkClient in project presto by prestodb.
the class EmbeddedKafka method createTopics.
public void createTopics(int partitions, int replication, Properties topicProperties, String... topics) {
checkState(started.get() && !stopped.get(), "not started!");
ZkClient zkClient = new ZkClient(getZookeeperConnectString(), 30_000, 30_000, ZKStringSerializer$.MODULE$);
try {
for (String topic : topics) {
AdminUtils.createTopic(zkClient, topic, partitions, replication, topicProperties);
}
} finally {
zkClient.close();
}
}
use of org.I0Itec.zkclient.ZkClient in project samza by apache.
the class ZkCoordinationServiceFactory method getCoordinationService.
// TODO - Why should this method be synchronized?
public synchronized CoordinationUtils getCoordinationService(String groupId, String participantId, Config config) {
ZkConfig zkConfig = new ZkConfig(config);
ZkClient zkClient = createZkClient(zkConfig.getZkConnect(), zkConfig.getZkSessionTimeoutMs(), zkConfig.getZkConnectionTimeoutMs());
// make sure the 'path' exists
createZkPath(zkConfig.getZkConnect(), zkClient);
ZkUtils zkUtils = new ZkUtils(new ZkKeyBuilder(groupId), zkClient, zkConfig.getZkConnectionTimeoutMs());
return new ZkCoordinationUtils(participantId, zkConfig, zkUtils);
}
Aggregations