gpt4 book ai didi

io.fabric8.zookeeper.ZkPath.loadURL()方法的使用及代码示例

转载 作者:知者 更新时间:2024-03-15 19:52:40 25 4
gpt4 key购买 nike

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

ZkPath.loadURL介绍

[英]Loads a zoo keeper URL content using the provided ZooKeeper client.
[中]使用提供的ZooKeeper客户端加载zoo keeper URL内容。

代码示例

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

@Override
  public String getValue(String key) {
    if (key.startsWith("zk:")) {
      try {
        return new String(ZkPath.loadURL(curator, key), "UTF-8");
      } catch (Exception e) {
        //ignore and just return null.
      }
    }
    return null;
  }
});

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

@Override
  public String getValue(String key) {
    if (key.startsWith("zk:")) {
      try {
        return new String(ZkPath.loadURL(curator, key), "UTF-8");
      } catch (Exception e) {
        //ignore and just return null.
      }
    }
    return null;
  }
});

代码示例来源: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: jboss-fuse/fabric8

@Override
  public InputStream getInputStream() throws IOException {
    assertValid();
    try {
      return new ByteArrayInputStream(ZkPath.loadURL(curator.get(), url.toString()));
    } catch (Exception e) {
      LOGGER.error("Error opening zookeeper url", e);
      throw (IOException) new IOException("Error opening zookeeper url").initCause(e);
    }
  }
}

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

@Override
  public InputStream getInputStream() throws IOException {
    assertValid();
    try {
      return new ByteArrayInputStream(ZkPath.loadURL(curator.get(), url.toString()));
    } catch (Exception e) {
      LOGGER.error("Error opening zookeeper url", e);
      throw (IOException) new IOException("Error opening zookeeper url").initCause(e);
    }
  }
}

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

@Override
  public String resolve(FabricService fabricService, Map<String, Map<String, String>> configs, String pid, String key, String value) {
    try {
      return new String(ZkPath.loadURL(fabricService.adapt(CuratorFramework.class), value), "UTF-8");
    } catch (KeeperException.NoNodeException e) {
      LOGGER.warn("Could not load property value: {}. Ignoring.", value, e);
      return "";
    } catch (Exception e) {
      throw FabricException.launderThrowable(e);
    }
  }
}

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

private String getWebUrl(String containerPath) throws Exception {
  if (curator.get().checkExists().forPath(containerPath) != null) {
    byte[] bytes = ZkPath.loadURL(curator.get(), containerPath);
    String text = new String(bytes);
    // NOTE this is a bit naughty, we should probably be doing
    // Jackson parsing here; but we only need 1 String and
    // this avoids the jackson runtime dependency - its just a bit brittle
    // only finding http endpoints and all
    String prefix = "\"services\":[\"";
    int idx = text.indexOf(prefix);
    String answer = text;
    if (idx > 0) {
      int startIndex = idx + prefix.length();
      int endIdx = text.indexOf("\"]", startIndex);
      if (endIdx > 0) {
        answer = text.substring(startIndex, endIdx);
        if (answer.length() > 0) {
          // lets expand any variables
          answer = ZooKeeperUtils.getSubstitutedData(curator.get(), answer);
          return answer;
        }
      }
    }
  }
  return null;
}

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