本文整理汇总了Java中org.apache.zookeeper.server.DataTree.addDataNode方法的典型用法代码示例。如果您正苦于以下问题:Java DataTree.addDataNode方法的具体用法?Java DataTree.addDataNode怎么用?Java DataTree.addDataNode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.zookeeper.server.DataTree
的用法示例。
在下文中一共展示了DataTree.addDataNode方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: recurseThroughDataTree
import org.apache.zookeeper.server.DataTree; //导入方法依赖的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);
}
}
}