Java Code Examples for com.alibaba.rocketmq.tools.admin.DefaultMQAdminExt#examineTopicRouteInfo()
The following examples show how to use
com.alibaba.rocketmq.tools.admin.DefaultMQAdminExt#examineTopicRouteInfo() .
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: TopicRouteSubCommand.java From reading-and-annotate-rocketmq-3.4.6 with GNU General Public License v3.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 2
Source File: TopicListSubCommand.java From reading-and-annotate-rocketmq-3.4.6 with GNU General Public License v3.0 | 6 votes |
private String findTopicBelongToWhichCluster(final String topic, final ClusterInfo clusterInfo, final DefaultMQAdminExt defaultMQAdminExt) throws RemotingException, MQClientException, InterruptedException { TopicRouteData topicRouteData = defaultMQAdminExt.examineTopicRouteInfo(topic); BrokerData brokerData = topicRouteData.getBrokerDatas().get(0); String brokerName = brokerData.getBrokerName(); Iterator<Entry<String, Set<String>>> it = clusterInfo.getClusterAddrTable().entrySet().iterator(); while (it.hasNext()) { Entry<String, Set<String>> next = it.next(); if (next.getValue().contains(brokerName)) { return next.getKey(); } } return null; }
Example 3
Source File: TopicService.java From rocketmq with Apache License 2.0 | 6 votes |
@CmdTrace(cmdClazz = TopicRouteSubCommand.class) public TopicRouteData route(String topicName) throws Throwable { Throwable t = null; DefaultMQAdminExt adminExt = getDefaultMQAdminExt(); try { adminExt.start(); TopicRouteData topicRouteData = adminExt.examineTopicRouteInfo(topicName); return topicRouteData; } catch (Throwable e) { logger.error(e.getMessage(), e); t = e; } finally { shutdownDefaultMQAdminExt(adminExt); } throw t; }
Example 4
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 5
Source File: TopicListSubCommand.java From rocketmq with Apache License 2.0 | 6 votes |
private String findTopicBelongToWhichCluster(final String topic, final ClusterInfo clusterInfo, final DefaultMQAdminExt defaultMQAdminExt) throws RemotingException, MQClientException, InterruptedException { TopicRouteData topicRouteData = defaultMQAdminExt.examineTopicRouteInfo(topic); BrokerData brokerData = topicRouteData.getBrokerDatas().get(0); String brokerName = brokerData.getBrokerName(); Iterator<Entry<String, Set<String>>> it = clusterInfo.getClusterAddrTable().entrySet().iterator(); while (it.hasNext()) { Entry<String, Set<String>> next = it.next(); if (next.getValue().contains(brokerName)) { return next.getKey(); } } return null; }
Example 6
Source File: TopicRouteSubCommand.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(); 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 7
Source File: TopicListSubCommand.java From RocketMQ-Master-analyze with Apache License 2.0 | 6 votes |
private String findTopicBelongToWhichCluster(final String topic, final ClusterInfo clusterInfo, final DefaultMQAdminExt defaultMQAdminExt) throws RemotingException, MQClientException, InterruptedException { TopicRouteData topicRouteData = defaultMQAdminExt.examineTopicRouteInfo(topic); BrokerData brokerData = topicRouteData.getBrokerDatas().get(0); String brokerName = brokerData.getBrokerName(); Iterator<Entry<String, Set<String>>> it = clusterInfo.getClusterAddrTable().entrySet().iterator(); while (it.hasNext()) { Entry<String, Set<String>> next = it.next(); if (next.getValue().contains(brokerName)) { return next.getKey(); } } return null; }
Example 8
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 9
Source File: CloneGroupOffsetCommand.java From rocketmq with Apache License 2.0 | 5 votes |
@Override public void execute(CommandLine commandLine, Options options, RPCHook rpcHook) { String srcGroup = commandLine.getOptionValue("s").trim(); String destGroup = commandLine.getOptionValue("d").trim(); String topic = commandLine.getOptionValue("t").trim(); DefaultMQAdminExt defaultMQAdminExt = new DefaultMQAdminExt(rpcHook); defaultMQAdminExt.setInstanceName("admin-" + Long.toString(System.currentTimeMillis())); try { defaultMQAdminExt.start(); ConsumeStats consumeStats = defaultMQAdminExt.examineConsumeStats(srcGroup); Set<MessageQueue> mqs = consumeStats.getOffsetTable().keySet(); if (mqs != null && !mqs.isEmpty()) { TopicRouteData topicRoute = defaultMQAdminExt.examineTopicRouteInfo(topic); for (MessageQueue mq : mqs) { String addr = null; for (BrokerData brokerData : topicRoute.getBrokerDatas()) { if (brokerData.getBrokerName().equals(mq.getBrokerName())) { addr = brokerData.selectBrokerAddr(); break; } } long offset = consumeStats.getOffsetTable().get(mq).getBrokerOffset(); if (offset >= 0) { defaultMQAdminExt.updateConsumeOffset(addr, destGroup, mq, offset); } } } 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 10
Source File: AllocateMQSubCommand.java From rocketmq with Apache License 2.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(); } }