Package org.apache.zookeeper

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


                // good, expected that
            }
            Stat stat = new Stat();
            // Test basic create, ls, and getData
            LOG.info("Before create /ben");
            zk.create("/ben", "Ben was here".getBytes(), Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
            LOG.info("Before getChildren /");
            List<String> children = zk.getChildren("/", false);
            assertEquals(1, children.size());
            assertEquals("ben", children.get(0));
            String value = new String(zk.getData("/ben", false, stat));
View Full Code Here


                }
                LOG.info("Comment: asseting passed for frog setting /");
            } catch (KeeperException.NoNodeException e) {
                // OK, expected that
            }
            zk.create("/frog", "hi".getBytes(), Ids.OPEN_ACL_UNSAFE,
                    CreateMode.PERSISTENT);
            // the first poll is just a session delivery
            LOG.info("Comment: checking for events length "
                     + watcher.events.size());
            WatchedEvent event = watcher.events.poll(10, TimeUnit.SECONDS);
View Full Code Here

            assertEquals(EventType.NodeCreated, event.getType());
            assertEquals(KeeperState.SyncConnected, event.getState());
            // Test child watch and create with sequence
            zk.getChildren("/ben", true);
            for (int i = 0; i < 10; i++) {
                zk.create("/ben/" + i + "-", Integer.toString(i).getBytes(),
                        Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT_SEQUENTIAL);
            }
            children = zk.getChildren("/ben", false);
            Collections.sort(children);
            assertEquals(10, children.size());
View Full Code Here

        byte data[] = new byte[1024];
        ZooKeeper zk = null;
        try {
            zk = createClient();
            long startTime = System.currentTimeMillis();
            zk.create(path, data, Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
            long baseLatency = System.currentTimeMillis() - startTime;
           
            for(int i = 0; i < 16; i++) {
                startTime = System.currentTimeMillis();
                zk.create(path + '/' + i, data, Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
View Full Code Here

            zk.create(path, data, Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
            long baseLatency = System.currentTimeMillis() - startTime;
           
            for(int i = 0; i < 16; i++) {
                startTime = System.currentTimeMillis();
                zk.create(path + '/' + i, data, Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
                long latency = System.currentTimeMillis() - startTime;
                System.out.println("Latency = " + latency);
                //assertTrue(latency < baseLatency + 10);
                for(int j = 0; j < 1024; j++) {
                    zk.create(path + '/' + i + '/' + j, data, Ids.OPEN_ACL_UNSAFE,
View Full Code Here

                zk.create(path + '/' + i, data, Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
                long latency = System.currentTimeMillis() - startTime;
                System.out.println("Latency = " + latency);
                //assertTrue(latency < baseLatency + 10);
                for(int j = 0; j < 1024; j++) {
                    zk.create(path + '/' + i + '/' + j, data, Ids.OPEN_ACL_UNSAFE,
                            CreateMode.EPHEMERAL, new AsyncCallback.StringCallback() {
                        public void processResult(int rc, String path,
                                Object ctx, String name) {
                        }}, null);
                }
View Full Code Here

    private void utestPrep() throws IOException,
            InterruptedException, KeeperException {
        ZooKeeper zk = new ZooKeeper("127.0.0.1:33221", 30000, this);
        for (int i = 0; i < 10000; i++) {
            zk.create("/" + i, null, Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
        }
        zk.close();
    }

    private void utestGet() throws IOException, InterruptedException, KeeperException {
View Full Code Here

  private void checkRoot() throws IOException,
      InterruptedException {
    ZooKeeper zk = new ZooKeeper(hostPort, 10000, this);

    try {
      zk.create(dirOnZK, null, Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
    } catch (KeeperException.NodeExistsException ke) {
        // expected, sort of
    } catch (KeeperException ke) {
        fail("Unexpected exception code for create " + dirOnZK + ": "
            + ke.getMessage());
View Full Code Here

        fail("Unexpected exception code for create " + dirOnZK + ": "
            + ke.getMessage());
    }

    try {
      zk.create(testDirOnZK, null, Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
    } catch (KeeperException.NodeExistsException ke) {
        // expected, sort of
    } catch (KeeperException ke) {
        fail("Unexpected exception code for create " + testDirOnZK + ": "
            + ke.getMessage());
View Full Code Here

    ZooKeeper zk = new ZooKeeper(hostPort, 10000, this);

    Stat stat = zk.exists(parentName, false);
    if (stat == null) {
      try {
        zk.create(parentName, null, Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
      } catch (KeeperException ke) {
        fail("Creating node " + parentName + ke.getMessage());
      }
    }
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.