Java 类org.apache.zookeeper.KeeperException.NoNodeException 实例源码

项目:hadoop-oss    文件:ZKDelegationTokenSecretManager.java   
private DelegationKey getKeyFromZK(int keyId) throws IOException {
  String nodePath =
      getNodePath(ZK_DTSM_MASTER_KEY_ROOT, DELEGATION_KEY_PREFIX + keyId);
  try {
    byte[] data = zkClient.getData().forPath(nodePath);
    if ((data == null) || (data.length == 0)) {
      return null;
    }
    ByteArrayInputStream bin = new ByteArrayInputStream(data);
    DataInputStream din = new DataInputStream(bin);
    DelegationKey key = new DelegationKey();
    key.readFields(din);
    return key;
  } catch (KeeperException.NoNodeException e) {
    LOG.error("No node in path [" + nodePath + "]");
  } catch (Exception ex) {
    throw new IOException(ex);
  }
  return null;
}
项目:pai    文件:RequestManager.java   
/**
 * REGION InternalUtils
 */
// Throw NonTransientException to stop AM ASAP, in case the LauncherService or the NodeManager is down,
// which may lead AM process cannot be killed in time.
private void checkAmVersion() throws Exception {
  // LauncherStatus should always exist.
  LauncherStatus launcherStatus;
  try {
    launcherStatus = zkStore.getLauncherStatus();
  } catch (NoNodeException e) {
    throw new NonTransientException(
        "Failed to getLauncherStatus to checkAmVersion, LauncherStatus is already deleted on ZK", e);
  }

  Integer newAmVersion = launcherStatus.getLauncherConfiguration().getAmVersion();
  if (!newAmVersion.equals(conf.getAmVersion())) {
    throw new NonTransientException(String.format(
        "AmVersion mismatch: Local Version %s, Latest Version %s",
        conf.getAmVersion(), newAmVersion));
  }
}
项目:fuck_zookeeper    文件:DataTreeV1.java   
public Stat setData(String path, byte data[], int version, long zxid,
        long time) throws KeeperException.NoNodeException {
    Stat s = new Stat();
    DataNodeV1 n = nodes.get(path);
    if (n == null) {
        throw new KeeperException.NoNodeException();
    }
    synchronized (n) {
        n.data = data;
        n.stat.setMtime(time);
        n.stat.setMzxid(zxid);
        n.stat.setVersion(version);
        n.copyStat(s);
    }
    dataWatches.triggerWatch(path, EventType.NodeDataChanged);
    return s;
}
项目:fuck_zookeeper    文件:DataTreeV1.java   
void killSession(long session) {
    // the list is already removed from the ephemerals
    // so we do not have to worry about synchronyzing on
    // the list. This is only called from FinalRequestProcessor
    // so there is no need for synchornization. The list is not
    // changed here. Only create and delete change the list which
    // are again called from FinalRequestProcessor in sequence.
    HashSet<String> list = ephemerals.remove(session);
    if (list != null) {
        for (String path : list) {
            try {
                deleteNode(path);
                if (LOG.isDebugEnabled()) {
                    LOG.debug("Deleting ephemeral node " + path
                            + " for session 0x"
                            + Long.toHexString(session));
                }
            } catch (NoNodeException e) {
                LOG.warn("Ignoring NoNodeException for path " + path
                        + " while removing ephemeral for dead session 0x"
                        + Long.toHexString(session));
            }
        }
    }
}
项目:fuck_zookeeper    文件:DataTree.java   
public Stat setData(String path, byte data[], int version, long zxid,
        long time) throws KeeperException.NoNodeException {
    Stat s = new Stat();
    DataNode n = nodes.get(path);
    if (n == null) {
        throw new KeeperException.NoNodeException();
    }
    byte lastdata[] = null;
    synchronized (n) {
        lastdata = n.data;
        n.data = data;
        n.stat.setMtime(time);
        n.stat.setMzxid(zxid);
        n.stat.setVersion(version);
        n.copyStat(s);
    }
    // now update if the path is in a quota subtree.
    String lastPrefix;
    if((lastPrefix = getMaxPrefixWithQuota(path)) != null) {
      this.updateBytes(lastPrefix, (data == null ? 0 : data.length)
          - (lastdata == null ? 0 : lastdata.length));
    }
    dataWatches.triggerWatch(path, EventType.NodeDataChanged);
    return s;
}
项目:fuck_zookeeper    文件:DataTree.java   
public List<String> getChildren(String path, Stat stat, Watcher watcher)
        throws KeeperException.NoNodeException {
    DataNode n = nodes.get(path);
    if (n == null) {
        throw new KeeperException.NoNodeException();
    }
    synchronized (n) {
        if (stat != null) {
            n.copyStat(stat);
        }
        ArrayList<String> children;
        Set<String> childs = n.getChildren();
        if (childs != null) {
            children = new ArrayList<String>(childs.size());
            children.addAll(childs);
        } else {
            children = new ArrayList<String>(0);
        }

        if (watcher != null) {
            childWatches.addWatch(path, watcher);
        }
        return children;
    }
}
项目:fuck_zookeeper    文件:DataTree.java   
void killSession(long session, long zxid) {
    // the list is already removed from the ephemerals
    // so we do not have to worry about synchronizing on
    // the list. This is only called from FinalRequestProcessor
    // so there is no need for synchronization. The list is not
    // changed here. Only create and delete change the list which
    // are again called from FinalRequestProcessor in sequence.
    HashSet<String> list = ephemerals.remove(session);
    if (list != null) {
        for (String path : list) {
            try {
                deleteNode(path, zxid);
                if (LOG.isDebugEnabled()) {
                    LOG
                            .debug("Deleting ephemeral node " + path
                                    + " for session 0x"
                                    + Long.toHexString(session));
                }
            } catch (NoNodeException e) {
                LOG.warn("Ignoring NoNodeException for path " + path
                        + " while removing ephemeral for dead session 0x"
                        + Long.toHexString(session));
            }
        }
    }
}
项目:fuck_zookeeper    文件:DataTree.java   
/**
  * This method sets the Cversion and Pzxid for the specified node to the
  * values passed as arguments. The values are modified only if newCversion
  * is greater than the current Cversion. A NoNodeException is thrown if
  * a znode for the specified path is not found.
  *
  * @param path
  *     Full path to the znode whose Cversion needs to be modified.
  *     A "/" at the end of the path is ignored.
  * @param newCversion
  *     Value to be assigned to Cversion
  * @param zxid
  *     Value to be assigned to Pzxid
  * @throws KeeperException.NoNodeException
  *     If znode not found.
  **/
