use of org.apache.inlong.manager.common.pojo.agent.FileAgentCommandInfo.CommandInfoBean in project incubator-inlong by apache.
the class AgentServiceImpl method dealCommandResult.
@Deprecated
private void dealCommandResult(FileAgentCommandInfo info) {
if (CollectionUtils.isEmpty(info.getCommandInfo())) {
LOGGER.warn("command info is empty, just return");
return;
}
for (CommandInfoBean command : info.getCommandInfo()) {
SourceFileDetailEntity current = fileDetailMapper.selectByPrimaryKey(command.getTaskId());
if (current == null) {
continue;
}
int op = command.getOp();
if (op == 2 || op == 6 || op == 8) {
// Channel results issued by special orders
DataSourceCmdConfigEntity cmd = new DataSourceCmdConfigEntity();
if (command.getId() > 0) {
// Modify the data result status of special commands
cmd.setId(command.getId());
cmd.setBsend(true);
cmd.setModifyTime(new Date());
cmd.setResultInfo(String.valueOf(command.getCommandResult()));
sourceCmdConfigMapper.updateByPrimaryKeySelective(cmd);
}
} else {
// Modify the result status of the data collection task
if (current.getModifyTime().getTime() - command.getDeliveryTime().getTime() > 1000 * 5) {
LOGGER.warn(" task id {} receive heartbeat time delay more than 5's, skip it!", command.getTaskId());
continue;
}
int result = command.getCommandResult();
int nextStatus = EntityStatus.AGENT_NORMAL.getCode();
int previousStatus = current.getStatus();
if (previousStatus / 100 == 2) {
// Modify 30x -> 10x
if (result == 0) {
// Processed successfully
if (previousStatus == EntityStatus.AGENT_ADD.getCode()) {
nextStatus = EntityStatus.AGENT_NORMAL.getCode();
} else if (previousStatus == EntityStatus.AGENT_DELETE.getCode()) {
nextStatus = EntityStatus.AGENT_DISABLE.getCode();
}
} else if (result == 1) {
// Processing failed
nextStatus = EntityStatus.AGENT_FAILURE.getCode();
}
SourceFileDetailEntity update = new SourceFileDetailEntity();
update.setId(command.getTaskId());
update.setStatus(nextStatus);
update.setPreviousStatus(previousStatus);
fileDetailMapper.updateByPrimaryKeySelective(update);
}
}
}
}
Aggregations