• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java DataNode类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.apache.zookeeper.server.DataNode的典型用法代码示例。如果您正苦于以下问题:Java DataNode类的具体用法?Java DataNode怎么用?Java DataNode使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



DataNode类属于org.apache.zookeeper.server包,在下文中一共展示了DataNode类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: testTxnFailure

import org.apache.zookeeper.server.DataNode; //导入依赖的package包/类
/**
 * For ZOOKEEPER-1046. Verify if cversion and pzxid if incremented
 * after create/delete failure during restore.
 */
@Test
public void testTxnFailure() throws Exception {
    long count = 1;
    File tmpDir = ClientBase.createTmpDir();
    FileTxnSnapLog logFile = new FileTxnSnapLog(tmpDir, tmpDir);
    DataTree dt = new DataTree();
    dt.createNode("/test", new byte[0], null, 0, -1, 1, 1);
    for (count = 1; count <= 3; count++) {
        dt.createNode("/test/" + count, new byte[0], null, 0, -1, count,
                System.currentTimeMillis());
    }
    DataNode zk = dt.getNode("/test");

    // Make create to fail, then verify cversion.
    LOG.info("Attempting to create " + "/test/" + (count - 1));
    doOp(logFile, OpCode.create, "/test/" + (count - 1), dt, zk);

    // Make delete fo fail, then verify cversion.
    // this doesn't happen anymore, we only set the cversion on create
    // LOG.info("Attempting to delete " + "/test/" + (count + 1));
    // doOp(logFile, OpCode.delete, "/test/" + (count + 1), dt, zk);
}
 
开发者ID:gerritjvv,项目名称:bigstreams,代码行数:27,代码来源:LoadFromLogTest.java


示例2: printDataNode

import org.apache.zookeeper.server.DataNode; //导入依赖的package包/类
/**
 *
 * @param dataNode <code>DataNode</code> to print information from.
 * @param dataState <code>DataState</code> is needed because it holds ACL.
 */
public void printDataNode(DataNode dataNode, DataState dataState) {

    println("cZxid:\t\t" + Util.longToHexString(dataNode.stat.getCzxid()));
    println("mZxid:\t\t" + Util.longToHexString(dataNode.stat.getMzxid()));
    println("ctime:\t\t" + new Date(dataNode.stat.getCtime()));
    println("mtime:\t\t" + new Date(dataNode.stat.getMtime()));
    println("version:\t" + dataNode.stat.getVersion());
    println("cversion:\t" + dataNode.stat.getCversion());
    println("aversion:\t" + dataNode.stat.getAversion());
    println("ephemeralOwner:\t" + Util.longToHexString(dataNode.stat.getEphemeralOwner()));
    printACL(dataState.getACL(dataNode));

    byte[] data = readData(dataNode);

    if (data != null) {
        println("data:\t\t" + dd.decode(data));
    } else {
        println("data:\t\tnull");
    }

}
 
开发者ID:alenca,项目名称:zklogtool,代码行数:27,代码来源:DataNodePrinter.java


示例3: testTxnFailure

import org.apache.zookeeper.server.DataNode; //导入依赖的package包/类
/**
 * For ZOOKEEPER-1046. Verify if cversion and pzxid if incremented
 * after create/delete failure during restore.
 */
@Test
public void testTxnFailure() throws Exception {
    long count = 1;
    File tmpDir = ClientBase.createTmpDir();
    FileTxnSnapLog logFile = new FileTxnSnapLog(tmpDir, tmpDir);
    DataTree dt = new DataTree();
    dt.createNode("/test", new byte[0], null, 0, 1, 1);
    for (count = 1; count <= 3; count++) {
        dt.createNode("/test/" + count, new byte[0], null, 0, count,
                System.currentTimeMillis());
    }
    DataNode zk = dt.getNode("/test");

    // Make create to fail, then verify cversion.
  
    doOp(logFile, OpCode.create, "/test/" + (count - 1), dt, zk);

    // Make delete fo fail, then verify cversion.
 
    doOp(logFile, OpCode.delete, "/test/" + (count + 1), dt, zk);
}
 
