aloyszhang commented on code in PR #10602:
URL: https://github.com/apache/inlong/pull/10602#discussion_r1672139451
##########
inlong-manager/manager-service/src/main/java/org/apache/inlong/manager/service/source/AbstractSourceOperator.java:
##########
@@ -346,4 +403,222 @@ public void syncSourceFieldInfo(SourceRequest request,
String operator) {
public Integer addDataAddTask(DataAddTaskRequest request, String operator)
{
throw new BusinessException(String.format("not support data add task
for type =%s", request.getSourceType()));
}
+
+ private void updateAgentTaskConfig(SourceRequest request, String operator)
{
+ try {
+ if (SourceType.AUTO_PUSH.equals(request.getSourceType())) {
+ return;
+ }
+ final String clusterName = request.getInlongClusterName();
+ final String ip = request.getAgentIp();
+ final String uuid = request.getUuid();
+ if (StringUtils.isBlank(clusterName) || StringUtils.isBlank(ip)) {
+ return;
+ }
+ AgentTaskConfigEntity existEntity =
agentTaskConfigEntityMapper.selectByIdentifier(ip, clusterName);
+ AgentTaskConfigEntity agentTaskConfigEntity = new
AgentTaskConfigEntity();
+ if (existEntity != null) {
+ agentTaskConfigEntity =
CommonBeanUtils.copyProperties(existEntity, AgentTaskConfigEntity::new, true);
+ }
+ List<StreamSourceEntity> normalSourceEntities =
sourceMapper.selectByStatusAndCluster(
+
SourceStatus.NORMAL_STATUS_SET.stream().map(SourceStatus::getCode)
+ .collect(Collectors.toList()),
+ clusterName, ip, uuid);
+ List<StreamSourceEntity> taskLists = new
ArrayList<>(normalSourceEntities);
+ List<StreamSourceEntity> stopSourceEntities =
sourceMapper.selectByStatusAndCluster(
+
SourceStatus.STOP_STATUS_SET.stream().map(SourceStatus::getCode)
+ .collect(Collectors.toList()),
+ clusterName, ip, uuid);
+ taskLists.addAll(stopSourceEntities);
+ LOGGER.debug("success to add task : {}", taskLists.size());
+ List<DataConfig> runningTaskConfig = Lists.newArrayList();
+ List<CmdConfig> cmdConfigs =
sourceCmdConfigMapper.queryCmdByAgentIp(request.getAgentIp()).stream()
+ .map(cmd -> {
+ CmdConfig cmdConfig = new CmdConfig();
+ cmdConfig.setDataTime(cmd.getSpecifiedDataTime());
+ cmdConfig.setOp(cmd.getCmdType());
+ cmdConfig.setId(cmd.getId());
+ cmdConfig.setTaskId(cmd.getTaskId());
+ return cmdConfig;
+ }).collect(Collectors.toList());
+ if (CollectionUtils.isEmpty(taskLists)) {
+
agentTaskConfigEntity.setIsDeleted(agentTaskConfigEntity.getId());
+
agentTaskConfigEntityMapper.updateByIdSelective(agentTaskConfigEntity);
+ return;
+ }
+ for (StreamSourceEntity sourceEntity : taskLists) {
+ int op = sourceEntity.getStatus() % MODULUS_100;
+ DataConfig dataConfig = getDataConfig(sourceEntity, op);
+ runningTaskConfig.add(dataConfig);
+ }
+ TaskResult taskResult =
+
TaskResult.builder().dataConfigs(runningTaskConfig).cmdConfigs(cmdConfigs).build();
+ String md5 = DigestUtils.md5Hex(GSON.toJson(taskResult));
+ taskResult.setMd5(md5);
+ taskResult.setCode(AgentResponseCode.SUCCESS);
+ agentTaskConfigEntity.setAgentIp(request.getAgentIp());
+
agentTaskConfigEntity.setClusterName(request.getInlongClusterName());
+
agentTaskConfigEntity.setTaskParams(objectMapper.writeValueAsString(taskResult));
+
+ LOGGER.debug("begin to get agent config info for {}", request);
+ Set<String> tagSet = new HashSet<>(16);
+ List<StreamSourceEntity> sourceEntities =
Review Comment:
not used.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]