Search in sources :

Example 1 with DataConfig

use of org.apache.inlong.common.pojo.agent.DataConfig in project incubator-inlong by apache.

the class AgentServiceImpl method getDataConfig.

/**
 * Get the DataConfig from the stream source entity
 */
private DataConfig getDataConfig(StreamSourceEntity entity, int op) {
    DataConfig dataConfig = new DataConfig();
    dataConfig.setIp(entity.getAgentIp());
    dataConfig.setUuid(entity.getUuid());
    dataConfig.setOp(String.valueOf(op));
    dataConfig.setTaskId(entity.getId());
    dataConfig.setTaskType(getTaskType(entity));
    dataConfig.setTaskName(entity.getSourceName());
    dataConfig.setSnapshot(entity.getSnapshot());
    dataConfig.setExtParams(entity.getExtParams());
    LocalDateTime dateTime = LocalDateTime.ofInstant(entity.getModifyTime().toInstant(), ZoneId.systemDefault());
    dataConfig.setDeliveryTime(dateTime.format(TIME_FORMATTER));
    String groupId = entity.getInlongGroupId();
    String streamId = entity.getInlongStreamId();
    dataConfig.setInlongGroupId(groupId);
    dataConfig.setInlongStreamId(streamId);
    InlongStreamEntity streamEntity = streamMapper.selectByIdentifier(groupId, streamId);
    dataConfig.setSyncSend(streamEntity.getSyncSend());
    return dataConfig;
}
Also used : LocalDateTime(java.time.LocalDateTime) DataConfig(org.apache.inlong.common.pojo.agent.DataConfig) InlongStreamEntity(org.apache.inlong.manager.dao.entity.InlongStreamEntity)

Example 2 with DataConfig

use of org.apache.inlong.common.pojo.agent.DataConfig in project incubator-inlong by apache.

the class AgentServiceImpl method getTaskResult.

/**
 * Get task result by the request
 */
@Transactional(isolation = Isolation.REPEATABLE_READ)
TaskResult getTaskResult(TaskRequest request) {
    // Query the tasks that needed to add or active - without agentIp and uuid
    List<Integer> addedStatusList = Arrays.asList(SourceState.TO_BE_ISSUED_ADD.getCode(), SourceState.TO_BE_ISSUED_ACTIVE.getCode());
    List<StreamSourceEntity> addList = sourceMapper.selectByStatusForUpdate(addedStatusList);
    // Query other tasks by agentIp and uuid - not included status with TO_BE_ISSUED_ADD and TO_BE_ISSUED_ACTIVE
    List<Integer> statusList = Arrays.asList(SourceState.TO_BE_ISSUED_DELETE.getCode(), SourceState.TO_BE_ISSUED_RETRY.getCode(), SourceState.TO_BE_ISSUED_BACKTRACK.getCode(), SourceState.TO_BE_ISSUED_FROZEN.getCode(), SourceState.TO_BE_ISSUED_CHECK.getCode(), SourceState.TO_BE_ISSUED_REDO_METRIC.getCode(), SourceState.TO_BE_ISSUED_MAKEUP.getCode());
    String agentIp = request.getAgentIp();
    String uuid = request.getUuid();
    List<StreamSourceEntity> entityList = sourceMapper.selectByStatusAndIp(statusList, agentIp, uuid);
    entityList.addAll(addList);
    List<DataConfig> dataConfigs = Lists.newArrayList();
    for (StreamSourceEntity entity : entityList) {
        // Change 20x to 30x
        int id = entity.getId();
        int status = entity.getStatus();
        int op = status % MODULUS_100;
        if (status / MODULUS_100 == UNISSUED_STATUS) {
            sourceMapper.updateStatus(id, ISSUED_STATUS * MODULUS_100 + op);
        } else {
            LOGGER.info("skip task status not in 20x, id={}", id);
            continue;
        }
        DataConfig dataConfig = getDataConfig(entity, op);
        dataConfigs.add(dataConfig);
    }
    // Query pending special commands
    List<CmdConfig> cmdConfigs = getAgentCmdConfigs(request);
    // Update agentIp and uuid for the added and active tasks
    for (StreamSourceEntity entity : addList) {
        sourceMapper.updateIpAndUuid(entity.getId(), agentIp, uuid);
    }
    return TaskResult.builder().dataConfigs(dataConfigs).cmdConfigs(cmdConfigs).build();
}
Also used : CmdConfig(org.apache.inlong.common.pojo.agent.CmdConfig) DataConfig(org.apache.inlong.common.pojo.agent.DataConfig) StreamSourceEntity(org.apache.inlong.manager.dao.entity.StreamSourceEntity) Transactional(org.springframework.transaction.annotation.Transactional)

Example 3 with DataConfig

use of org.apache.inlong.common.pojo.agent.DataConfig in project incubator-inlong by apache.

the class ManagerFetcher method dealWithFileTaskResult.

/**
 * the fetch file command can be normal or special
 */
private void dealWithFileTaskResult(TaskResult taskResult) {
    LOGGER.info("deal with fetch result {}", taskResult);
    for (DataConfig dataConfig : taskResult.getDataConfigs()) {
        TriggerProfile profile = TriggerProfile.getTriggerProfiles(dataConfig);
        LOGGER.info("the triggerProfile: {}", profile.toJsonStr());
        if (profile.hasKey(JOB_TRIGGER)) {
            dealWithTdmTriggerProfile(profile);
        } else {
            dealWithJobProfile(profile);
        }
    }
    for (CmdConfig cmdConfig : taskResult.getCmdConfigs()) {
        dealWithTdmCmd(cmdConfig);
    }
}
Also used : CmdConfig(org.apache.inlong.common.pojo.agent.CmdConfig) DataConfig(org.apache.inlong.common.pojo.agent.DataConfig) TriggerProfile(org.apache.inlong.agent.conf.TriggerProfile)

Aggregations

DataConfig (org.apache.inlong.common.pojo.agent.DataConfig)3 CmdConfig (org.apache.inlong.common.pojo.agent.CmdConfig)2 LocalDateTime (java.time.LocalDateTime)1 TriggerProfile (org.apache.inlong.agent.conf.TriggerProfile)1 InlongStreamEntity (org.apache.inlong.manager.dao.entity.InlongStreamEntity)1 StreamSourceEntity (org.apache.inlong.manager.dao.entity.StreamSourceEntity)1 Transactional (org.springframework.transaction.annotation.Transactional)1