public void setCversionPzxid(String path, int newCversion, long zxid)
    throws KeeperException.NoNodeException {
    if (path.endsWith("/")) {
       path = path.substring(0, path.length() - 1);
    }
    DataNode node = nodes.get(path);
    if (node == null) {
        throw new KeeperException.NoNodeException(path);
    }
    synchronized (node) {
        if(newCversion == -1) {
            newCversion = node.stat.getCversion() + 1;
        }
        if (newCversion > node.stat.getCversion()) {
            node.stat.setCversion(newCversion);
            node.stat.setPzxid(zxid);
        }
    }
}
项目:https-github.com-apache-zookeeper    文件:DataTree.java   
public Stat setData(String path, byte data[], int version, long zxid,
        long time) throws KeeperException.NoNodeException {
    Stat s = new Stat();
    DataNode n = nodes.get(path);
    if (n == null) {
        throw new KeeperException.NoNodeException();
    }
    byte lastdata[] = null;
    synchronized (n) {
        lastdata = n.data;
        n.data = data;
        n.stat.setMtime(time);
        n.stat.setMzxid(zxid);
        n.stat.setVersion(version);
        n.copyStat(s);
    }
    // now update if the path is in a quota subtree.
    String lastPrefix = getMaxPrefixWithQuota(path);
    if(lastPrefix != null) {
      this.updateBytes(lastPrefix, (data == null ? 0 : data.length)
          - (lastdata == null ? 0 : lastdata.length));
    }
    dataWatches.triggerWatch(path, EventType.NodeDataChanged);
    return s;
}
项目:https-github.com-apache-zookeeper    文件:DataTree.java   
public List<String> getChildren(String path, Stat stat, Watcher watcher)
        throws KeeperException.NoNodeException {
    DataNode n = nodes.get(path);
    if (n == null) {
        throw new KeeperException.NoNodeException();
    }
    synchronized (n) {
        if (stat != null) {
            n.copyStat(stat);
        }
        List<String> children=new ArrayList<String>(n.getChildren());

        if (watcher != null) {
            childWatches.addWatch(path, watcher);
        }
        return children;
    }
}
项目:https-github.com-apache-zookeeper    文件:DataTree.java   
void killSession(long session, long zxid) {
    // the list is already removed from the ephemerals
    // so we do not have to worry about synchronizing on
    // the list. This is only called from FinalRequestProcessor
    // so there is no need for synchronization. The list is not
    // changed here. Only create and delete change the list which
    // are again called from FinalRequestProcessor in sequence.
    Set<String> list = ephemerals.remove(session);
    if (list != null) {
        for (String path : list) {
            try {
                deleteNode(path, zxid);
                if (LOG.isDebugEnabled()) {
                    LOG
                            .debug("Deleting ephemeral node " + path
                                    + " for session 0x"
                                    + Long.toHexString(session));
                }
            } catch (NoNodeException e) {
                LOG.warn("Ignoring NoNodeException for path " + path
                        + " while removing ephemeral for dead session 0x"
                        + Long.toHexString(session));
            }
        }
    }
}
项目:https-github.com-apache-zookeeper    文件:DataTree.java   
/**
  * This method sets the Cversion and Pzxid for the specified node to the
  * values passed as arguments. The values are modified only if newCversion
  * is greater than the current Cversion. A NoNodeException is thrown if
  * a znode for the specified path is not found.
  *
  * @param path
  *     Full path to the znode whose Cversion needs to be modified.
  *     A "/" at the end of the path is ignored.
  * @param newCversion
  *     Value to be assigned to Cversion
  * @param zxid
  *     Value to be assigned to Pzxid
  * @throws KeeperException.NoNodeException
  *     If znode not found.
  **/
