Examples of waitForConnected()


Examples of org.apache.activemq.leveldb.replicated.groups.ZKClient.waitForConnected()

    protected void createBrokerCluster(int brokerCount) throws Exception {
        // Store the partitioning in ZK.
        ZKClient zk_client = new ZKClient("localhost:" + connector.getLocalPort(), Timespan.parse("10s"), null);
        try {
            zk_client.start();
            zk_client.waitForConnected(Timespan.parse("30s"));
            try {
                zk_client.delete(zkPath);
            } catch (Throwable e) {
            }
            zk_client.create(zkPath, partitioning.toString(), CreateMode.PERSISTENT);
View Full Code Here

Examples of org.apache.zookeeper.test.ClientBase.CountdownWatcher.waitForConnected()

        Assert.assertTrue("waiting for server being up ", ClientBase
                .waitForServerUp(HOSTPORT, CONNECTION_TIMEOUT));

        CountdownWatcher watcher = new CountdownWatcher();
        ZooKeeper zk = new ZooKeeper(HOSTPORT, CONNECTION_TIMEOUT, watcher);
        watcher.waitForConnected(CONNECTION_TIMEOUT);

        List<String> joiners = new ArrayList<String>();
        joiners.add("server.2=localhost:1234:1235;1236");
        // generate some transactions that will get logged
        try {
View Full Code Here

Examples of org.apache.zookeeper.test.ClientBase.CountdownWatcher.waitForConnected()

         * Reusing the index variable to select a follower to connect to
         */
        index = (index == 1) ? 2 : 1;
        qu.shutdown(index);
        final ZooKeeper zk3 = new DisconnectableZooKeeper("127.0.0.1:" + qu.getPeer(3).peer.getClientPort(), 1000,watcher3);
        watcher3.waitForConnected(CONNECTION_TIMEOUT);
        zk3.create("/mybar", null, ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.EPHEMERAL_SEQUENTIAL);

        qu.restart(index);
        ZooKeeper zk = new DisconnectableZooKeeper("127.0.0.1:" + qu.getPeer(index).peer.getClientPort(), 1000, watcher1);

View Full Code Here

Examples of org.apache.zookeeper.test.ClientBase.CountdownWatcher.waitForConnected()

        ZooKeeper zk2 = new DisconnectableZooKeeper("127.0.0.1:" + qu.getPeer(index).peer.getClientPort(), 1000,watcher2);
        final ZooKeeper zk3 = new DisconnectableZooKeeper("127.0.0.1:" + qu.getPeer(3).peer.getClientPort(), 1000, watcher3);
        watcher1.waitForConnected(CONNECTION_TIMEOUT);
        watcher2.waitForConnected(CONNECTION_TIMEOUT);
        watcher3.waitForConnected(CONNECTION_TIMEOUT);
        zk.create("/first", new byte[0], ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);     
        zk2.create("/mybar", null, ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.EPHEMERAL_SEQUENTIAL);

       
        final AtomicBoolean runNow = new AtomicBoolean(false);
View Full Code Here

Examples of org.apache.zookeeper.test.ClientBase.CountdownWatcher.waitForConnected()

        public void run() {
            try {
                CountdownWatcher watcher = new CountdownWatcher();
                zk = new TestableZooKeeper(qb.hostPort, CONNECTION_TIMEOUT,
                        watcher);
                watcher.waitForConnected(CONNECTION_TIMEOUT);
                while(bang) {
                    incOutstanding(); // before create otw race
                    zk.create("/test-", new byte[0], Ids.OPEN_ACL_UNSAFE,
                            CreateMode.PERSISTENT_SEQUENTIAL, this, null);
                }
View Full Code Here

Examples of org.apache.zookeeper.test.ClientBase.CountdownWatcher.waitForConnected()

            index++;
       
        ZooKeeper zk = new ZooKeeper(
                "127.0.0.1:" + qu.getPeer((index == 1)?2:1).peer.getClientPort(),
                ClientBase.CONNECTION_TIMEOUT, watcher);
        watcher.waitForConnected(CONNECTION_TIMEOUT);
       
        // break the quorum
        qu.shutdown(index);

        // try to reestablish the quorum
View Full Code Here

Examples of org.apache.zookeeper.test.ClientBase.CountdownWatcher.waitForConnected()

            index++;
       
        ZooKeeper zk = new ZooKeeper(
                "127.0.0.1:" + qu.getPeer((index == 1)?2:1).peer.getClientPort(),
                ClientBase.CONNECTION_TIMEOUT, watcher);
        watcher.waitForConnected(CONNECTION_TIMEOUT);
       
        List<OpResult> results = new ArrayList<OpResult>();

        results = zk.multi(Arrays.asList(
                Op.create("/multi0", new byte[0], Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT),
View Full Code Here

Examples of org.apache.zookeeper.test.ClientBase.CountdownWatcher.waitForConnected()

    @Test
    public void testReadOnlyClient() throws Exception {
        CountdownWatcher watcher = new CountdownWatcher();
        ZooKeeper zk = new ZooKeeper(qu.getConnString(), CONNECTION_TIMEOUT,
                watcher, true);
        watcher.waitForConnected(CONNECTION_TIMEOUT); // ensure zk got connected

        final String data = "Data to be read in RO mode";
        final String node = "/tnode";
        zk.create(node, data.getBytes(), ZooDefs.Ids.OPEN_ACL_UNSAFE,
                CreateMode.PERSISTENT);
View Full Code Here

Examples of org.apache.zookeeper.test.ClientBase.CountdownWatcher.waitForConnected()

        zk.create(node, data.getBytes(), ZooDefs.Ids.OPEN_ACL_UNSAFE,
                CreateMode.PERSISTENT);

        watcher.reset();
        qu.shutdown(2);
        watcher.waitForConnected(CONNECTION_TIMEOUT);

        // read operation during r/o mode
        String remoteData = new String(zk.getData(node, false, null));
        Assert.assertEquals(data, remoteData);
View Full Code Here

Examples of org.apache.zookeeper.test.ClientBase.CountdownWatcher.waitForConnected()

        watcher.reset();
        qu.start(2);
        Assert.assertTrue("waiting for server up", ClientBase.waitForServerUp(
                "127.0.0.1:" + qu.getPeer(2).clientPort, CONNECTION_TIMEOUT));
        watcher.waitForConnected(CONNECTION_TIMEOUT);
        zk.setData(node, "We're in the quorum now".getBytes(), -1);

        zk.close();
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.