Java Code Examples for com.alibaba.rocketmq.tools.admin.DefaultMQAdminExt#deleteKvConfig()

The following examples show how to use com.alibaba.rocketmq.tools.admin.DefaultMQAdminExt#deleteKvConfig() . 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: DeleteKvConfigCommand.java    From reading-and-annotate-rocketmq-3.4.6 with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void execute(CommandLine commandLine, Options options, RPCHook rpcHook) {
    DefaultMQAdminExt defaultMQAdminExt = new DefaultMQAdminExt(rpcHook);
    defaultMQAdminExt.setInstanceName(Long.toString(System.currentTimeMillis()));
    try {
        // namespace
        String namespace = commandLine.getOptionValue('s').trim();
        // key name
        String key = commandLine.getOptionValue('k').trim();

        defaultMQAdminExt.start();
        defaultMQAdminExt.deleteKvConfig(namespace, key);
        System.out.printf("delete kv config from namespace success.\n");
        return;
    }
    catch (Exception e) {
        e.printStackTrace();
    }
    finally {
        defaultMQAdminExt.shutdown();
    }
}
 
Example 2
Source File: NamesrvService.java    From rocketmq with Apache License 2.0 6 votes vote down vote up
@CmdTrace(cmdClazz = DeleteKvConfigCommand.class)
public boolean deleteKvConfig(String namespace, String key) throws Throwable {
    Throwable t = null;
    DefaultMQAdminExt defaultMQAdminExt = getDefaultMQAdminExt();
    try {
        defaultMQAdminExt.start();
        defaultMQAdminExt.deleteKvConfig(namespace, key);
        return true;
    }
    catch (Throwable e) {
        logger.error(e.getMessage(), e);
        t = e;
    }
    finally {
        shutdownDefaultMQAdminExt(defaultMQAdminExt);
    }
    throw t;
}
 
Example 3
Source File: DeleteKvConfigCommand.java    From rocketmq with Apache License 2.0 6 votes vote down vote up
@Override
public void execute(CommandLine commandLine, Options options, RPCHook rpcHook) {
    DefaultMQAdminExt defaultMQAdminExt = new DefaultMQAdminExt(rpcHook);
    defaultMQAdminExt.setInstanceName(Long.toString(System.currentTimeMillis()));
    try {
        // namespace
        String namespace = commandLine.getOptionValue('s').trim();
        // key name
        String key = commandLine.getOptionValue('k').trim();

        defaultMQAdminExt.start();
        defaultMQAdminExt.deleteKvConfig(namespace, key);
        System.out.printf("delete kv config from namespace success.%n");
        return;
    } catch (Exception e) {
        e.printStackTrace();
    } finally {
        defaultMQAdminExt.shutdown();
    }
}
 
Example 4
Source File: DeleteKvConfigCommand.java    From RocketMQ-Master-analyze with Apache License 2.0 6 votes vote down vote up
@Override
public void execute(CommandLine commandLine, Options options, RPCHook rpcHook) {
    DefaultMQAdminExt defaultMQAdminExt = new DefaultMQAdminExt(rpcHook);
    defaultMQAdminExt.setInstanceName(Long.toString(System.currentTimeMillis()));
    try {
        // namespace
        String namespace = commandLine.getOptionValue('s').trim();
        // key name
        String key = commandLine.getOptionValue('k').trim();

        defaultMQAdminExt.start();
        defaultMQAdminExt.deleteKvConfig(namespace, key);
        System.out.printf("delete kv config from namespace success.\n");
        return;
    }
    catch (Exception e) {
        e.printStackTrace();
    }
    finally {
        defaultMQAdminExt.shutdown();
    }
}
 
Example 5
Source File: NamesrvService.java    From rocketmq with Apache License 2.0 5 votes vote down vote up
@CmdTrace(cmdClazz = DeleteProjectGroupCommand.class)
public boolean deleteProjectGroup(String ip, String project) throws Throwable {
    Throwable t = null;
    DefaultMQAdminExt defaultMQAdminExt = getDefaultMQAdminExt();
    String namespace = NamesrvUtil.NAMESPACE_PROJECT_CONFIG;
    try {
        if (StringUtils.isNotBlank(ip)) {
            defaultMQAdminExt.start();
            defaultMQAdminExt.deleteKvConfig(namespace, ip);
            return true;
        }
        else if (StringUtils.isNotBlank(project)) {
            defaultMQAdminExt.start();
            defaultMQAdminExt.deleteIpsByProjectGroup(project);
            return true;
        }
        else {
            throw new IllegalStateException("project or ip can not be all blank!");
        }
    }
    catch (Throwable e) {
        logger.error(e.getMessage(), e);
        t = e;
    }
    finally {
        shutdownDefaultMQAdminExt(defaultMQAdminExt);
    }
    throw t;
}
 
Example 6
Source File: DeleteProjectGroupCommand.java    From RocketMQ-Master-analyze with Apache License 2.0 5 votes vote down vote up
@Override
public void execute(CommandLine commandLine, Options options, RPCHook rpcHook) {
    DefaultMQAdminExt defaultMQAdminExt = new DefaultMQAdminExt(rpcHook);
    defaultMQAdminExt.setInstanceName(Long.toString(System.currentTimeMillis()));
    try {
        String namespace = NamesrvUtil.NAMESPACE_PROJECT_CONFIG;

        if (commandLine.hasOption("i")) {
            String ip = commandLine.getOptionValue('i').trim();
            defaultMQAdminExt.start();
            defaultMQAdminExt.deleteKvConfig(namespace, ip);
            System.out.printf("delete project group from namespace by server ip success.\n");
        }
        else if (commandLine.hasOption("p")) {
            String project = commandLine.getOptionValue('p').trim();
            defaultMQAdminExt.start();
            defaultMQAdminExt.deleteIpsByProjectGroup(project);
            System.out.printf("delete all server ip from namespace by project group success.\n");
        }
        else {
            ServerUtil.printCommandLineHelp("mqadmin " + this.commandName(), options);
        }
    }
    catch (Exception e) {
        e.printStackTrace();
    }
    finally {
        defaultMQAdminExt.shutdown();
    }
}