public void setCversionPzxid(String path, int newCversion, long zxid)
    throws KeeperException.NoNodeException {
    if (path.endsWith("/")) {
       path = path.substring(0, path.length() - 1);
    }
    DataNode node = nodes.get(path);
    if (node == null) {
        throw new KeeperException.NoNodeException(path);
    }
    synchronized (node) {
        if(newCversion == -1) {
            newCversion = node.stat.getCversion() + 1;
        }
        if (newCversion > node.stat.getCversion()) {
            node.stat.setCversion(newCversion);
            node.stat.setPzxid(zxid);
        }
    }
}
项目:kmanager    文件:OffsetGetter.java   
public List<OffsetInfo> processTopic(String group, String topic) throws Exception {
    List<String> partitionIds = null;
    try {
        partitionIds = JavaConversions.seqAsJavaList(ZKUtils.getZKUtilsFromKafka()
                .getChildren(ZkUtils.BrokerTopicsPath() + "/" + topic + "/partitions"));
    } catch (Exception e) {
        if (e instanceof NoNodeException) {
            LOG.warn("Is topic >" + topic + "< exists!", e);
            return null;
        }
    }
    List<OffsetInfo> offsetInfos = new ArrayList<OffsetInfo>();
    OffsetInfo offsetInfo = null;
    if (partitionIds == null) {
        // TODO that topic exists in consumer node but not in topics node?!
        return null;
    }

    for (String partitionId : partitionIds) {
        offsetInfo = processPartition(group, topic, partitionId);
        if (offsetInfo != null) {
            offsetInfos.add(offsetInfo);
        }
    }
    return offsetInfos;
}
项目:ZooKeeper    文件:DataTreeV1.java   
public Stat setData(String path, byte data[], int version, long zxid,
        long time) throws KeeperException.NoNodeException {
    Stat s = new Stat();
    DataNodeV1 n = nodes.get(path);
    if (n == null) {
        throw new KeeperException.NoNodeException();
    }
    synchronized (n) {
        n.data = data;
        n.stat.setMtime(time);
        n.stat.setMzxid(zxid);
        n.stat.setVersion(version);
        n.copyStat(s);
    }
    dataWatches.triggerWatch(path, EventType.NodeDataChanged);
    return s;
}
项目:ZooKeeper    文件:DataTreeV1.java   
void killSession(long session) {
    // the list is already removed from the ephemerals
    // so we do not have to worry about synchronyzing on
    // the list. This is only called from FinalRequestProcessor
    // so there is no need for synchornization. The list is not
    // changed here. Only create and delete change the list which
    // are again called from FinalRequestProcessor in sequence.
    HashSet<String> list = ephemerals.remove(session);
    if (list != null) {
        for (String path : list) {
            try {
                deleteNode(path);
                if (LOG.isDebugEnabled()) {
                    LOG.debug("Deleting ephemeral node " + path
                            + " for session 0x"
                            + Long.toHexString(session));
                }
            } catch (NoNodeException e) {
                LOG.warn("Ignoring NoNodeException for path " + path
                        + " while removing ephemeral for dead session 0x"
                        + Long.toHexString(session));
            }
        }
    }
}
项目:ZooKeeper    文件:DataTree.java   
public Stat setData(String path, byte data[], int version, long zxid,
        long time) throws KeeperException.NoNodeException {
    Stat s = new Stat();
    DataNode n = nodes.get(path);
    if (n == null) {
        throw new KeeperException.NoNodeException();
    }
    byte lastdata[] = null;
    synchronized (n) {
        lastdata = n.data;
        n.data = data;
        n.stat.setMtime(time);
        n.stat.setMzxid(zxid);
        n.stat.setVersion(version);
        n.copyStat(s);
    }
    // now update if the path is in a quota subtree.
    String lastPrefix;
    if((lastPrefix = getMaxPrefixWithQuota(path)) != null) {
      this.updateBytes(lastPrefix, (data == null ? 0 : data.length)
          - (lastdata == null ? 0 : lastdata.length));
    }
    dataWatches.triggerWatch(path, EventType.NodeDataChanged);
    return s;
}
项目:ZooKeeper    文件:DataTree.java   
public List<String> getChildren(String path, Stat stat, Watcher watcher)
        throws KeeperException.NoNodeException {
    DataNode n = nodes.get(path);
    if (n == null) {
        throw new KeeperException.NoNodeException();
    }
    synchronized (n) {
        if (stat != null) {
            n.copyStat(stat);
        }
        List<String> children = new ArrayList<String>(n.getChildren());

        if (watcher != null) {
            childWatches.addWatch(path, watcher);
        }
        return children;
    }
}
项目:ZooKeeper    文件:DataTree.java   
void killSession(long session, long zxid) {
    // the list is already removed from the ephemerals
    // so we do not have to worry about synchronizing on
    // the list. This is only called from FinalRequestProcessor
    // so there is no need for synchronization. The list is not
    // changed here. Only create and delete change the list which
    // are again called from FinalRequestProcessor in sequence.
    HashSet<String> list = ephemerals.remove(session);
    if (list != null) {
        for (String path : list) {
            try {
                deleteNode(path, zxid);
                if (LOG.isDebugEnabled()) {
                    LOG
                            .debug("Deleting ephemeral node " + path
                                    + " for session 0x"
                                    + Long.toHexString(session));
                }
            } catch (NoNodeException e) {
                LOG.warn("Ignoring NoNodeException for path " + path
                        + " while removing ephemeral for dead session 0x"
                        + Long.toHexString(session));
            }
        }
    }
}
项目:ZooKeeper    文件:DataTree.java   
/**
  * This method sets the Cversion and Pzxid for the specified node to the
  * values passed as arguments. The values are modified only if newCversion
  * is greater than the current Cversion. A NoNodeException is thrown if
  * a znode for the specified path is not found.
  *
  * @param path
  *     Full path to the znode whose Cversion needs to be modified.
  *     A "/" at the end of the path is ignored.
  * @param newCversion
  *     Value to be assigned to Cversion
  * @param zxid
  *     Value to be assigned to Pzxid
  * @throws KeeperException.NoNodeException
  *     If znode not found.
  **/
