Java 类org.apache.zookeeper.common.PathTrie 实例源码

项目:fuck_zookeeper    文件:DataTreeTest.java   
@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"));       
}
项目:https-github.com-apache-zookeeper    文件:DataTreeTest.java   
@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"));
}
项目:ZooKeeper    文件:DataTreeTest.java   
@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"));       
}
项目:StreamProcessingInfrastructure    文件:DataTreeTest.java   
@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"));       
}
项目:zookeeper    文件:DataTreeTest.java   
@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"));       
}
项目:SecureKeeper    文件:DataTreeTest.java   
@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"));       
}
项目:SecureKeeper    文件:DataTreeTest.java   
@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"));       
}
项目:StreamBench    文件:DataTreeTest.java   
@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"));       
}