@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(), "");
  }
  private void setCurSequence(Application application) {
    List<Node> nodes = application.getSubscribedNodeManager().getNodeList(NodeType.JOB_TRACKER);
    totalNodes = CollectionUtils.sizeOf(nodes);
    if (totalNodes == 0) {
      curSequence = 0;
    } else if (totalNodes == 1) {
      curSequence = 0;
    } else {
      List<Node> copy = new ArrayList<Node>(nodes);
      Collections.sort(
          copy,
          new Comparator<Node>() {
            @Override
            public int compare(Node left, Node right) {
              return left.getCreateTime().compareTo(right.getCreateTime());
            }
          });

      int index = 0;
      for (Node node : copy) {
        if (node.getIdentity().equals(application.getConfig().getIdentity())) {
          // 当前节点
          curSequence = index;
          break;
        }
        index++;
      }
    }
  }
  @RequestMapping("node-list-get")
  public RestfulResponse getNodeList(NodeRequest request) {
    RestfulResponse response = new RestfulResponse();

    List<Node> nodes = registryService.getOnlineNodes(request);

    response.setSuccess(true);
    response.setResults(CollectionUtils.sizeOf(nodes));
    response.setRows(nodes);

    return response;
  }
 @Override
 public void log(List<JobLogPo> jobLogPos) {
   if (CollectionUtils.isEmpty(jobLogPos)) {
     return;
   }
   if (lazyLog) {
     checkOverflowSize();
     for (JobLogPo jobLogPo : jobLogPos) {
       memoryQueue.offer(jobLogPo);
     }
     // checkCapacity
     checkCapacity();
   } else {
     jobLogger.log(jobLogPos);
   }
 }
  private void populateMap(Object bean) {
    Class<?> clazz = bean.getClass();
    Set<MethodInfo> methodInfos = getGetterMethodInfo(clazz);

    if (CollectionUtils.isNotEmpty(methodInfos)) {
      for (MethodInfo methodInfo : methodInfos) {
        try {
          Object result = methodInfo.getMethod().invoke(bean, (Object[]) null);
          if (result != null) {
            this.map.put(methodInfo.getFieldName(), wrap(result));
          }
        } catch (Exception ignored) {
        }
      }
    }
  }
 @RequestMapping("/monitor/monitor-data-get")
 public RestfulResponse taskTrackerMonitorInfoGet(MonitorDataRequest request) {
   RestfulResponse response = new RestfulResponse();
   if (request.getNodeType() == null) {
     response.setSuccess(false);
     response.setMsg("nodeType can not be null.");
     return response;
   }
   if (request.getStartTime() == null || request.getEndTime() == null) {
     response.setSuccess(false);
     response.setMsg("Search time range must be input.");
     return response;
   }
   List<? extends AbstractMonitorDataPo> rows = monitorDataService.queryMonitorDataSum(request);
   response.setSuccess(true);
   response.setRows(rows);
   response.setResults(CollectionUtils.sizeOf(rows));
   return response;
 }
 @Override
 public boolean add(List<JobFeedbackPo> jobFeedbackPos) {
   if (CollectionUtils.isEmpty(jobFeedbackPos)) {
     return true;
   }
   // insert ignore duplicate record
   Object[] params = new Object[2];
   for (JobFeedbackPo jobFeedbackPo : jobFeedbackPos) {
     params[0] = jobFeedbackPo.getGmtCreated();
     params[1] = JSON.toJSONString(jobFeedbackPo.getTaskTrackerJobResult());
     try {
       String jobClientNodeGroup =
           jobFeedbackPo.getTaskTrackerJobResult().getJobWrapper().getJob().getSubmitNodeGroup();
       getSqlTemplate().update(getRealSql(insertSQL, jobClientNodeGroup), params);
     } catch (SQLException e) {
       throw new JobQueueException(e);
     }
   }
   return true;
 }