gpt4 book ai didi

me.hao0.antares.common.util.ZkPaths.pathOfServer()方法的使用及代码示例

转载 作者:知者 更新时间:2024-03-17 20:15:31 27 4
gpt4 key购买 nike

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

ZkPaths.pathOfServer介绍

[英]Get the path of the server
[中]获取服务器的路径

代码示例

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

/**
 * Try to wait server to start
 * @param server the server
 * @return return true if server started, or false
 */
private Boolean tryWaitServerStart(String server) {
  Sleeps.sleep(serverFailoverWaitTime);
  // check server register?
  String serverPath = ZkPaths.pathOfServer(server);
  return zk.client().checkExists(serverPath);
}

代码示例来源: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);

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

/**
 * Checking the job is scheduling or not
 * @param appName the app name
 * @param jobClass the job class
 * @return return true if the job is scheduling, or false
 */
public Boolean checkJobScheduling(String appName, String jobClass) {
  String jobPath = ZkPaths.pathOfJob(appName, jobClass);
  if(!zk.client().checkExists(jobPath)){
    return Boolean.FALSE;
  }
  String scheduler = getJobScheduler(appName, jobClass);
  if(Strings.isNullOrEmpty(scheduler)){
    // The scheduler is empty
    return Boolean.FALSE;
  }
  if(!zk.client().checkExists(ZkPaths.pathOfServer(scheduler))){
    // The scheduler server offline
    return Boolean.FALSE;
  }
  return Boolean.TRUE;
}

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