Java Code Examples for com.alibaba.rocketmq.tools.admin.DefaultMQAdminExt#shutdown()
The following examples show how to use
com.alibaba.rocketmq.tools.admin.DefaultMQAdminExt#shutdown() .
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: UpdateProjectGroupCommand.java From RocketMQ-Master-analyze with Apache License 2.0 | 6 votes |
@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; String ip = commandLine.getOptionValue('i').trim(); String project = commandLine.getOptionValue('p').trim(); defaultMQAdminExt.start(); defaultMQAdminExt.createAndUpdateKvConfig(namespace, ip, project); System.out.printf("create or update kv config to namespace success.\n"); return; } catch (Exception e) { e.printStackTrace(); } finally { defaultMQAdminExt.shutdown(); } }
Example 2
Source File: TopicRouteSubCommand.java From rocketmq with Apache License 2.0 | 6 votes |
@Override public void execute(final CommandLine commandLine, final Options options, RPCHook rpcHook) { DefaultMQAdminExt defaultMQAdminExt = new DefaultMQAdminExt(rpcHook); defaultMQAdminExt.setInstanceName(Long.toString(System.currentTimeMillis())); try { defaultMQAdminExt.start(); String topic = commandLine.getOptionValue('t').trim(); TopicRouteData topicRouteData = defaultMQAdminExt.examineTopicRouteInfo(topic); String json = topicRouteData.toJson(true); System.out.println(json); } catch (Exception e) { e.printStackTrace(); } finally { defaultMQAdminExt.shutdown(); } }
Example 3
Source File: QueryMsgByIdSubCommand.java From rocketmq with Apache License 2.0 | 6 votes |
@Override public void execute(CommandLine commandLine, Options options, RPCHook rpcHook) { DefaultMQAdminExt defaultMQAdminExt = new DefaultMQAdminExt(rpcHook); defaultMQAdminExt.setInstanceName(Long.toString(System.currentTimeMillis())); try { defaultMQAdminExt.start(); final String msgId = commandLine.getOptionValue('i').trim(); if (commandLine.hasOption('g') && commandLine.hasOption('d')) { final String consumerGroup = commandLine.getOptionValue('g').trim(); final String clientId = commandLine.getOptionValue('d').trim(); ConsumeMessageDirectlyResult result = defaultMQAdminExt.consumeMessageDirectly(consumerGroup, clientId, msgId); System.out.println(result); } else { queryById(defaultMQAdminExt, msgId); } } catch (Exception e) { e.printStackTrace(); } finally { defaultMQAdminExt.shutdown(); } }
Example 4
Source File: DeleteTopicSubCommand.java From rocketmq with Apache License 2.0 | 6 votes |
@Override public void execute(CommandLine commandLine, Options options, RPCHook rpcHook) { DefaultMQAdminExt adminExt = new DefaultMQAdminExt(rpcHook); adminExt.setInstanceName(Long.toString(System.currentTimeMillis())); try { String topic = commandLine.getOptionValue('t').trim(); if (commandLine.hasOption('c')) { String clusterName = commandLine.getOptionValue('c').trim(); adminExt.start(); deleteTopic(adminExt, clusterName, topic); return; } ServerUtil.printCommandLineHelp("mqadmin " + this.commandName(), options); } catch (Exception e) { e.printStackTrace(); } finally { adminExt.shutdown(); } }
Example 5
Source File: ClusterListSubCommand.java From RocketMQ-Master-analyze with Apache License 2.0 | 6 votes |
@Override public void execute(final CommandLine commandLine, final Options options, RPCHook rpcHook) { DefaultMQAdminExt defaultMQAdminExt = new DefaultMQAdminExt(rpcHook); defaultMQAdminExt.setInstanceName(Long.toString(System.currentTimeMillis())); try { defaultMQAdminExt.start(); if (commandLine.hasOption('m')) { this.printClusterMoreStats(defaultMQAdminExt); } else { this.printClusterBaseInfo(defaultMQAdminExt); } } catch (Exception e) { e.printStackTrace(); } finally { defaultMQAdminExt.shutdown(); } }
Example 6
Source File: QueryMsgByIdSubCommand.java From RocketMQ-Master-analyze with Apache License 2.0 | 5 votes |
@Override public void execute(CommandLine commandLine, Options options, RPCHook rpcHook) { DefaultMQAdminExt defaultMQAdminExt = new DefaultMQAdminExt(rpcHook); defaultMQAdminExt.setInstanceName(Long.toString(System.currentTimeMillis())); try { defaultMQAdminExt.start(); final String msgId = commandLine.getOptionValue('i').trim(); if (commandLine.hasOption('g') && commandLine.hasOption('d')) { final String consumerGroup = commandLine.getOptionValue('g').trim(); final String clientId = commandLine.getOptionValue('d').trim(); ConsumeMessageDirectlyResult result = defaultMQAdminExt.consumeMessageDirectly(consumerGroup, clientId, msgId); System.out.println(result); } else { queryById(defaultMQAdminExt, msgId); } } catch (Exception e) { e.printStackTrace(); } finally { defaultMQAdminExt.shutdown(); } }
Example 7
Source File: AllocateMQSubCommand.java From reading-and-annotate-rocketmq-3.4.6 with GNU General Public License v3.0 | 5 votes |
@Override public void execute(CommandLine commandLine, Options options, RPCHook rpcHook) { DefaultMQAdminExt adminExt = new DefaultMQAdminExt(rpcHook); adminExt.setInstanceName(Long.toString(System.currentTimeMillis())); try { adminExt.start(); String topic = commandLine.getOptionValue('t').trim(); String ips = commandLine.getOptionValue('i').trim(); final String[] split = ips.split(","); final List<String> ipList = new LinkedList<String>(); for (String ip : split) { ipList.add(ip); } final TopicRouteData topicRouteData = adminExt.examineTopicRouteInfo(topic); final Set<MessageQueue> mqs = MQClientInstance.topicRouteData2TopicSubscribeInfo(topic, topicRouteData); final AllocateMessageQueueAveragely averagely = new AllocateMessageQueueAveragely(); RebalanceResult rr = new RebalanceResult(); for (String i : ipList) { final List<MessageQueue> mqResult = averagely.allocate("aa", i, new ArrayList<MessageQueue>(mqs), ipList); rr.getResult().put(i, mqResult); } final String json = RemotingSerializable.toJson(rr, false); System.out.println(json); } catch (Exception e) { e.printStackTrace(); } finally { adminExt.shutdown(); } }
Example 8
Source File: ProducerConnectionSubCommand.java From RocketMQ-Master-analyze with Apache License 2.0 | 5 votes |
@Override public void execute(CommandLine commandLine, Options options, RPCHook rpcHook) { DefaultMQAdminExt defaultMQAdminExt = new DefaultMQAdminExt(rpcHook); defaultMQAdminExt.setInstanceName(Long.toString(System.currentTimeMillis())); try { defaultMQAdminExt.start(); String group = commandLine.getOptionValue('g').trim(); String topic = commandLine.getOptionValue('t').trim(); ProducerConnection pc = defaultMQAdminExt.examineProducerConnectionInfo(group, topic); int i = 1; for (Connection conn : pc.getConnectionSet()) { System.out.printf("%04d %-32s %-22s %-8s %s\n", // i++, // conn.getClientId(), // conn.getClientAddr(), // conn.getLanguage(), // MQVersion.getVersionDesc(conn.getVersion())// ); } } catch (Exception e) { e.printStackTrace(); } finally { defaultMQAdminExt.shutdown(); } }
Example 9
Source File: ClusterListSubCommand.java From reading-and-annotate-rocketmq-3.4.6 with GNU General Public License v3.0 | 5 votes |
@Override public void execute(final CommandLine commandLine, final Options options, RPCHook rpcHook) { DefaultMQAdminExt defaultMQAdminExt = new DefaultMQAdminExt(rpcHook); defaultMQAdminExt.setInstanceName(Long.toString(System.currentTimeMillis())); long printInterval = 1; boolean enableInterval = commandLine.hasOption('i'); if (enableInterval) { printInterval = Long.parseLong(commandLine.getOptionValue('i')) * 1000; } try { defaultMQAdminExt.start(); do { if (commandLine.hasOption('m')) { this.printClusterMoreStats(defaultMQAdminExt); } else { this.printClusterBaseInfo(defaultMQAdminExt); } Thread.sleep(printInterval); System.out.println(""); } while (enableInterval); } catch (Exception e) { e.printStackTrace(); } finally { defaultMQAdminExt.shutdown(); } }
Example 10
Source File: QueryMsgByUniqueKeySubCommand.java From rocketmq with Apache License 2.0 | 5 votes |
@Override public void execute(CommandLine commandLine, Options options, RPCHook rpcHook) { DefaultMQAdminExt defaultMQAdminExt = new DefaultMQAdminExt(rpcHook); defaultMQAdminExt.setInstanceName(Long.toString(System.currentTimeMillis())); try { defaultMQAdminExt.start(); final String msgId = commandLine.getOptionValue('i').trim(); final String topic = commandLine.getOptionValue('t').trim(); if (commandLine.hasOption('g') && commandLine.hasOption('d')) { final String consumerGroup = commandLine.getOptionValue('g').trim(); final String clientId = commandLine.getOptionValue('d').trim(); ConsumeMessageDirectlyResult result = defaultMQAdminExt.consumeMessageDirectly(consumerGroup, clientId, topic,msgId); System.out.println(result); } else { queryById(defaultMQAdminExt,topic, msgId); } } catch (Exception e) { e.printStackTrace(); } finally { defaultMQAdminExt.shutdown(); } }
Example 11
Source File: ClusterListSubCommand.java From rocketmq with Apache License 2.0 | 5 votes |
@Override public void execute(final CommandLine commandLine, final Options options, RPCHook rpcHook) { DefaultMQAdminExt defaultMQAdminExt = new DefaultMQAdminExt(rpcHook); defaultMQAdminExt.setInstanceName(Long.toString(System.currentTimeMillis())); long printInterval = 1; boolean enableInterval = commandLine.hasOption('i'); if (enableInterval) { printInterval = Long.parseLong(commandLine.getOptionValue('i')) * 1000; } try { defaultMQAdminExt.start(); do { if (commandLine.hasOption('m')) { this.printClusterMoreStats(defaultMQAdminExt); } else { this.printClusterBaseInfo(defaultMQAdminExt); } Thread.sleep(printInterval); System.out.println(""); } while (enableInterval); } catch (Exception e) { e.printStackTrace(); } finally { defaultMQAdminExt.shutdown(); } }
Example 12
Source File: CleanUnusedTopicCommand.java From reading-and-annotate-rocketmq-3.4.6 with GNU General Public License v3.0 | 5 votes |
@Override public void execute(CommandLine commandLine, Options options, RPCHook rpcHook) { DefaultMQAdminExt defaultMQAdminExt = new DefaultMQAdminExt(rpcHook); defaultMQAdminExt.setInstanceName(Long.toString(System.currentTimeMillis())); try { boolean result = false; defaultMQAdminExt.start(); if (commandLine.hasOption('b')) { String addr = commandLine.getOptionValue('b').trim(); result = defaultMQAdminExt.cleanUnusedTopicByAddr(addr); } else { String cluster = commandLine.getOptionValue('c'); if (null != cluster) cluster = cluster.trim(); result = defaultMQAdminExt.cleanUnusedTopicByAddr(cluster); } System.out.println(result ? "success" : "false"); } catch (Exception e) { e.printStackTrace(); } finally { defaultMQAdminExt.shutdown(); } }
Example 13
Source File: DeleteProjectGroupCommand.java From RocketMQ-Master-analyze with Apache License 2.0 | 5 votes |
@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(); } }
Example 14
Source File: ProducerConnectionSubCommand.java From rocketmq with Apache License 2.0 | 5 votes |
@Override public void execute(CommandLine commandLine, Options options, RPCHook rpcHook) { DefaultMQAdminExt defaultMQAdminExt = new DefaultMQAdminExt(rpcHook); defaultMQAdminExt.setInstanceName(Long.toString(System.currentTimeMillis())); try { defaultMQAdminExt.start(); String group = commandLine.getOptionValue('g').trim(); String topic = commandLine.getOptionValue('t').trim(); ProducerConnection pc = defaultMQAdminExt.examineProducerConnectionInfo(group, topic); int i = 1; for (Connection conn : pc.getConnectionSet()) { System.out.printf("%04d %-32s %-22s %-8s %s%n",// i++,// conn.getClientId(),// conn.getClientAddr(),// conn.getLanguage(),// MQVersion.getVersionDesc(conn.getVersion())// ); } } catch (Exception e) { e.printStackTrace(); } finally { defaultMQAdminExt.shutdown(); } }
Example 15
Source File: CloneGroupOffsetCommand.java From reading-and-annotate-rocketmq-3.4.6 with GNU General Public License v3.0 | 5 votes |
@Override public void execute(CommandLine commandLine, Options options, RPCHook rpcHook) { DefaultMQAdminExt defaultMQAdminExt = new DefaultMQAdminExt(rpcHook); defaultMQAdminExt.setInstanceName(Long.toString(System.currentTimeMillis())); try { String srcGroup = commandLine.getOptionValue("s").trim(); String destGroup = commandLine.getOptionValue("d").trim(); String topic = ""; if (commandLine.hasOption('t')) { topic = commandLine.getOptionValue("t").trim(); } boolean isOffline = false; if (commandLine.hasOption('o')) { isOffline = Boolean.parseBoolean(commandLine.getOptionValue("o").trim()); } defaultMQAdminExt.start(); defaultMQAdminExt.cloneGroupOffset(srcGroup, destGroup, topic, isOffline); System.out.printf("clone group offset success. srcGroup[%s], destGroup=[%s], topic[%s]", srcGroup, destGroup, topic); } catch (Exception e) { e.printStackTrace(); } finally { defaultMQAdminExt.shutdown(); } }
Example 16
Source File: QueryMsgByIdSubCommand.java From reading-and-annotate-rocketmq-3.4.6 with GNU General Public License v3.0 | 5 votes |
@Override public void execute(CommandLine commandLine, Options options, RPCHook rpcHook) { DefaultMQAdminExt defaultMQAdminExt = new DefaultMQAdminExt(rpcHook); defaultMQAdminExt.setInstanceName(Long.toString(System.currentTimeMillis())); try { defaultMQAdminExt.start(); final String msgId = commandLine.getOptionValue('i').trim(); if (commandLine.hasOption('g') && commandLine.hasOption('d')) { final String consumerGroup = commandLine.getOptionValue('g').trim(); final String clientId = commandLine.getOptionValue('d').trim(); ConsumeMessageDirectlyResult result = defaultMQAdminExt.consumeMessageDirectly(consumerGroup, clientId, msgId); System.out.println(result); } else { queryById(defaultMQAdminExt, msgId); } } catch (Exception e) { e.printStackTrace(); } finally { defaultMQAdminExt.shutdown(); } }
Example 17
Source File: QueryMsgByOffsetSubCommand.java From RocketMQ-Master-analyze with Apache License 2.0 | 4 votes |
@Override public void execute(CommandLine commandLine, Options options, RPCHook rpcHook) { DefaultMQAdminExt defaultMQAdminExt = new DefaultMQAdminExt(rpcHook); DefaultMQPullConsumer defaultMQPullConsumer = new DefaultMQPullConsumer(MixAll.TOOLS_CONSUMER_GROUP); defaultMQAdminExt.setInstanceName(Long.toString(System.currentTimeMillis())); defaultMQPullConsumer.setInstanceName(Long.toString(System.currentTimeMillis())); try { String topic = commandLine.getOptionValue('t').trim(); String brokerName = commandLine.getOptionValue('b').trim(); String queueId = commandLine.getOptionValue('i').trim(); String offset = commandLine.getOptionValue('o').trim(); MessageQueue mq = new MessageQueue(); mq.setTopic(topic); mq.setBrokerName(brokerName); mq.setQueueId(Integer.parseInt(queueId)); defaultMQPullConsumer.start(); defaultMQAdminExt.start(); PullResult pullResult = defaultMQPullConsumer.pull(mq, "*", Long.parseLong(offset), 1); if (pullResult != null) { switch (pullResult.getPullStatus()) { case FOUND: QueryMsgByIdSubCommand.queryById(defaultMQAdminExt, pullResult.getMsgFoundList().get(0).getMsgId()); break; case NO_MATCHED_MSG: case NO_NEW_MSG: case OFFSET_ILLEGAL: default: break; } } } catch (Exception e) { e.printStackTrace(); } finally { defaultMQPullConsumer.shutdown(); defaultMQAdminExt.shutdown(); } }
Example 18
Source File: TopicStatusSubCommand.java From reading-and-annotate-rocketmq-3.4.6 with GNU General Public License v3.0 | 4 votes |
@Override public void execute(final CommandLine commandLine, final Options options, RPCHook rpcHook) { DefaultMQAdminExt defaultMQAdminExt = new DefaultMQAdminExt(rpcHook); defaultMQAdminExt.setInstanceName(Long.toString(System.currentTimeMillis())); try { defaultMQAdminExt.start(); String topic = commandLine.getOptionValue('t').trim(); TopicStatsTable topicStatsTable = defaultMQAdminExt.examineTopicStats(topic); List<MessageQueue> mqList = new LinkedList<MessageQueue>(); mqList.addAll(topicStatsTable.getOffsetTable().keySet()); Collections.sort(mqList); System.out.printf("%-32s %-4s %-20s %-20s %s\n",// "#Broker Name",// "#QID",// "#Min Offset",// "#Max Offset",// "#Last Updated" // ); for (MessageQueue mq : mqList) { TopicOffset topicOffset = topicStatsTable.getOffsetTable().get(mq); String humanTimestamp = ""; if (topicOffset.getLastUpdateTimestamp() > 0) { humanTimestamp = UtilAll.timeMillisToHumanString2(topicOffset.getLastUpdateTimestamp()); } System.out.printf("%-32s %-4d %-20d %-20d %s\n",// UtilAll.frontStringAtLeast(mq.getBrokerName(), 32),// mq.getQueueId(),// topicOffset.getMinOffset(),// topicOffset.getMaxOffset(),// humanTimestamp // ); } } catch (Exception e) { e.printStackTrace(); } finally { defaultMQAdminExt.shutdown(); } }
Example 19
Source File: ConsumerConnectionSubCommand.java From RocketMQ-Master-analyze with Apache License 2.0 | 4 votes |
@Override public void execute(CommandLine commandLine, Options options, RPCHook rpcHook) { DefaultMQAdminExt defaultMQAdminExt = new DefaultMQAdminExt(rpcHook); defaultMQAdminExt.setInstanceName(Long.toString(System.currentTimeMillis())); try { defaultMQAdminExt.start(); String group = commandLine.getOptionValue('g').trim(); ConsumerConnection cc = defaultMQAdminExt.examineConsumerConnectionInfo(group); // 打印连接 int i = 1; for (Connection conn : cc.getConnectionSet()) { System.out.printf("%03d %-32s %-22s %-8s %s\n", // i++, // conn.getClientId(), // conn.getClientAddr(), // conn.getLanguage(), // MQVersion.getVersionDesc(conn.getVersion())// ); } // 打印订阅关系 System.out.println("\nBelow is subscription:"); Iterator<Entry<String, SubscriptionData>> it = cc.getSubscriptionTable().entrySet().iterator(); i = 1; while (it.hasNext()) { Entry<String, SubscriptionData> entry = it.next(); SubscriptionData sd = entry.getValue(); System.out.printf("%03d Topic: %-40s SubExpression: %s\n", // i++, // sd.getTopic(), // sd.getSubString()// ); } // 打印其他订阅参数 System.out.println(""); System.out.printf("ConsumeType: %s\n", cc.getConsumeType()); System.out.printf("MessageModel: %s\n", cc.getMessageModel()); System.out.printf("ConsumeFromWhere: %s\n", cc.getConsumeFromWhere()); } catch (Exception e) { e.printStackTrace(); } finally { defaultMQAdminExt.shutdown(); } }
Example 20
Source File: AbstractService.java From rocketmq with Apache License 2.0 | 4 votes |
protected void shutdownDefaultMQAdminExt(DefaultMQAdminExt defaultMQAdminExt) { defaultMQAdminExt.shutdown(); }