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

x33g5p2x  于2022-02-05 转载在 其他  
字(7.5k)|赞(0)|评价(0)|浏览(131)

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

ZooKeeperUtils.setData介绍

暂无

代码示例

代码示例来源:origin: jboss-fuse/fabric8

public static void setData(CuratorFramework curator, String path, String value) throws Exception {
  setData(curator, path, value != null ? value.getBytes(UTF_8) : null);
}

代码示例来源:origin: io.fabric8/fabric-zookeeper

public static void setData(CuratorFramework curator, String path, String value, CreateMode createMode) throws Exception {
  setData(curator, path, value != null ? value.getBytes(UTF_8) : null, createMode);
}

代码示例来源:origin: io.fabric8/fabric-zookeeper

public void setStringData(String zkPath, String data, CreateMode createMode) throws Exception {
  String currentValue = cache.get(data);
  if (currentValue == null || !Objects.equal(currentValue, data)) {
    ZooKeeperUtils.setData(curator, zkPath, data, createMode);
    cache.put(zkPath, data);
  }
}

代码示例来源:origin: io.fabric8/fabric-zookeeper

public static void copy(CuratorFramework curator, String from, String to) throws Exception {
  for (String child : curator.getChildren().forPath(from)) {
    String fromChild = from + "/" + child;
    String toChild = to + "/" + child;
    if (curator.checkExists().forPath(toChild) == null) {
      byte[] data = curator.getData().forPath(fromChild);
      setData(curator, toChild, data);
      copy(curator, fromChild, toChild);
    }
  }
}

代码示例来源:origin: io.fabric8/fabric-core-agent-jclouds

@Override
  public Credentials setValue(Credentials credentials) {
    try {
      setData(curator, ZkPath.CLOUD_NODE_IDENTITY.getPath(normalizeKey(key)), credentials.identity);
      setData(curator, ZkPath.CLOUD_NODE_CREDENTIAL.getPath(normalizeKey(key)), credentials.credential);
    } catch (Exception e) {
      LOGGER.warn("Failed to store jclouds credentials to zookeeper.", e);
    }
    return credentials;
  }
}

代码示例来源:origin: jboss-fuse/fabric8

public void setStringData(String zkPath, String data, CreateMode createMode) throws Exception {
  String currentValue = cache.get(data);
  if (currentValue == null || !Objects.equal(currentValue, data)) {
    ZooKeeperUtils.setData(curator, zkPath, data, createMode);
    cache.put(zkPath, data);
  }
}

代码示例来源:origin: jboss-fuse/fabric8

public static void copy(CuratorFramework curator, String from, String to) throws Exception {
  for (String child : curator.getChildren().forPath(from)) {
    String fromChild = from + "/" + child;
    String toChild = to + "/" + child;
    if (curator.checkExists().forPath(toChild) == null) {
      byte[] data = curator.getData().forPath(fromChild);
      setData(curator, toChild, data);
      copy(curator, fromChild, toChild);
    }
  }
}

代码示例来源:origin: jboss-fuse/fabric8

public static void copy(CuratorFramework source, CuratorFramework dest, String path) throws Exception {
  for (String child : source.getChildren().forPath(path)) {
    child = ZKPaths.makePath(path, child);
    Stat stat = source.checkExists().forPath(child);
    if (stat != null && stat.getEphemeralOwner() == 0 && dest.checkExists().forPath(child) == null) {
      byte[] data = source.getData().forPath(child);
      setData(dest, child, data);
      copy(source, dest, child);
    }
  }
}

代码示例来源:origin: io.fabric8/fabric-zookeeper

public static void copy(CuratorFramework source, CuratorFramework dest, String path) throws Exception {
  for (String child : source.getChildren().forPath(path)) {
    child = ZKPaths.makePath(path, child);
    Stat stat = source.checkExists().forPath(child);
    if (stat != null && stat.getEphemeralOwner() == 0 && dest.checkExists().forPath(child) == null) {
      byte[] data = source.getData().forPath(child);
      setData(dest, child, data);
      copy(source, dest, child);
    }
  }
}

代码示例来源:origin: io.fabric8/fabric-commands

@Override
  protected Object doExecute() throws Exception {
    if (Strings.isNotBlank(newAlgorithm)) {
      setData(getCurator(), ZkPath.AUTHENTICATION_CRYPT_ALGORITHM.getPath(), newAlgorithm);
    }
    return null;
  }
}

代码示例来源:origin: jboss-fuse/fabric8

@Override
public void setDefaultJvmOptions(String jvmOptions) {
  assertValid();
  try {
    String opts = jvmOptions != null ? jvmOptions : "";
    setData(curator.get(), JVM_OPTIONS_PATH, opts);
  } catch (Exception e) {
    throw FabricException.launderThrowable(e);
  }
}

