imaffe commented on a change in pull request #607:
URL: https://github.com/apache/rocketmq-externals/pull/607#discussion_r464160137



##########
File path: 
rocketmq-connect/rocketmq-connect-runtime/src/main/java/org/apache/rocketmq/connect/runtime/tools/command/StopAllSubCommand.java
##########
@@ -0,0 +1,35 @@
+package org.apache.rocketmq.connect.runtime.tools.command;
+
+import org.apache.commons.cli.CommandLine;
+import org.apache.commons.cli.Options;
+import org.apache.rocketmq.connect.runtime.rest.RestSender;
+import org.apache.rocketmq.tools.command.SubCommandException;
+
+public class StopAllSubCommand implements SubCommand {
+    @Override
+    public String commandName() {
+        return "stopAll";
+    }
+
+    @Override
+    public String commandDesc() {
+        return "Stop and delete all Connectors and all configuration 
information";
+    }
+
+    @Override
+    public Options buildCommandlineOptions(Options options) {
+        return options;
+    }
+
+    @Override
+    public void execute(CommandLine commandLine, Options options) throws 
SubCommandException {
+        try {
+            String url = "http://localhost:8081/connectors/"; + commandName();

Review comment:
       Why this url is hardcoded in code ~

##########
File path: 
rocketmq-connect/rocketmq-connect-runtime/src/main/java/org/apache/rocketmq/connect/runtime/rest/RestSender.java
##########
@@ -0,0 +1,38 @@
+package org.apache.rocketmq.connect.runtime.rest;

Review comment:
       We need to add Apache header at the start of each file~

##########
File path: 
rocketmq-connect/rocketmq-connect-runtime/src/main/java/org/apache/rocketmq/connect/runtime/tools/command/CreateConnectorSubCommand.java
##########
@@ -0,0 +1,62 @@
+package org.apache.rocketmq.connect.runtime.tools.command;
+
+import org.apache.commons.cli.CommandLine;
+import org.apache.commons.cli.Option;
+import org.apache.commons.cli.Options;
+import org.apache.rocketmq.connect.runtime.rest.RestSender;
+import org.apache.rocketmq.tools.command.SubCommandException;
+
+import java.io.*;
+import java.nio.charset.StandardCharsets;
+
+public class CreateConnectorSubCommand implements SubCommand {
+    @Override
+    public String commandName() {
+        return "createConnector";
+    }
+
+    @Override
+    public String commandDesc() {
+        return "Create and start a connector by connector's config";
+    }
+
+    @Override
+    public Options buildCommandlineOptions(Options options) {
+        Option opt = new Option("c", "connectorName", true, "connector name");
+        opt.setRequired(true);
+        options.addOption(opt);
+        opt = new Option("p", "path", true, "Configuration file path");
+        opt.setRequired(true);
+        options.addOption(opt);
+        return options;
+    }
+
+    @Override
+    public void execute(CommandLine commandLine, Options options) throws 
SubCommandException {
+        try{
+            String connectorName = commandLine.getOptionValue('c').trim();
+            String baseUrl = "http://localhost:8081/connectors/"; + 
connectorName + "?config=";
+            String filePath = commandLine.getOptionValue('p').trim();
+            String config = readFile(filePath);
+            System.out.println("Send request to " + baseUrl + config);

Review comment:
       Is this format clear enough for users?




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

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to