本文整理了Java中io.fabric8.zookeeper.utils.ZooKeeperUtils.deleteSafe()
方法的一些代码示例,展示了ZooKeeperUtils.deleteSafe()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZooKeeperUtils.deleteSafe()
方法的具体详情如下:
包路径:io.fabric8.zookeeper.utils.ZooKeeperUtils
类名称:ZooKeeperUtils
方法名:deleteSafe
[英]Deletes a path and (when there are no other children) also parent path - up to given parent
[中]删除一个路径,并且(当没有其他子路径时)还删除父路径,直到给定的父路径
代码示例来源:origin: io.fabric8/fabric-zookeeper
public void delete(String path) throws Exception {
ZooKeeperUtils.deleteSafe(curator, path);
}
代码示例来源:origin: jboss-fuse/fabric8
public void delete(String path) throws Exception {
ZooKeeperUtils.deleteSafe(curator, path);
}
代码示例来源:origin: io.fabric8/fabric-zookeeper
public static void deleteSafe(CuratorFramework curator, String path) throws Exception {
if (curator.checkExists().forPath(path) != null) {
for (String child : curator.getChildren().forPath(path)) {
deleteSafe(curator, path + "/" + child);
}
try {
curator.delete().forPath(path);
} catch (KeeperException.NotEmptyException ex) {
deleteSafe(curator, path);
}
}
}
代码示例来源:origin: jboss-fuse/fabric8
public static void deleteSafe(CuratorFramework curator, String path) throws Exception {
if (curator.checkExists().forPath(path) != null) {
for (String child : curator.getChildren().forPath(path)) {
deleteSafe(curator, path + "/" + child);
}
try {
curator.delete().forPath(path);
} catch (KeeperException.NotEmptyException ex) {
deleteSafe(curator, path);
}
}
}
代码示例来源: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-maven-proxy
private void unregister(String type) {
Set<String> proxyNodes = registeredProxies.get(type);
if (proxyNodes != null) {
try {
for (String entry : registeredProxies.get(type)) {
deleteSafe(curator.get(), entry);
}
} catch (Exception e) {
LOGGER.warn("Failed to remove maven proxy from registry.");
}
registeredProxies.get(type).clear();
}
}
代码示例来源: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: 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: io.fabric8/fabric-core-agent-jclouds
/**
* Removes {@link Credentials} for {@link Cache} and Zookeeper.
*/
public synchronized Credentials remove(Object o) {
Credentials credentials = cache.asMap().remove(o);
try {
if (credentials == null) {
credentials = get(o);
}
String normalizedKey = normalizeKey(o);
deleteSafe(curator, ZkPath.CLOUD_NODE_IDENTITY.getPath(normalizedKey));
deleteSafe(curator, ZkPath.CLOUD_NODE_CREDENTIAL.getPath(normalizedKey));
} catch (Exception e) {
LOGGER.warn("Failed to remove jclouds credentials to zookeeper.", e);
}
return credentials;
}
代码示例来源:origin: io.fabric8/fabric-core-agent-jclouds
public synchronized void clear() {
cache.cleanUp();
try {
for (String nodeId : keySet()) {
deleteSafe(curator, ZkPath.CLOUD_NODE_IDENTITY.getPath(nodeId));
deleteSafe(curator, ZkPath.CLOUD_NODE_CREDENTIAL.getPath(nodeId));
}
} catch (Exception e) {
LOGGER.warn("Failed to clear zookeeper jclouds credentials store.", e);
}
}
代码示例来源:origin: jboss-fuse/fabric8
private void cleanUpDirtyZKNodes(InterProcessSemaphoreV2 interProcessLock) {
if (interProcessLock != null) {
try {
LOGGER.info("Cleaning eventual partial nodes");
Collection<String> participantNodes = interProcessLock.getParticipantNodes();
for (String nodePath : participantNodes) {
String path = "/fabric/registry/ports/lock/leases/" + nodePath;
LOGGER.debug("Remove dirty zk lock node: {}", path);
deleteSafe(curator.get(), path);
}
} catch (Exception e) {
LOGGER.error("Error while cleaning zk partial nodes", e);
}
} else {
LOGGER.info("No registerPort leftovers nodes found");
}
}
代码示例来源:origin: jboss-fuse/fabric8
if (curator.checkExists().forPath(path) != null) {
for (String child : curator.getChildren().forPath(path)) {
deleteSafe(curator, path + "/" + child);
deleteSafe(curator, path);
代码示例来源:origin: jboss-fuse/fabric8
@Override
public void deleteContainer(FabricService fabricService, String containerId) {
assertValid();
try {
if (curator.get() == null) {
throw new IllegalStateException("Zookeeper service not available");
}
// Wipe all config entries that are related to the container for all versions.
ProfileService profileService = fabricService.adapt(ProfileService.class);
for (String version : profileService.getVersions()) {
deleteSafe(curator.get(), ZkPath.CONFIG_VERSIONS_CONTAINER.getPath(version, containerId));
}
deleteSafe(curator.get(), ZkPath.CONFIG_CONTAINER.getPath(containerId));
deleteSafe(curator.get(), ZkPath.CONTAINER.getPath(containerId));
deleteSafe(curator.get(), ZkPath.CONTAINER_ALIVE.getPath(containerId));
deleteSafe(curator.get(), ZkPath.CONTAINER_DOMAINS.getPath(containerId));
deleteSafe(curator.get(), ZkPath.CONTAINER_PROVISION.getPath(containerId));
deleteSafe(curator.get(), ZkPath.CONTAINER_STATUS.getPath(containerId));
deleteSafe(curator.get(), ZkPath.AUTHENTICATION_CONTAINER.getPath(containerId));
} catch (Exception e) {
throw FabricException.launderThrowable(e);
}
}
代码示例来源:origin: jboss-fuse/fabric8
private void doHandleNotification(Notification notif, Object o) {
LOGGER.trace("handleNotification[{}]", notif);
if (notif instanceof MBeanServerNotification) {
MBeanServerNotification notification = (MBeanServerNotification) notif;
String domain = notification.getMBeanName().getDomain();
String path = CONTAINER_DOMAIN.getPath((String) o, domain);
try {
if (MBeanServerNotification.REGISTRATION_NOTIFICATION.equals(notification.getType())) {
if (domains.add(domain) && exists(curator.get(), path) == null) {
setData(curator.get(), path, "");
}
} else if (MBeanServerNotification.UNREGISTRATION_NOTIFICATION.equals(notification.getType())) {
domains.clear();
domains.addAll(Arrays.asList(mbeanServer.get().getDomains()));
if (!domains.contains(domain)) {
// domain is no present any more
deleteSafe(curator.get(), path);
}
}
} catch (IllegalStateException e){
handleException(e);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
LOGGER.info("Thread was interrupted while waiting for Zookeeper connection. Skipping JMX notification.");
} catch (Exception e) {
LOGGER.warn("Exception while jmx domain synchronization from event: " + notif + ". This exception will be ignored.", e);
}
}
}
代码示例来源:origin: io.fabric8/fabric-core-agent-jclouds
@Override
protected Object doExecute() throws Exception {
boolean connected = getCurator().getZookeeperClient().isConnected();
Container current = null;
if (connected) {
deleteSafe(getCurator(), ZkPath.CLOUD_SERVICE.getPath(name));
current = fabricService.getCurrentContainer();
}
//Remove compute configurations for the service.
Configuration[] computeConfigs = findConfigurationByFactoryPid("org.jclouds.compute");
if (computeConfigs != null) {
for (Configuration configuration : computeConfigs) {
Dictionary props = configuration.getProperties();
if (props != null) {
String contextName = (String) props.get(Constants.NAME);
if (name.equals(contextName)) {
configuration.delete();
}
}
}
}
return null;
}
代码示例来源:origin: jboss-fuse/fabric8
@Override
public void setContainerAlive(String id, boolean flag) {
assertValid();
try {
if (flag) {
setData(curator.get(), ZkPath.CONTAINER_ALIVE.getPath(id), "alive");
} else {
deleteSafe(curator.get(), ZkPath.CONTAINER_ALIVE.getPath(id));
}
} catch (KeeperException.NoNodeException e) {
// ignore
} catch (Exception e) {
throw FabricException.launderThrowable(e);
}
}
代码示例来源:origin: jboss-fuse/fabric8
private void registerDomains() throws Exception {
String runtimeIdentity = runtimeProperties.get().getRuntimeIdentity();
String domainsNode = CONTAINER_DOMAINS.getPath(runtimeIdentity);
try {
Stat stat = exists(curator.get(), domainsNode);
if (stat != null) {
try {
deleteSafe(curator.get(), domainsNode);
} catch (IllegalStateException e) {
handleException(e);
}
}
synchronized (this) {
domains.addAll(Arrays.asList(mbeanServer.get().getDomains()));
for (String domain : domains) {
try {
setData(curator.get(), CONTAINER_DOMAIN.getPath(runtimeIdentity, domain), "", CreateMode.EPHEMERAL);
} catch (IllegalStateException e) {
handleException(e);
}
}
}
} catch (IllegalStateException e){
handleException(e);
}
}
代码示例来源:origin: jboss-fuse/fabric8
unregisterPort(container, pid, key, lease);
deleteSafe(curator.get(), containerPortsPidPath);
代码示例来源:origin: io.fabric8.runtime/fabric-runtime-embedded
Stat stat = ZooKeeperUtils.exists(curator.get(), domainsNode);
if (stat != null) {
ZooKeeperUtils.deleteSafe(curator.get(), domainsNode);
内容来源于网络,如有侵权,请联系作者删除!