This is an automated email from the ASF dual-hosted git repository.

dockerzhang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/inlong.git


The following commit(s) were added to refs/heads/master by this push:
     new fea2d2140 [INLONG-5698][Manager] Fixed the DataProxy cluster tag was 
restored after the manager was restarted (#5699)
fea2d2140 is described below

commit fea2d21407e0fce329939fdc18b38b4ce3f83d87
Author: fuweng11 <[email protected]>
AuthorDate: Thu Aug 25 17:38:15 2022 +0800

    [INLONG-5698][Manager] Fixed the DataProxy cluster tag was restored after 
the manager was restarted (#5699)
---
 .../manager/dao/mapper/InlongClusterEntityMapper.java     |  2 ++
 .../main/resources/mappers/InlongClusterEntityMapper.xml  | 15 +++++++++++++++
 .../manager/service/core/heartbeat/HeartbeatManager.java  | 11 ++++-------
 3 files changed, 21 insertions(+), 7 deletions(-)

diff --git 
a/inlong-manager/manager-dao/src/main/java/org/apache/inlong/manager/dao/mapper/InlongClusterEntityMapper.java
 
b/inlong-manager/manager-dao/src/main/java/org/apache/inlong/manager/dao/mapper/InlongClusterEntityMapper.java
index d1c7c40ed..36ca245df 100644
--- 
a/inlong-manager/manager-dao/src/main/java/org/apache/inlong/manager/dao/mapper/InlongClusterEntityMapper.java
+++ 
b/inlong-manager/manager-dao/src/main/java/org/apache/inlong/manager/dao/mapper/InlongClusterEntityMapper.java
@@ -40,6 +40,8 @@ public interface InlongClusterEntityMapper {
     List<InlongClusterEntity> selectByKey(@Param("clusterTag") String 
clusterTag, @Param("name") String name,
             @Param("type") String type);
 
+    InlongClusterEntity selectByNameAndType(@Param("name") String name, 
@Param("type") String type);
+
     List<InlongClusterEntity> selectByCondition(ClusterPageRequest request);
 
     /**
diff --git 
a/inlong-manager/manager-dao/src/main/resources/mappers/InlongClusterEntityMapper.xml
 
b/inlong-manager/manager-dao/src/main/resources/mappers/InlongClusterEntityMapper.xml
index 1df48fbcb..ca518dad6 100644
--- 
a/inlong-manager/manager-dao/src/main/resources/mappers/InlongClusterEntityMapper.xml
+++ 
b/inlong-manager/manager-dao/src/main/resources/mappers/InlongClusterEntityMapper.xml
@@ -105,6 +105,21 @@
         </where>
         order by modify_time desc
     </select>
+    <select id="selectByNameAndType" 
resultType="org.apache.inlong.manager.dao.entity.InlongClusterEntity">
+        select
+        <include refid="Base_Column_List"/>
+        from inlong_cluster
+        <where>
+            is_deleted = 0
+            <if test="type != null and type != ''">
+                and type = #{type, jdbcType=VARCHAR}
+            </if>
+            <if test="name != null and name != ''">
+                and name = #{name, jdbcType=VARCHAR}
+            </if>
+        </where>
+        order by modify_time desc
+    </select>
     <select id="selectByCondition"
             
parameterType="org.apache.inlong.manager.pojo.cluster.ClusterPageRequest"
             
resultType="org.apache.inlong.manager.dao.entity.InlongClusterEntity">
diff --git 
a/inlong-manager/manager-service/src/main/java/org/apache/inlong/manager/service/core/heartbeat/HeartbeatManager.java
 
b/inlong-manager/manager-service/src/main/java/org/apache/inlong/manager/service/core/heartbeat/HeartbeatManager.java
index 8353842ae..6027fa908 100644
--- 
a/inlong-manager/manager-service/src/main/java/org/apache/inlong/manager/service/core/heartbeat/HeartbeatManager.java
+++ 
b/inlong-manager/manager-service/src/main/java/org/apache/inlong/manager/service/core/heartbeat/HeartbeatManager.java
@@ -24,7 +24,6 @@ import com.github.benmanes.caffeine.cache.RemovalCause;
 import com.github.benmanes.caffeine.cache.Scheduler;
 import lombok.Getter;
 import lombok.extern.slf4j.Slf4j;
-import org.apache.commons.collections.CollectionUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.inlong.common.heartbeat.AbstractHeartbeatManager;
 import org.apache.inlong.common.heartbeat.ComponentHeartbeat;
@@ -44,7 +43,6 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 
 import javax.annotation.PostConstruct;
-import java.util.List;
 import java.util.concurrent.Executors;
 import java.util.concurrent.TimeUnit;
 
@@ -158,12 +156,11 @@ public class HeartbeatManager implements 
AbstractHeartbeatManager {
         final String clusterName = componentHeartbeat.getClusterName();
         final String type = componentHeartbeat.getComponentType();
         final String clusterTag = componentHeartbeat.getClusterTag();
-        List<InlongClusterEntity> entities = 
clusterMapper.selectByKey(clusterTag, clusterName, type);
-        if (CollectionUtils.isNotEmpty(entities)) {
+        InlongClusterEntity entity = 
clusterMapper.selectByNameAndType(clusterName, type);
+        if (null != entity) {
             // TODO Load balancing needs to be considered.
-            InlongClusterEntity cluster = entities.get(0);
-            InlongClusterOperator operator = 
clusterOperatorFactory.getInstance(cluster.getType());
-            return operator.getFromEntity(cluster);
+            InlongClusterOperator operator = 
clusterOperatorFactory.getInstance(entity.getType());
+            return operator.getFromEntity(entity);
         }
 
         InlongClusterEntity cluster = new InlongClusterEntity();

Reply via email to