コード例 #1
0
  @Override
  public RemotingCommand processRequest(ChannelHandlerContext ctx, RemotingCommand request)
      throws RemotingCommandException {

    BizLogSendRequest requestBody = request.getBody();

    List<BizLog> bizLogs = requestBody.getBizLogs();
    if (CollectionUtils.isNotEmpty(bizLogs)) {
      for (BizLog bizLog : bizLogs) {
        JobLogPo jobLogPo = new JobLogPo();
        jobLogPo.setGmtCreated(SystemClock.now());
        jobLogPo.setLogTime(bizLog.getLogTime());
        jobLogPo.setTaskTrackerNodeGroup(bizLog.getTaskTrackerNodeGroup());
        jobLogPo.setTaskTrackerIdentity(bizLog.getTaskTrackerIdentity());
        jobLogPo.setJobId(bizLog.getJobId());
        jobLogPo.setTaskId(bizLog.getTaskId());
        jobLogPo.setMsg(bizLog.getMsg());
        jobLogPo.setSuccess(true);
        jobLogPo.setLevel(bizLog.getLevel());
        jobLogPo.setLogType(LogType.BIZ);
        application.getJobLogger().log(jobLogPo);
      }
    }

    return RemotingCommand.createResponseCommand(
        JobProtos.ResponseCode.BIZ_LOG_SEND_SUCCESS.code(), "");
  }
コード例 #2
0
  @Override
  public RemotingCommand processRequest(ChannelHandlerContext ctx, final RemotingCommand request)
      throws RemotingCommandException {

    JobPushRequest requestBody = request.getBody();

    // JobTracker 分发来的 job
    final JobWrapper jobWrapper = requestBody.getJobWrapper();

    try {
      application.getRunnerPool().execute(jobWrapper, jobRunnerCallback);
    } catch (NoAvailableJobRunnerException e) {
      // 任务推送失败
      return RemotingCommand.createResponseCommand(
          JobProtos.ResponseCode.NO_AVAILABLE_JOB_RUNNER.code(),
          "job push failure , no available job runner!");
    }

    // 任务推送成功
    return RemotingCommand.createResponseCommand(
        JobProtos.ResponseCode.JOB_PUSH_SUCCESS.code(), "job push success!");
  }