gpt4 book ai didi

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

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

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

ZkClient.mkdirs介绍

[英]Make directories if necessary
[中]必要时制作目录

代码示例

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

/**
 * Update the job fire time info
 * @param appName the app name
 * @param jobClass the job class
 * @param jobFireTime the job fire time
 * @return return true if update successfully, or false
 */
public Boolean updateJobFireTime(String appName, String jobClass, JobFireTime jobFireTime) {
  String jobFireTimeNode = ZkPaths.pathOfJobFireTime(appName, jobClass);
  zk.client().mkdirs(jobFireTimeNode);
  return zk.client().update(jobFireTimeNode, JSON.toJSONString(jobFireTime));
}

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

public AppClientCluster(AntaresZkClient zk, String appName){
  this.appName = appName;
  this.zk = zk;
  // get alive clients once
  String appClientsPath = ZkPaths.pathOfAppClients(appName);
  zk.client().mkdirs(appClientsPath);
  List<String> clients = zk.client().gets(appClientsPath);
  if (!CollectionUtil.isNullOrEmpty(clients)){
    alives.addAll(clients);
  }
}

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

/**
 * Update the job's scheudler
 * @param appName the app name
 * @param jobClass the job class
 * @param scheduler the scheduler
 * @return return true if update successfully, or false
 */
public Boolean updateJobScheduler(String appName, String jobClass, String scheduler) {
  String jobSchedulerNode = ZkPaths.pathOfJobScheduler(appName, jobClass);
  zk.client().mkdirs(jobSchedulerNode);
  return zk.client().update(jobSchedulerNode, scheduler);
}

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

@Override
public void doStart() {
  String jobInstancesLockPath = Lock.PREFIX + ZkPaths.JOB_INSTANCES;
  zk.client().mkdirs(jobInstancesLockPath);
  emptyChildCleaner = new ChildReaper(zk.client().client(), jobInstancesLockPath, Reaper.Mode.REAP_INDEFINITELY);
  try {
    String serversFailover = Lock.PREFIX + ZkPaths.SERVER_FAILOVER;
    zk.client().mkdirs(serversFailover);
    emptyChildCleaner.addPath(serversFailover);
    emptyChildCleaner.start();
  } catch (Exception e) {
    throw new ZkException(e);
  }
}

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

/**
 * Update the job running state directly
 * @param appName the app name
 * @param jobClass the job class
 * @param state the target state
 * @return return true if update successfully, or false
 */
public Boolean updateJobStateDirectly(String appName, String jobClass, JobState state){
  String jobStateNode = ZkPaths.pathOfJobState(appName, jobClass);
  zk.client().mkdirs(jobStateNode);
  return zk.client().update(jobStateNode, state.value());
}

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

@Override
public void doStart(){
  // mk app clients path
  zk.mkdirs(ZkPaths.pathOfAppClients(client.getAppName()));
  // register client self
  clientRegister = new ClientRegister(client);
  clientRegister.start();
  // get servers once
  getServersOnce();
  // listen servers
  listenOnServerChanged();
}

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

@Override
public Response<List<ClientInfo>> listClients(Long appId) {
  try {
    App app = appDao.findById(appId);
    if (app == null){
      Logs.warn("The app(id={}) doesn't exist when list clients", appId);
      return Response.ok(Collections.<ClientInfo>emptyList());
    }
    String appClientsPath = ZkPaths.pathOfAppClients(app.getAppName());
    zk.client().mkdirs(appClientsPath);
    List<String> clients = zk.client().gets(appClientsPath);
    if(CollectionUtil.isNullOrEmpty(clients)){
      return Response.ok(Collections.<ClientInfo>emptyList());
    }
    List<ClientInfo> clientInfos = Lists.newArrayListWithExpectedSize(clients.size());
    ClientInfo clientInfo;
    for (String client : clients){
      clientInfo = new ClientInfo();
      clientInfo.setAddr(client);
      clientInfos.add(clientInfo);
    }
    return Response.ok(clientInfos);
  } catch (Exception e){
    Logs.error("failed to list clients, cause: {}", Throwables.getStackTraceAsString(e));
    return Response.notOk("client.list.failed");
  }
}

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

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