You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@inlong.apache.org by "healchow (via GitHub)" <gi...@apache.org> on 2023/05/10 06:53:41 UTC
[GitHub] [inlong] healchow commented on a diff in pull request #7989: [INLONG-7987][Manager] Add heartbeat timeout status to the source
healchow commented on code in PR #7989:
URL: https://github.com/apache/inlong/pull/7989#discussion_r1189433602
##########
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:
It is a bad practice to read and write DB in a loop.
Can you change to update records in batches?
--
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-unsubscribe@inlong.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org