Search in sources :

Example 1 with DataSourceCmdConfigEntity

use of org.apache.inlong.manager.dao.entity.DataSourceCmdConfigEntity 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);
            }
        }
    }
}
Also used : DataSourceCmdConfigEntity(org.apache.inlong.manager.dao.entity.DataSourceCmdConfigEntity) CommandInfoBean(org.apache.inlong.manager.common.pojo.agent.FileAgentCommandInfo.CommandInfoBean) SourceFileDetailEntity(org.apache.inlong.manager.dao.entity.SourceFileDetailEntity) Date(java.util.Date)

Aggregations

Date (java.util.Date)1 CommandInfoBean (org.apache.inlong.manager.common.pojo.agent.FileAgentCommandInfo.CommandInfoBean)1 DataSourceCmdConfigEntity (org.apache.inlong.manager.dao.entity.DataSourceCmdConfigEntity)1 SourceFileDetailEntity (org.apache.inlong.manager.dao.entity.SourceFileDetailEntity)1