本文整理了Java中org.apache.accumulo.fate.zookeeper.ZooReaderWriter.getChildren()
方法的一些代码示例,展示了ZooReaderWriter.getChildren()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZooReaderWriter.getChildren()
方法的具体详情如下:
包路径:org.apache.accumulo.fate.zookeeper.ZooReaderWriter
类名称:ZooReaderWriter
方法名:getChildren
暂无
代码示例来源:origin: apache/accumulo
public List<String> getWorkQueued() throws KeeperException, InterruptedException {
ArrayList<String> children = new ArrayList<>(zoo.getChildren(path));
children.remove(LOCKS_NODE);
return children;
}
代码示例来源:origin: apache/accumulo
@Override
public void run() {
log.debug("Looking for work in {}", path);
try {
lookForWork(processor, zoo.getChildren(path));
} catch (KeeperException e) {
log.error("Failed to look for work", e);
} catch (InterruptedException e) {
log.info("Interrupted looking for work", e);
}
}
}, timerInitialDelay, timerPeriod);
代码示例来源:origin: apache/accumulo
@Override
public void process(WatchedEvent event) {
nextEvent.event("Noticed recovery changes", event.getType());
try {
// watcher only fires once, add it back
zReaderWriter.getChildren(zroot + Constants.ZRECOVERY, this);
} catch (Exception e) {
log.error("Failed to add log recovery watcher back", e);
}
}
});
代码示例来源:origin: apache/accumulo
List<String> children = zoo.getChildren(path, watcher);
condVar.wait(10000);
children = zoo.getChildren(path, watcher);
代码示例来源:origin: apache/accumulo
public Map<TServerInstance,List<UUID>> getAllMarkers() throws WalMarkerException {
Map<TServerInstance,List<UUID>> result = new HashMap<>();
try {
String path = root();
for (String child : zoo.getChildren(path)) {
TServerInstance inst = new TServerInstance(child);
List<UUID> logs = result.get(inst);
if (logs == null) {
result.put(inst, logs = new ArrayList<>());
}
// This function is called by the Accumulo GC which deletes WAL markers. Therefore we do not
// expect the following call to fail because the WAL info in ZK was deleted.
for (String idString : zoo.getChildren(path + "/" + child)) {
logs.add(UUID.fromString(idString));
}
}
} catch (KeeperException | InterruptedException e) {
throw new WalMarkerException(e);
}
return result;
}
代码示例来源:origin: apache/accumulo
@Override
public void process(WatchedEvent event) {
switch (event.getType()) {
case NodeChildrenChanged:
if (event.getPath().equals(path))
try {
lookForWork(processor, zoo.getChildren(path, this));
} catch (KeeperException e) {
log.error("Failed to look for work", e);
} catch (InterruptedException e) {
log.info("Interrupted looking for work", e);
}
else
log.info("Unexpected path for NodeChildrenChanged event {}", event.getPath());
break;
case NodeCreated:
case NodeDataChanged:
case NodeDeleted:
case None:
log.info("Got unexpected zookeeper event: {} for {}", event.getType(), path);
break;
}
}
});
代码示例来源:origin: apache/accumulo
public List<DeadServer> getList() {
List<DeadServer> result = new ArrayList<>();
try {
List<String> children = zoo.getChildren(path);
if (children != null) {
for (String child : children) {
Stat stat = new Stat();
byte[] data;
try {
data = zoo.getData(path + "/" + child, stat);
} catch (NoNodeException nne) {
// Another thread or process can delete child while this loop is running.
// We ignore this error since it's harmless if we miss the deleted server
// in the dead server list.
continue;
}
DeadServer server = new DeadServer(child, stat.getMtime(), new String(data, UTF_8));
result.add(server);
}
}
} catch (Exception ex) {
log.error("{}", ex.getMessage(), ex);
}
return result;
}
代码示例来源:origin: apache/accumulo
/**
* Fetch all {@link AuthenticationKey}s currently stored in ZooKeeper beneath the configured
* {@code baseNode}.
*
* @return A list of {@link AuthenticationKey}s
*/
public List<AuthenticationKey> getCurrentKeys() throws KeeperException, InterruptedException {
checkState(initialized.get(), "Not initialized");
List<String> children = zk.getChildren(baseNode);
// Shortcircuit to avoid a list creation
if (children.isEmpty()) {
return Collections.emptyList();
}
// Deserialize each byte[] into an AuthenticationKey
List<AuthenticationKey> keys = new ArrayList<>(children.size());
for (String child : children) {
byte[] data = zk.getData(qualifyPath(child), null);
if (data != null) {
AuthenticationKey key = new AuthenticationKey();
try {
key.readFields(new DataInputStream(new ByteArrayInputStream(data)));
} catch (IOException e) {
throw new AssertionError("Error reading from in-memory buffer which should not happen",
e);
}
keys.add(key);
}
}
return keys;
}
代码示例来源:origin: apache/accumulo
lookForWork(processor, zoo.getChildren(path));
} catch (KeeperException e) {
log.error("Failed to look for work", e);
代码示例来源:origin: apache/accumulo
/**
* @param args
* : the name or UUID of the instance to be deleted
*/
public static void main(String[] args) throws Exception {
Opts opts = new Opts();
opts.parseArgs(DeleteZooInstance.class.getName(), args);
ZooReaderWriter zk = new ZooReaderWriter(new SiteConfiguration());
// try instance name:
Set<String> instances = new HashSet<>(zk.getChildren(Constants.ZROOT + Constants.ZINSTANCES));
Set<String> uuids = new HashSet<>(zk.getChildren(Constants.ZROOT));
uuids.remove("instances");
if (instances.contains(opts.instance)) {
String path = Constants.ZROOT + Constants.ZINSTANCES + "/" + opts.instance;
byte[] data = zk.getData(path, null);
deleteRetry(zk, path);
deleteRetry(zk, Constants.ZROOT + "/" + new String(data, UTF_8));
} else if (uuids.contains(opts.instance)) {
// look for the real instance name
for (String instance : instances) {
String path = Constants.ZROOT + Constants.ZINSTANCES + "/" + instance;
byte[] data = zk.getData(path, null);
if (opts.instance.equals(new String(data, UTF_8)))
deleteRetry(zk, path);
}
deleteRetry(zk, Constants.ZROOT + "/" + opts.instance);
}
}
代码示例来源:origin: apache/accumulo
while (true) {
try {
context.getZooReaderWriter().getChildren(Constants.ZROOT);
break;
} catch (InterruptedException e) {
代码示例来源:origin: apache/accumulo
public List<Path> getWalsInUse(TServerInstance tsi) throws WalMarkerException {
List<Path> result = new ArrayList<>();
try {
String zpath = root() + "/" + tsi;
zoo.sync(zpath);
for (String child : zoo.getChildren(zpath)) {
byte[] zdata = null;
try {
// This function is called by the Master. Its possible that Accumulo GC deletes an
// unreferenced WAL in ZK after the call to getChildren above. Catch this exception inside
// the loop so that not all children are ignored.
zdata = zoo.getData(zpath + "/" + child, null);
} catch (KeeperException.NoNodeException e) {
log.debug("WAL state removed {} {} during getWalsInUse. Likely a race condition between "
+ "master and GC.", tsi, child);
}
if (zdata != null) {
Pair<WalState,Path> parts = parse(zdata);
if (parts.getFirst() != WalState.UNREFERENCED) {
result.add(parts.getSecond());
}
}
}
} catch (KeeperException.NoNodeException e) {
log.debug("{} has no wal entry in zookeeper, assuming no logs", tsi);
} catch (KeeperException | InterruptedException e) {
throw new WalMarkerException(e);
}
return result;
}
代码示例来源:origin: apache/accumulo
public static void main(String[] args) throws Exception {
try (ServerContext context = new ServerContext(new SiteConfiguration())) {
String tserverPath = context.getZooKeeperRoot() + Constants.ZTSERVERS;
Opts opts = new Opts();
opts.parseArgs(TabletServerLocks.class.getName(), args);
ZooCache cache = context.getZooCache();
ZooReaderWriter zoo = context.getZooReaderWriter();
if (opts.list) {
List<String> tabletServers = zoo.getChildren(tserverPath);
for (String tabletServer : tabletServers) {
byte[] lockData = ZooLock.getLockData(cache, tserverPath + "/" + tabletServer, null);
String holder = null;
if (lockData != null) {
holder = new String(lockData, UTF_8);
}
System.out.printf("%32s %16s%n", tabletServer, holder);
}
} else if (opts.delete != null) {
ZooLock.deleteLock(zoo, tserverPath + "/" + args[1]);
} else {
System.out.println(
"Usage : " + TabletServerLocks.class.getName() + " -list|-delete <tserver lock>");
}
}
}
代码示例来源:origin: apache/accumulo
private static GCStatus fetchGcStatus() {
GCStatus result = null;
HostAndPort address = null;
try {
// Read the gc location from its lock
ZooReaderWriter zk = context.getZooReaderWriter();
String path = context.getZooKeeperRoot() + Constants.ZGC_LOCK;
List<String> locks = zk.getChildren(path, null);
if (locks != null && locks.size() > 0) {
Collections.sort(locks);
address = new ServerServices(new String(zk.getData(path + "/" + locks.get(0), null), UTF_8))
.getAddress(Service.GC_CLIENT);
GCMonitorService.Client client = ThriftUtil.getClient(new GCMonitorService.Client.Factory(),
address, context);
try {
result = client.getStatus(Tracer.traceInfo(), getContext().rpcCreds());
} finally {
ThriftUtil.returnClient(client);
}
}
} catch (Exception ex) {
log.warn("Unable to contact the garbage collector at " + address, ex);
}
return result;
}
代码示例来源:origin: apache/accumulo
String tserversPath = Constants.ZROOT + "/" + iid + Constants.ZTSERVERS;
try {
List<String> children = zoo.getChildren(tserversPath);
for (String child : children) {
message("Deleting " + tserversPath + "/" + child + " from zookeeper", opts);
else {
String path = tserversPath + "/" + child;
if (zoo.getChildren(path).size() > 0) {
if (!ZooLock.deleteLock(zoo, path, "tserver")) {
message("Did not delete " + tserversPath + "/" + child, opts);
代码示例来源:origin: apache/accumulo
zoo.mkdirs(path + "/" + LOCKS_NODE);
List<String> children = zoo.getChildren(path, new Watcher() {
@Override
public void process(WatchedEvent event) {
代码示例来源:origin: apache/accumulo
zReaderWriter.getChildren(zroot + Constants.ZRECOVERY, new Watcher() {
@Override
public void process(WatchedEvent event) {
内容来源于网络,如有侵权,请联系作者删除!