gpt4 book ai didi

org.I0Itec.zkclient.ZkClient.readData()方法的使用及代码示例

转载 作者:知者 更新时间:2024-03-17 12:38:40 27 4
gpt4 key购买 nike

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

ZkClient.readData介绍

暂无

代码示例

代码示例来源:origin: ltsopensource/light-task-scheduler

@Override
public <T> T getData(String path) {
  return zkClient.readData(path);
}

代码示例来源:origin: ltsopensource/light-task-scheduler

@Override
public <T> T getData(String path) {
  return zkClient.readData(path);
}

代码示例来源:origin: networknt/light-4j

@Override
@SuppressWarnings("TypeParameterUnusedInFormals")
public <T> T readData(String path, boolean returnNullIfPathNotExists) {
  return zkClient.readData(path, returnNullIfPathNotExists);
}

代码示例来源:origin: networknt/light-4j

@Override
@SuppressWarnings("TypeParameterUnusedInFormals")
public <T> T readData(String path) {
  return zkClient.readData(path);
}

代码示例来源:origin: killme2008/Metamorphosis

public static String readDataMaybeNull(final ZkClient client, final String path) {
  return client.readData(path, true);
}

代码示例来源:origin: killme2008/Metamorphosis

public static String readData(final ZkClient client, final String path) {
  return client.readData(path);
}

代码示例来源:origin: apache/incubator-dubbo

public String getData(String path) {
  Assert.notNull(client, new IllegalStateException("Zookeeper is not connected yet!"));
  return client.readData(path);
}

代码示例来源:origin: apache/incubator-dubbo

public String getData(String path) {
  Assert.notNull(client, new IllegalStateException("Zookeeper is not connected yet!"));
  return client.readData(path);
}

代码示例来源:origin: weibocom/motan

/**
 * 获取指定group的指令列表
 *
 * @param groupName
 * @return
 */
@Override
public String getCommands(String groupName) {
  return zkClient.readData(getCommandPath(groupName), true);
}

代码示例来源:origin: linkedin/cruise-control

private void loadPersistedFailedBrokerList() {
 String failedBrokerListString = _zkClient.readData(_failedBrokersZkPath);
 parsePersistedFailedBrokers(failedBrokerListString);
}

代码示例来源:origin: weibocom/motan

@Override
public List<JSONObject> getNodes(String group, String service, String nodeType) {
  List<JSONObject> result = new ArrayList<JSONObject>();
  List<String> nodes = getChildren(toNodeTypePath(group, service, nodeType));
  for (String nodeName : nodes) {
    JSONObject node = new JSONObject();
    String info = zkClient.readData(toNodePath(group, service, nodeType, nodeName), true);
    node.put("host", nodeName);
    node.put("info", info);
    result.add(node);
  }
  return result;
}

代码示例来源:origin: apache/incubator-pinot

public List<String> getLiveBrokers() {
 List<String> brokerUrls = new ArrayList<>();
 try {
  byte[] brokerResourceNodeData = zkClient.readData(BROKER_EXTERNAL_VIEW_PATH, true);
  brokerResourceNodeData = unpackZnodeIfNecessary(brokerResourceNodeData);
  JsonNode jsonObject = OBJECT_READER.readTree(new ByteArrayInputStream(brokerResourceNodeData));
  JsonNode brokerResourceNode = jsonObject.get("mapFields");
  Iterator<Entry<String, JsonNode>> resourceEntries = brokerResourceNode.fields();
  while (resourceEntries.hasNext()) {
   JsonNode resource = resourceEntries.next().getValue();
   Iterator<Entry<String, JsonNode>> brokerEntries = resource.fields();
   while (brokerEntries.hasNext()) {
    Entry<String, JsonNode> brokerEntry = brokerEntries.next();
    String brokerName = brokerEntry.getKey();
    if (brokerName.startsWith("Broker_") && "ONLINE".equals(brokerEntry.getValue().asText())) {
     // Turn Broker_12.34.56.78_1234 into 12.34.56.78:1234
     String brokerHostPort = brokerName.replace("Broker_", "").replace("_", ":");
     brokerUrls.add(brokerHostPort);
    }
   }
  }
 } catch (Exception e) {
  LOGGER.warn("Exception while reading External view from zookeeper", e);
  // ignore
 }
 return brokerUrls;
}

代码示例来源:origin: apache/incubator-pinot

