You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@inlong.apache.org by GitBox <gi...@apache.org> on 2022/10/25 03:48:05 UTC

[GitHub] [inlong] vernedeng opened a new pull request, #6275: [INLONG-6104][Manager] Refator getSortSource

vernedeng opened a new pull request, #6275:
URL: https://github.com/apache/inlong/pull/6275

   ### Prepare a Pull Request
   *(Change the title refer to the following example)*
   
   - Title Example: [INLONG-XYZ][Component] Title of the pull request
   
   *(The following *XYZ* should be replaced by the actual [GitHub Issue](https://github.com/apache/inlong/issues) number)*
   
   - Fixes #6104
   
   ### Motivation
   
   *Explain here the context, and why you're making that change. What is the problem you're trying to solve?*
   
   ### Modifications
   
   *Describe the modifications you've done.*
   
   ### Verifying this change
   
   *(Please pick either of the following options)*
   
   - [ ] This change is a trivial rework/code cleanup without any test coverage.
   
   - [ ] This change is already covered by existing tests, such as:
     *(please describe tests)*
   
   - [ ] This change added tests and can be verified as follows:
   
     *(example:)*
     - *Added integration tests for end-to-end deployment with large payloads (10MB)*
     - *Extended integration test for recovery after broker failure*
   
   ### Documentation
   
     - Does this pull request introduce a new feature? (yes / no)
     - If yes, how is the feature documented? (not applicable / docs / JavaDocs / not documented)
     - If a feature is not applicable for documentation, explain why?
     - If a feature is not documented yet in this PR, please create a follow-up issue for adding the documentation
   


-- 
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


[GitHub] [inlong] vernedeng commented on a diff in pull request #6275: [INLONG-6104][Manager] Refactor getSortSource

Posted by GitBox <gi...@apache.org>.
vernedeng commented on code in PR #6275:
URL: https://github.com/apache/inlong/pull/6275#discussion_r1007761583


##########
inlong-manager/manager-pojo/src/main/java/org/apache/inlong/manager/pojo/sort/standalone/SortSourceStreamSinkInfo.java:
##########
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.inlong.manager.pojo.sort.standalone;
+
+import com.google.gson.Gson;
+import lombok.Data;
+import org.apache.commons.lang3.StringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+@Data
+public class SortSourceStreamSinkInfo {
+
+    private static final long serialVersionUID = 1L;
+    private static final Logger LOGGER = LoggerFactory.getLogger(SortSourceStreamSinkInfo.class);
+    String sortClusterName;
+    String sortTaskName;
+    String groupId;
+    String extParams;
+    Map<String, String> extParamsMap;
+
+    public Map<String, String> getExtParamsMap() {
+        if (extParamsMap != null) {
+            return extParamsMap;
+        }
+        if (StringUtils.isNotBlank(extParams)) {
+            try {
+                Gson gson = new Gson();

Review Comment:
   fixed, thx



-- 
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


[GitHub] [inlong] vernedeng commented on a diff in pull request #6275: [INLONG-6104][Manager] Refactor getSortSource

Posted by GitBox <gi...@apache.org>.
vernedeng commented on code in PR #6275:
URL: https://github.com/apache/inlong/pull/6275#discussion_r1005157552


##########
inlong-manager/manager-dao/src/main/resources/mappers/StreamSinkEntityMapper.xml:
##########
@@ -350,6 +350,13 @@
             </if>
         </where>
     </select>
+    <select id="selectAllStreamSinks" resultType="org.apache.inlong.manager.dao.entity.StreamSinkEntity">
+        select
+        <include refid="Base_Column_List"/>
+        from stream_sink
+        where is_deleted = 0
+        group by inlong_cluster_name, sort_task_name, sort_consumer_group, sink_type, data_node_name

Review Comment:
   fixed, thx



##########
inlong-manager/manager-service/src/main/java/org/apache/inlong/manager/service/core/impl/SortSourceServiceImpl.java:
##########
@@ -177,6 +194,156 @@ public SortSourceConfigResponse getSourceConfig(
 
     }
 
+    private void reloadAllSourceConfigV2() {
+        List<StreamSinkEntity> sinkEntities = streamSinkEntityMapper.selectAllStreamSinks();
+        // convert to Map<clusterName, Map<taskName, List<groupId>>> format.
+        Map<String, Map<String, List<String>>> groupMap = new ConcurrentHashMap<>();
+        sinkEntities.forEach(stream -> {
+            Map<String, List<String>> task2groupsMap =
+                    groupMap.computeIfAbsent(stream.getInlongClusterName(), k -> new ConcurrentHashMap<>());
+            List<String> groupIdList =
+                    task2groupsMap.computeIfAbsent(stream.getSortTaskName(), k -> new ArrayList<>());
+            groupIdList.add(stream.getInlongGroupId());
+        });
+
+        // get all group topic info by groupId
+        Map<String, List<InlongGroupTopicInfo>> allGroupTopicInfo = sinkEntities.stream()
+                .flatMap(entity -> {
+                    InlongGroupTopicInfo topicInfo = groupService.getTopic(entity.getInlongGroupId());
+                    InlongGroupTopicInfo backupTopicInfo = groupService.getBackupTopic(entity.getInlongGroupId());
+                    return Stream.of(topicInfo, backupTopicInfo);
+                })
+                .filter(Objects::nonNull)
+                .collect(Collectors.groupingBy(InlongGroupTopicInfo::getInlongGroupId));
+
+        // Prepare CacheZones for each cluster and task
+        Map<String, Map<String, String>> newMd5Map = new ConcurrentHashMap<>();
+        Map<String, Map<String, CacheZoneConfig>> newConfigMap = new ConcurrentHashMap<>();
+        groupMap.forEach((clusterName, task2Group) -> {
+
+            // prepare the new config and md5
+            Map<String, CacheZoneConfig> task2Config = new ConcurrentHashMap<>();
+            Map<String, String> task2Md5 = new ConcurrentHashMap<>();
+
+            task2Group.forEach((taskName, groupList) -> {
+                CacheZoneConfig cacheZoneConfig =
+                        CacheZoneConfig.builder()
+                                .sortClusterName(clusterName)
+                                .sortTaskId(taskName)
+                                .build();
+                List<InlongGroupTopicInfo> relatedGroupInfos = groupList.stream()
+                        .flatMap(groupId -> allGroupTopicInfo.get(groupId).stream())
+                        .collect(Collectors.toList());
+                Map<String, CacheZone> cacheZoneMap = this.parsePulsarCacheZones(relatedGroupInfos);
+                cacheZoneConfig.setCacheZones(cacheZoneMap);
+
+                String jsonStr = GSON.toJson(cacheZoneConfig);
+                String md5 = DigestUtils.md5Hex(jsonStr);
+                task2Config.put(taskName, cacheZoneConfig);
+                task2Md5.put(taskName, md5);
+            });
+
+            newConfigMap.put(clusterName, task2Config);
+            newMd5Map.put(clusterName, task2Md5);
+        });
+
+        sortSourceConfigMap = newConfigMap;
+        sortSourceMd5Map = newMd5Map;
+    }
+
+    private Map<String, CacheZone> parsePulsarCacheZones(List<InlongGroupTopicInfo> groupTopicInfos) {
+        Map<String, CacheZone> cacheZoneMap = new HashMap<>();
+        groupTopicInfos.forEach(info -> this.parseCacheZones(info, cacheZoneMap));
+        return cacheZoneMap;
+    }
+
+    private void parseCacheZones(InlongGroupTopicInfo info, Map<String, CacheZone> cacheZoneMap) {
+        switch (info.getMqType().toUpperCase()) {

Review Comment:
   fixed, thx



-- 
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


[GitHub] [inlong] dockerzhang merged pull request #6275: [INLONG-6104][Manager] Support getting backup info in getSortSource

Posted by GitBox <gi...@apache.org>.
dockerzhang merged PR #6275:
URL: https://github.com/apache/inlong/pull/6275


-- 
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


[GitHub] [inlong] healchow commented on a diff in pull request #6275: [INLONG-6104][Manager] Refactor getSortSource

Posted by GitBox <gi...@apache.org>.
healchow commented on code in PR #6275:
URL: https://github.com/apache/inlong/pull/6275#discussion_r1007737389


##########
inlong-manager/manager-service/src/main/java/org/apache/inlong/manager/service/core/SortConfigLoader.java:
##########
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.inlong.manager.service.core;
+
+import org.apache.inlong.manager.dao.entity.InlongGroupExtEntity;
+import org.apache.inlong.manager.dao.entity.InlongStreamExtEntity;
+import org.apache.inlong.manager.pojo.sort.standalone.SortSourceClusterInfo;
+import org.apache.inlong.manager.pojo.sort.standalone.SortSourceGroupInfo;
+import org.apache.inlong.manager.pojo.sort.standalone.SortSourceStreamInfo;
+import org.apache.inlong.manager.pojo.sort.standalone.SortSourceStreamSinkInfo;
+
+import java.util.List;
+
+public interface SortConfigLoader {

Review Comment:
   Please add Java docs for classes, interfaces, and public methods.



-- 
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


[GitHub] [inlong] healchow commented on a diff in pull request #6275: [INLONG-6104][Manager] Refactor getSortSource

Posted by GitBox <gi...@apache.org>.
healchow commented on code in PR #6275:
URL: https://github.com/apache/inlong/pull/6275#discussion_r1004216562


##########
inlong-manager/manager-service/src/test/java/org/apache/inlong/manager/service/sort/SortServiceImplTest.java:
##########
@@ -195,20 +216,50 @@ private void prepareDataNode(String taskName) {
     }
 
     private void prepareGroupId(String groupId) {
-        InlongGroupEntity entity = new InlongGroupEntity();
-        entity.setInlongGroupId(groupId);
-        entity.setInlongClusterTag(TEST_TAG);
-        entity.setMqResource(TEST_TOPIC);
-        entity.setMqType("PULSAR");
-        entity.setName("testName");
-        entity.setDescription("testDescription");
-        entity.setCreator(TEST_CREATOR);
-        entity.setInCharges(TEST_CREATOR);
-        entity.setCreateTime(new Date());
-        entity.setModifyTime(new Date());
-        entity.setIsDeleted(InlongConstants.UN_DELETED);
-        entity.setVersion(InlongConstants.INITIAL_VERSION);
-        inlongGroupEntityMapper.insert(entity);
+        InlongPulsarRequest request = new InlongPulsarRequest();
+        request.setInlongGroupId(groupId);
+        request.setMqResource("test namespace");
+        request.setInlongClusterTag(TEST_TAG);
+        request.setVersion(InlongConstants.INITIAL_VERSION);
+        request.setName("test group name");

Review Comment:
   Suggest adding `-` or `_` between words for name, backup topic, etc.



-- 
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


[GitHub] [inlong] healchow commented on a diff in pull request #6275: [INLONG-6104][Manager] Refactor getSortSource

Posted by GitBox <gi...@apache.org>.
healchow commented on code in PR #6275:
URL: https://github.com/apache/inlong/pull/6275#discussion_r1007726437


##########
inlong-manager/manager-dao/src/main/java/org/apache/inlong/manager/dao/mapper/InlongStreamEntityMapper.java:
##########
@@ -71,4 +73,5 @@ int updateStatusByIdentifier(@Param("groupId") String groupId, @Param("streamId"
      */
     int deleteByInlongGroupIds(@Param("groupIdList") List<String> groupIdList);
 
+    Cursor<SortSourceStreamInfo> selectAllStreams();

Review Comment:
   Did this Cursor need `@Options`?



-- 
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


[GitHub] [inlong] vernedeng commented on a diff in pull request #6275: [INLONG-6104][Manager] Refactor getSortSource

Posted by GitBox <gi...@apache.org>.
vernedeng commented on code in PR #6275:
URL: https://github.com/apache/inlong/pull/6275#discussion_r1005157259


##########
inlong-manager/manager-service/src/test/java/org/apache/inlong/manager/service/sort/SortServiceImplTest.java:
##########
@@ -195,20 +216,50 @@ private void prepareDataNode(String taskName) {
     }
 
     private void prepareGroupId(String groupId) {
-        InlongGroupEntity entity = new InlongGroupEntity();
-        entity.setInlongGroupId(groupId);
-        entity.setInlongClusterTag(TEST_TAG);
-        entity.setMqResource(TEST_TOPIC);
-        entity.setMqType("PULSAR");
-        entity.setName("testName");
-        entity.setDescription("testDescription");
-        entity.setCreator(TEST_CREATOR);
-        entity.setInCharges(TEST_CREATOR);
-        entity.setCreateTime(new Date());
-        entity.setModifyTime(new Date());
-        entity.setIsDeleted(InlongConstants.UN_DELETED);
-        entity.setVersion(InlongConstants.INITIAL_VERSION);
-        inlongGroupEntityMapper.insert(entity);
+        InlongPulsarRequest request = new InlongPulsarRequest();
+        request.setInlongGroupId(groupId);
+        request.setMqResource("test namespace");
+        request.setInlongClusterTag(TEST_TAG);
+        request.setVersion(InlongConstants.INITIAL_VERSION);
+        request.setName("test group name");

Review Comment:
   fixed, thx



-- 
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


[GitHub] [inlong] healchow commented on a diff in pull request #6275: [INLONG-6104][Manager] Refactor getSortSource

Posted by GitBox <gi...@apache.org>.
healchow commented on code in PR #6275:
URL: https://github.com/apache/inlong/pull/6275#discussion_r1007733750


##########
inlong-manager/manager-pojo/src/main/java/org/apache/inlong/manager/pojo/sort/standalone/SortSourceStreamSinkInfo.java:
##########
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.inlong.manager.pojo.sort.standalone;
+
+import com.google.gson.Gson;
+import lombok.Data;
+import org.apache.commons.lang3.StringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+@Data
+public class SortSourceStreamSinkInfo {
+
+    private static final long serialVersionUID = 1L;
+    private static final Logger LOGGER = LoggerFactory.getLogger(SortSourceStreamSinkInfo.class);
+    String sortClusterName;
+    String sortTaskName;
+    String groupId;
+    String extParams;
+    Map<String, String> extParamsMap;
+
+    public Map<String, String> getExtParamsMap() {
+        if (extParamsMap != null) {
+            return extParamsMap;
+        }
+        if (StringUtils.isNotBlank(extParams)) {
+            try {
+                Gson gson = new Gson();

Review Comment:
   Suggest using a global instance.



-- 
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


[GitHub] [inlong] vernedeng commented on a diff in pull request #6275: [INLONG-6104][Manager] Refactor getSortSource

Posted by GitBox <gi...@apache.org>.
vernedeng commented on code in PR #6275:
URL: https://github.com/apache/inlong/pull/6275#discussion_r1007735074


##########
inlong-manager/manager-dao/src/main/java/org/apache/inlong/manager/dao/mapper/InlongStreamEntityMapper.java:
##########
@@ -71,4 +73,5 @@ int updateStatusByIdentifier(@Param("groupId") String groupId, @Param("streamId"
      */
     int deleteByInlongGroupIds(@Param("groupIdList") List<String> groupIdList);
 
+    Cursor<SortSourceStreamInfo> selectAllStreams();

Review Comment:
   Yes, I forgot it.  
   



-- 
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


[GitHub] [inlong] vernedeng commented on a diff in pull request #6275: [INLONG-6104][Manager] Refactor getSortSource

Posted by GitBox <gi...@apache.org>.
vernedeng commented on code in PR #6275:
URL: https://github.com/apache/inlong/pull/6275#discussion_r1007762112


##########
inlong-manager/manager-service/src/main/java/org/apache/inlong/manager/service/core/SortConfigLoader.java:
##########
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.inlong.manager.service.core;
+
+import org.apache.inlong.manager.dao.entity.InlongGroupExtEntity;
+import org.apache.inlong.manager.dao.entity.InlongStreamExtEntity;
+import org.apache.inlong.manager.pojo.sort.standalone.SortSourceClusterInfo;
+import org.apache.inlong.manager.pojo.sort.standalone.SortSourceGroupInfo;
+import org.apache.inlong.manager.pojo.sort.standalone.SortSourceStreamInfo;
+import org.apache.inlong.manager.pojo.sort.standalone.SortSourceStreamSinkInfo;
+
+import java.util.List;
+
+public interface SortConfigLoader {

Review Comment:
   fixed, thx



-- 
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


[GitHub] [inlong] vernedeng commented on a diff in pull request #6275: [INLONG-6104][Manager] Refactor getSortSource

Posted by GitBox <gi...@apache.org>.
vernedeng commented on code in PR #6275:
URL: https://github.com/apache/inlong/pull/6275#discussion_r1005157552


##########
inlong-manager/manager-dao/src/main/resources/mappers/StreamSinkEntityMapper.xml:
##########
@@ -350,6 +350,13 @@
             </if>
         </where>
     </select>
+    <select id="selectAllStreamSinks" resultType="org.apache.inlong.manager.dao.entity.StreamSinkEntity">
+        select
+        <include refid="Base_Column_List"/>
+        from stream_sink
+        where is_deleted = 0
+        group by inlong_cluster_name, sort_task_name, sort_consumer_group, sink_type, data_node_name

Review Comment:
   The way sort-standalone manager metadata is to prepare all configs and cache them in local memory, then reload them in a certain time interval.
   Because the number of sort-standalone node is more than ten thousand, it will introduce very high load if prepare each node config after each request.
   The cpu and memory utility is less than 5% and 10% of a 8 cores, 20GB manager node, in the senarios of more than 10 thousand groupId, 20 thousand streamsink and 1 hundred dataNodes



-- 
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


[GitHub] [inlong] healchow commented on a diff in pull request #6275: [INLONG-6104][Manager] Refactor getSortSource

Posted by GitBox <gi...@apache.org>.
healchow commented on code in PR #6275:
URL: https://github.com/apache/inlong/pull/6275#discussion_r1004222088


##########
inlong-manager/manager-service/src/main/java/org/apache/inlong/manager/service/core/impl/SortSourceServiceImpl.java:
##########
@@ -177,6 +194,156 @@ public SortSourceConfigResponse getSourceConfig(
 
     }
 
+    private void reloadAllSourceConfigV2() {
+        List<StreamSinkEntity> sinkEntities = streamSinkEntityMapper.selectAllStreamSinks();
+        // convert to Map<clusterName, Map<taskName, List<groupId>>> format.
+        Map<String, Map<String, List<String>>> groupMap = new ConcurrentHashMap<>();
+        sinkEntities.forEach(stream -> {
+            Map<String, List<String>> task2groupsMap =
+                    groupMap.computeIfAbsent(stream.getInlongClusterName(), k -> new ConcurrentHashMap<>());
+            List<String> groupIdList =
+                    task2groupsMap.computeIfAbsent(stream.getSortTaskName(), k -> new ArrayList<>());
+            groupIdList.add(stream.getInlongGroupId());
+        });
+
+        // get all group topic info by groupId
+        Map<String, List<InlongGroupTopicInfo>> allGroupTopicInfo = sinkEntities.stream()
+                .flatMap(entity -> {
+                    InlongGroupTopicInfo topicInfo = groupService.getTopic(entity.getInlongGroupId());
+                    InlongGroupTopicInfo backupTopicInfo = groupService.getBackupTopic(entity.getInlongGroupId());
+                    return Stream.of(topicInfo, backupTopicInfo);
+                })
+                .filter(Objects::nonNull)
+                .collect(Collectors.groupingBy(InlongGroupTopicInfo::getInlongGroupId));
+
+        // Prepare CacheZones for each cluster and task
+        Map<String, Map<String, String>> newMd5Map = new ConcurrentHashMap<>();
+        Map<String, Map<String, CacheZoneConfig>> newConfigMap = new ConcurrentHashMap<>();
+        groupMap.forEach((clusterName, task2Group) -> {
+
+            // prepare the new config and md5
+            Map<String, CacheZoneConfig> task2Config = new ConcurrentHashMap<>();
+            Map<String, String> task2Md5 = new ConcurrentHashMap<>();
+
+            task2Group.forEach((taskName, groupList) -> {
+                CacheZoneConfig cacheZoneConfig =
+                        CacheZoneConfig.builder()
+                                .sortClusterName(clusterName)
+                                .sortTaskId(taskName)
+                                .build();
+                List<InlongGroupTopicInfo> relatedGroupInfos = groupList.stream()
+                        .flatMap(groupId -> allGroupTopicInfo.get(groupId).stream())
+                        .collect(Collectors.toList());
+                Map<String, CacheZone> cacheZoneMap = this.parsePulsarCacheZones(relatedGroupInfos);
+                cacheZoneConfig.setCacheZones(cacheZoneMap);
+
+                String jsonStr = GSON.toJson(cacheZoneConfig);
+                String md5 = DigestUtils.md5Hex(jsonStr);
+                task2Config.put(taskName, cacheZoneConfig);
+                task2Md5.put(taskName, md5);
+            });
+
+            newConfigMap.put(clusterName, task2Config);
+            newMd5Map.put(clusterName, task2Md5);
+        });
+
+        sortSourceConfigMap = newConfigMap;
+        sortSourceMd5Map = newMd5Map;
+    }
+
+    private Map<String, CacheZone> parsePulsarCacheZones(List<InlongGroupTopicInfo> groupTopicInfos) {
+        Map<String, CacheZone> cacheZoneMap = new HashMap<>();
+        groupTopicInfos.forEach(info -> this.parseCacheZones(info, cacheZoneMap));
+        return cacheZoneMap;
+    }
+
+    private void parseCacheZones(InlongGroupTopicInfo info, Map<String, CacheZone> cacheZoneMap) {
+        switch (info.getMqType().toUpperCase()) {

Review Comment:
   No need to upper case, it is an error if it was not matched.



-- 
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


[GitHub] [inlong] healchow commented on a diff in pull request #6275: [INLONG-6104][Manager] Refactor getSortSource

Posted by GitBox <gi...@apache.org>.
healchow commented on code in PR #6275:
URL: https://github.com/apache/inlong/pull/6275#discussion_r1004218952


##########
inlong-manager/manager-dao/src/main/resources/mappers/StreamSinkEntityMapper.xml:
##########
@@ -350,6 +350,13 @@
             </if>
         </where>
     </select>
+    <select id="selectAllStreamSinks" resultType="org.apache.inlong.manager.dao.entity.StreamSinkEntity">
+        select
+        <include refid="Base_Column_List"/>
+        from stream_sink
+        where is_deleted = 0
+        group by inlong_cluster_name, sort_task_name, sort_consumer_group, sink_type, data_node_name

Review Comment:
   The result size for this SQL may be so large, suggest using a pagination query, or adding some filter parameters to reduce the result size.



-- 
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