Search in sources :

Example 6 with RestSender

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);
    }
}
Also used : SubCommandException(org.apache.rocketmq.tools.command.SubCommandException) RestSender(org.apache.rocketmq.connect.cli.utils.RestSender) URL(java.net.URL) SubCommandException(org.apache.rocketmq.tools.command.SubCommandException)

Example 7 with RestSender

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);
    }
}
Also used : SubCommandException(org.apache.rocketmq.tools.command.SubCommandException) RestSender(org.apache.rocketmq.connect.cli.utils.RestSender) URL(java.net.URL) SubCommandException(org.apache.rocketmq.tools.command.SubCommandException)

Example 8 with RestSender

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);
    }
}
Also used : SubCommandException(org.apache.rocketmq.tools.command.SubCommandException) RestSender(org.apache.rocketmq.connect.cli.utils.RestSender) URL(java.net.URL) IOException(java.io.IOException) SubCommandException(org.apache.rocketmq.tools.command.SubCommandException)

Example 9 with RestSender

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);
    }
}
Also used : SubCommandException(org.apache.rocketmq.tools.command.SubCommandException) RestSender(org.apache.rocketmq.connect.cli.utils.RestSender) URL(java.net.URL) SubCommandException(org.apache.rocketmq.tools.command.SubCommandException)

Example 10 with RestSender

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);
    }
}
Also used : SubCommandException(org.apache.rocketmq.tools.command.SubCommandException) RestSender(org.apache.rocketmq.connect.cli.utils.RestSender) URL(java.net.URL) SubCommandException(org.apache.rocketmq.tools.command.SubCommandException)

Aggregations

URL (java.net.URL)11 RestSender (org.apache.rocketmq.connect.cli.utils.RestSender)11 SubCommandException (org.apache.rocketmq.tools.command.SubCommandException)11 IOException (java.io.IOException)1