gpt4 book ai didi

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

转载 作者:知者 更新时间:2024-03-17 19:53:31 28 4
gpt4 key购买 nike

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

ZkPaths.pathOfJobInstances介绍

[英]Get the path of job instances
[中]获取作业实例的路径

代码示例

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

/**
 * Find the job instance ids of the job
 * @param appName the app name
 * @param jobClass the job class
 * @return the job instance ids
 */
public List<String> findJobInstances(String appName, String jobClass){
  String jobInstancesNode = ZkPaths.pathOfJobInstances(appName, jobClass);
  return zk.client().gets(jobInstancesNode);
}

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

/**
 * Make the job instances node
 * @param appName the app name
 * @param jobClass the job class
 * @return return true if make successfully, or false
 */
public Boolean mkJobInstances(String appName, String jobClass) {
  return zk.client().mkdirs(ZkPaths.pathOfJobInstances(appName, jobClass));
}

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

/**
 * Check the job has one running job instance
 * @param appName the app name
 * @param jobClass the job class
 * @return return true if has one running job instance, or false
 */
public boolean hasJobInstance(String appName, String jobClass) {
  String jobInstanceNodePath = ZkPaths.pathOfJobInstances(appName, jobClass);
  List<String> instances = zk.client().gets(jobInstanceNodePath);
  return !CollectionUtil.isNullOrEmpty(instances);
}

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

@Override
public void doStart() {
  String appName = client.getAppName();
  String jobClass = getJobClass();
  String jobInstancesNodePath = ZkPaths.pathOfJobInstances(appName, jobClass);
  this.watcher = client.getZk().newChildWatcher(jobInstancesNodePath, new ChildListener() {
    @Override
    protected void onAdd(String path, byte[] data) {
      // fired a new job instance
      String instanceId = ZkPaths.lastNode(path);
      if (Strings.isNullOrEmpty(instanceId)) return;
      // execute the job
      client.getJobExecutor().execute(Long.valueOf(instanceId), ZkJob.this);
    }
  });
}

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