本文整理了Java中org.linkedin.zookeeper.tracker.ZooKeeperTreeTracker.getTree()
方法的一些代码示例,展示了ZooKeeperTreeTracker.getTree()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZooKeeperTreeTracker.getTree()
方法的具体详情如下:
包路径:org.linkedin.zookeeper.tracker.ZooKeeperTreeTracker
类名称:ZooKeeperTreeTracker
方法名:getTree
暂无
代码示例来源:origin: org.fusesource.fabric/fabric-configadmin
protected List<String> getChildren(ZooKeeperTreeTracker<String> tree, String node) {
List<String> children = new ArrayList<String>();
if (tree != null) {
Pattern p = Pattern.compile(node + "/[^/]*");
for (String c : tree.getTree().keySet()) {
if (p.matcher(c).matches()) {
children.add(c.substring(c.lastIndexOf('/') + 1));
}
}
}
return children;
}
代码示例来源:origin: org.fusesource.insight/insight-graph
@Override
public void validateSetup(Query query) throws ValidationException {
Map<String, TrackedNode<OutputWriter>> tree = tracker.getTree();
for (Map.Entry<String, TrackedNode<OutputWriter>> entry : tree.entrySet()) {
String name = entry.getKey();
TrackedNode<OutputWriter> value = entry.getValue();
OutputWriter data = value.getData();
if (data != null) {
configureWriter(data);
data.validateSetup(query);
}
}
}
代码示例来源:origin: org.fusesource.insight/insight-graph
@Override
public void doWrite(Query query) throws Exception {
Map<String, TrackedNode<OutputWriter>> tree = tracker.getTree();
for (Map.Entry<String, TrackedNode<OutputWriter>> entry : tree.entrySet()) {
String name = entry.getKey();
TrackedNode<OutputWriter> value = entry.getValue();
OutputWriter data = value.getData();
if (data != null) {
configureWriter(data);
data.doWrite(query);
}
}
}
代码示例来源:origin: org.fusesource.fabric/fabric-configadmin
private void load(String pid, String node, Dictionary dict) throws KeeperException, InterruptedException, IOException {
ZooKeeperTreeTracker<String> tree = track(node);
TrackedNode<String> root = tree != null ? tree.getTree().get(node) : null;
String[] parents = getParents(root);
for (String parent : parents) {
load(pid, ZkProfiles.getPath(version, parent), dict);
}
TrackedNode<String> cfg = tree != null ? tree.getTree().get(node + "/" + pid + ".properties") : null;
if (cfg != null) {
//if (cfg != null && !DELETED.equals(cfg.getData())) {
Properties properties = toProperties(cfg.getData());
// clear out the dict if it had a deleted key.
if (properties.remove(DELETED) != null) {
Enumeration keys = dict.keys();
while (keys.hasMoreElements()) {
dict.remove(keys.nextElement());
}
}
for (Map.Entry<Object, Object> entry : properties.entrySet()) {
if (DELETED.equals(entry.getValue())) {
dict.remove(entry.getKey());
} else {
dict.put(entry.getKey(), entry.getValue());
}
}
}
}
代码示例来源:origin: org.fusesource.fabric/fabric-configadmin
private void getPids(String node, Set<String> pids) throws KeeperException, InterruptedException, IOException {
ZooKeeperTreeTracker<String> tree = track(node);
TrackedNode<String> root = tree != null ? tree.getTree().get(node) : null;
String[] parents = getParents(root);
for (String parent : parents) {
getPids(ZkProfiles.getPath(version, parent), pids);
}
for (String pid : getChildren(tree, node)) {
if (pid.endsWith(".properties")) {
pid = stripSuffix(pid, ".properties");
pids.add(pid);
}
}
}
代码示例来源:origin: org.fusesource.fabric/fabric-configadmin
protected ZooKeeperTreeTracker<String> track(String path) throws InterruptedException, KeeperException, IOException {
ZooKeeperTreeTracker<String> tree = trees.get(path);
if (tree == null) {
if (ZooKeeperUtils.exists(zooKeeper, path) != null) {
tree = new ZooKeeperTreeTracker<String>(zooKeeper, new ZKStringDataReader(), path);
trees.put(path, tree);
tree.track(this);
String[] parents = getParents(tree.getTree().get(path));
for (String parent : parents) {
track(ZkPath.CONFIG_VERSIONS_PROFILE.getPath(version, parent));
}
} else {
// If the node does not exist yet, we track the parent to make
// sure we receive the node creation event
String p = ZkPath.CONFIG_VERSIONS_PROFILES.getPath(version);
if (!trees.containsKey(p)) {
tree = new ZooKeeperTreeTracker<String>(zooKeeper, new ZKStringDataReader(), p, 1);
trees.put(p, tree);
tree.track(this);
}
return null;
}
}
return tree;
}
内容来源于网络,如有侵权,请联系作者删除!