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/09/21 03:58:41 UTC

[GitHub] [inlong] healchow commented on a diff in pull request #5958: [INLONG-5102][Manager] Command tools add CRUD for inlong cluster

healchow commented on code in PR #5958:
URL: https://github.com/apache/inlong/pull/5958#discussion_r976004147


##########
inlong-manager/manager-common/src/main/java/org/apache/inlong/manager/common/enums/ClusterType.java:
##########
@@ -27,4 +30,24 @@ public class ClusterType {
     public static final String PULSAR = "PULSAR";
     public static final String DATAPROXY = "DATAPROXY";
     public static final String KAFKA = "KAFKA";
+
+    private static final Set<String> TYPE_SET = new HashSet<String>() {
+        {
+            add(ClusterType.AGENT);
+            add(ClusterType.TUBEMQ);
+            add(ClusterType.PULSAR);
+            add(ClusterType.DATAPROXY);
+            add(ClusterType.KAFKA);
+        }
+    };
+
+    public static String forType(String clusterType) {
+        for (String type : TYPE_SET) {

Review Comment:
   Why use for loop on a Set? Suggest getting directly.



##########
inlong-manager/manager-client-tools/src/main/java/org/apache/inlong/manager/client/cli/CreateCommand.java:
##########
@@ -90,4 +94,30 @@ void run() {
             }
         }
     }
+
+    @Parameters(commandDescription = "Create cluster by json file")
+    private static class CreateCluster extends AbstractCommandRunner {
+
+        @Parameter()
+        private List<String> params;
+
+        @Parameter(names = {"-f", "--file"}, description = "json file", converter = FileConverter.class)
+        private File file;
+
+        @Override
+        void run() throws Exception {
+            String content = ClientUtils.readFile(file);
+            if (StringUtils.isBlank(content)) {
+                System.out.println("Create cluster failed: file was empty!");
+                return;
+            }
+            ClusterRequest request = objectMapper.readValue(content, ClusterRequest.class);
+            ClientUtils.initClientFactory();
+            InlongClusterClient clusterClient = ClientUtils.clientFactory.getClusterClient();
+            Integer isSave = clusterClient.saveCluster(request);

Review Comment:
   Why `isSave`? Maybe changing to `id` is more clearly.



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