本文整理了Java中org.apache.accumulo.fate.zookeeper.ZooReader.getChildren()
方法的一些代码示例,展示了ZooReader.getChildren()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZooReader.getChildren()
方法的具体详情如下:
包路径:org.apache.accumulo.fate.zookeeper.ZooReader
类名称:ZooReader
方法名:getChildren
暂无
代码示例来源:origin: apache/accumulo
private static TreeSet<UUID> getInstanceIDs(ZooReader zk, boolean printErrors) {
TreeSet<UUID> ts = new TreeSet<>();
try {
List<String> children = zk.getChildren(Constants.ZROOT);
for (String iid : children) {
if (iid.equals("instances"))
continue;
try {
ts.add(UUID.fromString(iid));
} catch (Exception e) {
log.error("Exception: ", e);
}
}
} catch (Exception e) {
handleException(e, printErrors);
}
return ts;
}
代码示例来源:origin: apache/accumulo
private static void recurse(ZooReader zoo, String root, Visitor v) {
try {
v.visit(zoo, root);
for (String child : zoo.getChildren(root)) {
recurse(zoo, root + "/" + child, v);
}
} catch (Exception ex) {
throw new RuntimeException(ex);
}
}
代码示例来源:origin: apache/accumulo
private static TreeMap<String,UUID> getInstanceNames(ZooReader zk, boolean printErrors) {
String instancesPath = Constants.ZROOT + Constants.ZINSTANCES;
TreeMap<String,UUID> tm = new TreeMap<>();
List<String> names;
try {
names = zk.getChildren(instancesPath);
} catch (Exception e) {
handleException(e, printErrors);
return tm;
}
for (String name : names) {
String instanceNamePath = Constants.ZROOT + Constants.ZINSTANCES + "/" + name;
try {
UUID iid = UUID.fromString(new String(zk.getData(instanceNamePath, null), UTF_8));
tm.put(name, iid);
} catch (Exception e) {
handleException(e, printErrors);
tm.put(name, null);
}
}
return tm;
}
代码示例来源:origin: apache/accumulo
private int updateAuthKeys(String path) throws KeeperException, InterruptedException {
int keysAdded = 0;
for (String child : zk.getChildren(path, this)) {
String childPath = path + "/" + child;
try {
// Get the node data and reset the watcher
AuthenticationKey key = deserializeKey(zk.getData(childPath, this, null));
secretManager.addKey(key);
keysAdded++;
} catch (NoNodeException e) {
// The master expired(deleted) the key between when we saw it in getChildren() and when we
// went to add it to our secret manager.
log.trace("{} was deleted when we tried to access it", childPath);
}
}
return keysAdded;
}
代码示例来源:origin: apache/accumulo
protected void updateHostsFromZooKeeper() throws KeeperException, InterruptedException {
if (pathExists || zoo.exists(path)) {
pathExists = true;
updateHosts(path, zoo.getChildren(path, this));
} else {
zoo.exists(path, this);
}
}
代码示例来源:origin: org.apache.accumulo/accumulo-server-base
private static TreeSet<UUID> getInstanceIDs(ZooReader zk, boolean printErrors) {
TreeSet<UUID> ts = new TreeSet<>();
try {
List<String> children = zk.getChildren(Constants.ZROOT);
for (String iid : children) {
if (iid.equals("instances"))
continue;
try {
ts.add(UUID.fromString(iid));
} catch (Exception e) {
log.error("Exception: " + e);
}
}
} catch (Exception e) {
handleException(e, printErrors);
}
return ts;
}
代码示例来源:origin: org.apache.accumulo/accumulo-server
private static TreeSet<UUID> getInstanceIDs(ZooReader zk) {
TreeSet<UUID> ts = new TreeSet<UUID>();
try {
List<String> children = zk.getChildren(Constants.ZROOT);
for (String iid : children) {
if (iid.equals("instances"))
continue;
try {
ts.add(UUID.fromString(iid));
} catch (Exception e) {
log.error("Exception: " + e);
}
}
} catch (Exception e) {
handleException(e);
}
return ts;
}
代码示例来源:origin: org.apache.accumulo/accumulo-server-base
private static void recurse(ZooReader zoo, String root, Visitor v) {
try {
v.visit(zoo, root);
for (String child : zoo.getChildren(root)) {
recurse(zoo, root + "/" + child, v);
}
} catch (Exception ex) {
throw new RuntimeException(ex);
}
}
代码示例来源:origin: org.apache.accumulo/accumulo-server
private static void recurse(ZooReader zoo, String root, Visitor v) {
try {
v.visit(zoo, root);
for (String child : zoo.getChildren(root)) {
recurse(zoo, root + "/" + child, v);
}
} catch (Exception ex) {
throw new RuntimeException(ex);
}
}
代码示例来源:origin: org.apache.accumulo/accumulo-server
private static TreeMap<String,UUID> getInstanceNames(ZooReader zk) {
String instancesPath = Constants.ZROOT + Constants.ZINSTANCES;
TreeMap<String,UUID> tm = new TreeMap<String,UUID>();
List<String> names;
try {
names = zk.getChildren(instancesPath);
} catch (Exception e) {
handleException(e);
return tm;
}
for (String name : names) {
String instanceNamePath = Constants.ZROOT + Constants.ZINSTANCES + "/" + name;
try {
UUID iid = UUID.fromString(new String(zk.getData(instanceNamePath, null), UTF_8));
tm.put(name, iid);
} catch (Exception e) {
handleException(e);
tm.put(name, null);
}
}
return tm;
}
代码示例来源:origin: org.apache.accumulo/accumulo-server-base
private static TreeMap<String,UUID> getInstanceNames(ZooReader zk, boolean printErrors) {
String instancesPath = Constants.ZROOT + Constants.ZINSTANCES;
TreeMap<String,UUID> tm = new TreeMap<>();
List<String> names;
try {
names = zk.getChildren(instancesPath);
} catch (Exception e) {
handleException(e, printErrors);
return tm;
}
for (String name : names) {
String instanceNamePath = Constants.ZROOT + Constants.ZINSTANCES + "/" + name;
try {
UUID iid = UUID.fromString(new String(zk.getData(instanceNamePath, null), UTF_8));
tm.put(name, iid);
} catch (Exception e) {
handleException(e, printErrors);
tm.put(name, null);
}
}
return tm;
}
代码示例来源:origin: org.apache.accumulo/accumulo-test
Set<TServerInstance> getTServers(Instance instance) throws KeeperException, InterruptedException {
Set<TServerInstance> result = new HashSet<>();
ZooReader rdr = new ZooReader(instance.getZooKeepers(), instance.getZooKeepersSessionTimeOut());
String base = ZooUtil.getRoot(instance) + Constants.ZTSERVERS;
for (String child : rdr.getChildren(base)) {
try {
List<String> children = rdr.getChildren(base + "/" + child);
if (children.size() > 0) {
Collections.sort(children);
Stat stat = new Stat();
byte[] data = rdr.getData(base + "/" + child + "/" + children.get(0), stat);
if (!"master".equals(new String(data, UTF_8))) {
result.add(new TServerInstance(AddressUtil.parseAddress(child, false),
stat.getEphemeralOwner()));
}
}
} catch (KeeperException.NoNodeException ex) {
// someone beat us too it
}
}
return result;
}
代码示例来源:origin: org.apache.accumulo/accumulo-server-base
private int updateAuthKeys(String path) throws KeeperException, InterruptedException {
int keysAdded = 0;
for (String child : zk.getChildren(path, this)) {
String childPath = path + "/" + child;
try {
// Get the node data and reset the watcher
AuthenticationKey key = deserializeKey(zk.getData(childPath, this, null));
secretManager.addKey(key);
keysAdded++;
} catch (NoNodeException e) {
// The master expired(deleted) the key between when we saw it in getChildren() and when we
// went to add it to our secret manager.
log.trace("{} was deleted when we tried to access it", childPath);
}
}
return keysAdded;
}
代码示例来源:origin: org.apache.accumulo/accumulo-tracer
protected void updateHostsFromZooKeeper() throws KeeperException, InterruptedException {
if (pathExists || zoo.exists(path)) {
pathExists = true;
updateHosts(path, zoo.getChildren(path, this));
} else {
zoo.exists(path, this);
}
}
代码示例来源:origin: org.apache.accumulo/accumulo-test
@Test
public void tserverReplicationServicePortsAreAdvertised() throws Exception {
// Wait for the cluster to be up
Connector conn = getConnector();
Instance inst = conn.getInstance();
// Wait for a tserver to come up to fulfill this request
conn.tableOperations().create("foo");
Scanner s = conn.createScanner("foo", Authorizations.EMPTY);
Assert.assertEquals(0, Iterables.size(s));
ZooReader zreader = new ZooReader(inst.getZooKeepers(), inst.getZooKeepersSessionTimeOut());
Set<String> tserverHost = new HashSet<>();
tserverHost.addAll(zreader.getChildren(ZooUtil.getRoot(inst) + Constants.ZTSERVERS));
Set<HostAndPort> replicationServices = new HashSet<>();
for (String tserver : tserverHost) {
try {
byte[] portData = zreader.getData(
ZooUtil.getRoot(inst) + ReplicationConstants.ZOO_TSERVERS + "/" + tserver, null);
HostAndPort replAddress = HostAndPort.fromString(new String(portData, UTF_8));
replicationServices.add(replAddress);
} catch (Exception e) {
log.error("Could not find port for {}", tserver, e);
Assert.fail("Did not find replication port advertisement for " + tserver);
}
}
// Each tserver should also have equial replicaiton services running internally
Assert.assertEquals("Expected an equal number of replication servicers and tservers",
tserverHost.size(), replicationServices.size());
}
内容来源于网络,如有侵权,请联系作者删除!