Examples of ZNode


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

      T readData = _accessor.get(path, stat, AccessOption.THROW_EXCEPTION_IFNOTEXIST);

      update(path, readData, 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);
          }
        }
      }
    } catch (ZkNoNodeException e) {
View Full Code Here

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

    _lock = new ReentrantReadWriteLock();
    _cache = new ConcurrentHashMap<String, ZNode>();
  }

  public void addToParentChildSet(String parentPath, String childName) {
    ZNode znode = _cache.get(parentPath);
    if (znode != null) {
      znode.addChild(childName);
    }
  }
View Full Code Here

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

    }
  }

  public void addToParentChildSet(String parentPath, List<String> childNames) {
    if (childNames != null && !childNames.isEmpty()) {
      ZNode znode = _cache.get(parentPath);
      if (znode != null) {
        znode.addChildren(childNames);
      }
    }
  }
View Full Code Here

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

      }
    }
  }

  public void removeFromParentChildSet(String parentPath, String name) {
    ZNode zNode = _cache.get(parentPath);
    if (zNode != null) {
      zNode.removeChild(name);
    }
  }
View Full Code Here

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

      String parentPath = HelixUtil.getZkParentPath(path);
      String name = HelixUtil.getZkName(path);
      removeFromParentChildSet(parentPath, name);

      ZNode znode = _cache.remove(path);
      if (znode != null) {
        // recursively remove children nodes
        Set<String> childNames = znode.getChildSet();
        for (String childName : childNames) {
          String childPath = path + "/" + childName;
          purgeRecursive(childPath);
        }
      }
View Full Code Here

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

    String serverPath = prependChroot(clientPath);

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

      if (znode != null) {
        // TODO: shall return a deep copy instead of reference
        record = ((T) znode.getData());
        if (stat != null) {
          DataTree.copyStat(znode.getStat(), stat);
        }
        return record;

      } else {
        // if cache miss, fall back to zk and update cache
View Full Code Here

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

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

      } else {
        // if cache miss, fall back to zk and update cache
        try {
          cache.lockWrite();
View Full Code Here

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

    Cache<T> cache = getCache(serverPaths);
    if (cache != null) {
      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

    String serverParentPath = prependChroot(parentPath);

    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 {
        // System.out.println("zk-cache-miss");
        try {
View Full Code Here

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

  public void update(String path, T data, Stat stat) {
    String parentPath = HelixUtil.getZkParentPath(path);
    String childName = HelixUtil.getZkName(path);

    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);
        fireEvents(path, EventType.NodeCreated);
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.