开发者ID:prodigeni,项目名称:zookeeper.dsc,代码行数:26,代码来源:LoadFromLogTest.java


示例4: convertDataNode

import org.apache.zookeeper.server.DataNode; //导入依赖的package包/类
/**
 * convert a given old datanode to new datanode
 * @param dt the new datatree
 * @param parent the parent of the datanode to be constructed
 * @param oldDataNode the old datanode 
 * @return the new datanode
 */
private DataNode convertDataNode(DataTree dt, DataNode parent, 
        DataNodeV1 oldDataNode) {
    StatPersisted stat = convertStat(oldDataNode.stat);
    DataNode dataNode =  new DataNode(parent, oldDataNode.data,
            dt.getACL(oldDataNode), stat);
    dataNode.setChildren(oldDataNode.children);
    return dataNode;
}
 
开发者ID:maoling,项目名称:fuck_zookeeper,代码行数:16,代码来源:UpgradeSnapShotV1.java


示例5: recurseThroughDataTree

import org.apache.zookeeper.server.DataNode; //导入依赖的package包/类
/**
 * recurse through the old datatree and construct the 
 * new data tree
 * @param dataTree the new datatree to be constructed
 * @param path the path to start with
 */
private void recurseThroughDataTree(DataTree dataTree, String path) {
    if (path == null)
        return;
    DataNodeV1 oldDataNode = oldDataTree.getNode(path);
    HashSet<String> children = oldDataNode.children;
    DataNode parent = null;
    if ("".equals(path)) {
        parent = null;
    }
    else {
        int lastSlash = path.lastIndexOf('/');
        String parentPath = path.substring(0, lastSlash);
        parent = dataTree.getNode(parentPath);
    }
    DataNode thisDatNode = convertDataNode(dataTree, parent,
                                oldDataNode);
    dataTree.addDataNode(path, thisDatNode);
    if (children == null || children.size() == 0) {
        return;
    }
    else {
        for (String child: children) {
            recurseThroughDataTree(dataTree, path + "/" +child);
        }
    }
}
 
开发者ID:maoling,项目名称:fuck_zookeeper,代码行数:33,代码来源:UpgradeSnapShotV1.java


示例6: testIncrementCversion

import org.apache.zookeeper.server.DataNode; //导入依赖的package包/类
/**
 * For ZOOKEEPER-1046 test if cversion is getting incremented correctly.
 */
@Test(timeout = 60000)
public void testIncrementCversion() throws Exception {
    dt.createNode("/test", new byte[0], null, 0, dt.getNode("/").stat.getCversion()+1, 1, 1);
    DataNode zk = dt.getNode("/test");
    int prevCversion = zk.stat.getCversion();
    long prevPzxid = zk.stat.getPzxid();
    dt.setCversionPzxid("/test/",  prevCversion + 1, prevPzxid + 1);
    int newCversion = zk.stat.getCversion();
    long newPzxid = zk.stat.getPzxid();
    Assert.assertTrue("<cversion, pzxid> verification failed. Expected: <" +
            (prevCversion + 1) + ", " + (prevPzxid + 1) + ">, found: <" +
            newCversion + ", " + newPzxid + ">",
            (newCversion == prevCversion + 1 && newPzxid == prevPzxid + 1));
}
 
开发者ID:maoling,项目名称:fuck_zookeeper,代码行数:18,代码来源:DataTreeTest.java


示例7: testTxnFailure

import org.apache.zookeeper.server.DataNode; //导入依赖的package包/类
/**
 * For ZOOKEEPER-1046. Verify if cversion and pzxid if incremented
 * after create/delete failure during restore.
 */
