@Ignore @Test public void testExecute() throws SubCommandException { UpdateKvConfigCommand cmd = new UpdateKvConfigCommand(); Options options = ServerUtil.buildCommandlineOptions(new Options()); String[] subargs = new String[]{"-s namespace", "-k topicname", "-v unit_test"}; final CommandLine commandLine = ServerUtil.parseCmdLine("mqadmin " + cmd.commandName() + cmd.commandDesc(), subargs, cmd.buildCommandlineOptions(options), new PosixParser()); cmd.execute(commandLine, options, null); }
@Override public void execute(CommandLine commandLine, Options options, RPCHook rpcHook) throws SubCommandException { DefaultMQAdminExt defaultMQAdminExt = new DefaultMQAdminExt(rpcHook); defaultMQAdminExt.setInstanceName(Long.toString(System.currentTimeMillis())); try { String namespace = commandLine.getOptionValue('s').trim(); String key = commandLine.getOptionValue('k').trim(); String value = commandLine.getOptionValue('v').trim(); defaultMQAdminExt.start(); defaultMQAdminExt.createAndUpdateKvConfig(namespace, key, value); System.out.printf("create or update kv config to namespace success.%n"); } catch (Exception e) { throw new SubCommandException(this.getClass().getSimpleName() + " command failed", e); } finally { defaultMQAdminExt.shutdown(); } }
UpdateKvConfigCommand implements SubCommand { @Override public void execute(CommandLine commandLine, Options options, RPCHook rpcHook) throws SubCommandException { DefaultMQAdminExt defaultMQAdminExt = new DefaultMQAdminExt(rpcHook); defaultMQAdminExt.setInstanceName(Long.toString(System.currentTimeMillis())); try { String namespace = commandLine.getOptionValue('s').trim(); String key = commandLine.getOptionValue('k').trim(); String value = commandLine.getOptionValue('v').trim(); defaultMQAdminExt.start(); defaultMQAdminExt.createAndUpdateKvConfig(namespace, key, value); System.out.printf("create or update kv config to namespace success.%n"); } catch (Exception e) { throw new SubCommandException(this.getClass().getSimpleName() + " command failed", e); } finally { defaultMQAdminExt.shutdown(); } } }
UpdateKvConfigCommand implements SubCommand { @Override public void execute(CommandLine commandLine, Options options, RPCHook rpcHook) throws SubCommandException { DefaultMQAdminExt defaultMQAdminExt = new DefaultMQAdminExt(rpcHook); defaultMQAdminExt.setInstanceName(Long.toString(System.currentTimeMillis())); try { String namespace = commandLine.getOptionValue('s').trim(); String key = commandLine.getOptionValue('k').trim(); String value = commandLine.getOptionValue('v').trim(); defaultMQAdminExt.start(); defaultMQAdminExt.createAndUpdateKvConfig(namespace, key, value); System.out.printf("create or update kv config to namespace success.%n"); } catch (Exception e) { throw new SubCommandException(this.getClass().getSimpleName() + " command failed", e); } finally { defaultMQAdminExt.shutdown(); } }  }
UpdateKvConfigCommand implements SubCommand { @Override public void execute(CommandLine commandLine, Options options, RPCHook rpcHook) throws SubCommandException { DefaultMQAdminExt defaultMQAdminExt = new DefaultMQAdminExt(rpcHook); defaultMQAdminExt.setInstanceName(Long.toString(System.currentTimeMillis())); try { String namespace = commandLine.getOptionValue('s').trim(); String key = commandLine.getOptionValue('k').trim(); String value = commandLine.getOptionValue('v').trim(); defaultMQAdminExt.start(); defaultMQAdminExt.createAndUpdateKvConfig(namespace, key, value); System.out.printf("create or update kv config to namespace success.%n"); } catch (Exception e) { throw new SubCommandException(this.getClass().getSimpleName() + " command failed", e); } finally { defaultMQAdminExt.shutdown(); } }  @Override String commandName(); @Override String commandDesc(); @Override Options buildCommandlineOptions(Options options); @Override void execute(CommandLine commandLine, Options options, RPCHook rpcHook); }
UpdateKvConfigCommand implements SubCommand { @Override public void execute(CommandLine commandLine, Options options, RPCHook rpcHook) throws SubCommandException { DefaultMQAdminExt defaultMQAdminExt = new DefaultMQAdminExt(rpcHook); defaultMQAdminExt.setInstanceName(Long.toString(System.currentTimeMillis())); try { String namespace = commandLine.getOptionValue('s').trim(); String key = commandLine.getOptionValue('k').trim(); String value = commandLine.getOptionValue('v').trim(); defaultMQAdminExt.start(); defaultMQAdminExt.createAndUpdateKvConfig(namespace, key, value); System.out.printf("create or update kv config to namespace success.%n"); } catch (Exception e) { throw new SubCommandException(this.getClass().getSimpleName() + " command failed", e); } finally { defaultMQAdminExt.shutdown(); } }  @Override String commandName(); @Override String commandDesc(); @Override Options buildCommandlineOptions(Options options); @Override void execute(CommandLine commandLine, Options options, RPCHook rpcHook);  }