fuweng11 commented on code in PR #7989:
URL: https://github.com/apache/inlong/pull/7989#discussion_r1190668816


##########
inlong-manager/manager-service/src/main/java/org/apache/inlong/manager/service/core/impl/AgentServiceImpl.java:
##########
@@ -416,6 +418,24 @@ private void preProcessLabelFileTasks(TaskRequest 
taskRequest) {
         });
     }
 
+    private void preTimeoutTasks(TaskRequest taskRequest) {
+        // If the agent report succeeds, restore the source status
+        List<StreamSourceEntity> sourceEntities = 
sourceMapper.selectByAgentIpAndCluster(
+                
Collections.singletonList(SourceStatus.HEARTBEAT_TIMEOUT.getCode()),
+                Lists.newArrayList(SourceType.FILE), taskRequest.getAgentIp(), 
taskRequest.getClusterName());
+        for (StreamSourceEntity sourceEntity : sourceEntities) {
+            // restore state for all source by ip and type
+            if (sourceEntity.getIsDeleted() != 0) {
+                sourceEntity.setPreviousStatus(sourceEntity.getStatus());
+                
sourceEntity.setStatus(SourceStatus.TO_BE_ISSUED_DELETE.getCode());
+            } else {
+                sourceEntity.setStatus(sourceEntity.getPreviousStatus());
+                
sourceEntity.setPreviousStatus(SourceStatus.HEARTBEAT_TIMEOUT.getCode());
+            }
+            sourceMapper.updateByPrimaryKeySelective(sourceEntity);

Review Comment:
   done



##########
inlong-manager/manager-service/src/main/java/org/apache/inlong/manager/service/heartbeat/HeartbeatManager.java:
##########
@@ -162,6 +177,23 @@ public void reportHeartbeat(HeartbeatMsg heartbeat) {
                     handlerNum += insertClusterNode(clusterInfo, heartbeatMsg, 
clusterInfo.getCreator());
                 } else {
                     handlerNum += updateClusterNode(clusterNode, heartbeatMsg);
+                    // If the agent report succeeds, restore the source status
+                    if (Objects.equals(clusterNode.getType(), 
ClusterType.AGENT)) {
+                        List<StreamSourceEntity> sourceEntities = 
sourceMapper.selectByAgentIpAndCluster(
+                                
Collections.singletonList(SourceStatus.HEARTBEAT_TIMEOUT.getCode()),
+                                Lists.newArrayList(SourceType.FILE), 
heartbeat.getIp(), heartbeatMsg.getClusterName());
+                        for (StreamSourceEntity sourceEntity : sourceEntities) 
{
+                            // restore state for all source by ip and type
+                            if (sourceEntity.getIsDeleted() != 0) {
+                                
sourceEntity.setPreviousStatus(sourceEntity.getStatus());
+                                
sourceEntity.setStatus(SourceStatus.TO_BE_ISSUED_DELETE.getCode());
+                            } else {
+                                
sourceEntity.setStatus(sourceEntity.getPreviousStatus());
+                                
sourceEntity.setPreviousStatus(SourceStatus.HEARTBEAT_TIMEOUT.getCode());
+                            }
+                            
sourceMapper.updateByPrimaryKeySelective(sourceEntity);

Review Comment:
   done



-- 
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: commits-unsubscr...@inlong.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to