Package org.apache.zookeeper.data

Examples of org.apache.zookeeper.data.Stat


      } else {
        // If region is in offline and split state check the ZKNode
        if (regionInfo.isOffline() && regionInfo.isSplit()) {
          String node = ZKAssign.getNodeName(this.watcher, regionInfo
              .getEncodedName());
          Stat stat = new Stat();
          byte[] data = ZKUtil.getDataNoWatch(this.watcher, node, stat);
          // If znode does not exist dont consider this region
          if (data == null) {
            LOG.debug("Region "+ regionInfo.getRegionNameAsString() + " split is completed. "
                + "Hence need not add to regions list");
View Full Code Here


                        @Override
                        public void eventReceived(CuratorFramework client, CuratorEvent event) throws Exception
                        {
                            if ( event.getType() == CuratorEventType.EXISTS )
                            {
                                Stat stat = client.checkExists().forPath("/yo/yo/yo");
                                Assert.assertNull(stat);

                                client.create().inBackground(event.getContext()).forPath("/what");
                            }
                            else if ( event.getType() == CuratorEventType.CREATE )
View Full Code Here

            client = CuratorFrameworkFactory.newClient(server.getConnectString(), new RetryOneTime(1));
            client.start();

            readBytes = client.getData().forPath("/test");
            Assert.assertEquals(writtenBytes, readBytes);
            Stat    stat = client.checkExists().forPath("/ghost");
            Assert.assertNull(stat);

            String  realPath = client.create().withMode(CreateMode.PERSISTENT_SEQUENTIAL).forPath("/pseq", writtenBytes);
            Assert.assertNotSame(realPath, "/pseq");
View Full Code Here

    // shutdown HBase cluster
    TEST_UTIL.shutdownMiniHBaseCluster();
    // create a RIT node in offline state
    ZooKeeperWatcher zkw = TEST_UTIL.getZooKeeperWatcher();
    ZKAssign.createNodeOffline(zkw, hri, dstName);
    Stat stat = new Stat();
    byte[] data =
        ZKAssign.getDataNoWatch(zkw, hri.getEncodedName(), stat);
    assertTrue(data != null);
    RegionTransition rt = RegionTransition.parseFrom(data);
    assertTrue(rt.getEventType() == EventType.M_ZK_REGION_OFFLINE);
View Full Code Here

      }

      String url = null;
      try {
        // get new URL
        Stat stat = new Stat();
        byte[] urlAsBytes = zk.getData(ZK_MODEL, this, stat);
        int latestVersion = stat.getVersion();

        url = new String(urlAsBytes, Charsets.UTF_8);

        // check for change
        URL modelUrl = new URL(url);
View Full Code Here

                    /* We need only the last portion of this znode */
                    int index = getLocalSuffix();                  
                    if ( index > suffixToZnode.firstKey() )
                    {
                        String pathToCheck = path + "/" + getImmediatelyPrecedingZnode(suffixToZnode, index);
                        Stat stat = zk.exists(pathToCheck, true);
                        if ( stat != null )
                        {
                            logger_.debug("Awaiting my turn ...");
                            condition_.await();
                            logger_.debug("Checking to see if leader is around ...");
View Full Code Here

    }

    private byte[] getData(final String znode) {
        try {
            final Stat stat = zkCurator.checkExists().usingWatcher(this).forPath(znode);
            if (stat != null) {
                return zkCurator.getData().usingWatcher(this).forPath(znode);
            }
        } catch (final Exception e) {
            LOGGER.warn("Zookeeper exception.", e);
View Full Code Here

  }
 
 
  protected static void createNodeIfNotExist(ZooKeeper zk,String path,byte[] data) throws KeeperException, InterruptedException
  {
    Stat node = zk.exists(path, false);
   
    if (node == null)
    {
      zk.create(path,data, Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
    }
View Full Code Here

    }
  }
 
  protected static void updateOrCreateNode(ZooKeeper zk,String path,byte[] data) throws KeeperException, InterruptedException
  {
    Stat node = zk.exists(path, false);
   
    if (node == null)
    {
      zk.create(path,data,Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
    }
View Full Code Here

        org.apache.zookeeper.CreateMode.PERSISTENT);
  }

  public boolean existsNode(CuratorFramework zk, String path, boolean watch)
      throws Exception {
    Stat stat = null;
    if (watch) {
      stat = zk.checkExists().watched()
          .forPath(PathUtils.normalize_path(path));
    } else {
      stat = zk.checkExists().forPath(PathUtils.normalize_path(path));
View Full Code Here

TOP

Related Classes of org.apache.zookeeper.data.Stat

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.