本文整理了Java中io.fabric8.zookeeper.utils.ZooKeeperUtils.exists()
方法的一些代码示例,展示了ZooKeeperUtils.exists()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZooKeeperUtils.exists()
方法的具体详情如下:
包路径:io.fabric8.zookeeper.utils.ZooKeeperUtils
类名称:ZooKeeperUtils
方法名:exists
暂无
代码示例来源:origin: io.fabric8/fabric-zookeeper
public void deleteData(String path) throws Exception {
if (ZooKeeperUtils.exists(curator, path) != null) {
LOG.info("unregistered web app at " + path);
ZooKeeperUtils.deleteSafe(curator, path);
}
cache.remove(path);
}
}
代码示例来源:origin: jboss-fuse/fabric8
public void deleteData(String path) throws Exception {
if (ZooKeeperUtils.exists(curator, path) != null) {
LOG.info("unregistered web app at " + path);
ZooKeeperUtils.deleteSafe(curator, path);
}
cache.remove(path);
}
}
代码示例来源: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
protected void removeZkPath(String path) throws Exception {
CuratorFramework curator = this.curator.get();
if (curator != null && ZooKeeperUtils.exists(curator, path) != null) {
LOGGER.info("Unregister API at " + path);
ZooKeeperUtils.deleteSafe(curator, path);
}
registeredZkPaths.remove(path);
}
代码示例来源: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: jboss-fuse/fabric8
protected void removeZkPathUpToParent(String path, boolean restApi) throws Exception {
String parentPath = restApi ? "/fabric/registry/clusters/apis/rest" : "/fabric/registry/clusters/apis/ws";
CuratorFramework curator = this.curator.get();
if (curator != null && ZooKeeperUtils.exists(curator, path) != null) {
LOGGER.info("Unregister API at " + path);
ZooKeeperUtils.deleteSafeUpTo(curator, path, parentPath);
}
registeredZkPaths.remove(path);
}
代码示例来源:origin: io.fabric8/fabric-cxf-registry
protected void removeZkPath(String path) throws Exception {
CuratorFramework curator = this.curator.get();
if (curator != null && ZooKeeperUtils.exists(curator, path) != null) {
LOGGER.info("Unregister API at " + path);
ZooKeeperUtils.deleteSafe(curator, path);
}
registeredZkPaths.remove(path);
}
代码示例来源:origin: jboss-fuse/fabric8
public static String getSubstitutedPath(final CuratorFramework curator, String path) throws Exception {
String normalized = path != null && path.contains("#") ? path.substring(0, path.lastIndexOf('#')) : path;
if (normalized != null && exists(curator, normalized) != null) {
byte[] data = ZkPath.loadURL(curator, path);
if (data != null && data.length > 0) {
String str = new String(ZkPath.loadURL(curator, path), "UTF-8");
return getSubstitutedData(curator, str);
}
}
return null;
}
代码示例来源:origin: io.fabric8/fabric-zookeeper
public static String getSubstitutedPath(final CuratorFramework curator, String path) throws Exception {
String normalized = path != null && path.contains("#") ? path.substring(0, path.lastIndexOf('#')) : path;
if (normalized != null && exists(curator, normalized) != null) {
byte[] data = ZkPath.loadURL(curator, path);
if (data != null && data.length > 0) {
String str = new String(ZkPath.loadURL(curator, path), "UTF-8");
return getSubstitutedData(curator, str);
}
}
return null;
}
代码示例来源:origin: io.fabric8/fabric-commands
@Override
protected Object doExecute() throws Exception {
if (exists(getCurator(), ZkPath.AUTHENTICATION_CRYPT_ALGORITHM.getPath()) != null) {
System.out.println(getStringData(getCurator(), ZkPath.AUTHENTICATION_CRYPT_ALGORITHM.getPath()));
}
return null;
}
}
代码示例来源:origin: jboss-fuse/fabric8
@Override
public boolean isContainerAlive(String id) {
assertValid();
try {
return exists(curator.get(), ZkPath.CONTAINER_ALIVE.getPath(id)) != null;
} catch (KeeperException.NoNodeException e) {
return false;
} catch (Exception e) {
throw FabricException.launderThrowable(e);
}
}
代码示例来源:origin: io.fabric8/fabric-commands
@Override
protected Object doExecute() throws Exception {
if (exists(getCurator(), ZkPath.AUTHENTICATION_CRYPT_PASSWORD.getPath()) != null) {
System.out.println(PasswordEncoder.decode(getStringData(getCurator(), ZkPath.AUTHENTICATION_CRYPT_PASSWORD.getPath())));
}
return null;
}
}
代码示例来源:origin: io.fabric8.runtime/fabric-runtime-container-wildfly-registration
/**
* Returns the global resolution policy.
*/
private String getGlobalResolutionPolicy(RuntimeProperties sysprops, CuratorFramework zooKeeper) throws Exception {
String policy = ZkDefs.LOCAL_HOSTNAME;
List<String> validResolverList = Arrays.asList(ZkDefs.VALID_RESOLVERS);
if (ZooKeeperUtils.exists(zooKeeper, ZkPath.POLICIES.getPath(ZkDefs.RESOLVER)) != null) {
policy = ZooKeeperUtils.getStringData(zooKeeper, ZkPath.POLICIES.getPath(ZkDefs.RESOLVER));
} else if (sysprops.getProperty(ZkDefs.GLOBAL_RESOLVER_PROPERTY) != null && validResolverList.contains(sysprops.getProperty(ZkDefs.GLOBAL_RESOLVER_PROPERTY))) {
policy = sysprops.getProperty(ZkDefs.GLOBAL_RESOLVER_PROPERTY);
ZooKeeperUtils.setData(zooKeeper, ZkPath.POLICIES.getPath("resolver"), policy);
}
return policy;
}
代码示例来源:origin: io.fabric8.runtime/embedded
/**
* Returns the global resolution policy.
*/
private String getGlobalResolutionPolicy(RuntimeProperties sysprops, CuratorFramework zooKeeper) throws Exception {
String policy = ZkDefs.LOCAL_HOSTNAME;
List<String> validResolverList = Arrays.asList(ZkDefs.VALID_RESOLVERS);
if (ZooKeeperUtils.exists(zooKeeper, ZkPath.POLICIES.getPath(ZkDefs.RESOLVER)) != null) {
policy = ZooKeeperUtils.getStringData(zooKeeper, ZkPath.POLICIES.getPath(ZkDefs.RESOLVER));
} else if (sysprops.getProperty(ZkDefs.GLOBAL_RESOLVER_PROPERTY) != null && validResolverList.contains(sysprops.getProperty(ZkDefs.GLOBAL_RESOLVER_PROPERTY))) {
policy = sysprops.getProperty(ZkDefs.GLOBAL_RESOLVER_PROPERTY);
ZooKeeperUtils.setData(zooKeeper, ZkPath.POLICIES.getPath("resolver"), policy);
}
return policy;
}
代码示例来源:origin: io.fabric8.runtime/fabric-runtime-embedded
/**
* Returns the global resolution policy.
*/
private String getGlobalResolutionPolicy(RuntimeProperties sysprops, CuratorFramework zooKeeper) throws Exception {
String policy = ZkDefs.LOCAL_HOSTNAME;
List<String> validResolverList = Arrays.asList(ZkDefs.VALID_RESOLVERS);
if (ZooKeeperUtils.exists(zooKeeper, ZkPath.POLICIES.getPath(ZkDefs.RESOLVER)) != null) {
policy = ZooKeeperUtils.getStringData(zooKeeper, ZkPath.POLICIES.getPath(ZkDefs.RESOLVER));
} else if (sysprops.getProperty(ZkDefs.GLOBAL_RESOLVER_PROPERTY) != null && validResolverList.contains(sysprops.getProperty(ZkDefs.GLOBAL_RESOLVER_PROPERTY))) {
policy = sysprops.getProperty(ZkDefs.GLOBAL_RESOLVER_PROPERTY);
ZooKeeperUtils.setData(zooKeeper, ZkPath.POLICIES.getPath("resolver"), policy);
}
return policy;
}
代码示例来源:origin: jboss-fuse/fabric8
private String getContainerResolutionPolicy(CuratorFramework zooKeeper, String container) throws Exception {
String policy = null;
List<String> validResolverList = Arrays.asList(ZkDefs.VALID_RESOLVERS);
if (exists(zooKeeper, ZkPath.CONTAINER_RESOLVER.getPath(container)) != null) {
policy = getStringData(zooKeeper, ZkPath.CONTAINER_RESOLVER.getPath(container));
} else if (bootstrapConfiguration.get().getLocalResolver() != null && validResolverList.contains(bootstrapConfiguration.get().getLocalResolver())) {
policy = bootstrapConfiguration.get().getLocalResolver();
}
return policy;
}
代码示例来源:origin: io.fabric8.runtime/fabric-runtime-container-karaf-registration
private String getContainerResolutionPolicy(CuratorFramework zooKeeper, String container) throws Exception {
String policy = null;
List<String> validResolverList = Arrays.asList(ZkDefs.VALID_RESOLVERS);
if (exists(zooKeeper, ZkPath.CONTAINER_RESOLVER.getPath(container)) != null) {
policy = getStringData(zooKeeper, ZkPath.CONTAINER_RESOLVER.getPath(container));
} else if (bootstrapConfiguration.get().getLocalResolver() != null && validResolverList.contains(bootstrapConfiguration.get().getLocalResolver())) {
policy = bootstrapConfiguration.get().getLocalResolver();
}
return policy;
}
代码示例来源:origin: io.fabric8.runtime/fabric-runtime-container-tomcat-registration
/**
* Returns the container specific resolution policy.
*/
private String getContainerResolutionPolicy(CuratorFramework zooKeeper, String container) throws Exception {
String policy = null;
List<String> validResolverList = Arrays.asList(ZkDefs.VALID_RESOLVERS);
if (exists(zooKeeper, ZkPath.CONTAINER_RESOLVER.getPath(container)) != null) {
policy = getStringData(zooKeeper, ZkPath.CONTAINER_RESOLVER.getPath(container));
} else if (bootstrapConfiguration.get().getLocalResolver() != null && validResolverList.contains(bootstrapConfiguration.get().getLocalResolver())) {
policy = bootstrapConfiguration.get().getLocalResolver();
}
return policy;
}
代码示例来源:origin: io.fabric8.runtime/fabric-runtime-container-wildfly-registration
/**
* Returns the container specific resolution policy.
*/
private String getContainerResolutionPolicy(CuratorFramework zooKeeper, String container) throws Exception {
String policy = null;
List<String> validResolverList = Arrays.asList(ZkDefs.VALID_RESOLVERS);
if (exists(zooKeeper, ZkPath.CONTAINER_RESOLVER.getPath(container)) != null) {
policy = getStringData(zooKeeper, ZkPath.CONTAINER_RESOLVER.getPath(container));
} else if (bootstrapConfiguration.get().getLocalResolver() != null && validResolverList.contains(bootstrapConfiguration.get().getLocalResolver())) {
policy = bootstrapConfiguration.get().getLocalResolver();
}
return policy;
}
代码示例来源:origin: io.fabric8.runtime/fabric-runtime-container-karaf-registration
private void checkAlive() throws Exception {
RuntimeProperties sysprops = runtimeProperties.get();
String runtimeIdentity = sysprops.getRuntimeIdentity();
String nodeAlive = CONTAINER_ALIVE.getPath(runtimeIdentity);
Stat stat = exists(curator.get(), nodeAlive);
if (stat != null) {
if (stat.getEphemeralOwner() != curator.get().getZookeeperClient().getZooKeeper().getSessionId()) {
delete(curator.get(), nodeAlive);
create(curator.get(), nodeAlive, CreateMode.EPHEMERAL);
}
} else {
create(curator.get(), nodeAlive, CreateMode.EPHEMERAL);
}
}
内容来源于网络,如有侵权,请联系作者删除!