You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@inlong.apache.org by he...@apache.org on 2022/09/26 08:24:44 UTC
[inlong] branch master updated: [INLONG-6004][Manager] Command tools add CRUD for inlong cluster node (#6007)
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 6d9966167 [INLONG-6004][Manager] Command tools add CRUD for inlong cluster node (#6007)
6d9966167 is described below
commit 6d9966167c89388cb14381e59176399e51eccaa5
Author: haifxu <xh...@gmail.com>
AuthorDate: Mon Sep 26 16:24:40 2022 +0800
[INLONG-6004][Manager] Command tools add CRUD for inlong cluster node (#6007)
---
.../inlong/manager/client/cli/CreateCommand.java | 28 ++++++++++++++++++
.../inlong/manager/client/cli/DeleteCommand.java | 24 ++++++++++++++++
.../inlong/manager/client/cli/DescribeCommand.java | 24 ++++++++++++++++
.../inlong/manager/client/cli/ListCommand.java | 33 +++++++++++++++++++++-
.../inlong/manager/client/cli/UpdateCommand.java | 27 ++++++++++++++++++
.../manager/client/cli/pojo/ClusterNodeInfo.java | 28 ++++++++++++++++++
6 files changed, 163 insertions(+), 1 deletion(-)
diff --git a/inlong-manager/manager-client-tools/src/main/java/org/apache/inlong/manager/client/cli/CreateCommand.java b/inlong-manager/manager-client-tools/src/main/java/org/apache/inlong/manager/client/cli/CreateCommand.java
index b314f2755..2c05d560d 100644
--- a/inlong-manager/manager-client-tools/src/main/java/org/apache/inlong/manager/client/cli/CreateCommand.java
+++ b/inlong-manager/manager-client-tools/src/main/java/org/apache/inlong/manager/client/cli/CreateCommand.java
@@ -26,6 +26,7 @@ import org.apache.inlong.manager.client.api.InlongStreamBuilder;
import org.apache.inlong.manager.client.api.inner.client.InlongClusterClient;
import org.apache.inlong.manager.client.cli.pojo.CreateGroupConf;
import org.apache.inlong.manager.client.cli.util.ClientUtils;
+import org.apache.inlong.manager.pojo.cluster.ClusterNodeRequest;
import org.apache.inlong.manager.pojo.cluster.ClusterRequest;
import org.apache.inlong.manager.pojo.cluster.ClusterTagRequest;
@@ -46,6 +47,7 @@ public class CreateCommand extends AbstractCommand {
jcommander.addCommand("group", new CreateGroup());
jcommander.addCommand("cluster", new CreateCluster());
jcommander.addCommand("cluster-tag", new CreateClusterTag());
+ jcommander.addCommand("cluster-node", new CreateClusterNode());
}
@Parameters(commandDescription = "Create group by json file")
@@ -143,4 +145,30 @@ public class CreateCommand extends AbstractCommand {
}
}
}
+
+ @Parameters(commandDescription = "Create cluster node by json file")
+ private static class CreateClusterNode extends AbstractCommandRunner {
+
+ @Parameter()
+ private List<String> params;
+
+ @Parameter(names = {"-f", "--file"}, description = "json file", converter = FileConverter.class)
+ private File file;
+
+ @Override
+ void run() {
+ try {
+ String content = ClientUtils.readFile(file);
+ ClusterNodeRequest request = objectMapper.readValue(content, ClusterNodeRequest.class);
+ ClientUtils.initClientFactory();
+ InlongClusterClient clusterClient = ClientUtils.clientFactory.getClusterClient();
+ Integer nodeId = clusterClient.saveNode(request);
+ if (nodeId != null) {
+ System.out.println("Create cluster node success! ID: " + nodeId);
+ }
+ } catch (Exception e) {
+ System.out.println(e.getMessage());
+ }
+ }
+ }
}
diff --git a/inlong-manager/manager-client-tools/src/main/java/org/apache/inlong/manager/client/cli/DeleteCommand.java b/inlong-manager/manager-client-tools/src/main/java/org/apache/inlong/manager/client/cli/DeleteCommand.java
index e9734a846..984404bf5 100644
--- a/inlong-manager/manager-client-tools/src/main/java/org/apache/inlong/manager/client/cli/DeleteCommand.java
+++ b/inlong-manager/manager-client-tools/src/main/java/org/apache/inlong/manager/client/cli/DeleteCommand.java
@@ -41,6 +41,7 @@ public class DeleteCommand extends AbstractCommand {
jcommander.addCommand("group", new DeleteGroup());
jcommander.addCommand("cluster", new DeleteCluster());
jcommander.addCommand("cluster-tag", new DeleteClusterTag());
+ jcommander.addCommand("cluster-node", new DeleteClusterNode());
}
@Parameters(commandDescription = "Delete group by group id")
@@ -112,4 +113,27 @@ public class DeleteCommand extends AbstractCommand {
}
}
}
+
+ @Parameters(commandDescription = "Delete cluster node by node id")
+ private static class DeleteClusterNode extends AbstractCommandRunner {
+
+ @Parameter()
+ private List<String> params;
+
+ @Parameter(names = {"-id", "--id"}, required = true, description = "cluster node id")
+ private int nodeId;
+
+ @Override
+ void run() {
+ try {
+ ClientUtils.initClientFactory();
+ InlongClusterClient clusterClient = ClientUtils.clientFactory.getClusterClient();
+ if (clusterClient.deleteNode(nodeId)) {
+ System.out.println("Delete cluster node success!");
+ }
+ } catch (Exception e) {
+ System.out.println(e.getMessage());
+ }
+ }
+ }
}
diff --git a/inlong-manager/manager-client-tools/src/main/java/org/apache/inlong/manager/client/cli/DescribeCommand.java b/inlong-manager/manager-client-tools/src/main/java/org/apache/inlong/manager/client/cli/DescribeCommand.java
index 77f263b75..82bd9c56b 100644
--- a/inlong-manager/manager-client-tools/src/main/java/org/apache/inlong/manager/client/cli/DescribeCommand.java
+++ b/inlong-manager/manager-client-tools/src/main/java/org/apache/inlong/manager/client/cli/DescribeCommand.java
@@ -28,6 +28,7 @@ import org.apache.inlong.manager.client.cli.pojo.GroupInfo;
import org.apache.inlong.manager.client.cli.util.ClientUtils;
import org.apache.inlong.manager.client.cli.util.PrintUtils;
import org.apache.inlong.manager.pojo.cluster.ClusterInfo;
+import org.apache.inlong.manager.pojo.cluster.ClusterNodeResponse;
import org.apache.inlong.manager.pojo.cluster.ClusterTagResponse;
import org.apache.inlong.manager.pojo.common.PageResult;
import org.apache.inlong.manager.pojo.group.InlongGroupBriefInfo;
@@ -56,6 +57,7 @@ public class DescribeCommand extends AbstractCommand {
jcommander.addCommand("source", new DescribeSource());
jcommander.addCommand("cluster", new DescribeCluster());
jcommander.addCommand("cluster-tag", new DescribeClusterTag());
+ jcommander.addCommand("cluster-node", new DescribeClusterNode());
}
@Parameters(commandDescription = "Get stream details")
@@ -207,4 +209,26 @@ public class DescribeCommand extends AbstractCommand {
}
}
}
+
+ @Parameters(commandDescription = "Get cluster node details")
+ private static class DescribeClusterNode extends AbstractCommandRunner {
+
+ @Parameter()
+ private List<String> params;
+
+ @Parameter(names = {"-id", "--id"}, required = true, description = "cluster node id")
+ private int nodeId;
+
+ @Override
+ void run() {
+ try {
+ ClientUtils.initClientFactory();
+ InlongClusterClient clusterClient = ClientUtils.clientFactory.getClusterClient();
+ ClusterNodeResponse nodeInfo = clusterClient.getNode(nodeId);
+ PrintUtils.printJson(nodeInfo);
+ } catch (Exception e) {
+ System.out.println(e.getMessage());
+ }
+ }
+ }
}
diff --git a/inlong-manager/manager-client-tools/src/main/java/org/apache/inlong/manager/client/cli/ListCommand.java b/inlong-manager/manager-client-tools/src/main/java/org/apache/inlong/manager/client/cli/ListCommand.java
index b5fc82eeb..330a93dae 100644
--- a/inlong-manager/manager-client-tools/src/main/java/org/apache/inlong/manager/client/cli/ListCommand.java
+++ b/inlong-manager/manager-client-tools/src/main/java/org/apache/inlong/manager/client/cli/ListCommand.java
@@ -24,6 +24,7 @@ import org.apache.inlong.manager.client.api.inner.client.InlongGroupClient;
import org.apache.inlong.manager.client.api.inner.client.InlongStreamClient;
import org.apache.inlong.manager.client.api.inner.client.StreamSinkClient;
import org.apache.inlong.manager.client.api.inner.client.StreamSourceClient;
+import org.apache.inlong.manager.client.cli.pojo.ClusterNodeInfo;
import org.apache.inlong.manager.client.cli.pojo.ClusterTagInfo;
import org.apache.inlong.manager.client.cli.pojo.GroupInfo;
import org.apache.inlong.manager.client.cli.pojo.SinkInfo;
@@ -34,6 +35,7 @@ import org.apache.inlong.manager.client.cli.util.PrintUtils;
import org.apache.inlong.manager.client.cli.validator.ClusterTypeValidator;
import org.apache.inlong.manager.common.enums.SimpleGroupStatus;
import org.apache.inlong.manager.pojo.cluster.ClusterInfo;
+import org.apache.inlong.manager.pojo.cluster.ClusterNodeResponse;
import org.apache.inlong.manager.pojo.cluster.ClusterPageRequest;
import org.apache.inlong.manager.pojo.cluster.ClusterTagPageRequest;
import org.apache.inlong.manager.pojo.cluster.ClusterTagResponse;
@@ -64,6 +66,7 @@ public class ListCommand extends AbstractCommand {
jcommander.addCommand("source", new ListSource());
jcommander.addCommand("cluster", new ListCluster());
jcommander.addCommand("cluster-tag", new ListClusterTag());
+ jcommander.addCommand("cluster-node", new ListClusterNode());
}
@Parameters(commandDescription = "Get stream summary information")
@@ -217,7 +220,7 @@ public class ListCommand extends AbstractCommand {
@Parameter()
private List<String> params;
- @Parameter(names = {"-ct", "--tag"}, description = "cluster tag")
+ @Parameter(names = {"--tag"}, description = "cluster tag")
private String tag;
@Override
@@ -234,4 +237,32 @@ public class ListCommand extends AbstractCommand {
}
}
}
+
+ @Parameters(commandDescription = "Get cluster node summary information")
+ private static class ListClusterNode extends AbstractCommandRunner {
+
+ @Parameter()
+ private List<String> params;
+
+ @Parameter(names = {"--tag"}, description = "cluster tag")
+ private String tag;
+
+ @Parameter(names = {"--type"}, description = "cluster type")
+ private String type;
+
+ @Override
+ void run() {
+ try {
+ ClientUtils.initClientFactory();
+ ClusterPageRequest request = new ClusterPageRequest();
+ request.setClusterTag(tag);
+ request.setType(type);
+ InlongClusterClient clusterClient = ClientUtils.clientFactory.getClusterClient();
+ PageResult<ClusterNodeResponse> nodeInfo = clusterClient.listNode(request);
+ PrintUtils.print(nodeInfo.getList(), ClusterNodeInfo.class);
+ } catch (Exception e) {
+ System.out.println(e.getMessage());
+ }
+ }
+ }
}
diff --git a/inlong-manager/manager-client-tools/src/main/java/org/apache/inlong/manager/client/cli/UpdateCommand.java b/inlong-manager/manager-client-tools/src/main/java/org/apache/inlong/manager/client/cli/UpdateCommand.java
index e16b0491c..f1045f78e 100644
--- a/inlong-manager/manager-client-tools/src/main/java/org/apache/inlong/manager/client/cli/UpdateCommand.java
+++ b/inlong-manager/manager-client-tools/src/main/java/org/apache/inlong/manager/client/cli/UpdateCommand.java
@@ -25,6 +25,7 @@ import org.apache.inlong.manager.client.api.InlongClient;
import org.apache.inlong.manager.client.api.InlongGroup;
import org.apache.inlong.manager.client.api.inner.client.InlongClusterClient;
import org.apache.inlong.manager.client.cli.util.ClientUtils;
+import org.apache.inlong.manager.pojo.cluster.ClusterNodeRequest;
import org.apache.inlong.manager.pojo.cluster.ClusterRequest;
import org.apache.inlong.manager.pojo.cluster.ClusterTagRequest;
import org.apache.inlong.manager.pojo.sort.BaseSortConf;
@@ -47,6 +48,7 @@ public class UpdateCommand extends AbstractCommand {
jcommander.addCommand("group", new UpdateCommand.UpdateGroup());
jcommander.addCommand("cluster", new UpdateCommand.UpdateCluster());
jcommander.addCommand("cluster-tag", new UpdateCommand.UpdateClusterTag());
+ jcommander.addCommand("cluster-node", new UpdateCommand.UpdateClusterNode());
}
@Parameters(commandDescription = "Update group by json file")
@@ -131,4 +133,29 @@ public class UpdateCommand extends AbstractCommand {
}
}
}
+
+ @Parameters(commandDescription = "Update cluster node by json file")
+ private static class UpdateClusterNode extends AbstractCommandRunner {
+
+ @Parameter()
+ private List<String> params;
+
+ @Parameter(names = {"-f", "--file"}, description = "json file", converter = FileConverter.class)
+ private File file;
+
+ @Override
+ void run() {
+ try {
+ String content = ClientUtils.readFile(file);
+ ClusterNodeRequest request = objectMapper.readValue(content, ClusterNodeRequest.class);
+ ClientUtils.initClientFactory();
+ InlongClusterClient clusterClient = ClientUtils.clientFactory.getClusterClient();
+ if (clusterClient.updateNode(request)) {
+ System.out.println("Update cluster node success!");
+ }
+ } catch (Exception e) {
+ System.out.println(e.getMessage());
+ }
+ }
+ }
}
diff --git a/inlong-manager/manager-client-tools/src/main/java/org/apache/inlong/manager/client/cli/pojo/ClusterNodeInfo.java b/inlong-manager/manager-client-tools/src/main/java/org/apache/inlong/manager/client/cli/pojo/ClusterNodeInfo.java
new file mode 100644
index 000000000..302502746
--- /dev/null
+++ b/inlong-manager/manager-client-tools/src/main/java/org/apache/inlong/manager/client/cli/pojo/ClusterNodeInfo.java
@@ -0,0 +1,28 @@
+/*
+ * 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.client.cli.pojo;
+
+import lombok.Data;
+
+@Data
+public class ClusterNodeInfo {
+
+ private String type;
+ private String ip;
+ private Integer port;
+}