public void setCversionPzxid(String path, int newCversion, long zxid)
    throws KeeperException.NoNodeException {
    if (path.endsWith("/")) {
       path = path.substring(0, path.length() - 1);
    }
    DataNode node = nodes.get(path);
    if (node == null) {
        throw new KeeperException.NoNodeException(path);
    }
    synchronized (node) {
        if(newCversion == -1) {
            newCversion = node.stat.getCversion() + 1;
        }
        if (newCversion > node.stat.getCversion()) {
            node.stat.setCversion(newCversion);
            node.stat.setPzxid(zxid);
        }
    }
}
项目:ditb    文件:AssignmentManager.java   
private boolean deleteNodeInStates(String encodedName,
    String desc, ServerName sn, EventType... types) {
  try {
    for (EventType et: types) {
      if (ZKAssign.deleteNode(watcher, encodedName, et, sn)) {
        return true;
      }
    }
    LOG.info("Failed to delete the " + desc + " node for "
      + encodedName + ". The node type may not match");
  } catch (NoNodeException e) {
    if (LOG.isDebugEnabled()) {
      LOG.debug("The " + desc + " node for " + encodedName + " already deleted");
    }
  } catch (KeeperException ke) {
    server.abort("Unexpected ZK exception deleting " + desc
      + " node for the region " + encodedName, ke);
  }
  return false;
}
项目:ditb    文件:ZKDataMigrator.java   
private void checkAndMigrateQueuesToPB(ZooKeeperWatcher zkw, String znode, String rs)
    throws KeeperException, NoNodeException, InterruptedException {
  String rsPath = ZKUtil.joinZNode(znode, rs);
  List<String> peers = ZKUtil.listChildrenNoWatch(zkw, rsPath);
  if (peers == null || peers.isEmpty()) return;
  String peerPath = null;
  for (String peer : peers) {
    peerPath = ZKUtil.joinZNode(rsPath, peer);
    List<String> files = ZKUtil.listChildrenNoWatch(zkw, peerPath);
    if (files == null || files.isEmpty()) continue;
    String filePath = null;
    for (String file : files) {
      filePath = ZKUtil.joinZNode(peerPath, file);
      byte[] data = ZKUtil.getData(zkw, filePath);
      if (data == null || Bytes.equals(data, HConstants.EMPTY_BYTE_ARRAY)) continue;
      if (ProtobufUtil.isPBMagicPrefix(data)) continue;
      ZKUtil.setData(zkw, filePath,
        ZKUtil.positionToByteArray(Long.parseLong(Bytes.toString(data))));
    }
  }
}
项目:ditb    文件:ZKDataMigrator.java   
private void checkAndMigratePeerZnodesToPB(ZooKeeperWatcher zkw, String znode,
    List<String> peers) throws KeeperException, NoNodeException, InterruptedException {
  for (String peer : peers) {
    String peerZnode = ZKUtil.joinZNode(znode, peer);
    byte[] data = ZKUtil.getData(zkw, peerZnode);
    if (!ProtobufUtil.isPBMagicPrefix(data)) {
      migrateClusterKeyToPB(zkw, peerZnode, data);
    }
    String peerStatePath = ZKUtil.joinZNode(peerZnode,
      getConf().get("zookeeper.znode.replication.peers.state", "peer-state"));
    if (ZKUtil.checkExists(zkw, peerStatePath) != -1) {
      data = ZKUtil.getData(zkw, peerStatePath);
      if (ProtobufUtil.isPBMagicPrefix(data)) continue;
      migratePeerStateToPB(zkw, data, peerStatePath);
    }
  }
}
项目:ditb    文件:ZKUtil.java   
/**
 * Creates the specified node and all parent nodes required for it to exist.  The creation of
 * parent znodes is not atomic with the leafe znode creation but the data is written atomically
 * when the leaf node is created.
 *
 * No watches are set and no errors are thrown if the node already exists.
 *
 * The nodes created are persistent and open access.
 *
 * @param zkw zk reference
 * @param znode path of node
 * @throws KeeperException if unexpected zookeeper exception
 */
