Examples of ZNode


Examples of org.apache.helix.store.zk.ZNode

      try
      {
        cache.lockRead();
        for (int i = 0; i < size; i++)
        {
          ZNode zNode = cache.get(serverPaths.get(i));
          if (zNode != null)
          {
            // TODO: shall return a deep copy instead of reference
            records.set(i, (T) zNode.getData());
            readStats.set(i, zNode.getStat());
          }
          else
          {
            needRead = true;
            needReads[i] = true;
View Full Code Here

Examples of org.apache.helix.store.zk.ZNode

    Cache<T> cache = getCache(serverParentPath);
    if (cache != null)
    {
      // System.out.println("zk-cache");
      ZNode znode = cache.get(serverParentPath);

      if (znode != null && znode.getChildSet() != Collections.<String> emptySet())
      {
        // System.out.println("zk-cache-hit: " + parentPath);
        List<String> childNames = new ArrayList<String>(znode.getChildSet());
        Collections.sort(childNames);
        return childNames;
      }
      else
      {
View Full Code Here

Examples of org.apache.helix.store.zk.ZNode

  {
    String parentPath = new File(path).getParent();
    String childName = new File(path).getName();

    addToParentChildSet(parentPath, childName);
    ZNode znode = _cache.get(path);
    if (znode == null)
    {
      _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);
View Full Code Here

Examples of org.apache.helix.store.zk.ZNode

        // we still need to subscribe child change
      }

      // recursively update children nodes if not exists
      // System.out.println("subcribeChildChange: " + path);
      ZNode znode = _cache.get(path);
      List<String> childNames = _accessor.subscribeChildChanges(path, this);
      if (childNames != null && !childNames.isEmpty())
      {
        for (String childName : childNames)
        {
          if (!znode.hasChild(childName))
          {
            String childPath = path + "/" + childName;
            znode.addChild(childName);
            updateRecursive(childPath);
          }
        }
      }
    }
View Full Code Here

Examples of org.apache.helix.store.zk.ZNode

      // 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())
View Full Code Here

Examples of org.apache.helix.store.zk.ZNode

  {
    String parentPath = new File(path).getParent();
    String childName = new File(path).getName();
    addToParentChildSet(parentPath, childName);
   
    ZNode znode = _cache.get(path);
    if (znode == null)
    {
      _cache.put(path, new ZNode(path, data, stat));
    }
    else
    {
      znode.setData(data);
      znode.setStat(stat);
    }
  }
View Full Code Here

Examples of org.apache.helix.store.zk.ZNode

//        znode.setData(readData);
//        znode.setStat(stat);
//      }

      // recursively update children nodes if not exists
      ZNode znode = _cache.get(path);
      List<String> childNames = _accessor.getChildNames(path, 0);
      if (childNames != null && childNames.size() > 0)
      {
        for (String childName : childNames)
        {
          String childPath = path + "/" + childName;
          if (!znode.hasChild(childName))
          {
            znode.addChild(childName);
            updateRecursive(childPath);
          }
        }
      }
    }
View Full Code Here

Examples of org.apache.helix.store.zk.ZNode

    TreeMap<String, ZNode> map = new TreeMap<String, ZNode>();
    map.putAll(cache);

    for (String key : map.keySet())
    {
      ZNode node = map.get(key);
      TreeSet<String> childSet = new TreeSet<String>();
      childSet.addAll(node.getChildSet());
      System.out.print(key + "=" + node.getData() + ", " + childSet + ", "
          + (node.getStat() == null ? "null\n" : node.getStat()));
    }
    System.out.println("END:Print cache");
  }
View Full Code Here

Examples of org.apache.helix.store.zk.ZNode

    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);

      for (String childName : childNames)
      {
        String childPath = path + "/" + childName;
View Full Code Here

Examples of org.apache.helix.store.zk.ZNode

    {
      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);
      map.put(path, node);

      if (childNames != null && !childNames.isEmpty())
      {
        for (String childName : childNames)
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.