Search in sources :

Example 21 with ZkClient

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);
}
Also used : ZkClient(org.I0Itec.zkclient.ZkClient) ZookeeperRegistry(com.weibo.api.motan.registry.zookeeper.ZookeeperRegistry) InputStream(java.io.InputStream) Properties(java.util.Properties) URL(com.weibo.api.motan.rpc.URL) Before(org.junit.Before)

Example 22 with 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()));
}
Also used : ZkClient(org.I0Itec.zkclient.ZkClient) ZkUtils(kafka.utils.ZkUtils) ZkConnection(org.I0Itec.zkclient.ZkConnection)

Example 23 with ZkClient

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();
    }
}
Also used : ZkClient(org.I0Itec.zkclient.ZkClient) ZooKeeperStringSerializer(org.apache.flink.streaming.connectors.kafka.testutils.ZooKeeperStringSerializer) ZkUtils(kafka.utils.ZkUtils)

Example 24 with ZkClient

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();
    }
}
Also used : ZkClient(org.I0Itec.zkclient.ZkClient)

Example 25 with ZkClient

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);
}
Also used : ZkClient(org.I0Itec.zkclient.ZkClient) ZkConfig(org.apache.samza.config.ZkConfig)

Aggregations

ZkClient (org.I0Itec.zkclient.ZkClient)31 Properties (java.util.Properties)10 ZkUtils (kafka.utils.ZkUtils)7 KafkaConfig (kafka.server.KafkaConfig)6 ZkConnection (org.I0Itec.zkclient.ZkConnection)6 Before (org.junit.Before)6 IOException (java.io.IOException)5 File (java.io.File)4 InputStream (java.io.InputStream)4 MockTime (kafka.utils.MockTime)4 Time (kafka.utils.Time)4 EmbeddedZookeeper (kafka.zk.EmbeddedZookeeper)3 DateTime (org.joda.time.DateTime)3 PinotHelixResourceManager (com.linkedin.pinot.controller.helix.core.PinotHelixResourceManager)2 URL (com.weibo.api.motan.rpc.URL)2 ISE (io.druid.java.util.common.ISE)2 HashSet (java.util.HashSet)2 TopicExistsException (kafka.common.TopicExistsException)2 TestingServer (org.apache.curator.test.TestingServer)2 KafkaProducer (org.apache.kafka.clients.producer.KafkaProducer)2