Package org.apache.zookeeper.data

Examples of org.apache.zookeeper.data.Stat


    if (cache != null)
    {
      try
      {
        cache.lockWrite();
        Stat setStat = new Stat();
        List<String> pathsCreated = new ArrayList<String>();
        T updateData =
            _baseAccessor.update(serverPath, updater, pathsCreated, setStat, options);
        boolean success = (updateData != null);
        updateCache(cache, pathsCreated, success, serverPath, updateData, setStat);
View Full Code Here


    String serverPath = prependChroot(clientPath);

    Cache<T> cache = getCache(serverPath);
    if (cache != null)
    {
      Stat stat = new Stat();
      ZNode znode = cache.get(serverPath);

      if (znode != null)
      {
        return znode.getStat();
View Full Code Here

    while (!queue.isEmpty())
    {
      Pair pair = queue.removeFirst();
      String path = pair._path;
      DataNode head = dt.getNode(path);
      Stat stat = new Stat();
      byte[] data = null;
      try
      {
        data = dt.getData(path, stat, null);
      } catch (NoNodeException e)
View Full Code Here

  private ZNRecord readZkDataStatAndChild(String zkPath, ZkClient zkClient)
  {
    ZNRecord result = null;

    // read data and stat
    Stat stat = new Stat();
    ZNRecord data = zkClient.readDataAndStat(zkPath, stat, true);
    if (data != null)
    {
      result = data;
    }
    else
    {
      result = new ZNRecord("");
    }
    result.setSimpleField("zkPath", zkPath);
    result.setSimpleField("stat", stat.toString());
    result.setSimpleField("numChildren", "" + stat.getNumChildren());
    result.setSimpleField("ctime", "" + new Date(stat.getCtime()));
    result.setSimpleField("mtime", "" + new Date(stat.getMtime()));
    result.setSimpleField("dataLength", "" + stat.getDataLength());

    // read childrenList
    List<String> children = zkClient.getChildren(zkPath);
    if (children != null && children.size() > 0)
    {
View Full Code Here

      _cache.put(path, new ZNode(path, data, stat));
      fireEvents(path, EventType.NodeCreated);
    }
    else
    {
      Stat oldStat = znode.getStat();

      znode.setData(data);
      znode.setStat(stat);
      // System.out.println("\t\t--setData. path: " + path + ", data: " + data);

      if (oldStat.getCzxid() != stat.getCzxid())
      {
        fireEvents(path, EventType.NodeDeleted);
        fireEvents(path, EventType.NodeCreated);
      }
      else if (oldStat.getVersion() != stat.getVersion())
      {
        // System.out.println("\t--fireNodeChanged: " + path + ", oldVersion: " +
        // oldStat.getVersion() + ", newVersion: " + stat.getVersion());
        fireEvents(path, EventType.NodeDataChanged);
      }
View Full Code Here

      {
        // subscribe changes before read
        _accessor.subscribeDataChanges(path, this);

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

        update(path, readData, stat);
      }
      catch (ZkNoNodeException e)
View Full Code Here

    try
    {
      _lock.writeLock().lock();

      // TODO: optimize it by get stat from callback
      Stat stat = new Stat();
      Object readData =
          _accessor.get(dataPath, stat, AccessOption.THROW_EXCEPTION_IFNOTEXIST);

      ZNode znode = _cache.get(dataPath);
      if (znode != null)
      {
        Stat oldStat = znode.getStat();

        // System.out.println("handleDataChange: " + dataPath + ", data: " + data);
        // System.out.println("handleDataChange: " + dataPath + ", oldCzxid: " +
        // oldStat.getCzxid() + ", newCzxid: " + stat.getCzxid()
        // + ", oldVersion: " + oldStat.getVersion() + ", newVersion: " +
        // stat.getVersion());
        znode.setData(readData);
        znode.setStat(stat);

        // if create right after delete, and zkCallback comes after create
        // no DataDelete() will be fired, instead will fire 2 DataChange()
        // see ZkClient.fireDataChangedEvents()
        if (oldStat.getCzxid() != stat.getCzxid())
        {
          fireEvents(dataPath, EventType.NodeDeleted);
          fireEvents(dataPath, EventType.NodeCreated);
        }
        else if (oldStat.getVersion() != stat.getVersion())
        {
          // System.out.println("\t--fireNodeChanged: " + dataPath + ", oldVersion: " +
          // oldStat.getVersion() + ", newVersion: " + stat.getVersion());
          fireEvents(dataPath, EventType.NodeDataChanged);
        }
View Full Code Here

  private ZNRecord readZkChild(String zkPath, ZkClient zkClient)
  {
    ZNRecord result = null;

    // read data and stat
    Stat stat = new Stat();
    ZNRecord data = zkClient.readDataAndStat(zkPath, stat, true);
    if (data != null)
    {
      result = data;
    }
View Full Code Here

  void testGetStat()
  {
    String path = "/tmp/getStatTest";
    _zkClient.deleteRecursive(path);

    Stat stat, newStat;
    stat = _zkClient.getStat(path);
    AssertJUnit.assertNull(stat);
    _zkClient.createPersistent(path, true);

    stat = _zkClient.getStat(path);
View Full Code Here

    List<ZNRecord> childRecords = new ArrayList<ZNRecord>();
    for (String child : children)
    {
      String childPath = path + "/" + child;
      Stat newStat = new Stat();
      ZNRecord record = client.readDataAndStat(childPath, newStat, true);
      if (record != null)
      {
        record.setVersion(newStat.getVersion());
        record.setCreationTime(newStat.getCtime());
        record.setModifiedTime(newStat.getMtime());
        childRecords.add(record);
      }
    }
    return childRecords;
  }
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.