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

healchow 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 af61f5c59 [INLONG-5051][Manager] Get Sort cluster allows a cluster 
with an empty tasks (#5091)
af61f5c59 is described below

commit af61f5c598ea874223e3bd2e81988c18bd4269c0
Author: vernedeng <[email protected]>
AuthorDate: Mon Jul 18 10:49:00 2022 +0800

    [INLONG-5051][Manager] Get Sort cluster allows a cluster with an empty 
tasks (#5091)
---
 .../manager/service/core/impl/SortClusterServiceImpl.java | 15 ++++++++-------
 .../manager/service/core/impl/SortServiceImplTest.java    |  2 +-
 2 files changed, 9 insertions(+), 8 deletions(-)

diff --git 
a/inlong-manager/manager-service/src/main/java/org/apache/inlong/manager/service/core/impl/SortClusterServiceImpl.java
 
b/inlong-manager/manager-service/src/main/java/org/apache/inlong/manager/service/core/impl/SortClusterServiceImpl.java
index ee6274d9b..f6d87b8be 100644
--- 
a/inlong-manager/manager-service/src/main/java/org/apache/inlong/manager/service/core/impl/SortClusterServiceImpl.java
+++ 
b/inlong-manager/manager-service/src/main/java/org/apache/inlong/manager/service/core/impl/SortClusterServiceImpl.java
@@ -40,7 +40,7 @@ import javax.annotation.PostConstruct;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
-import java.util.Optional;
+import java.util.Objects;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.Executors;
 import java.util.concurrent.ScheduledExecutorService;
@@ -125,13 +125,13 @@ public class SortClusterServiceImpl implements 
SortClusterService {
                     .build();
         }
 
-        // there is no config
+        // there is no config, but still return success.
         if (sortClusterConfigMap.get(clusterName) == null) {
             String errMsg = "There is not config for cluster " + clusterName;
             LOGGER.info(errMsg);
             return SortClusterResponse.builder()
                     .msg(errMsg)
-                    .code(RESPONSE_CODE_REQ_PARAMS_ERROR)
+                    .code(RESPONSE_CODE_SUCCESS)
                     .build();
         }
 
@@ -229,6 +229,7 @@ public class SortClusterServiceImpl implements 
SortClusterService {
                     SortSinkInfo sinkParams = 
taskSinkParamMap.get(task.getDataNodeName());
                     return this.getTaskConfig(taskName, type, idParams, 
sinkParams);
                 })
+                .filter(Objects::nonNull)
                 .collect(Collectors.toList());
 
         return SortClusterConfig.builder()
@@ -255,10 +256,10 @@ public class SortClusterServiceImpl implements 
SortClusterService {
             List<SortIdInfo> idParams,
             SortSinkInfo sinkParams) {
 
-        Optional.ofNullable(idParams)
-                .orElseThrow(() -> new IllegalStateException(("There is no any 
id params of task " + taskName)));
-        Optional.ofNullable(sinkParams)
-                .orElseThrow(() -> new IllegalStateException("There is no any 
sink params of task " + taskName));
+        // return null if id params or sink params are empty.
+        if (idParams == null || sinkParams == null) {
+            return null;
+        }
 
         if (!type.equalsIgnoreCase(sinkParams.getType())) {
             throw new IllegalArgumentException(
diff --git 
a/inlong-manager/manager-service/src/test/java/org/apache/inlong/manager/service/core/impl/SortServiceImplTest.java
 
b/inlong-manager/manager-service/src/test/java/org/apache/inlong/manager/service/core/impl/SortServiceImplTest.java
index 9ff8442f9..3b11f728c 100644
--- 
a/inlong-manager/manager-service/src/test/java/org/apache/inlong/manager/service/core/impl/SortServiceImplTest.java
+++ 
b/inlong-manager/manager-service/src/test/java/org/apache/inlong/manager/service/core/impl/SortServiceImplTest.java
@@ -163,7 +163,7 @@ public class SortServiceImplTest extends ServiceBaseTest {
     public void testClusterErrorClusterName() {
         SortClusterResponse response = 
sortService.getClusterConfig("errCluster", "");
         System.out.println(response.toString());
-        Assertions.assertEquals(-101, response.getCode());
+        Assertions.assertEquals(0, response.getCode());
         Assertions.assertNull(response.getMd5());
         Assertions.assertNull(response.getData());
         Assertions.assertNotNull(response.getMsg());

Reply via email to