當前位置: 首頁>>代碼示例>>Java>>正文


Java KeeperException.NoNodeException方法代碼示例

本文整理匯總了Java中org.apache.zookeeper.KeeperException.NoNodeException方法的典型用法代碼示例。如果您正苦於以下問題:Java KeeperException.NoNodeException方法的具體用法?Java KeeperException.NoNodeException怎麽用?Java KeeperException.NoNodeException使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.zookeeper.KeeperException的用法示例。


在下文中一共展示了KeeperException.NoNodeException方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: deserializeTree

import org.apache.zookeeper.KeeperException; //導入方法依賴的package包/類
private static void deserializeTree(int depth, int width, int len)
        throws InterruptedException, IOException, KeeperException.NodeExistsException, KeeperException.NoNodeException {
    BinaryInputArchive ia;
    int count;
    {
        DataTree tree = new DataTree();
        SerializationPerfTest.createNodes(tree, "/", depth, width, tree.getNode("/").stat.getCversion(), new byte[len]);
        count = tree.getNodeCount();

        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        BinaryOutputArchive oa = BinaryOutputArchive.getArchive(baos);
        tree.serialize(oa, "test");
        baos.flush();

        ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
        ia = BinaryInputArchive.getArchive(bais);
    }

    DataTree dserTree = new DataTree();

    System.gc();
    long start = System.nanoTime();
    dserTree.deserialize(ia, "test");
    long end = System.nanoTime();
    long durationms = (end - start) / 1000000L;
    long pernodeus = ((end - start) / 1000L) / count;

    Assert.assertEquals(count, dserTree.getNodeCount());

    LOG.info("Deserialized " + count + " nodes in " + durationms
            + " ms (" + pernodeus + "us/node), depth=" + depth + " width="
            + width + " datalen=" + len);
}
 
開發者ID:didichuxing2,項目名稱:https-github.com-apache-zookeeper,代碼行數:34,代碼來源:DeserializationPerfTest.java

示例2: setData

import org.apache.zookeeper.KeeperException; //導入方法依賴的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;
}
 
開發者ID:l294265421,項目名稱:ZooKeeper,代碼行數:18,代碼來源:DataTreeV1.java

示例3: setCversionPzxid

import org.apache.zookeeper.KeeperException; //導入方法依賴的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);
        }
    }
}
 
開發者ID:didichuxing2,項目名稱:https-github.com-apache-zookeeper,代碼行數:36,代碼來源:DataTree.java

示例4: setData

import org.apache.zookeeper.KeeperException; //導入方法依賴的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;
}
 
開發者ID:maoling,項目名稱:fuck_zookeeper,代碼行數:26,代碼來源:DataTree.java

示例5: setACL

import org.apache.zookeeper.KeeperException; //導入方法依賴的package包/類
public Stat setACL(String path, List<ACL> acl, int version)
        throws KeeperException.NoNodeException {
    Stat stat = new Stat();
    DataNode n = nodes.get(path);
    if (n == null) {
        throw new KeeperException.NoNodeException();
    }
    synchronized (n) {
        aclCache.removeUsage(n.acl);
        n.stat.setAversion(version);
        n.acl = aclCache.convertAcls(acl);
        n.copyStat(stat);
        return stat;
    }
}
 
開發者ID:maoling,項目名稱:fuck_zookeeper,代碼行數:16,代碼來源:DataTree.java

示例6: deserializeTree

import org.apache.zookeeper.KeeperException; //導入方法依賴的package包/類
private static void deserializeTree(int depth, int width, int len)
        throws InterruptedException, IOException, KeeperException.NodeExistsException, KeeperException.NoNodeException {
    BinaryInputArchive ia;
    int count;
    {
        DataTree tree = new DataTree();
        SerializationPerfTest.createNodes(tree, "/", depth, tree.getNode("/").stat.getCversion(), width, new byte[len]);
        count = tree.getNodeCount();

        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        BinaryOutputArchive oa = BinaryOutputArchive.getArchive(baos);
        tree.serialize(oa, "test");
        baos.flush();

        ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
        ia = BinaryInputArchive.getArchive(bais);
    }

    DataTree dserTree = new DataTree();

    System.gc();
    long start = System.nanoTime();
    dserTree.deserialize(ia, "test");
    long end = System.nanoTime();
    long durationms = (end - start) / 1000000L;
    long pernodeus = ((end - start) / 1000L) / count;

    Assert.assertEquals(count, dserTree.getNodeCount());

    LOG.info("Deserialized " + count + " nodes in " + durationms
            + " ms (" + pernodeus + "us/node), depth=" + depth + " width="
            + width + " datalen=" + len);
}
 
開發者ID:l294265421,項目名稱:ZooKeeper,代碼行數:34,代碼來源:DeserializationPerfTest.java

示例7: deleteMetaLocation