public static void createWithParents(ZooKeeperWatcher zkw, String znode, byte[] data)
throws KeeperException {
  try {
    if(znode == null) {
      return;
    }
    zkw.getRecoverableZooKeeper().create(znode, data, createACL(zkw, znode),
        CreateMode.PERSISTENT);
  } catch(KeeperException.NodeExistsException nee) {
    return;
  } catch(KeeperException.NoNodeException nne) {
    createWithParents(zkw, getParent(znode));
    createWithParents(zkw, znode, data);
  } catch(InterruptedException ie) {
    zkw.interruptedException(ie);
  }
}
项目:aliyun-oss-hadoop-fs    文件:ZKDelegationTokenSecretManager.java   
private DelegationKey getKeyFromZK(int keyId) throws IOException {
  String nodePath =
      getNodePath(ZK_DTSM_MASTER_KEY_ROOT, DELEGATION_KEY_PREFIX + keyId);
  try {
    byte[] data = zkClient.getData().forPath(nodePath);
    if ((data == null) || (data.length == 0)) {
      return null;
    }
    ByteArrayInputStream bin = new ByteArrayInputStream(data);
    DataInputStream din = new DataInputStream(bin);
    DelegationKey key = new DelegationKey();
    key.readFields(din);
    return key;
  } catch (KeeperException.NoNodeException e) {
    LOG.error("No node in path [" + nodePath + "]");
  } catch (Exception ex) {
    throw new IOException(ex);
  }
  return null;
}
项目:zookeeper    文件:DataTree.java   
public Stat setData(String path, byte data[], int version, long zxid,
        long time) throws KeeperException.NoNodeException {
    Stat s = new Stat();
    DataNode n = nodes.get(path);
    if (n == null) {
        throw new KeeperException.NoNodeException();
    }
    byte lastdata[] = null;
    synchronized (n) {
        lastdata = n.data;
        n.data = data;
        n.stat.setMtime(time);
        n.stat.setMzxid(zxid);
        n.stat.setVersion(version);
        n.copyStat(s);
    }
    // now update if the path is in a quota subtree.
    String lastPrefix;
    if((lastPrefix = getMaxPrefixWithQuota(path)) != null) {
      this.updateBytes(lastPrefix, (data == null ? 0 : data.length)
          - (lastdata == null ? 0 : lastdata.length));
    }
    dataWatches.triggerWatch(path, EventType.NodeDataChanged);
    return s;
}
项目:Mastering-Mesos    文件:StateManager.java   
public List<SingularityHostState> getHostStates() {
  List<String> children = getChildren(ROOT_PATH);
  List<SingularityHostState> states = Lists.newArrayListWithCapacity(children.size());

  for (String child : children) {

    try {
      byte[] bytes = curator.getData().forPath(ZKPaths.makePath(ROOT_PATH, child));

      states.add(hostStateTranscoder.fromBytes(bytes));
    } catch (NoNodeException nne) {
    } catch (Exception e) {
      throw Throwables.propagate(e);
    }
  }

  return states;
}
项目:SecureKeeper    文件:DataTree.java   
public Stat setData(String path, byte data[], int version, long zxid,
        long time) throws KeeperException.NoNodeException {
    Stat s = new Stat();
    DataNode n = nodes.get(path);
    if (n == null) {
        throw new KeeperException.NoNodeException();
    }
    byte lastdata[] = null;
    synchronized (n) {
        lastdata = n.data;
        n.data = data;
        n.stat.setMtime(time);
        n.stat.setMzxid(zxid);
        n.stat.setVersion(version);
        n.copyStat(s);
    }
    // now update if the path is in a quota subtree.
    String lastPrefix = getMaxPrefixWithQuota(path);
    if(lastPrefix != null) {
      this.updateBytes(lastPrefix, (data == null ? 0 : data.length)
          - (lastdata == null ? 0 : lastdata.length));
    }
    dataWatches.triggerWatch(path, EventType.NodeDataChanged);
    return s;
}
项目:StreamProcessingInfrastructure    文件:DataTreeV1.java   
void killSession(long session) {
    // the list is already removed from the ephemerals
    // so we do not have to worry about synchronyzing on
    // the list. This is only called from FinalRequestProcessor
    // so there is no need for synchornization. The list is not
    // changed here. Only create and delete change the list which
    // are again called from FinalRequestProcessor in sequence.
    HashSet<String> list = ephemerals.remove(session);
    if (list != null) {
        for (String path : list) {
            try {
                deleteNode(path);
                if (LOG.isDebugEnabled()) {
                    LOG.debug("Deleting ephemeral node " + path
                            + " for session 0x"
                            + Long.toHexString(session));
                }
            } catch (NoNodeException e) {
                LOG.warn("Ignoring NoNodeException for path " + path
                        + " while removing ephemeral for dead session 0x"
                        + Long.toHexString(session));
            }
        }
    }
}
项目:StreamProcessingInfrastructure    文件:DataTree.java   
public Stat setData(String path, byte data[], int version, long zxid,
        long time) throws KeeperException.NoNodeException {
    Stat s = new Stat();
    DataNode n = nodes.get(path);
    if (n == null) {
        throw new KeeperException.NoNodeException();
    }
    byte lastdata[] = null;
    synchronized (n) {
        lastdata = n.data;
        n.data = data;
        n.stat.setMtime(time);
        n.stat.setMzxid(zxid);
        n.stat.setVersion(version);
        n.copyStat(s);
    }
    // now update if the path is in a quota subtree.
    String lastPrefix;
    if((lastPrefix = getMaxPrefixWithQuota(path)) != null) {
      this.updateBytes(lastPrefix, (data == null ? 0 : data.length)
          - (lastdata == null ? 0 : lastdata.length));
    }
    dataWatches.triggerWatch(path, EventType.NodeDataChanged);
    return s;
}
项目:StreamProcessingInfrastructure    文件:DataTree.java   
public List<String> getChildren(String path, Stat stat, Watcher watcher)
        throws KeeperException.NoNodeException {
    DataNode n = nodes.get(path);
    if (n == null) {
        throw new KeeperException.NoNodeException();
    }
    synchronized (n) {
        if (stat != null) {
            n.copyStat(stat);
        }
        ArrayList<String> children;
        Set<String> childs = n.getChildren();
        if (childs != null) {
            children = new ArrayList<String>(childs.size());
            children.addAll(childs);
        } else {
            children = new ArrayList<String>(0);
        }

        if (watcher != null) {
            childWatches.addWatch(path, watcher);
        }
        return children;
    }
}
项目:zookeeper    文件:DataTree.java   
public List<String> getChildren(String path, Stat stat, Watcher watcher)
        throws KeeperException.NoNodeException {
    DataNode n = nodes.get(path);
    if (n == null) {
        throw new KeeperException.NoNodeException();
    }
    synchronized (n) {
        if (stat != null) {
            n.copyStat(stat);
        }
        ArrayList<String> children;
        Set<String> childs = n.getChildren();
        if (childs != null) {
            children = new ArrayList<String>(childs.size());
            children.addAll(childs);
        } else {
            children = new ArrayList<String>(0);
        }

        if (watcher != null) {
            childWatches.addWatch(path, watcher);
        }
        return children;
    }
}
项目:StreamProcessingInfrastructure    文件:DataTree.java   
/**
  * This method sets the Cversion and Pzxid for the specified node to the
  * values passed as arguments. The values are modified only if newCversion
  * is greater than the current Cversion. A NoNodeException is thrown if
  * a znode for the specified path is not found.
  *
  * @param path
  *     Full path to the znode whose Cversion needs to be modified.
  *     A "/" at the end of the path is ignored.
  * @param newCversion
  *     Value to be assigned to Cversion
  * @param zxid
  *     Value to be assigned to Pzxid
  * @throws KeeperException.NoNodeException
  *     If znode not found.
  **/
