Package org.I0Itec.zkclient

Examples of org.I0Itec.zkclient.ZkClient


    public int getServerPort() {
        return PORT;
    }

    public ZkClient createZkClient() {
        return new ZkClient("localhost:" + PORT);
    }
View Full Code Here


public class Utils {

    private static Logger logger = LoggerFactory.getLogger(Utils.class);

    public static CountDownLatch getReadySignal(String zkString, final String parentPath, final int counts) {
        ZkClient zkClient = new ZkClient(zkString);
        if (zkClient.exists(parentPath)) {
            System.out.println(parentPath + " path exists and will be deleted");
            zkClient.deleteRecursive(parentPath);
        }
        zkClient.createPersistent(parentPath);
        final CountDownLatch signalReady = new CountDownLatch(1);
        zkClient.subscribeChildChanges(parentPath, new IZkChildListener() {

            @Override
            public void handleChildChange(String arg0, List<String> arg1) throws Exception {

                if (parentPath.equals(arg0)) {
View Full Code Here

        DeployAppArgs deployArgs = new DeployAppArgs();

        Tools.parseArgs(deployArgs, args);

        try {
            ZkClient zkClient = new ZkClient(deployArgs.zkConnectionString, deployArgs.timeout);
            zkClient.setZkSerializer(new ZNRecordSerializer());

            URI s4rURI = null;

            if (deployArgs.s4rPath != null) {
                s4rURI = new URI(deployArgs.s4rPath);
View Full Code Here

    private ZkClient client ;
    Map<String, String> brokers ;

    public ZkUtils(String zkConnectString, int sessionTimeout, int connectTimeout) {
        client = new ZkClient(zkConnectString, sessionTimeout, connectTimeout, new StringSerializer() );
        log.info("Connected zk");
    }
View Full Code Here

    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();
        }
    }
View Full Code Here

        // "metamorphosis.testZkConfig", (ManagerListener) null);
        this.zkConfig = new ZKConfig();// DiamondUtils.getZkConfig(this.diamondManager,
        // 10000);
        this.zkConfig.zkConnect = "localhost:2181";
        this.client =
                new ZkClient(this.zkConfig.zkConnect, this.zkConfig.zkSessionTimeoutMs,
                    this.zkConfig.zkConnectionTimeoutMs, new ZkUtils.StringSerializer());
        this.metaZookeeper = new MetaZookeeper(this.client, this.zkConfig.zkRoot);
        this.loadBalanceStrategy = new DefaultLoadBalanceStrategy();
        this.slaveConsumerZooKeeper =
                new SlaveConsumerZooKeeper(this.metaZookeeper, this.remotingClient, this.client, this.zkConfig,
View Full Code Here

            // ȷ���Ƿ�ȫ����ƫ�ɹ�
            final String consumerId = "SamsaMasterBrokerUnitTest";
            final int brokerId = metaBroker.getMetaConfig().getBrokerId();
            // ����consumer�ڵ���Ϣ���Ա�recover
            final String consumersPath = metaBroker.getBrokerZooKeeper().getMetaZookeeper().consumersPath;
            final ZkClient zkClient = metaBroker.getBrokerZooKeeper().getZkClient();
            int consumerIdCounter = 0;
            for (final MessageInfo msgInfo : offsetInfos) {
                final int consumerIndex = consumerIdCounter++;
                final String offsetPath =
                        consumersPath + "/" + consumerId + consumerIndex + "/offsets/" + topic + "/" + brokerId + "-"
                                + msgInfo.partition;
                assertTrue(zkClient.exists(offsetPath));
                final String dataStr = ZkUtils.readDataMaybeNull(zkClient, offsetPath);
                assertNotNull(dataStr);
                final OffsetInfo offsetInfo = SamsaMasterBroker.readOffsetInfo(offsetPath, dataStr);
                System.out.println(msgInfo + "    " + dataStr);
                assertEquals(msgInfo.msgId, offsetInfo.msgId);
                assertEquals(msgInfo.offset, offsetInfo.offset);
            }
            // ȷ�ϵ��������ƫ��0
            final String offsetPath = consumersPath + "/" + consumerId + "/offsets/" + topic + "/" + brokerId + "-" + 4;
            assertTrue(zkClient.exists(offsetPath));
            final String dataStr = ZkUtils.readDataMaybeNull(zkClient, offsetPath);
            assertNotNull(dataStr);
            final OffsetInfo offsetInfo = SamsaMasterBroker.readOffsetInfo(offsetPath, dataStr);
            assertEquals(-1, offsetInfo.msgId);
            assertEquals(0, offsetInfo.offset);
View Full Code Here

        final String consumerId = "SamsaMasterBrokerUnitTest";
        final int brokerId = metaBroker.getMetaConfig().getBrokerId();
        // ����consumer�ڵ���Ϣ���Ա�recover
        final String consumersPath = metaBroker.getBrokerZooKeeper().getMetaZookeeper().consumersPath;
        final Random rand = new Random();
        final ZkClient zkClient = metaBroker.getBrokerZooKeeper().getZkClient();
        ZkUtils.deletePathRecursive(zkClient, consumersPath);
        int consumerIdCounter = 0;
        for (final MessageInfo msgInfo : offsetInfos) {
            final int consumerIndex = consumerIdCounter++;
            final String offsetPath =
View Full Code Here


    private void start(final ZKConfig zkConfig) {
        log.info("Initialize zk client...");
        this.zkClient =
                new ZkClient(zkConfig.zkConnect, zkConfig.zkSessionTimeoutMs, zkConfig.zkConnectionTimeoutMs,
                    new ZkUtils.StringSerializer());
        this.zkClient.subscribeStateChanges(new SessionExpireListener());
        this.metaZookeeper = new MetaZookeeper(this.zkClient, zkConfig.zkRoot);
    }
View Full Code Here

        }
    }


    private ZkClient newZkClient(final ZKConfig zkConfig) throws InitException {
        return new ZkClient(zkConfig.zkConnect, zkConfig.zkSessionTimeoutMs, zkConfig.zkConnectionTimeoutMs,
            new StringSerializer());
    }
View Full Code Here

TOP

Related Classes of org.I0Itec.zkclient.ZkClient

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.