public Map<String, List<String>> getTableToBrokersMap() {
 Map<String, Set<String>> brokerUrlsMap = new HashMap<>();
 try {
  byte[] brokerResourceNodeData = zkClient.readData("/EXTERNALVIEW/brokerResource", true);
  brokerResourceNodeData = unpackZnodeIfNecessary(brokerResourceNodeData);
  JsonNode jsonObject = OBJECT_READER.readTree(new ByteArrayInputStream(brokerResourceNodeData));

代码示例来源:origin: weibocom/motan

@Override
protected String discoverCommand(URL url) {
  try {
    String commandPath = ZkUtils.toCommandPath(url);
    String command = "";
    if (zkClient.exists(commandPath)) {
      command = zkClient.readData(commandPath);
    }
    return command;
  } catch (Throwable e) {
    throw new MotanFrameworkException(String.format("Failed to discover command %s from zookeeper(%s), cause: %s", url, getUrl(), e.getMessage()));
  }
}

代码示例来源:origin: weibocom/motan

String data = null;
try {
  data = zkClient.readData(nodePath, true);
} catch (Exception e) {
  LoggerUtil.warn("get zkdata fail!" + e.getMessage());

代码示例来源:origin: apache/incubator-pinot

ZNRecord record = client.readData("/PinotPerfTestCluster/EXTERNALVIEW/" + TABLE_NAME);
while (true) {
 System.out.println("record = " + record);
 record = client.readData("/PinotPerfTestCluster/EXTERNALVIEW/" + TABLE_NAME);

代码示例来源:origin: apache/incubator-pinot

private void modifyExistingInstanceConfig(ZkClient zkClient)
  throws InterruptedException {
 String instanceName = "Server_localhost_" + new Random().nextInt(NUM_INSTANCES);
 String instanceConfigPath = PropertyPathBuilder.instanceConfig(_helixClusterName, instanceName);
 Assert.assertTrue(zkClient.exists(instanceConfigPath));
 ZNRecord znRecord = zkClient.readData(instanceConfigPath, null);
 InstanceConfig cachedInstanceConfig = _helixResourceManager.getHelixInstanceConfig(instanceName);
 String originalPort = cachedInstanceConfig.getPort();
 Assert.assertNotNull(originalPort);
 String newPort = Long.toString(System.currentTimeMillis());
 Assert.assertTrue(!newPort.equals(originalPort));
 // Set new port to this instance config.
 znRecord.setSimpleField(InstanceConfig.InstanceConfigProperty.HELIX_PORT.toString(), newPort);
 zkClient.writeData(instanceConfigPath, znRecord);
 long maxTime = System.currentTimeMillis() + MAX_TIMEOUT_IN_MILLISECOND;
 InstanceConfig latestCachedInstanceConfig = _helixResourceManager.getHelixInstanceConfig(instanceName);
 String latestPort = latestCachedInstanceConfig.getPort();
 while (!newPort.equals(latestPort) && System.currentTimeMillis() < maxTime) {
  Thread.sleep(100L);
  latestCachedInstanceConfig = _helixResourceManager.getHelixInstanceConfig(instanceName);
  latestPort = latestCachedInstanceConfig.getPort();
 }
 Assert.assertTrue(System.currentTimeMillis() < maxTime, "Timeout when waiting for adding instance config");
 // Set original port back to this instance config.
 znRecord.setSimpleField(InstanceConfig.InstanceConfigProperty.HELIX_PORT.toString(), originalPort);
 zkClient.writeData(instanceConfigPath, znRecord);
}

代码示例来源:origin: javahongxi/whatsmars

public String getData(String path) {
  Assert.notNull(client, new IllegalStateException("Zookeeper is not connected yet!"));
  return client.readData(path);
}

代码示例来源:origin: Dromara/soul

private void loadWatchAppAuth() {
  final String appAuthParent = ZkPathConstants.APP_AUTH_PARENT;
  if (!zkClient.exists(appAuthParent)) {
    zkClient.createPersistent(appAuthParent, true);
  }
  final List<String> childrenList = zkClient.getChildren(appAuthParent);
  if (CollectionUtils.isNotEmpty(childrenList)) {
    childrenList.forEach(children -> {
      String realPath = buildRealPath(appAuthParent, children);
      final AppAuthZkDTO appAuthZkDTO = zkClient.readData(realPath);
      Optional.ofNullable(appAuthZkDTO)
          .ifPresent(dto -> AUTH_MAP.put(dto.getAppKey(), dto));
      subscribeAppAuthDataChanges(realPath);
    });
  }
  zkClient.subscribeChildChanges(appAuthParent, (parentPath, currentChilds) -> {
    if (CollectionUtils.isNotEmpty(currentChilds)) {
      final List<String> unsubscribePath = unsubscribePath(childrenList, currentChilds);
      unsubscribePath.stream().map(children -> buildRealPath(parentPath, children))
          .forEach(this::subscribeAppAuthDataChanges);
    }
  });
}

代码示例来源:origin: Dromara/soul

private void loadWatcherPlugin() {
  Arrays.stream(PluginEnum.values()).forEach(pluginEnum -> {
    String pluginPath = ZkPathConstants.buildPluginPath(pluginEnum.getName());
    if (!zkClient.exists(pluginPath)) {
      zkClient.createPersistent(pluginPath, true);
    }
    PluginZkDTO data = zkClient.readData(pluginPath);
    Optional.ofNullable(data).ifPresent(d -> PLUGIN_MAP.put(pluginEnum.getName(), data));
    zkClient.subscribeDataChanges(pluginPath, new IZkDataListener() {
      @Override
      public void handleDataChange(final String dataPath, final Object data) {
        Optional.ofNullable(data)
            .ifPresent(o -> {
              PluginZkDTO dto = (PluginZkDTO) o;
              PLUGIN_MAP.put(dto.getName(), dto);
            });
      }
      @Override
      public void handleDataDeleted(final String dataPath) {
        PLUGIN_MAP.remove(pluginEnum.getName());
      }
    });
  });
}

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