public void setCversionPzxid(String path, int newCversion, long zxid)
    throws KeeperException.NoNodeException {
    if (path.endsWith("/")) {
       path = path.substring(0, path.length() - 1);
    }
    DataNode node = nodes.get(path);
    if (node == null) {
        throw new KeeperException.NoNodeException(path);
    }
    synchronized (node) {
        if(newCversion == -1) {
            newCversion = node.stat.getCversion() + 1;
        }
        if (newCversion > node.stat.getCversion()) {
            node.stat.setCversion(newCversion);
            node.stat.setPzxid(zxid);
        }
    }
}
项目:bigstreams    文件:DataTreeV1.java   
public Stat setData(String path, byte data[], int version, long zxid,
        long time) throws KeeperException.NoNodeException {
    Stat s = new Stat();
    DataNodeV1 n = nodes.get(path);
    if (n == null) {
        throw new KeeperException.NoNodeException();
    }
    synchronized (n) {
        n.data = data;
        n.stat.setMtime(time);
        n.stat.setMzxid(zxid);
        n.stat.setVersion(version);
        n.copyStat(s);
    }
    dataWatches.triggerWatch(path, EventType.NodeDataChanged);
    return s;
}
项目:bigstreams    文件:DataTreeV1.java   
void killSession(long session) {
    // the list is already removed from the ephemerals
    // so we do not have to worry about synchronyzing on
    // the list. This is only called from FinalRequestProcessor
    // so there is no need for synchornization. The list is not
    // changed here. Only create and delete change the list which
    // are again called from FinalRequestProcessor in sequence.
    HashSet<String> list = ephemerals.remove(session);
    if (list != null) {
        for (String path : list) {
            try {
                deleteNode(path);
                if (LOG.isDebugEnabled()) {
                    LOG.debug("Deleting ephemeral node " + path
                            + " for session 0x"
                            + Long.toHexString(session));
                }
            } catch (NoNodeException e) {
                LOG.warn("Ignoring NoNodeException for path " + path
                        + " while removing ephemeral for dead session 0x"
                        + Long.toHexString(session));
            }
        }
    }
}
项目:bigstreams    文件:DataTree.java   
public Stat setData(String path, byte data[], int version, long zxid,
        long time) throws KeeperException.NoNodeException {
    Stat s = new Stat();
    DataNode n = nodes.get(path);
    if (n == null) {
        throw new KeeperException.NoNodeException();
    }
    byte lastdata[] = null;
    synchronized (n) {
        lastdata = n.data;
        n.data = data;
        n.stat.setMtime(time);
        n.stat.setMzxid(zxid);
        n.stat.setVersion(version);
        n.copyStat(s);
    }
    // now update if the path is in a quota subtree.
    String lastPrefix;
    if((lastPrefix = getMaxPrefixWithQuota(path)) != null) {
      this.updateBytes(lastPrefix, (data == null ? 0 : data.length)
          - (lastdata == null ? 0 : lastdata.length));
    }
    dataWatches.triggerWatch(path, EventType.NodeDataChanged);
    return s;
}
项目:bigstreams    文件:DataTree.java   
void killSession(long session, long zxid) {
    // the list is already removed from the ephemerals
    // so we do not have to worry about synchronizing on
    // the list. This is only called from FinalRequestProcessor
    // so there is no need for synchronization. The list is not
    // changed here. Only create and delete change the list which
    // are again called from FinalRequestProcessor in sequence.
    HashSet<String> list = ephemerals.remove(session);
    if (list != null) {
        for (String path : list) {
            try {
                deleteNode(path, zxid);
                if (LOG.isDebugEnabled()) {
                    LOG
                            .debug("Deleting ephemeral node " + path
                                    + " for session 0x"
                                    + Long.toHexString(session));
                }
            } catch (NoNodeException e) {
                LOG.warn("Ignoring NoNodeException for path " + path
                        + " while removing ephemeral for dead session 0x"
                        + Long.toHexString(session));
            }
        }
    }
}
项目:SecureKeeper    文件:DataTree.java   
public List<String> getChildren(String path, Stat stat, Watcher watcher)
        throws KeeperException.NoNodeException {
    DataNode n = nodes.get(path);
    if (n == null) {
        throw new KeeperException.NoNodeException();
    }
    synchronized (n) {
        if (stat != null) {
            n.copyStat(stat);
        }
        ArrayList<String> children;
        Set<String> childs = n.getChildren();
        if (childs == null) {
            children = new ArrayList<String>(0);
        } else {
            children = new ArrayList<String>(childs);
        }

        if (watcher != null) {
            childWatches.addWatch(path, watcher);
        }
        return children;
    }
}
项目:bigstreams    文件:DataTreeV1.java   
void killSession(long session) {
    // the list is already removed from the ephemerals
    // so we do not have to worry about synchronyzing on
    // the list. This is only called from FinalRequestProcessor
    // so there is no need for synchornization. The list is not
    // changed here. Only create and delete change the list which
    // are again called from FinalRequestProcessor in sequence.
    HashSet<String> list = ephemerals.remove(session);
    if (list != null) {
        for (String path : list) {
            try {
                deleteNode(path);
                if (LOG.isDebugEnabled()) {
                    LOG.debug("Deleting ephemeral node " + path
                            + " for session 0x"
                            + Long.toHexString(session));
                }
            } catch (NoNodeException e) {
                LOG.warn("Ignoring NoNodeException for path " + path
                        + " while removing ephemeral for dead session 0x"
                        + Long.toHexString(session));
            }
        }
    }
}
项目:SecureKeeper    文件:DataTree.java   
public Stat setData(String path, byte data[], int version, long zxid,
        long time) throws KeeperException.NoNodeException {
    Stat s = new Stat();
    DataNode n = nodes.get(path);
    if (n == null) {
        throw new KeeperException.NoNodeException();
    }
    byte lastdata[] = null;
    synchronized (n) {
        lastdata = n.data;
        n.data = data;
        n.stat.setMtime(time);
        n.stat.setMzxid(zxid);
        n.stat.setVersion(version);
        n.copyStat(s);
    }
    // now update if the path is in a quota subtree.
    String lastPrefix = getMaxPrefixWithQuota(path);
    if(lastPrefix != null) {
      this.updateBytes(lastPrefix, (data == null ? 0 : data.length)
          - (lastdata == null ? 0 : lastdata.length));
    }
    dataWatches.triggerWatch(path, EventType.NodeDataChanged);
    return s;
}
项目:bigstreams    文件:DataTree.java   
public Stat setData(String path, byte data[], int version, long zxid,
        long time) throws KeeperException.NoNodeException {
    Stat s = new Stat();
    DataNode n = nodes.get(path);
    if (n == null) {
        throw new KeeperException.NoNodeException();
    }
    byte lastdata[] = null;
    synchronized (n) {
        lastdata = n.data;
        n.data = data;
        n.stat.setMtime(time);
        n.stat.setMzxid(zxid);
        n.stat.setVersion(version);
        n.copyStat(s);
    }
    // now update if the path is in a quota subtree.
    String lastPrefix;
    if((lastPrefix = getMaxPrefixWithQuota(path)) != null) {
      this.updateBytes(lastPrefix, (data == null ? 0 : data.length)
          - (lastdata == null ? 0 : lastdata.length));
    }
    dataWatches.triggerWatch(path, EventType.NodeDataChanged);
    return s;
}