Java Code Examples for org.apache.rocketmq.tools.admin.DefaultMQAdminExt#updateNameServerConfig()

The following examples show how to use org.apache.rocketmq.tools.admin.DefaultMQAdminExt#updateNameServerConfig() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: UpdateNamesrvConfigCommand.java    From DDMQ with Apache License 2.0 5 votes vote down vote up
@Override
public void execute(final CommandLine commandLine, final Options options,
    final RPCHook rpcHook) throws SubCommandException {
    DefaultMQAdminExt defaultMQAdminExt = new DefaultMQAdminExt(rpcHook);
    defaultMQAdminExt.setInstanceName(Long.toString(System.currentTimeMillis()));
    try {
        // key name
        String key = commandLine.getOptionValue('k').trim();
        // key name
        String value = commandLine.getOptionValue('v').trim();
        Properties properties = new Properties();
        properties.put(key, value);

        // servers
        String servers = commandLine.getOptionValue('n');
        List<String> serverList = null;
        if (servers != null && servers.length() > 0) {
            String[] serverArray = servers.trim().split(";");

            if (serverArray.length > 0) {
                serverList = Arrays.asList(serverArray);
            }
        }

        defaultMQAdminExt.start();

        defaultMQAdminExt.updateNameServerConfig(properties, serverList);

        System.out.printf("update name server config success!%s\n%s : %s\n",
            serverList == null ? "" : serverList, key, value);
    } catch (Exception e) {
        throw new SubCommandException(this.getClass().getSimpleName() + " command failed", e);
    } finally {
        defaultMQAdminExt.shutdown();
    }
}
 
Example 2
Source File: UpdateNamesrvConfigCommand.java    From rocketmq-4.3.0 with Apache License 2.0 5 votes vote down vote up
@Override
public void execute(final CommandLine commandLine, final Options options,
    final RPCHook rpcHook) throws SubCommandException {
    DefaultMQAdminExt defaultMQAdminExt = new DefaultMQAdminExt(rpcHook);
    defaultMQAdminExt.setInstanceName(Long.toString(System.currentTimeMillis()));
    try {
        // key name
        String key = commandLine.getOptionValue('k').trim();
        // key name
        String value = commandLine.getOptionValue('v').trim();
        Properties properties = new Properties();
        properties.put(key, value);

        // servers
        String servers = commandLine.getOptionValue('n');
        List<String> serverList = null;
        if (servers != null && servers.length() > 0) {
            String[] serverArray = servers.trim().split(";");

            if (serverArray.length > 0) {
                serverList = Arrays.asList(serverArray);
            }
        }

        defaultMQAdminExt.start();

        defaultMQAdminExt.updateNameServerConfig(properties, serverList);

        System.out.printf("update name server config success!%s\n%s : %s\n",
            serverList == null ? "" : serverList, key, value);
    } catch (Exception e) {
        throw new SubCommandException(this.getClass().getSimpleName() + " command failed", e);
    } finally {
        defaultMQAdminExt.shutdown();
    }
}
 
Example 3
Source File: UpdateNamesrvConfigCommand.java    From rocketmq-read with Apache License 2.0 5 votes vote down vote up
@Override
public void execute(final CommandLine commandLine, final Options options,
    final RPCHook rpcHook) throws SubCommandException {
    DefaultMQAdminExt defaultMQAdminExt = new DefaultMQAdminExt(rpcHook);
    defaultMQAdminExt.setInstanceName(Long.toString(System.currentTimeMillis()));
    try {
        // key name
        String key = commandLine.getOptionValue('k').trim();
        // key name
        String value = commandLine.getOptionValue('v').trim();
        Properties properties = new Properties();
        properties.put(key, value);

        // servers
        String servers = commandLine.getOptionValue('n');
        List<String> serverList = null;
        if (servers != null && servers.length() > 0) {
            String[] serverArray = servers.trim().split(";");

            if (serverArray.length > 0) {
                serverList = Arrays.asList(serverArray);
            }
        }

        defaultMQAdminExt.start();

        defaultMQAdminExt.updateNameServerConfig(properties, serverList);

        System.out.printf("update name server config success!%s\n%s : %s\n",
            serverList == null ? "" : serverList, key, value);
    } catch (Exception e) {
        throw new SubCommandException(this.getClass().getSimpleName() + " command failed", e);
    } finally {
        defaultMQAdminExt.shutdown();
    }
}
 
Example 4
Source File: UpdateNamesrvConfigCommand.java    From rocketmq with Apache License 2.0 5 votes vote down vote up
@Override
public void execute(final CommandLine commandLine, final Options options, final RPCHook rpcHook) {
    DefaultMQAdminExt defaultMQAdminExt = new DefaultMQAdminExt(rpcHook);
    defaultMQAdminExt.setInstanceName(Long.toString(System.currentTimeMillis()));
    try {
        // key name
        String key = commandLine.getOptionValue('k').trim();
        // key name
        String value = commandLine.getOptionValue('v').trim();
        Properties properties = new Properties();
        properties.put(key, value);

        // servers
        String servers = commandLine.getOptionValue('n');
        List<String> serverList = null;
        if (servers != null && servers.length() > 0) {
            String[] serverArray = servers.trim().split(";");

            if (serverArray.length > 0) {
                serverList = Arrays.asList(serverArray);
            }
        }

        defaultMQAdminExt.start();

        defaultMQAdminExt.updateNameServerConfig(properties, serverList);

        System.out.printf("update name server config success!%s\n%s : %s\n",
            serverList == null ? "" : serverList, key, value);
    } catch (Exception e) {
        e.printStackTrace();
    } finally {
        defaultMQAdminExt.shutdown();
    }
}
 
