本文整理了Java中io.fabric8.zookeeper.utils.ZooKeeperUtils.getChildren()
方法的一些代码示例,展示了ZooKeeperUtils.getChildren()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZooKeeperUtils.getChildren()
方法的具体详情如下:
包路径:io.fabric8.zookeeper.utils.ZooKeeperUtils
类名称:ZooKeeperUtils
方法名:getChildren
[英]Returns an empty list if the given path doesn't exist in curator
[中]如果给定路径在curator中不存在,则返回空列表
代码示例来源:origin: io.fabric8/fabric-core-agent-jclouds
/**
* Clears {@link Cache} and Zookeeper from all {@link Credentials}.
*/
public synchronized Set<String> keySet() {
Set<String> keys = new HashSet<String>();
try {
keys = new HashSet<String>(getChildren(curator, ZkPath.CLOUD_NODE.getPath()));
} catch (Exception e) {
LOGGER.warn("Failed to read from zookeeper jclouds credentials store.", e);
keys = cache.asMap().keySet();
}
return keys;
}
代码示例来源:origin: io.fabric8/fabric-zookeeper
public static List<String> getAllChildren(TreeCache cache, String path) throws Exception {
List<String> children = getChildren(cache, path);
List<String> allChildren = new ArrayList<String>();
for (String child : children) {
String fullPath = ZKPaths.makePath(path, child);
allChildren.add(fullPath);
allChildren.addAll(getAllChildren(cache, fullPath));
}
return allChildren;
}
代码示例来源:origin: jboss-fuse/fabric8
public static List<String> getAllChildren(TreeCacheExtended cache, String path) throws Exception {
List<String> children = getChildren(cache, path);
List<String> allChildren = new ArrayList<String>();
for (String child : children) {
String fullPath = ZKPaths.makePath(path, child);
allChildren.add(fullPath);
allChildren.addAll(getAllChildren(cache, fullPath));
}
return allChildren;
}
代码示例来源:origin: io.fabric8/fabric-zookeeper
public static List<String> getAllChildren(CuratorFramework curator, String path) throws Exception {
List<String> children = getChildren(curator, path);
List<String> allChildren = new ArrayList<String>();
for (String child : children) {
String fullPath = ZKPaths.makePath(path, child);
allChildren.add(fullPath);
allChildren.addAll(getAllChildren(curator, fullPath));
}
return allChildren;
}
代码示例来源:origin: io.fabric8/fabric-zookeeper
public static Properties getContainerTokens(CuratorFramework curator) throws Exception {
Properties props = new Properties();
if (exists(curator, CONTAINERS_NODE) != null) {
for (String key : getChildren(curator, CONTAINERS_NODE)) {
props.setProperty("container#" + key, getStringData(curator, CONTAINERS_NODE + "/" + key));
}
}
return props;
}
代码示例来源:origin: jboss-fuse/fabric8
public static List<String> getAllChildren(CuratorFramework curator, String path) throws Exception {
List<String> children = getChildren(curator, path);
List<String> allChildren = new ArrayList<String>();
for (String child : children) {
String fullPath = ZKPaths.makePath(path, child);
allChildren.add(fullPath);
allChildren.addAll(getAllChildren(curator, fullPath));
}
return allChildren;
}
代码示例来源:origin: jboss-fuse/fabric8
public static Properties getContainerTokens(CuratorFramework curator) throws Exception {
Properties props = new Properties();
if (exists(curator, CONTAINERS_NODE) != null) {
for (String key : getChildren(curator, CONTAINERS_NODE)) {
props.setProperty("container#" + key, getStringData(curator, CONTAINERS_NODE + "/" + key));
}
}
return props;
}
代码示例来源:origin: io.fabric8/fabric-commands
@SuppressWarnings("unchecked")
public int complete(String buffer, int cursor, List candidates) {
try {
if (curator.getZookeeperClient().isConnected()) {
// Guarantee that the final token is the one we're expanding
if (buffer == null) {
candidates.add("/");
return 1;
} else if (!buffer.startsWith("/")) {
return 0;
}
buffer = buffer.substring(0, cursor);
String path = buffer;
int idx = path.lastIndexOf("/") + 1;
String prefix = path.substring(idx);
// Only the root path can end in a /, so strip it off every other prefix
String dir = idx == 1 ? "/" : path.substring(0, idx - 1);
List<String> children = getChildren(curator, dir);
for (String child : children) {
if (child.startsWith(prefix)) {
candidates.add(child);
}
}
return candidates.size() == 0 ? buffer.length() : buffer.lastIndexOf("/") + 1;
}
} catch (Exception e) {
// Ignore
}
return 0;
}
代码示例来源:origin: jboss-fuse/fabric8
/**
* Returns the last modified time of the znode taking children into consideration.
*/
public static long lastModified(CuratorFramework curator, String path) throws Exception {
long lastModified = 0;
List<String> children = getChildren(curator, path);
if (children.isEmpty()) {
return exists(curator, path).getMtime();
} else {
for (String child : children) {
lastModified = Math.max(lastModified(curator, path + "/" + child), lastModified);
}
}
return lastModified;
}
代码示例来源:origin: io.fabric8/fabric-zookeeper
/**
* Returns the last modified time of the znode taking children into consideration.
*/
public static long lastModified(CuratorFramework curator, String path) throws Exception {
long lastModified = 0;
List<String> children = getChildren(curator, path);
if (children.isEmpty()) {
return exists(curator, path).getMtime();
} else {
for (String child : children) {
lastModified = Math.max(lastModified(curator, path + "/" + child), lastModified);
}
}
return lastModified;
}
代码示例来源:origin: jboss-fuse/fabric8
private String containerWebAppUrl(String versionsPath, String name) {
try {
if (exists(curator.get(), versionsPath) != null) {
List<String> children = getChildren(curator.get(), versionsPath);
if (children != null && !children.isEmpty()) {
for (String child : children) {
List<String> grandChildren = getChildren(curator.get(), parentPath);
if (!grandChildren.isEmpty()) {
String containerPath = parentPath + "/" + grandChildren.get(0);
代码示例来源:origin: io.fabric8/fabric-core-agent-jclouds
/**
* Returns the size of the getStore().
* If zookeeper is connected it returns the size of the zookeeper store, else it falls back to the cache.
*/
public synchronized int size() {
int size = 0;
{
try {
if (exists(curator, ZkPath.CLOUD_NODES.getPath()) != null) {
size = getChildren(curator, ZkPath.CLOUD_NODES.getPath()).size();
}
} catch (Exception ex) {
size = (int) cache.size();
}
}
return size;
}
代码示例来源:origin: io.fabric8/fabric-commands
@SuppressWarnings("unchecked")
public int complete(String buffer, int cursor, List candidates) {
StringsCompleter delegate = new StringsCompleter();
try {
if (curator.getZookeeperClient().isConnected()) {
delegate.getStrings().addAll(getChildren(curator, CLUSTER_PATH));
}
} catch (Exception ex) {
//ignore
}
return delegate.complete(buffer, cursor, candidates);
}
代码示例来源:origin: jboss-fuse/fabric8
@Override
public URI getMavenRepoURI() {
assertValid();
URI uri = URI.create(getDefaultRepo());
try {
if (exists(curator.get(), ZkPath.MAVEN_PROXY.getPath("download")) != null) {
List<String> children = getChildren(curator.get(), ZkPath.MAVEN_PROXY.getPath("download"));
if (children != null && !children.isEmpty()) {
Collections.sort(children);
String mavenRepo = getSubstitutedPath(curator.get(), ZkPath.MAVEN_PROXY.getPath("download") + "/" + children.get(0));
if (mavenRepo != null && !mavenRepo.endsWith("/")) {
mavenRepo += "/";
}
uri = new URI(mavenRepo);
}
}
} catch (Exception e) {
//On exception just return uri.
}
return uri;
}
代码示例来源:origin: jboss-fuse/fabric8
@Override
public URI getMavenRepoUploadURI() {
assertValid();
URI uri = URI.create(getDefaultRepo());
try {
if (exists(curator.get(), ZkPath.MAVEN_PROXY.getPath("upload")) != null) {
List<String> children = getChildren(curator.get(), ZkPath.MAVEN_PROXY.getPath("upload"));
if (children != null && !children.isEmpty()) {
Collections.sort(children);
String mavenRepo = getSubstitutedPath(curator.get(), ZkPath.MAVEN_PROXY.getPath("upload") + "/" + children.get(0));
if (mavenRepo != null && !mavenRepo.endsWith("/")) {
mavenRepo += "/";
}
uri = new URI(mavenRepo);
}
}
} catch (Exception e) {
//On exception just return uri.
}
return uri;
}
代码示例来源:origin: jboss-fuse/fabric8
List<URI> uris = new ArrayList<URI>();
if (exists(curator.get(), ZkPath.MAVEN_PROXY.getPath("download")) != null) {
List<String> children = getChildren(curator.get(), ZkPath.MAVEN_PROXY.getPath("download"));
if (children != null && !children.isEmpty()) {
Collections.sort(children);
代码示例来源:origin: jboss-fuse/fabric8
public ZkContents read(String path, boolean escape) throws Exception {
CuratorFramework curator = getCurator();
Stat exists = exists(curator, path);
if (exists == null) {
return null;
}
int numChildren = exists.getNumChildren();
int dataLength = exists.getDataLength();
List<String> children = null;
String data = null;
if (numChildren > 0) {
children = getChildren(curator, path);
} else {
data = getContents(path, escape);
}
return new ZkContents(dataLength, children, data);
}
代码示例来源:origin: jboss-fuse/fabric8
if (exists(curator.get(), path) != null) {
for (String pid : getChildren(curator.get(), path)) {
for (String key : getChildren(curator.get(), ZkPath.PORTS_CONTAINER_PID.getPath(container.getId(), pid))) {
String port = getStringData(curator.get(), ZkPath.PORTS_CONTAINER_PID_KEY.getPath(container.getId(), pid, key));
try {
代码示例来源:origin: jboss-fuse/fabric8
if (lease != null) {
if (exists(curator.get(), containerPortsPath) != null) {
for (String pid : getChildren(curator.get(), containerPortsPath)) {
unregisterPort(container, pid, lease);
代码示例来源:origin: jboss-fuse/fabric8
for (String key : getChildren(curator.get(), containerPortsPidPath)) {
unregisterPort(container, pid, key, lease);
内容来源于网络,如有侵权,请联系作者删除!