本文整理汇总了Java中org.apache.zookeeper.common.PathTrie类的典型用法代码示例。如果您正苦于以下问题:Java PathTrie类的具体用法?Java PathTrie怎么用?Java PathTrie使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
PathTrie类属于org.apache.zookeeper.common包,在下文中一共展示了PathTrie类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testPathTrieClearOnDeserialize
import org.apache.zookeeper.common.PathTrie; //导入依赖的package包/类
@Test(timeout = 60000)
public void testPathTrieClearOnDeserialize() throws Exception {
//Create a DataTree with quota nodes so PathTrie get updated
DataTree dserTree = new DataTree();
dserTree.createNode("/bug", new byte[20], null, -1, 1, 1, 1);
dserTree.createNode(Quotas.quotaZookeeper+"/bug", null, null, -1, 1, 1, 1);
dserTree.createNode(Quotas.quotaPath("/bug"), new byte[20], null, -1, 1, 1, 1);
dserTree.createNode(Quotas.statPath("/bug"), new byte[20], null, -1, 1, 1, 1);
//deserialize a DataTree; this should clear the old /bug nodes and pathTrie
DataTree tree = new DataTree();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
BinaryOutputArchive oa = BinaryOutputArchive.getArchive(baos);
tree.serialize(oa, "test");
baos.flush();
ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
BinaryInputArchive ia = BinaryInputArchive.getArchive(bais);
dserTree.deserialize(ia, "test");
Field pfield = DataTree.class.getDeclaredField("pTrie");
pfield.setAccessible(true);
PathTrie pTrie = (PathTrie)pfield.get(dserTree);
//Check that the node path is removed from pTrie
Assert.assertEquals("/bug is still in pTrie", "", pTrie.findMaxPrefix("/bug"));
}
示例2: testPathTrieClearOnDeserialize
import org.apache.zookeeper.common.PathTrie; //导入依赖的package包/类
@Test(timeout = 60000)
public void testPathTrieClearOnDeserialize() throws Exception {
//Create a DataTree with quota nodes so PathTrie get updated
DataTree dserTree = new DataTree();
dserTree.createNode("/bug", new byte[20], null, -1, 1, 1, 1);
dserTree.createNode(Quotas.quotaZookeeper+"/bug", null, null, -1, 1, 1, 1);
dserTree.createNode(Quotas.quotaPath("/bug"), new byte[20], null, -1, 1, 1, 1);
dserTree.createNode(Quotas.statPath("/bug"), new byte[20], null, -1, 1, 1, 1);
//deserialize a DataTree; this should clear the old /bug nodes and pathTrie
DataTree tree = new DataTree();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
BinaryOutputArchive oa = BinaryOutputArchive.getArchive(baos);
tree.serialize(oa, "test");
baos.flush();
ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
BinaryInputArchive ia = BinaryInputArchive.getArchive(bais);
dserTree.deserialize(ia, "test");
Field pfield = DataTree.class.getDeclaredField("pTrie");
pfield.setAccessible(true);
PathTrie pTrie = (PathTrie)pfield.get(dserTree);
//Check that the node path is removed from pTrie
Assert.assertEquals("/bug is still in pTrie", "", pTrie.findMaxPrefix("/bug"));
}
示例3: testPathTrieClearOnDeserialize
import org.apache.zookeeper.common.PathTrie; //导入依赖的package包/类
@Test(timeout = 60000)
public void testPathTrieClearOnDeserialize() throws Exception {
//Create a DataTree with quota nodes so PathTrie get updated
DataTree dserTree = new DataTree();
dserTree.createNode("/bug", new byte[20], null, -1, 1, 1, 1);
dserTree.createNode(Quotas.quotaZookeeper+"/bug", null, null, -1, 1, 1, 1);
dserTree.createNode(Quotas.quotaPath("/bug"), new byte[20], null, -1, 1, 1, 1);
dserTree.createNode(Quotas.statPath("/bug"), new byte[20], null, -1, 1, 1, 1);
//deserialize a DataTree; this should clear the old /bug nodes and pathTrie
DataTree tree = new DataTree();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
BinaryOutputArchive oa = BinaryOutputArchive.getArchive(baos);
tree.serialize(oa, "test");
baos.flush();
ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
BinaryInputArchive ia = BinaryInputArchive.getArchive(bais);
dserTree.deserialize(ia, "test");
Field pfield = DataTree.class.getDeclaredField("pTrie");
pfield.setAccessible(true);
PathTrie pTrie = (PathTrie)pfield.get(dserTree);
//Check that the node path is removed from pTrie
Assert.assertEquals("/bug is still in pTrie", "", pTrie.findMaxPrefix("/bug"));
}