本文整理匯總了Java中org.apache.zookeeper.KeeperException.NoNodeException類的典型用法代碼示例。如果您正苦於以下問題:Java NoNodeException類的具體用法?Java NoNodeException怎麽用?Java NoNodeException使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
NoNodeException類屬於org.apache.zookeeper.KeeperException包,在下文中一共展示了NoNodeException類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getKeyFromZK
import org.apache.zookeeper.KeeperException.NoNodeException; //導入依賴的package包/類
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;
}
示例2: checkAmVersion
import org.apache.zookeeper.KeeperException.NoNodeException; //導入依賴的package包/類
/**
* 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));
}
}
示例3: setData
import org.apache.zookeeper.KeeperException.NoNodeException; //導入依賴的package包/類
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;
}
示例4: killSession
import org.apache.zookeeper.KeeperException.NoNodeException; //導入依賴的package包/類
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));
}
}
}
}
示例5: setData
import org.apache.zookeeper.KeeperException.NoNodeException; //導入依賴的package包/類
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;
}
示例6: getChildren
import org.apache.zookeeper.KeeperException.NoNodeException; //導入依賴的package包/類
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;
}
}
示例7: killSession
import org.apache.zookeeper.KeeperException.NoNodeException; //導入依賴的package包/類
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));
}
}
}
}
示例8: setCversionPzxid
import org.apache.zookeeper.KeeperException.NoNodeException; //導入依賴的package包/類
/**
* 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);
}
}
}
示例9: setData
import org.apache.zookeeper.KeeperException.NoNodeException; //導入依賴的package包/類
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;
}
示例10: getChildren
import org.apache.zookeeper.KeeperException.NoNodeException; //導入依賴的package包/類
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;
}
}
示例11: killSession
import org.apache.zookeeper.KeeperException.NoNodeException; //導入依賴的package包/類
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));
}
}
}
}
示例12: processTopic
import org.apache.zookeeper.KeeperException.NoNodeException; //導入依賴的package包/類
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;
}
示例13: getChildren
import org.apache.zookeeper.KeeperException.NoNodeException; //導入依賴的package包/類
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;
}
}
示例14: deleteNodeInStates
import org.apache.zookeeper.KeeperException.NoNodeException; //導入依賴的package包/類
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;
}
示例15: checkAndMigrateQueuesToPB
import org.apache.zookeeper.KeeperException.NoNodeException; //導入依賴的package包/類
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))));
}
}
}