代码示例来源:origin: io.fabric8/fabric-commands

@Override
  protected Object doExecute() throws Exception {
    if (Strings.isNotBlank(newPassword)) {
      setData(getCurator(), ZkPath.AUTHENTICATION_CRYPT_PASSWORD.getPath(), PasswordEncoder.encode(newPassword));
    }
    return null;
  }
}

代码示例来源:origin: jboss-fuse/fabric8

@Override
public void setRequirements(FabricRequirements requirements) throws IOException {
  assertValid();
  try {
    String json = RequirementsJson.toJSON(requirements);
    setData(curator.get(), REQUIREMENTS_JSON_PATH, json);
  } catch (Exception e) {
    throw FabricException.launderThrowable(e);
  }
}

代码示例来源:origin: jboss-fuse/fabric8

@Override
public void setDefaultVersion(String versionId) {
  assertValid();
  try {
    setData(curator.get(), ZkPath.CONFIG_DEFAULT_VERSION.getPath(), versionId);
  } catch (Exception e) {
    throw FabricException.launderThrowable(e);
  }
}

代码示例来源:origin: jboss-fuse/fabric8

@Override
public void setContainerVersion(String containerId, String versionId) {
  assertValid();
  try {
    String oldVersionId = getStringData(curator.get(), ZkPath.CONFIG_CONTAINER.getPath(containerId));
    String oldProfileIds = getStringData(curator.get(), ZkPath.CONFIG_VERSIONS_CONTAINER.getPath(oldVersionId, containerId));
    setData(curator.get(), ZkPath.CONFIG_VERSIONS_CONTAINER.getPath(versionId, containerId), oldProfileIds);
    setData(curator.get(), ZkPath.CONFIG_CONTAINER.getPath(containerId), versionId);
  } catch (Exception e) {
    throw FabricException.launderThrowable(e);
  }
}

代码示例来源:origin: io.fabric8.runtime/fabric-runtime-container-wildfly-registration

private void registerJmx(Container container) throws Exception {
  String jmxUrl = getJmxUrl(container.getId(), getJmxPort());
  ZooKeeperUtils.setData(curator.get(), CONTAINER_JMX.getPath(container.getId()), jmxUrl);
}

代码示例来源:origin: jboss-fuse/fabric8

@Override
public void setContainerMetadata(CreateContainerMetadata metadata) {
  assertValid();
  //We encode the metadata so that they are more friendly to import/export.
  try {
    setData(curator.get(), ZkPath.CONTAINER_METADATA.getPath(metadata.getContainerName()), Base64Encoder.encode(ObjectUtils.toBytes(metadata)));
  } catch (Exception e) {
    throw FabricException.launderThrowable(e);
  }
}

代码示例来源:origin: io.fabric8.runtime/fabric8-runtime-container-tomcat-registration

private void registerHttp(Container container) throws Exception {
  boolean httpEnabled = isHttpEnabled();
  boolean httpsEnabled = isHttpsEnabled();
  String protocol = httpsEnabled && !httpEnabled ? "https" : "http";
  int httpPort = httpsEnabled && !httpEnabled ? getHttpsPort() : getHttpPort();
  String httpUrl = getHttpUrl(protocol, container.getId(), httpPort);
  ZooKeeperUtils.setData(curator.get(), CONTAINER_HTTP.getPath(container.getId()), httpUrl);
}

代码示例来源:origin: io.fabric8.runtime/fabric-runtime-container-wildfly-registration

private void registerHttp(Container container) throws Exception {
  boolean httpEnabled = isHttpEnabled();
  boolean httpsEnabled = isHttpsEnabled();
  String protocol = httpsEnabled && !httpEnabled ? "https" : "http";
  int httpPort = httpsEnabled && !httpEnabled ? getHttpsPort() : getHttpPort();
  String httpUrl = getHttpUrl(protocol, container.getId(), httpPort);
  ZooKeeperUtils.setData(curator.get(), CONTAINER_HTTP.getPath(container.getId()), httpUrl);
}

代码示例来源:origin: io.fabric8.runtime/fabric-runtime-container-tomcat-registration

private void registerHttp(Container container) throws Exception {
  boolean httpEnabled = isHttpEnabled();
  boolean httpsEnabled = isHttpsEnabled();
  String protocol = httpsEnabled && !httpEnabled ? "https" : "http";
  int httpPort = httpsEnabled && !httpEnabled ? getHttpsPort() : getHttpPort();
  String httpUrl = getHttpUrl(protocol, container.getId(), httpPort);
  ZooKeeperUtils.setData(curator.get(), CONTAINER_HTTP.getPath(container.getId()), httpUrl);
}

相关文章