本文整理了Java中com.addthis.hydra.job.store.ZookeeperDataStore.getChild()
方法的一些代码示例,展示了ZookeeperDataStore.getChild()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZookeeperDataStore.getChild()
方法的具体详情如下:
包路径:com.addthis.hydra.job.store.ZookeeperDataStore
类名称:ZookeeperDataStore
方法名:getChild
暂无
代码示例来源:origin: addthis/hydra
@Override
public Map<String, String> getAllChildren(String path) {
Map<String, String> rv = new HashMap<>();
List<String> children = getChildrenNames(path);
if (children != null) {
for (String child : children) {
try {
rv.put(child, getChild(path, child));
} catch (Exception ex) {
log.warn("Failed to fetch child " + child + " of " + path + ": " + ex, ex);
}
}
}
return rv;
}
代码示例来源:origin: addthis/hydra
/**
* Write some children to a specified location. Make sure their respective data is held intact, and that the list
* of children updates correctly after nodes are added or deleted.
*/
@Test public void crudChildren() throws Exception {
String savePath = "/other/path";
try {
String c1 = "child1";
String c2 = "child2";
spawnDataStore.delete(savePath);
spawnDataStore.putAsChild(savePath, c1, "data1");
spawnDataStore.putAsChild(savePath, c1, "data1_updated");
spawnDataStore.putAsChild(savePath, c2, "data2");
Set<String> bothChildren = Sets.newHashSet(spawnDataStore.getChildrenNames(savePath));
assertEquals("should get correct children", bothChildren, Sets.newHashSet(c1, c2));
assertEquals("should get updated value for c1", "data1_updated", spawnDataStore.getChild(savePath, c1));
spawnDataStore.deleteChild(savePath, c2);
Set<String> oneChild = Sets.newHashSet(spawnDataStore.getChildrenNames(savePath));
assertEquals("should get new correct children", oneChild, Sets.newHashSet(c1));
assertEquals("c1 should be intact", "data1_updated", spawnDataStore.getChild(savePath, c1));
spawnDataStore.delete(savePath);
assertNull("should get no children", spawnDataStore.getChildrenNames(savePath));
} finally {
spawnDataStore.delete(savePath);
}
}
}
内容来源于网络,如有侵权,请联系作者删除!