gpt4 book ai didi

io.fabric8.zookeeper.utils.ZooKeeperUtils.exists()方法的使用及代码示例

转载 作者:知者 更新时间:2024-03-16 11:28:40 29 4
gpt4 key购买 nike

本文整理了Java中io.fabric8.zookeeper.utils.ZooKeeperUtils.exists()方法的一些代码示例,展示了ZooKeeperUtils.exists()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZooKeeperUtils.exists()方法的具体详情如下:
包路径:io.fabric8.zookeeper.utils.ZooKeeperUtils
类名称:ZooKeeperUtils
方法名:exists

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);
  }
}

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com