@Test
public void testTxnFailure() throws Exception {
    long count = 1;
    File tmpDir = ClientBase.createTmpDir();
    FileTxnSnapLog logFile = new FileTxnSnapLog(tmpDir, tmpDir);
    DataTree dt = new DataTree();
    dt.createNode("/test", new byte[0], null, 0, -1, 1, 1);
    for (count = 1; count <= 3; count++) {
        dt.createNode("/test/" + count, new byte[0], null, 0, -1, count,
                System.currentTimeMillis());
    }
    DataNode zk = dt.getNode("/test");

    // Make create to fail, then verify cversion.
    LOG.info("Attempting to create " + "/test/" + (count - 1));
    doOp(logFile, OpCode.create, "/test/" + (count - 1), dt, zk, -1);

    LOG.info("Attempting to create " + "/test/" + (count - 1));
    doOp(logFile, OpCode.create, "/test/" + (count - 1), dt, zk,
            zk.stat.getCversion() + 1);
    
    LOG.info("Attempting to create " + "/test/" + (count - 1));
    doOp(logFile, OpCode.multi, "/test/" + (count - 1), dt, zk,
            zk.stat.getCversion() + 1);
    
    LOG.info("Attempting to create " + "/test/" + (count - 1));
    doOp(logFile, OpCode.multi, "/test/" + (count - 1), dt, zk,
            -1);

    // Make delete fo fail, then verify cversion.
    // this doesn't happen anymore, we only set the cversion on create
    // LOG.info("Attempting to delete " + "/test/" + (count + 1));
    // doOp(logFile, OpCode.delete, "/test/" + (count + 1), dt, zk);
}
 
开发者ID:maoling,项目名称:fuck_zookeeper,代码行数:39,代码来源:LoadFromLogTest.java


示例8: testTxnFailure

import org.apache.zookeeper.server.DataNode; //导入依赖的package包/类
/**
 * For ZOOKEEPER-1046. Verify if cversion and pzxid if incremented
 * after create/delete failure during restore.
 */
@Test
public void testTxnFailure() throws Exception {
    long count = 1;
    File tmpDir = ClientBase.createTmpDir();
    FileTxnSnapLog logFile = new FileTxnSnapLog(tmpDir, tmpDir);
    DataTree dt = new DataTree();
    dt.createNode("/test", new byte[0], null, 0, -1, 1, 1);
    for (count = 1; count <= 3; count++) {
        dt.createNode("/test/" + count, new byte[0], null, 0, -1, count,
                Time.currentElapsedTime());
    }
    DataNode zk = dt.getNode("/test");

    // Make create to fail, then verify cversion.
    LOG.info("Attempting to create " + "/test/" + (count - 1));
    doOp(logFile, OpCode.create, "/test/" + (count - 1), dt, zk, -1);

    LOG.info("Attempting to create " + "/test/" + (count - 1));
    doOp(logFile, OpCode.create, "/test/" + (count - 1), dt, zk,
            zk.stat.getCversion() + 1);

    LOG.info("Attempting to create " + "/test/" + (count - 1));
    doOp(logFile, OpCode.multi, "/test/" + (count - 1), dt, zk,
            zk.stat.getCversion() + 1);

    LOG.info("Attempting to create " + "/test/" + (count - 1));
    doOp(logFile, OpCode.multi, "/test/" + (count - 1), dt, zk,
            -1);

    // Make delete fo fail, then verify cversion.
    // this doesn't happen anymore, we only set the cversion on create
    // LOG.info("Attempting to delete " + "/test/" + (count + 1));
    // doOp(logFile, OpCode.delete, "/test/" + (count + 1), dt, zk);
}
 
开发者ID:didichuxing2,项目名称:https-github.com-apache-zookeeper,代码行数:39,代码来源:LoadFromLogTest.java


示例9: convertDataNode

import org.apache.zookeeper.server.DataNode; //导入依赖的package包/类
/**
 * convert a given old datanode to new datanode
 * @param dt the new datatree
 * @param parent the parent of the datanode to be constructed
 * @param oldDataNode the old datanode 
 * @return the new datanode
 */
