Java Code Examples for com.alibaba.rocketmq.common.UtilAll#timeMillisToHumanString2()
The following examples show how to use
com.alibaba.rocketmq.common.UtilAll#timeMillisToHumanString2() .
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: 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 2
Source File: TopicService.java From rocketmq with Apache License 2.0 | 4 votes |
@CmdTrace(cmdClazz = TopicStatusSubCommand.class) public Table stats(String topicName) throws Throwable { Throwable t = null; DefaultMQAdminExt defaultMQAdminExt = getDefaultMQAdminExt(); try { defaultMQAdminExt.start(); TopicStatsTable topicStatsTable = defaultMQAdminExt.examineTopicStats(topicName); 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" // // ); String[] thead = new String[] { "#Broker Name", "#QID", "#Min Offset", "#Max Offset", "#Last Updated" }; Table table = new Table(thead, mqList.size()); for (MessageQueue mq : mqList) { TopicOffset topicOffset = topicStatsTable.getOffsetTable().get(mq); String humanTimestamp = ""; if (topicOffset.getLastUpdateTimestamp() > 0) { humanTimestamp = UtilAll.timeMillisToHumanString2(topicOffset.getLastUpdateTimestamp()); } Object[] tr = table.createTR(); tr[0] = UtilAll.frontStringAtLeast(mq.getBrokerName(), 32); tr[1] = str(mq.getQueueId()); tr[2] = str(topicOffset.getMinOffset()); tr[3] = str(topicOffset.getMaxOffset()); tr[4] = humanTimestamp; table.insertTR(tr); // System.out.printf("%-32s %-4d %-20d %-20d %s\n",// // UtilAll.frontStringAtLeast(mq.getBrokerName(), 32),// // mq.getQueueId(),// // topicOffset.getMinOffset(),// // topicOffset.getMaxOffset(),// // humanTimestamp // // ); } return table; } catch (Throwable e) { logger.error(e.getMessage(), e); t = e; } finally { shutdownDefaultMQAdminExt(defaultMQAdminExt); } throw t; }
Example 3
Source File: TopicStatusSubCommand.java From rocketmq with Apache License 2.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 4
Source File: TopicStatusSubCommand.java From RocketMQ-Master-analyze with Apache License 2.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(); } }