gpt4 book ai didi

com.ke.kob.basic.constant.ZkPathConstant.clientTaskPath()方法的使用及代码示例

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

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

ZkPathConstant.clientTaskPath介绍

暂无

代码示例

代码示例来源:origin: LianjiaTech/kob

/**
 * 待回收积压任务
 * 根据一定权重进入回收方法,判断是否超过积压阈值,并回收已过期任务只可剩余任务数量
 *
 * @param projectCode 项目名称
 */
private void recoveryOverstockTask(String projectCode) {
  int random100 = new Random().nextInt(AdminConstant.ONE_HUNDRED);
  if (random100 < processorProperties.getTaskOverstockRecoveryWeight()) {
    List<String> taskPathList = zkClient.getChildren(ZkPathConstant.clientTaskPath(serverContext.getCluster(), projectCode));
    if (!KobUtils.isEmpty(taskPathList) && taskPathList.size() > processorProperties.getTaskOverstockRecoveryThreshold()) {
      List<TaskBaseContext> tasks = new ArrayList<>();
      for (String s : taskPathList) {
        TaskBaseContext task = JSONObject.parseObject(s, TaskBaseContext.class);
        task.setPath(ZkPathConstant.clientTaskPath(serverContext.getCluster(), projectCode) + ZkPathConstant.BACKSLASH + s);
        tasks.add(task);
      }
      Collections.sort(tasks);
      List<TaskBaseContext> overstockTask = tasks.subList(0, tasks.size() - processorProperties.getTaskOverstockRecoveryRetainCount());
      scheduleService.fireOverstockTask(zkClient, overstockTask, serverContext.getCluster());
    }
  }
}

代码示例来源:origin: LianjiaTech/kob

/**
 * 保存项目接入信息
 *
 * @return ResponseData
 */
@RequestMapping(value = "/save_project_access.json")
@ResponseBody
public ResponseData saveProjectAccess() {
  HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
  User user = (User) request.getSession().getAttribute(Attribute.SESSION_USER);
  String projectCode = request.getParameter("project_code");
  String regex = "([A-Z]|[a-z]|_){6,60}";
  if (KobUtils.isEmpty(projectCode) || !projectCode.matches(regex)) {
    return ResponseData.error("项目标识有误");
  }
  String projectName = request.getParameter("project_name");
  if (KobUtils.isEmpty(projectName) || projectName.length() > 60) {
    return ResponseData.error("项目名称有误");
  }
  boolean zkExist = zkClient.exists(ZkPathConstant.clientNodePath(cluster, projectCode));
  boolean dbExist = indexService.existProject(projectCode);
  if (zkExist || dbExist) {
    return ResponseData.error("项目已存在");
  }
  indexService.initProject(user.getCode(), user.getName(), user.getConfiguration(), projectCode, projectName);
  zkClient.createPersistent(ZkPathConstant.clientNodePath(cluster, projectCode), true);
  zkClient.createPersistent(ZkPathConstant.clientTaskPath(cluster, projectCode), true);
  return ResponseData.success();
}

代码示例来源:origin: LianjiaTech/kob

@Override
public void pushTask(ZkClient zkClient, TaskWaiting tw, String cluster) {
  TaskBaseContext context = new TaskBaseContext();
  context.setProjectCode(tw.getProjectCode());
  context.setJobUuid(tw.getJobUuid());
  context.setJobCn(tw.getJobCn());
  context.setTaskUuid(tw.getTaskUuid());
  context.setTaskKey(tw.getTaskKey());
  context.setTriggerTime(tw.getTriggerTime());
  context.setDesignatedNode(tw.getInnerParamsBean().getDesignatedNode());
  context.setRecommendNode(tw.getInnerParamsBean().getRecommendNode());
  context.setTryToExclusionNode(tw.getInnerParamsBean().getTryToExclusionNode());
  context.setUserParam(JSONObject.parseObject(tw.getUserParams()));
  String projectTaskPath = ZkPathConstant.clientTaskPath(cluster, context.getProjectCode());
  int state = TaskRecordStateConstant.PUSH_SUCCESS;
  Map<String, Object> param = new HashMap<>(10);
  try {
    zkClient.createPersistent(projectTaskPath + ZkPathConstant.BACKSLASH + JSONObject.toJSONString(context));
  } catch (Exception e) {
    log.error("pushTask_error 推送zk事件异常", e);
    state = TaskRecordStateConstant.PUSH_FAIL;
    param.put("complete", true);
  }
  param.put("state", state);
  taskRecordMapper.updateByTaskUuid(param, tw.getTaskUuid(), cluster);
}

代码示例来源:origin: LianjiaTech/kob

context.setTryToExclusionNode(retryTask.getInnerParamsBean().getTryToExclusionNode());
context.setUserParam(JSONObject.parseObject(retryTask.getUserParams()));
String projectTaskPath = ZkPathConstant.clientTaskPath(cluster, context.getProjectCode());
int state = TaskRecordStateConstant.PUSH_SUCCESS;
Map<String, Object> param = new HashMap<>(10);

代码示例来源:origin: LianjiaTech/kob

clientTaskPath = ZkPathConstant.clientTaskPath(prop.getCluster(), prop.getProjectCode());
clientNodePath = ZkPathConstant.clientNodePath(prop.getCluster(), prop.getProjectCode());
buildKobRunner(beans);

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