Example 5
Source File: UpdateNamesrvConfigCommand.java    From DDMQ with Apache License 2.0 5 votes vote down vote up
@Override
public void execute(final CommandLine commandLine, final Options options,
    final RPCHook rpcHook) throws SubCommandException {
    DefaultMQAdminExt defaultMQAdminExt = new DefaultMQAdminExt(rpcHook);
    defaultMQAdminExt.setInstanceName(Long.toString(System.currentTimeMillis()));
    try {
        // key name
        String key = commandLine.getOptionValue('k').trim();
        // key name
        String value = commandLine.getOptionValue('v').trim();
        Properties properties = new Properties();
        properties.put(key, value);

        // servers
        String servers = commandLine.getOptionValue('n');
        List<String> serverList = null;
        if (servers != null && servers.length() > 0) {
            String[] serverArray = servers.trim().split(";");

            if (serverArray.length > 0) {
                serverList = Arrays.asList(serverArray);
            }
        }

        defaultMQAdminExt.start();

        defaultMQAdminExt.updateNameServerConfig(properties, serverList);

        System.out.printf("update name server config success!%s\n%s : %s\n",
            serverList == null ? "" : serverList, key, value);
    } catch (Exception e) {
        throw new SubCommandException(this.getClass().getSimpleName() + " command failed", e);
    } finally {
        defaultMQAdminExt.shutdown();
    }
}
 
Example 6
Source File: UpdateNamesrvConfigCommand.java    From rocketmq-all-4.1.0-incubating with Apache License 2.0 5 votes vote down vote up
@Override
public void execute(final CommandLine commandLine, final Options options, final RPCHook rpcHook) throws SubCommandException {
    DefaultMQAdminExt defaultMQAdminExt = new DefaultMQAdminExt(rpcHook);
    defaultMQAdminExt.setInstanceName(Long.toString(System.currentTimeMillis()));
    try {
        // key name
        String key = commandLine.getOptionValue('k').trim();
        // key name
        String value = commandLine.getOptionValue('v').trim();
        Properties properties = new Properties();
        properties.put(key, value);

        // servers
        String servers = commandLine.getOptionValue('n');
        List<String> serverList = null;
        if (servers != null && servers.length() > 0) {
            String[] serverArray = servers.trim().split(";");

            if (serverArray.length > 0) {
                serverList = Arrays.asList(serverArray);
            }
        }

        defaultMQAdminExt.start();

        defaultMQAdminExt.updateNameServerConfig(properties, serverList);

        System.out.printf("update name server config success!%s\n%s : %s\n",
            serverList == null ? "" : serverList, key, value);
    } catch (Exception e) {
        throw new SubCommandException(this.getClass().getSimpleName() + " command failed", e);
    } finally {
        defaultMQAdminExt.shutdown();
    }
}
 
Example 7
Source File: UpdateNamesrvConfigCommand.java    From rocketmq_trans_message with Apache License 2.0 5 votes vote down vote up
@Override
public void execute(final CommandLine commandLine, final Options options, final RPCHook rpcHook) {
    DefaultMQAdminExt defaultMQAdminExt = new DefaultMQAdminExt(rpcHook);
    defaultMQAdminExt.setInstanceName(Long.toString(System.currentTimeMillis()));
    try {
        // key name
        String key = commandLine.getOptionValue('k').trim();
        // key name
        String value = commandLine.getOptionValue('v').trim();
        Properties properties = new Properties();
        properties.put(key, value);

        // servers
        String servers = commandLine.getOptionValue('n');
        List<String> serverList = null;
        if (servers != null && servers.length() > 0) {
            String[] serverArray = servers.trim().split(";");

            if (serverArray.length > 0) {
                serverList = Arrays.asList(serverArray);
            }
        }

        defaultMQAdminExt.start();

        defaultMQAdminExt.updateNameServerConfig(properties, serverList);

        System.out.printf("update name server config success!%s\n%s : %s\n",
            serverList == null ? "" : serverList, key, value);
    } catch (Exception e) {
        e.printStackTrace();
    } finally {
        defaultMQAdminExt.shutdown();
    }
}
 
Example 8
Source File: UpdateNamesrvConfigCommand.java    From rocketmq with Apache License 2.0 5 votes vote down vote up
@Override
public void execute(final CommandLine commandLine, final Options options,
    final RPCHook rpcHook) throws SubCommandException {
    DefaultMQAdminExt defaultMQAdminExt = new DefaultMQAdminExt(rpcHook);
    defaultMQAdminExt.setInstanceName(Long.toString(System.currentTimeMillis()));
    try {
        // key name
        String key = commandLine.getOptionValue('k').trim();
        // key name
        String value = commandLine.getOptionValue('v').trim();
        Properties properties = new Properties();
        properties.put(key, value);

        // servers
        String servers = commandLine.getOptionValue('n');
        List<String> serverList = null;
        if (servers != null && servers.length() > 0) {
            String[] serverArray = servers.trim().split(";");

            if (serverArray.length > 0) {
                serverList = Arrays.asList(serverArray);
            }
        }

        defaultMQAdminExt.start();

        defaultMQAdminExt.updateNameServerConfig(properties, serverList);

        System.out.printf("update name server config success!%s\n%s : %s\n",
            serverList == null ? "" : serverList, key, value);
    } catch (Exception e) {
        throw new SubCommandException(this.getClass().getSimpleName() + " command failed", e);
    } finally {
        defaultMQAdminExt.shutdown();
    }
}