当前位置: 首页>>代码示例>>Java>>正文


Java DataTree.deserialize方法代码示例

本文整理汇总了Java中org.apache.zookeeper.server.DataTree.deserialize方法的典型用法代码示例。如果您正苦于以下问题:Java DataTree.deserialize方法的具体用法?Java DataTree.deserialize怎么用?Java DataTree.deserialize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.zookeeper.server.DataTree的用法示例。


在下文中一共展示了DataTree.deserialize方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: deserializeSnapshot

import org.apache.zookeeper.server.DataTree; //导入方法依赖的package包/类
public static void deserializeSnapshot(DataTree dt,InputArchive ia,
        Map<Long, Integer> sessions) throws IOException {
    int count = ia.readInt("count");
    while (count > 0) {
        long id = ia.readLong("id");
        int to = ia.readInt("timeout");
        sessions.put(id, to);
        if (LOG.isTraceEnabled()) {
            ZooTrace.logTraceMessage(LOG, ZooTrace.SESSION_TRACE_MASK,
                    "loadData --- session in archive: " + id
                    + " with timeout: " + to);
        }
        count--;
    }
    dt.deserialize(ia, "tree");
}
 
开发者ID:maoling,项目名称:fuck_zookeeper,代码行数:17,代码来源:SerializeUtils.java

示例2: deserializeSnapshot

import org.apache.zookeeper.server.DataTree; //导入方法依赖的package包/类
public static void deserializeSnapshot(DataTree dt,InputArchive ia,
        Map<Long, Integer> sessions) throws IOException {
    // 读取session个数
    int count = ia.readInt("count");
    while (count > 0) {
        // session id
        long id = ia.readLong("id");
        // session超时时间
        int to = ia.readInt("timeout");
        // 解析session集合
        sessions.put(id, to);
        if (LOG.isTraceEnabled()) {
            ZooTrace.logTraceMessage(LOG, ZooTrace.SESSION_TRACE_MASK,
                    "loadData --- session in archive: " + id
                    + " with timeout: " + to);
        }
        count--;
    }
    // 反序列化tree
    dt.deserialize(ia, "tree");
}
 
开发者ID:txazo,项目名称:zookeeper,代码行数:22,代码来源:SerializeUtils.java

示例3: testPathTrieClearOnDeserialize

import org.apache.zookeeper.server.DataTree; //导入方法依赖的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"));       
}
 
开发者ID:maoling,项目名称:fuck_zookeeper,代码行数:31,代码来源:DataTreeTest.java

示例4: testPathTrieClearOnDeserialize

import org.apache.zookeeper.server.DataTree; //导入方法依赖的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"));       
}
 
开发者ID:sereca,项目名称:SecureKeeper,代码行数:31,代码来源:DataTreeTest.java


注:本文中的org.apache.zookeeper.server.DataTree.deserialize方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。