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/20 08:10:05 UTC

[GitHub] [inlong] haifxu opened a new pull request, #5958: [INLONG-5102][Manager] Add CRUD for inlong cluster

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

   ### Prepare a Pull Request
   
   - Fixes #5102 
   
   ### Motivation
   
   Manager tools supports CRUD for inlong cluster.
   
   ### Modifications
   
   1.Add CRUD for inlong cluster.
   2.Add cluster type parameter validation.
   2.Add cluster id validation in `org.apache.inlong.manager.client.api.inner.client.InlongClusterClient#update`.
   
   ### Verifying this change
   
   1. managerctl list cluster
   ```
   cluster      Get cluster summary information
         Usage: cluster [options]
           Options:
             --tag
               cluster tag
             --type
               cluster type
   ```
   2. managerctl describe cluster
   ```
   cluster      Get cluster details
         Usage: cluster [options]
           Options:
           * -id, --id
               cluster id
   ```
   3. managerctl create cluster
   ```
   cluster      Create cluster by json file
         Usage: cluster [options]
           Options:
             -f, --file
               json file
   ```
   4. managerctl update cluster
   ```
   cluster      Update cluster by json file
         Usage: cluster [options]
           Options:
             -f, --file
               json file
   ```
   5. managerctl delete cluster
   ```
   cluster      Delete cluster by cluster id
         Usage: cluster [options]
           Options:
           * -id, --id
               cluster id
   ```
   


-- 
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] haifxu commented on a diff in pull request #5958: [INLONG-5102][Manager] Command tools add CRUD for inlong cluster

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


##########
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:
   Done.



-- 
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 #5958: [INLONG-5102][Manager] Command tools add CRUD for inlong cluster

Posted by GitBox <gi...@apache.org>.
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


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

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


##########
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:
   Done.



-- 
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 #5958: [INLONG-5102][Manager] Command tools add CRUD for inlong cluster

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


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