Package org.apache.zookeeper.data

Examples of org.apache.zookeeper.data.Stat


//      String parentPath = new File(path).getParent();
//      String name = new File(path).getName();
//      addToParentChildSet(parentPath, name);

      // update this node
      Stat stat = new Stat();
      T readData = _accessor.get(path, stat, AccessOption.THROW_EXCEPTION_IFNOTEXIST);

      update(path, readData, stat);
     
//      ZNode znode = _cache.get(path);
View Full Code Here


    // test getStat()
    for (int i = 0; i < 10; i++)
    {
      String msgId = "msg_" + i;
      String path = PropertyPathConfig.getPath(PropertyType.MESSAGES, root, "host_0", msgId);
      Stat stat = accessor.getStat(path, 0);
      Assert.assertNotNull(stat, "Stat should exist");
      Assert.assertEquals(stat.getVersion(), 2, "DataVersion should be 2, since we set 1 and update 1");
    }

    // test sync remove
    for (int i = 0; i < 10; i++)
    {
View Full Code Here

                                     Map<String, ZNode> map,
                                     ZkClient zkclient)
  {
    try
    {
      Stat stat = new Stat();
      ZNRecord record = zkclient.readData(path, stat);
      List<String> childNames = zkclient.getChildren(path);
      ZNode node = new ZNode(path, record, stat);
      node.addChildren(childNames);
      map.put(path, node);
View Full Code Here

                                     Map<String, ZNode> map,
                                     BaseDataAccessor<ZNRecord> zkAccessor)
  {
    try
    {
      Stat stat = new Stat();
      ZNRecord record = zkAccessor.get(path, stat, 0);
      List<String> childNames = zkAccessor.getChildNames(path, 0);
      // System.out.println("childNames: " + childNames);
      ZNode node = new ZNode(path, record, stat);
      node.addChildren(childNames);
View Full Code Here

    {
      retry = false;
      try
      {
        // _zkClient.writeData(path, record);
        Stat setStat = _zkClient.writeDataGetStat(path, record, expectVersion);
        if (setstat != null)
          DataTree.copyStat(setStat, setstat);
      }
      catch (ZkNoNodeException e)
      {
View Full Code Here

    do
    {
      retry = false;
      try
      {
        Stat readStat = new Stat();
        T oldData = (T) _zkClient.readData(path, readStat);
        T newData = updater.update(oldData);
        Stat setStat = _zkClient.writeDataGetStat(path, newData, readStat.getVersion());
        if (stat != null)
        {
          DataTree.copyStat(setStat, stat);
        }
View Full Code Here

          }
          String path = paths.get(i);
          DataUpdater<T> updater = updaters.get(i);
          T newData = updater.update(curDataList.get(i));
          newDataList.add(newData);
          Stat curStat = curStats.get(i);
          if (curStat == null)
          {
            // node not exists
            failOnNoNode = true;
            needCreate[i] = true;
          }
          else
          {
            cbList[i] = new SetDataCallbackHandler();
            _zkClient.asyncSetData(path, newData, curStat.getVersion(), cbList[i]);
          }
        }

        // wait for completion
        boolean failOnBadVersion = false;
View Full Code Here

    String path = key.getPath();
    int options = constructOptions(type);
    ZNRecord record = null;
    try
    {
      Stat stat = new Stat();
      record = _baseDataAccessor.get(path, stat, options);
      if (record != null)
      {
        record.setCreationTime(stat.getCtime());
        record.setModifiedTime(stat.getMtime());
      }
    }
    catch (ZkNoNodeException e)
    {
      // OK
View Full Code Here

            retryOrThrow(retryCounter, e, "setData");
            break;
          case BADVERSION:
            // try to verify whether the previous setData success or not
            try{
              Stat stat = new Stat();
              byte[] revData = checkZk().getData(path, false, stat);
              if (Bytes.equals(revData, newData)) {
                // the bad version is caused by previous successful setData
                return stat;
              }
View Full Code Here

    List<String> nodes = checkZk().getChildren(parent, false);
    List<String> matching = filterByPrefix(nodes, nodePrefix);
    for (String node : matching) {
      String nodePath = parent + "/" + node;
      Stat stat = checkZk().exists(nodePath, false);
      if (stat != null) {
        return nodePath;
      }
    }
    return null;
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.