private DataNode convertDataNode(DataTree dt, DataNode parent, 
        DataNodeV1 oldDataNode) {
    StatPersisted stat = convertStat(oldDataNode.stat);
    DataNode dataNode =  new DataNode(parent, oldDataNode.data,
            dt.convertAcls(oldDataNode.acl), stat);
    dataNode.setChildren(oldDataNode.children);
    return dataNode;
}
 
开发者ID:gerritjvv,项目名称:bigstreams,代码行数:16,代码来源:UpgradeSnapShotV1.java


示例10: testIncrementCversion

import org.apache.zookeeper.server.DataNode; //导入依赖的package包/类
/**
 * For ZOOKEEPER-1046 test if cversion is getting incremented correctly.
 */
@Test
public void testIncrementCversion() throws Exception {
    dt.createNode("/test", new byte[0], null, 0, dt.getNode("/").stat.getCversion()+1, 1, 1);
    DataNode zk = dt.getNode("/test");
    int prevCversion = zk.stat.getCversion();
    long prevPzxid = zk.stat.getPzxid();
    dt.setCversionPzxid("/test/",  prevCversion + 1, prevPzxid + 1);
    int newCversion = zk.stat.getCversion();
    long newPzxid = zk.stat.getPzxid();
    Assert.assertTrue("<cversion, pzxid> verification failed. Expected: <" +
            (prevCversion + 1) + ", " + (prevPzxid + 1) + ">, found: <" +
            newCversion + ", " + newPzxid + ">",
            (newCversion == prevCversion + 1 && newPzxid == prevPzxid + 1));
}
 
开发者ID:gerritjvv,项目名称:bigstreams,代码行数:18,代码来源:DataTreeTest.java


示例11: testIncrementCversion

import org.apache.zookeeper.server.DataNode; //导入依赖的package包/类
/**
 * For ZOOKEEPER-1046 test if cversion is getting incremented correctly.
 */
@Test
public void testIncrementCversion() throws Exception {
    dt.createNode("/test", new byte[0], null, 0, dt.getNode("/").stat.getCversion()+1, 1, 1);
    DataNode zk = dt.getNode("/test");
    long prevCversion = zk.stat.getCversion();
    long prevPzxid = zk.stat.getPzxid();
    dt.incrementCversion("/test/",  prevPzxid + 1);
    long newCversion = zk.stat.getCversion();
    long newPzxid = zk.stat.getPzxid();
    Assert.assertTrue("<cversion, pzxid> verification failed. Expected: <" +
            (prevCversion + 1) + ", " + (prevPzxid + 1) + ">, found: <" +
            newCversion + ", " + newPzxid + ">",
            (newCversion == prevCversion + 1 && newPzxid == prevPzxid + 1));
}
 
开发者ID:gerritjvv,项目名称:bigstreams,代码行数:18,代码来源:DataTreeTest.java


示例12: traverse

import org.apache.zookeeper.server.DataNode; //导入依赖的package包/类
private static void traverse(DataTree dt, int startId, String startPath) throws Exception {
  LinkedList<Pair> queue = new LinkedList<Pair>();
  queue.add(new Pair(startPath, startId));
  while (!queue.isEmpty()) {
    Pair pair = queue.removeFirst();
    String path = pair._path;
    DataNode head = dt.getNode(path);
    Stat stat = new Stat();
    byte[] data = null;
    try {
      data = dt.getData(path, stat, null);
    } catch (NoNodeException e) {
      e.printStackTrace();
    }
    // print the node
    format(startId, pair, head, data);
    Set<String> children = head.getChildren();
    if (children != null) {
      for (String child : children) {
        String childPath;
        if (path.endsWith("/")) {
          childPath = path + child;
        } else {
          childPath = path + "/" + child;
        }
        queue.add(new Pair(childPath, startId));
      }
    }
    startId = startId + 1;
  }

}
 
开发者ID:apache,项目名称:helix,代码行数:33,代码来源:ZKLogFormatter.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Language类代码示例发布时间:2022-05-21
下一篇:
Java Change类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap