gpt4 book ai didi

me.hao0.antares.common.zk.ZkClient.createEphemeral()方法的使用及代码示例

转载 作者:知者 更新时间:2024-03-16 21:55:31 27 4
gpt4 key购买 nike

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

ZkClient.createEphemeral介绍

[英]Create an ephemeral path
[中]创建一条短暂的路径

代码示例

代码示例来源:origin: ihaolin/antares

/**
 * Create an ephemeral path
 * @param path path
 * @return the path created
 */
public String createEphemeral(String path) {
  return createEphemeral(path, (byte[]) null);
}

代码示例来源:origin: ihaolin/antares

/**
 * Create an ephemeral path
 * @param path path
 * @param data data
 * @return the path created
 */
public String createEphemeral(String path, Integer data) {
  return createEphemeral(path, data.toString());
}

代码示例来源:origin: ihaolin/antares

/**
 * Create an ephemeral path
 * @param path path
 * @param obj object data
 * @return the path created
 */
public String createEphemeral(String path, Object obj) {
  return createEphemeral(path, JSON.toJSONString(obj));
}

代码示例来源:origin: ihaolin/antares

@Override
  public void run() {
    ZkClient zk = client.getZk();
    // register period, prevent client disconnects unexpected
    String appClientPath = ZkPaths.pathOfAppClient(client.getAppName(), Systems.hostPid());
    if (!zk.checkExists(appClientPath)){
      zk.createEphemeral(appClientPath);
    }
  }
}, 1, 10, TimeUnit.SECONDS);

代码示例来源:origin: ihaolin/antares

@Override
  public void run() {
    String server = serverHost.get();
    // mkdirs /cluster/servers if necessary
    zk.client().mkdirs(ZkPaths.SERVERS);
    // register the server node
    String serverPath = ZkPaths.pathOfServer(server);
    if (!zk.client().checkExists(serverPath)){
      String result = zk.client().createEphemeral(ZkPaths.pathOfServer(server));
      Logs.info("server({}) registered: {}", server, result);
    }
  }
}, 1, 5, TimeUnit.SECONDS);

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