use of org.apache.rocketmq.connect.cli.utils.RestSender in project rocketmq-externals by apache.
the class QueryConnectorConfigSubCommand method execute.
@Override
public void execute(CommandLine commandLine, Options options) throws SubCommandException {
try {
String connectorName = commandLine.getOptionValue('c').trim();
String request = "/connectors/" + connectorName + "/config";
URL url = new URL(CLIConfigDefine.PROTOCOL, config.getHttpAddr(), config.getHttpPort(), request);
String result = new RestSender().sendHttpRequest(url.toString(), "");
System.out.printf("%s%n", result);
} catch (Exception e) {
throw new SubCommandException(this.getClass().getSimpleName() + " command failed", e);
}
}
use of org.apache.rocketmq.connect.cli.utils.RestSender in project rocketmq-externals by apache.
the class StopConnectorSubCommand method execute.
@Override
public void execute(CommandLine commandLine, Options options) throws SubCommandException {
try {
String connectorName = commandLine.getOptionValue('c').trim();
String request = "/connectors/" + connectorName + "/stop";
URL url = new URL(CLIConfigDefine.PROTOCOL, config.getHttpAddr(), config.getHttpPort(), request);
String result = new RestSender().sendHttpRequest(url.toString(), "");
System.out.printf("%s%n", result);
} catch (Exception e) {
throw new SubCommandException(this.getClass().getSimpleName() + " command failed", e);
}
}
use of org.apache.rocketmq.connect.cli.utils.RestSender in project rocketmq-externals by apache.
the class CreateConnectorSubCommand method execute.
@Override
public void execute(CommandLine commandLine, Options options) throws SubCommandException {
try {
String connectorName = commandLine.getOptionValue('c').trim();
String request = "/connectors/" + connectorName + "?config=";
URL baseUrl = new URL(CLIConfigDefine.PROTOCOL, config.getHttpAddr(), config.getHttpPort(), request);
String filePath = commandLine.getOptionValue('p').trim();
String config = readFile(filePath);
String result = new RestSender().sendHttpRequest(baseUrl.toString(), config);
System.out.printf(result + "%n");
} catch (Exception e) {
throw new SubCommandException(this.getClass().getSimpleName() + " command failed", e);
}
}
use of org.apache.rocketmq.connect.cli.utils.RestSender in project rocketmq-externals by apache.
the class GetClusterInfoSubCommand method execute.
@Override
public void execute(CommandLine commandLine, Options options) throws SubCommandException {
try {
String request = "/" + commandName();
URL url = new URL(CLIConfigDefine.PROTOCOL, config.getHttpAddr(), config.getHttpPort(), request);
String result = new RestSender().sendHttpRequest(url.toString(), "");
System.out.printf("%s%n", result);
} catch (Exception e) {
throw new SubCommandException(this.getClass().getSimpleName() + " command failed", e);
}
}
use of org.apache.rocketmq.connect.cli.utils.RestSender in project rocketmq-externals by apache.
the class GetAllocatedConnectors method execute.
@Override
public void execute(CommandLine commandLine, Options options) throws SubCommandException {
try {
String request = "/getAllocatedConnectors";
URL url = new URL(CLIConfigDefine.PROTOCOL, config.getHttpAddr(), config.getHttpPort(), request);
String result = new RestSender().sendHttpRequest(url.toString(), "");
showConnectorInfo(result);
} catch (Exception e) {
throw new SubCommandException(this.getClass().getSimpleName() + " command failed", e);
}
}
Aggregations