import org.apache.zookeeper.KeeperException; //導入方法依賴的package包/類
public void deleteMetaLocation(ZooKeeperWatcher zookeeper, int replicaId)
throws KeeperException {
  if (replicaId == HRegionInfo.DEFAULT_REPLICA_ID) {
    LOG.info("Deleting hbase:meta region location in ZooKeeper");
  } else {
    LOG.info("Deleting hbase:meta for " + replicaId + " region location in ZooKeeper");
  }
  try {
    // Just delete the node.  Don't need any watches.
    ZKUtil.deleteNode(zookeeper, zookeeper.getZNodeForReplica(replicaId));
  } catch(KeeperException.NoNodeException nne) {
    // Has already been deleted
  }
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:15,代碼來源:MetaTableLocator.java

示例8: removeKeyFromZK

import org.apache.zookeeper.KeeperException; //導入方法依賴的package包/類
public void removeKeyFromZK(AuthenticationKey key) {
  String keyZNode = getKeyNode(key.getKeyId());
  try {
    ZKUtil.deleteNode(watcher, keyZNode);
  } catch (KeeperException.NoNodeException nne) {
    LOG.error("Non-existent znode "+keyZNode+" for key "+key.getKeyId(), nne);
  } catch (KeeperException ke) {
    LOG.fatal("Failed removing znode "+keyZNode+" for key "+key.getKeyId(),
        ke);
    watcher.abort("Unhandled zookeeper error removing znode "+keyZNode+
        " for key "+key.getKeyId(), ke);
  }
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:14,代碼來源:ZKSecretWatcher.java

示例9: getACL

import org.apache.zookeeper.KeeperException; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
public List<ACL> getACL(String path, Stat stat) throws KeeperException.NoNodeException {
    DataNodeV1 n = nodes.get(path);
    if (n == null) {
        throw new KeeperException.NoNodeException();
    }
    synchronized (n) {
        n.copyStat(stat);
        return new ArrayList<ACL>(n.acl);
    }
}
 
開發者ID:l294265421,項目名稱:ZooKeeper,代碼行數:12,代碼來源:DataTreeV1.java

示例10: testSingleDeserialize

import org.apache.zookeeper.KeeperException; //導入方法依賴的package包/類
@Test
public void testSingleDeserialize() throws
        InterruptedException, IOException, KeeperException.NodeExistsException, KeeperException.NoNodeException {
    deserializeTree(1, 0, 20);
}
 
開發者ID:didichuxing2,項目名稱:https-github.com-apache-zookeeper,代碼行數:6,代碼來源:DeserializationPerfTest.java

示例11: test300Wide3DeepDeserialize

import org.apache.zookeeper.KeeperException; //導入方法依賴的package包/類
@Test
public void test300Wide3DeepDeserialize() throws
        InterruptedException, IOException, KeeperException.NodeExistsException, KeeperException.NoNodeException {
    deserializeTree(3, 300, 20);
}
 
開發者ID:maoling,項目名稱:fuck_zookeeper,代碼行數:6,代碼來源:DeserializationPerfTest.java

示例12: test300Wide3DeepSerialize

import org.apache.zookeeper.KeeperException; //導入方法依賴的package包/類
@Test
public void test300Wide3DeepSerialize()
        throws InterruptedException, IOException, KeeperException.NodeExistsException, KeeperException.NoNodeException {
    serializeTree(3, 300, 20);
}
 
開發者ID:didichuxing2,項目名稱:https-github.com-apache-zookeeper,代碼行數:6,代碼來源:SerializationPerfTest.java

示例13: testWideSerialize

import org.apache.zookeeper.KeeperException; //導入方法依賴的package包/類
@Test
public void testWideSerialize()
        throws InterruptedException, IOException, KeeperException.NodeExistsException, KeeperException.NoNodeException {
    serializeTree(2, 10000, 20);
}
 
開發者ID:maoling,項目名稱:fuck_zookeeper,代碼行數:6,代碼來源:SerializationPerfTest.java

示例14: test25Wide4DeepDeserialize

import org.apache.zookeeper.KeeperException; //導入方法依賴的package包/類
@Test
public void test25Wide4DeepDeserialize() throws
        InterruptedException, IOException, KeeperException.NodeExistsException, KeeperException.NoNodeException {
    deserializeTree(4, 25, 20);
}
 
開發者ID:l294265421,項目名稱:ZooKeeper,代碼行數:6,代碼來源:DeserializationPerfTest.java

示例15: createNode

import org.apache.zookeeper.KeeperException; //導入方法依賴的package包/類
/**
 * @param path
 * @param data
 * @param acl
 * @param ephemeralOwner
 *                the session id that owns this node. -1 indicates this is
 *                not an ephemeral node.
 * @param zxid
 * @param time
 * @return the patch of the created node
 * @throws KeeperException
 */
public String createNode(String path, byte data[], List<ACL> acl,
        long ephemeralOwner, long zxid, long time) 
        throws KeeperException.NoNodeException, KeeperException.NodeExistsException {
    int lastSlash = path.lastIndexOf('/');
    String parentName = path.substring(0, lastSlash);
    String childName = path.substring(lastSlash + 1);
    StatPersistedV1 stat = new StatPersistedV1();
    stat.setCtime(time);
    stat.setMtime(time);
    stat.setCzxid(zxid);
    stat.setMzxid(zxid);
    stat.setVersion(0);
    stat.setAversion(0);
    stat.setEphemeralOwner(ephemeralOwner);
    DataNodeV1 parent = nodes.get(parentName);
    if (parent == null) {
        throw new KeeperException.NoNodeException();
    }
    synchronized (parent) {
        if (parent.children.contains(childName)) {
            throw new KeeperException.NodeExistsException();
        }
        int cver = parent.stat.getCversion();
        cver++;
        parent.stat.setCversion(cver);
        DataNodeV1 child = new DataNodeV1(parent, data, acl, stat);
        parent.children.add(childName);
        nodes.put(path, child);
        if (ephemeralOwner != 0) {
            HashSet<String> list = ephemerals.get(ephemeralOwner);
            if (list == null) {
                list = new HashSet<String>();
                ephemerals.put(ephemeralOwner, list);
            }
            synchronized(list) {
                list.add(path);
            }
        }
    }
    dataWatches.triggerWatch(path, Event.EventType.NodeCreated);
    childWatches.triggerWatch(parentName.equals("")?"/":parentName, Event.EventType.NodeChildrenChanged);
    return path;
}
 
開發者ID:maoling,項目名稱:fuck_zookeeper,代碼行數:56,代碼來源:DataTreeV1.java


注:本文中的org.apache.zookeeper.KeeperException.NoNodeException方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。