Package org.apache.zookeeper

Examples of org.apache.zookeeper.ZooKeeper.create()


        String[] elements = path.split("/");
        String prefix = "";
        for (int i = 1; i < elements.length - 1; ++i) {
            prefix += "/" + elements[i];
            try {
                zookeeper.create(prefix, null, ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
                LOG.info("created path " + prefix);
            } catch (KeeperException.NodeExistsException exception) {
            }
        }
    }
View Full Code Here


        try {
            LOG.info("setting zookeeper path " + offsetPath + " value " + count);
            // -1 matches any version
            zookeeper.setData(offsetPath, data, -1);
        } catch (KeeperException.NoNodeException exception) {
            zookeeper.create(offsetPath, data, ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
        }
    }

    public void deleteCommittedOffsetTopicCount(String topic) throws Exception {
        ZooKeeper zookeeper = mZookeeperClient.get();
View Full Code Here

        LOG.info("starting up the zookeeper server .. waiting");
        assertTrue("waiting for server being up",
                ClientBase.waitForServerUp(HOSTPORT,CONNECTION_TIMEOUT));
        ZooKeeper zk = new ZooKeeper(HOSTPORT, 20000, this);
        for (int i =0; i < 2000; i++) {
            zk.create("/crctest- " + i , ("/crctest- " + i).getBytes(),
                    Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
        }
        f.shutdown();
        assertTrue("waiting for server down",
                   ClientBase.waitForServerDown(HOSTPORT,
View Full Code Here

                }
            };

            String names[] = new String[10];
            for (int i = 0; i < names.length; i++) {
                String name = zk.create("/tc-", "initialvalue".getBytes(),
                        Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT_SEQUENTIAL);
                names[i] = name;

                Stat stat = new Stat();
                zk.getData(name, watcher, stat);
View Full Code Here

       MyStatCallback cbs[] = new MyStatCallback[COUNT];
       MyWatcher watcher = new MyWatcher();
       int count[] = new int[1];
       TestableZooKeeper zk = createClient(watcher, hostPort);
       ZooKeeper zk2 = createClient(watcher, hostPort);
       zk2.create("/test", new byte[0], Ids.OPEN_ACL_UNSAFE, CreateMode.EPHEMERAL);
       for(int i = 0; i < COUNT/2; i++) {
           watches[i] = new MyWatcher();
           cbs[i] = new MyStatCallback();
           zk.exists("/test", watches[i], cbs[i], count);
       }
View Full Code Here

            opsCount = new CountDownLatch(limit);
            ZooKeeper zk = createClient();
           
            LOG.info("Beginning test:" + (new Date()).toString());
            for(int i = 0; i < 100; i++)
                zk.create("/test" + i, new byte[0], Ids.OPEN_ACL_UNSAFE,
                        CreateMode.PERSISTENT, this, results);
            zk.sync("/test", this, results);
            for(int i = 0; i < 100; i++)
                zk.delete("/test" + i, 0, this, results);
            for(int i = 0; i < 100; i++)
View Full Code Here

                e1.printStackTrace();
                throw new RuntimeException(e1);
            }
            for(int i = 0; i < REPS; i++) {
                try {
                    String name = zk.create("/testFile-", new byte[16], Ids.OPEN_ACL_UNSAFE,
                        CreateMode.EPHEMERAL_SEQUENTIAL);
                    zk.delete(name, -1, new TestHammer(), null);
                } catch(Exception e) {
                    i--;
                    e.printStackTrace();
View Full Code Here

        ZooKeeper zk = new ZooKeeper(HOSTPORT, 20000, this);
        String path;
        LOG.info("starting creating acls");
        for (int i = 0; i < 100; i++) {
            path = "/" + i;
            zk.create(path, path.getBytes(), Ids.OPEN_ACL_UNSAFE,
                    CreateMode.PERSISTENT);
        }
        assertTrue("size of the acl map ", (1 == zks.dataTree.longKeyMap.size()));
        for (int j =100; j < 200; j++) {
            path = "/" + j;
View Full Code Here

            id.setId(j + "");
            id.setScheme("host");
            acl.setId(id);
            ArrayList<ACL> list = new ArrayList<ACL>();
            list.add(acl);
            zk.create(path, path.getBytes(), list, CreateMode.PERSISTENT);
        }
        assertTrue("size of the acl map ", (101 == zks.dataTree.longKeyMap.size()));
        // now shutdown the server and restart it
        f.shutdown();
        assertTrue("waiting for server down",
View Full Code Here

            id.setId(j + "");
            id.setScheme("host");
            acl.setId(id);
            ArrayList<ACL> list = new ArrayList<ACL>();
            list.add(acl);
            zk.create(path, path.getBytes(), list, CreateMode.PERSISTENT);
        }
        assertTrue("acl map ", (106 == zks.dataTree.longKeyMap.size()));

        f.shutdown();
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.