org.apache.rocketmq.common.protocol.body.ConsumeStatus Java Examples
The following examples show how to use
org.apache.rocketmq.common.protocol.body.ConsumeStatus.
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: DefaultMonitorListenerTest.java From rocketmq-read with Apache License 2.0 | 5 votes |
@Test public void testReportConsumerRunningInfo() { TreeMap<String, ConsumerRunningInfo> criTable = new TreeMap<>(); ConsumerRunningInfo consumerRunningInfo = new ConsumerRunningInfo(); consumerRunningInfo.setSubscriptionSet(new TreeSet<SubscriptionData>()); consumerRunningInfo.setStatusTable(new TreeMap<String, ConsumeStatus>()); consumerRunningInfo.setSubscriptionSet(new TreeSet<SubscriptionData>()); consumerRunningInfo.setMqTable(new TreeMap<MessageQueue, ProcessQueueInfo>()); consumerRunningInfo.setProperties(new Properties()); criTable.put("test", consumerRunningInfo); defaultMonitorListener.reportConsumerRunningInfo(criTable); }
Example #2
Source File: DefaultMQPushConsumerImpl.java From rocketmq-all-4.1.0-incubating with Apache License 2.0 | 5 votes |
@Override public ConsumerRunningInfo consumerRunningInfo() { ConsumerRunningInfo info = new ConsumerRunningInfo(); Properties prop = MixAll.object2Properties(this.defaultMQPushConsumer); prop.put(ConsumerRunningInfo.PROP_CONSUME_ORDERLY, String.valueOf(this.consumeOrderly)); prop.put(ConsumerRunningInfo.PROP_THREADPOOL_CORE_SIZE, String.valueOf(this.consumeMessageService.getCorePoolSize())); prop.put(ConsumerRunningInfo.PROP_CONSUMER_START_TIMESTAMP, String.valueOf(this.consumerStartTimestamp)); info.setProperties(prop); Set<SubscriptionData> subSet = this.subscriptions(); info.getSubscriptionSet().addAll(subSet); Iterator<Entry<MessageQueue, ProcessQueue>> it = this.rebalanceImpl.getProcessQueueTable().entrySet().iterator(); while (it.hasNext()) { Entry<MessageQueue, ProcessQueue> next = it.next(); MessageQueue mq = next.getKey(); ProcessQueue pq = next.getValue(); ProcessQueueInfo pqinfo = new ProcessQueueInfo(); pqinfo.setCommitOffset(this.offsetStore.readOffset(mq, ReadOffsetType.MEMORY_FIRST_THEN_STORE)); pq.fillProcessQueueInfo(pqinfo); info.getMqTable().put(mq, pqinfo); } for (SubscriptionData sd : subSet) { ConsumeStatus consumeStatus = this.mQClientFactory.getConsumerStatsManager().consumeStatus(this.groupName(), sd.getTopic()); info.getStatusTable().put(sd.getTopic(), consumeStatus); } return info; }
Example #3
Source File: ConsumeStatusTest.java From DDMQ with Apache License 2.0 | 5 votes |
@Test public void testFromJson() throws Exception { ConsumeStatus cs = new ConsumeStatus(); cs.setConsumeFailedTPS(10); cs.setPullRT(100); cs.setPullTPS(1000); String json = RemotingSerializable.toJson(cs, true); ConsumeStatus fromJson = RemotingSerializable.fromJson(json, ConsumeStatus.class); assertThat(fromJson.getPullRT()).isCloseTo(cs.getPullRT(), within(0.0001)); assertThat(fromJson.getPullTPS()).isCloseTo(cs.getPullTPS(), within(0.0001)); assertThat(fromJson.getConsumeFailedTPS()).isCloseTo(cs.getConsumeFailedTPS(), within(0.0001)); }
Example #4
Source File: DefaultMonitorListenerTest.java From rocketmq-all-4.1.0-incubating with Apache License 2.0 | 5 votes |
@Test public void testReportConsumerRunningInfo() { TreeMap<String, ConsumerRunningInfo> criTable = new TreeMap<>(); ConsumerRunningInfo consumerRunningInfo = new ConsumerRunningInfo(); consumerRunningInfo.setSubscriptionSet(new TreeSet<SubscriptionData>()); consumerRunningInfo.setStatusTable(new TreeMap<String, ConsumeStatus>()); consumerRunningInfo.setSubscriptionSet(new TreeSet<SubscriptionData>()); consumerRunningInfo.setMqTable(new TreeMap<MessageQueue, ProcessQueueInfo>()); consumerRunningInfo.setProperties(new Properties()); criTable.put("test", consumerRunningInfo); defaultMonitorListener.reportConsumerRunningInfo(criTable); }
Example #5
Source File: DefaultMonitorListenerTest.java From DDMQ with Apache License 2.0 | 5 votes |
@Test public void testReportConsumerRunningInfo() { TreeMap<String, ConsumerRunningInfo> criTable = new TreeMap<>(); ConsumerRunningInfo consumerRunningInfo = new ConsumerRunningInfo(); consumerRunningInfo.setSubscriptionSet(new TreeSet<SubscriptionData>()); consumerRunningInfo.setStatusTable(new TreeMap<String, ConsumeStatus>()); consumerRunningInfo.setSubscriptionSet(new TreeSet<SubscriptionData>()); consumerRunningInfo.setMqTable(new TreeMap<MessageQueue, ProcessQueueInfo>()); consumerRunningInfo.setProperties(new Properties()); criTable.put("test", consumerRunningInfo); defaultMonitorListener.reportConsumerRunningInfo(criTable); }
Example #6
Source File: DefaultMQPushConsumerImpl.java From DDMQ with Apache License 2.0 | 5 votes |
@Override public ConsumerRunningInfo consumerRunningInfo() { ConsumerRunningInfo info = new ConsumerRunningInfo(); Properties prop = MixAll.object2Properties(this.defaultMQPushConsumer); prop.put(ConsumerRunningInfo.PROP_CONSUME_ORDERLY, String.valueOf(this.consumeOrderly)); prop.put(ConsumerRunningInfo.PROP_THREADPOOL_CORE_SIZE, String.valueOf(this.consumeMessageService.getCorePoolSize())); prop.put(ConsumerRunningInfo.PROP_CONSUMER_START_TIMESTAMP, String.valueOf(this.consumerStartTimestamp)); info.setProperties(prop); Set<SubscriptionData> subSet = this.subscriptions(); info.getSubscriptionSet().addAll(subSet); Iterator<Entry<MessageQueue, ProcessQueue>> it = this.rebalanceImpl.getProcessQueueTable().entrySet().iterator(); while (it.hasNext()) { Entry<MessageQueue, ProcessQueue> next = it.next(); MessageQueue mq = next.getKey(); ProcessQueue pq = next.getValue(); ProcessQueueInfo pqinfo = new ProcessQueueInfo(); pqinfo.setCommitOffset(this.offsetStore.readOffset(mq, ReadOffsetType.MEMORY_FIRST_THEN_STORE)); pq.fillProcessQueueInfo(pqinfo); info.getMqTable().put(mq, pqinfo); } for (SubscriptionData sd : subSet) { ConsumeStatus consumeStatus = this.mQClientFactory.getConsumerStatsManager().consumeStatus(this.groupName(), sd.getTopic()); info.getStatusTable().put(sd.getTopic(), consumeStatus); } return info; }
Example #7
Source File: ConsumeStatusTest.java From rocketmq with Apache License 2.0 | 5 votes |
@Test public void testFromJson() throws Exception { ConsumeStatus cs = new ConsumeStatus(); cs.setConsumeFailedTPS(10); cs.setPullRT(100); cs.setPullTPS(1000); String json = RemotingSerializable.toJson(cs, true); ConsumeStatus fromJson = RemotingSerializable.fromJson(json, ConsumeStatus.class); assertThat(fromJson.getPullRT()).isCloseTo(cs.getPullRT(), within(0.0001)); assertThat(fromJson.getPullTPS()).isCloseTo(cs.getPullTPS(), within(0.0001)); assertThat(fromJson.getConsumeFailedTPS()).isCloseTo(cs.getConsumeFailedTPS(), within(0.0001)); }
Example #8
Source File: DefaultMQPushConsumerImpl.java From DDMQ with Apache License 2.0 | 5 votes |
@Override public ConsumerRunningInfo consumerRunningInfo() { ConsumerRunningInfo info = new ConsumerRunningInfo(); Properties prop = MixAll.object2Properties(this.defaultMQPushConsumer); prop.put(ConsumerRunningInfo.PROP_CONSUME_ORDERLY, String.valueOf(this.consumeOrderly)); prop.put(ConsumerRunningInfo.PROP_THREADPOOL_CORE_SIZE, String.valueOf(this.consumeMessageService.getCorePoolSize())); prop.put(ConsumerRunningInfo.PROP_CONSUMER_START_TIMESTAMP, String.valueOf(this.consumerStartTimestamp)); info.setProperties(prop); Set<SubscriptionData> subSet = this.subscriptions(); info.getSubscriptionSet().addAll(subSet); Iterator<Entry<MessageQueue, ProcessQueue>> it = this.rebalanceImpl.getProcessQueueTable().entrySet().iterator(); while (it.hasNext()) { Entry<MessageQueue, ProcessQueue> next = it.next(); MessageQueue mq = next.getKey(); ProcessQueue pq = next.getValue(); ProcessQueueInfo pqinfo = new ProcessQueueInfo(); pqinfo.setCommitOffset(this.offsetStore.readOffset(mq, ReadOffsetType.MEMORY_FIRST_THEN_STORE)); pq.fillProcessQueueInfo(pqinfo); info.getMqTable().put(mq, pqinfo); } for (SubscriptionData sd : subSet) { ConsumeStatus consumeStatus = this.mQClientFactory.getConsumerStatsManager().consumeStatus(this.groupName(), sd.getTopic()); info.getStatusTable().put(sd.getTopic(), consumeStatus); } return info; }
Example #9
Source File: DefaultMonitorListenerTest.java From rocketmq with Apache License 2.0 | 5 votes |
@Test public void testReportConsumerRunningInfo() { TreeMap<String, ConsumerRunningInfo> criTable = new TreeMap<>(); ConsumerRunningInfo consumerRunningInfo = new ConsumerRunningInfo(); consumerRunningInfo.setSubscriptionSet(new TreeSet<SubscriptionData>()); consumerRunningInfo.setStatusTable(new TreeMap<String, ConsumeStatus>()); consumerRunningInfo.setSubscriptionSet(new TreeSet<SubscriptionData>()); consumerRunningInfo.setMqTable(new TreeMap<MessageQueue, ProcessQueueInfo>()); consumerRunningInfo.setProperties(new Properties()); criTable.put("test", consumerRunningInfo); defaultMonitorListener.reportConsumerRunningInfo(criTable); }
Example #10
Source File: ConsumeStatusTest.java From rocketmq-all-4.1.0-incubating with Apache License 2.0 | 5 votes |
@Test public void testFromJson() throws Exception { ConsumeStatus cs = new ConsumeStatus(); cs.setConsumeFailedTPS(10); cs.setPullRT(100); cs.setPullTPS(1000); String json = RemotingSerializable.toJson(cs, true); ConsumeStatus fromJson = RemotingSerializable.fromJson(json, ConsumeStatus.class); assertThat(fromJson.getPullRT()).isCloseTo(cs.getPullRT(), within(0.0001)); assertThat(fromJson.getPullTPS()).isCloseTo(cs.getPullTPS(), within(0.0001)); assertThat(fromJson.getConsumeFailedTPS()).isCloseTo(cs.getConsumeFailedTPS(), within(0.0001)); }
Example #11
Source File: DefaultMQPushConsumerImpl.java From rocketmq with Apache License 2.0 | 5 votes |
@Override public ConsumerRunningInfo consumerRunningInfo() { ConsumerRunningInfo info = new ConsumerRunningInfo(); Properties prop = MixAll.object2Properties(this.defaultMQPushConsumer); prop.put(ConsumerRunningInfo.PROP_CONSUME_ORDERLY, String.valueOf(this.consumeOrderly)); prop.put(ConsumerRunningInfo.PROP_THREADPOOL_CORE_SIZE, String.valueOf(this.consumeMessageService.getCorePoolSize())); prop.put(ConsumerRunningInfo.PROP_CONSUMER_START_TIMESTAMP, String.valueOf(this.consumerStartTimestamp)); info.setProperties(prop); Set<SubscriptionData> subSet = this.subscriptions(); info.getSubscriptionSet().addAll(subSet); Iterator<Entry<MessageQueue, ProcessQueue>> it = this.rebalanceImpl.getProcessQueueTable().entrySet().iterator(); while (it.hasNext()) { Entry<MessageQueue, ProcessQueue> next = it.next(); MessageQueue mq = next.getKey(); ProcessQueue pq = next.getValue(); ProcessQueueInfo pqinfo = new ProcessQueueInfo(); pqinfo.setCommitOffset(this.offsetStore.readOffset(mq, ReadOffsetType.MEMORY_FIRST_THEN_STORE)); pq.fillProcessQueueInfo(pqinfo); info.getMqTable().put(mq, pqinfo); } for (SubscriptionData sd : subSet) { ConsumeStatus consumeStatus = this.mQClientFactory.getConsumerStatsManager().consumeStatus(this.groupName(), sd.getTopic()); info.getStatusTable().put(sd.getTopic(), consumeStatus); } return info; }
Example #12
Source File: ConsumeStatusTest.java From rocketmq-read with Apache License 2.0 | 5 votes |
@Test public void testFromJson() throws Exception { ConsumeStatus cs = new ConsumeStatus(); cs.setConsumeFailedTPS(10); cs.setPullRT(100); cs.setPullTPS(1000); String json = RemotingSerializable.toJson(cs, true); ConsumeStatus fromJson = RemotingSerializable.fromJson(json, ConsumeStatus.class); assertThat(fromJson.getPullRT()).isCloseTo(cs.getPullRT(), within(0.0001)); assertThat(fromJson.getPullTPS()).isCloseTo(cs.getPullTPS(), within(0.0001)); assertThat(fromJson.getConsumeFailedTPS()).isCloseTo(cs.getConsumeFailedTPS(), within(0.0001)); }
Example #13
Source File: DefaultMQPushConsumerImpl.java From rocketmq_trans_message with Apache License 2.0 | 5 votes |
@Override public ConsumerRunningInfo consumerRunningInfo() { ConsumerRunningInfo info = new ConsumerRunningInfo(); Properties prop = MixAll.object2Properties(this.defaultMQPushConsumer); prop.put(ConsumerRunningInfo.PROP_CONSUME_ORDERLY, String.valueOf(this.consumeOrderly)); prop.put(ConsumerRunningInfo.PROP_THREADPOOL_CORE_SIZE, String.valueOf(this.consumeMessageService.getCorePoolSize())); prop.put(ConsumerRunningInfo.PROP_CONSUMER_START_TIMESTAMP, String.valueOf(this.consumerStartTimestamp)); info.setProperties(prop); Set<SubscriptionData> subSet = this.subscriptions(); info.getSubscriptionSet().addAll(subSet); Iterator<Entry<MessageQueue, ProcessQueue>> it = this.rebalanceImpl.getProcessQueueTable().entrySet().iterator(); while (it.hasNext()) { Entry<MessageQueue, ProcessQueue> next = it.next(); MessageQueue mq = next.getKey(); ProcessQueue pq = next.getValue(); ProcessQueueInfo pqinfo = new ProcessQueueInfo(); pqinfo.setCommitOffset(this.offsetStore.readOffset(mq, ReadOffsetType.MEMORY_FIRST_THEN_STORE)); pq.fillProcessQueueInfo(pqinfo); info.getMqTable().put(mq, pqinfo); } for (SubscriptionData sd : subSet) { ConsumeStatus consumeStatus = this.mQClientFactory.getConsumerStatsManager().consumeStatus(this.groupName(), sd.getTopic()); info.getStatusTable().put(sd.getTopic(), consumeStatus); } return info; }
Example #14
Source File: DefaultMonitorListenerTest.java From rocketmq_trans_message with Apache License 2.0 | 5 votes |
@Test public void testReportConsumerRunningInfo() { TreeMap<String, ConsumerRunningInfo> criTable = new TreeMap<>(); ConsumerRunningInfo consumerRunningInfo = new ConsumerRunningInfo(); consumerRunningInfo.setSubscriptionSet(new TreeSet<SubscriptionData>()); consumerRunningInfo.setStatusTable(new TreeMap<String, ConsumeStatus>()); consumerRunningInfo.setSubscriptionSet(new TreeSet<SubscriptionData>()); consumerRunningInfo.setMqTable(new TreeMap<MessageQueue, ProcessQueueInfo>()); consumerRunningInfo.setProperties(new Properties()); criTable.put("test", consumerRunningInfo); defaultMonitorListener.reportConsumerRunningInfo(criTable); }
Example #15
Source File: DefaultMQPushConsumerImpl.java From rocketmq-read with Apache License 2.0 | 5 votes |
/** * 获取消费者的运行时信息 * @return ; */ @Override public ConsumerRunningInfo consumerRunningInfo() { ConsumerRunningInfo info = new ConsumerRunningInfo(); Properties prop = MixAll.object2Properties(this.defaultMQPushConsumer); prop.put(ConsumerRunningInfo.PROP_CONSUME_ORDERLY, String.valueOf(this.consumeOrderly)); prop.put(ConsumerRunningInfo.PROP_THREADPOOL_CORE_SIZE, String.valueOf(this.consumeMessageService.getCorePoolSize())); prop.put(ConsumerRunningInfo.PROP_CONSUMER_START_TIMESTAMP, String.valueOf(this.consumerStartTimestamp)); info.setProperties(prop); Set<SubscriptionData> subSet = this.subscriptions(); info.getSubscriptionSet().addAll(subSet); Iterator<Entry<MessageQueue, ProcessQueue>> it = this.rebalanceImpl.getProcessQueueTable().entrySet().iterator(); while (it.hasNext()) { Entry<MessageQueue, ProcessQueue> next = it.next(); MessageQueue mq = next.getKey(); ProcessQueue pq = next.getValue(); ProcessQueueInfo pqinfo = new ProcessQueueInfo(); pqinfo.setCommitOffset(this.offsetStore.readOffset(mq, ReadOffsetType.MEMORY_FIRST_THEN_STORE)); pq.fillProcessQueueInfo(pqinfo); info.getMqTable().put(mq, pqinfo); } for (SubscriptionData sd : subSet) { ConsumeStatus consumeStatus = this.mQClientFactory.getConsumerStatsManager().consumeStatus(this.groupName(), sd.getTopic()); info.getStatusTable().put(sd.getTopic(), consumeStatus); } return info; }
Example #16
Source File: ConsumeStatusTest.java From rocketmq-4.3.0 with Apache License 2.0 | 5 votes |
@Test public void testFromJson() throws Exception { ConsumeStatus cs = new ConsumeStatus(); cs.setConsumeFailedTPS(10); cs.setPullRT(100); cs.setPullTPS(1000); String json = RemotingSerializable.toJson(cs, true); ConsumeStatus fromJson = RemotingSerializable.fromJson(json, ConsumeStatus.class); assertThat(fromJson.getPullRT()).isCloseTo(cs.getPullRT(), within(0.0001)); assertThat(fromJson.getPullTPS()).isCloseTo(cs.getPullTPS(), within(0.0001)); assertThat(fromJson.getConsumeFailedTPS()).isCloseTo(cs.getConsumeFailedTPS(), within(0.0001)); }
Example #17
Source File: ConsumeStatusTest.java From rocketmq_trans_message with Apache License 2.0 | 5 votes |
@Test public void testFromJson() throws Exception { ConsumeStatus cs = new ConsumeStatus(); cs.setConsumeFailedTPS(10); cs.setPullRT(100); cs.setPullTPS(1000); String json = RemotingSerializable.toJson(cs, true); ConsumeStatus fromJson = RemotingSerializable.fromJson(json, ConsumeStatus.class); assertThat(fromJson.getPullRT()).isCloseTo(cs.getPullRT(), within(0.0001)); assertThat(fromJson.getPullTPS()).isCloseTo(cs.getPullTPS(), within(0.0001)); assertThat(fromJson.getConsumeFailedTPS()).isCloseTo(cs.getConsumeFailedTPS(), within(0.0001)); }
Example #18
Source File: DefaultMonitorListenerTest.java From rocketmq-4.3.0 with Apache License 2.0 | 5 votes |
@Test public void testReportConsumerRunningInfo() { TreeMap<String, ConsumerRunningInfo> criTable = new TreeMap<>(); ConsumerRunningInfo consumerRunningInfo = new ConsumerRunningInfo(); consumerRunningInfo.setSubscriptionSet(new TreeSet<SubscriptionData>()); consumerRunningInfo.setStatusTable(new TreeMap<String, ConsumeStatus>()); consumerRunningInfo.setSubscriptionSet(new TreeSet<SubscriptionData>()); consumerRunningInfo.setMqTable(new TreeMap<MessageQueue, ProcessQueueInfo>()); consumerRunningInfo.setProperties(new Properties()); criTable.put("test", consumerRunningInfo); defaultMonitorListener.reportConsumerRunningInfo(criTable); }
Example #19
Source File: DefaultMQPushConsumerImpl.java From rocketmq with Apache License 2.0 | 5 votes |
@Override public ConsumerRunningInfo consumerRunningInfo() { ConsumerRunningInfo info = new ConsumerRunningInfo(); Properties prop = MixAll.object2Properties(this.defaultMQPushConsumer); prop.put(ConsumerRunningInfo.PROP_CONSUME_ORDERLY, String.valueOf(this.consumeOrderly)); prop.put(ConsumerRunningInfo.PROP_THREADPOOL_CORE_SIZE, String.valueOf(this.consumeMessageService.getCorePoolSize())); prop.put(ConsumerRunningInfo.PROP_CONSUMER_START_TIMESTAMP, String.valueOf(this.consumerStartTimestamp)); info.setProperties(prop); Set<SubscriptionData> subSet = this.subscriptions(); info.getSubscriptionSet().addAll(subSet); Iterator<Entry<MessageQueue, ProcessQueue>> it = this.rebalanceImpl.getProcessQueueTable().entrySet().iterator(); while (it.hasNext()) { Entry<MessageQueue, ProcessQueue> next = it.next(); MessageQueue mq = next.getKey(); ProcessQueue pq = next.getValue(); ProcessQueueInfo pqinfo = new ProcessQueueInfo(); pqinfo.setCommitOffset(this.offsetStore.readOffset(mq, ReadOffsetType.MEMORY_FIRST_THEN_STORE)); pq.fillProcessQueueInfo(pqinfo); info.getMqTable().put(mq, pqinfo); } for (SubscriptionData sd : subSet) { ConsumeStatus consumeStatus = this.mQClientFactory.getConsumerStatsManager().consumeStatus(this.groupName(), sd.getTopic()); info.getStatusTable().put(sd.getTopic(), consumeStatus); } return info; }
Example #20
Source File: DefaultMonitorListenerTest.java From rocketmq with Apache License 2.0 | 5 votes |
@Test public void testReportConsumerRunningInfo() { TreeMap<String, ConsumerRunningInfo> criTable = new TreeMap<>(); ConsumerRunningInfo consumerRunningInfo = new ConsumerRunningInfo(); consumerRunningInfo.setSubscriptionSet(new TreeSet<SubscriptionData>()); consumerRunningInfo.setStatusTable(new TreeMap<String, ConsumeStatus>()); consumerRunningInfo.setSubscriptionSet(new TreeSet<SubscriptionData>()); consumerRunningInfo.setMqTable(new TreeMap<MessageQueue, ProcessQueueInfo>()); consumerRunningInfo.setProperties(new Properties()); criTable.put("test", consumerRunningInfo); defaultMonitorListener.reportConsumerRunningInfo(criTable); }
Example #21
Source File: DMQPushConsumerHealthStats.java From pepper-metrics with Apache License 2.0 | 5 votes |
public void collectMetrics() { topicConsumerHealthStatsMap.clear(); final String consumerGroup = defaultMQPushConsumer.getConsumerGroup(); final ConsumerRunningInfo consumerRunningInfo = defaultMQPushConsumer.getDefaultMQPushConsumerImpl().consumerRunningInfo(); for (Map.Entry<String, ConsumeStatus> statusEntry : consumerRunningInfo.getStatusTable().entrySet()) { final String topic = statusEntry.getKey(); final ConsumeStatus consumeStatus = statusEntry.getValue(); final TopicConsumerHealthStats topicConsumerHealthStats = new TopicConsumerHealthStats(getRegistry(), getNamespace(), topic, consumerGroup, consumeStatus); topicConsumerHealthStatsMap.putIfAbsent(topic, topicConsumerHealthStats); } for (TopicConsumerHealthStats consumerHealthStats : topicConsumerHealthStatsMap.values()) { consumerHealthStats.collectMetrics(); } }
Example #22
Source File: ConsumeStatusTest.java From DDMQ with Apache License 2.0 | 5 votes |
@Test public void testFromJson() throws Exception { ConsumeStatus cs = new ConsumeStatus(); cs.setConsumeFailedTPS(10); cs.setPullRT(100); cs.setPullTPS(1000); String json = RemotingSerializable.toJson(cs, true); ConsumeStatus fromJson = RemotingSerializable.fromJson(json, ConsumeStatus.class); assertThat(fromJson.getPullRT()).isCloseTo(cs.getPullRT(), within(0.0001)); assertThat(fromJson.getPullTPS()).isCloseTo(cs.getPullTPS(), within(0.0001)); assertThat(fromJson.getConsumeFailedTPS()).isCloseTo(cs.getConsumeFailedTPS(), within(0.0001)); }
Example #23
Source File: DefaultMonitorListenerTest.java From DDMQ with Apache License 2.0 | 5 votes |
@Test public void testReportConsumerRunningInfo() { TreeMap<String, ConsumerRunningInfo> criTable = new TreeMap<>(); ConsumerRunningInfo consumerRunningInfo = new ConsumerRunningInfo(); consumerRunningInfo.setSubscriptionSet(new TreeSet<SubscriptionData>()); consumerRunningInfo.setStatusTable(new TreeMap<String, ConsumeStatus>()); consumerRunningInfo.setSubscriptionSet(new TreeSet<SubscriptionData>()); consumerRunningInfo.setMqTable(new TreeMap<MessageQueue, ProcessQueueInfo>()); consumerRunningInfo.setProperties(new Properties()); criTable.put("test", consumerRunningInfo); defaultMonitorListener.reportConsumerRunningInfo(criTable); }
Example #24
Source File: ConsumeStatusTest.java From rocketmq with Apache License 2.0 | 5 votes |
@Test public void testFromJson() throws Exception { ConsumeStatus cs = new ConsumeStatus(); cs.setConsumeFailedTPS(10); cs.setPullRT(100); cs.setPullTPS(1000); String json = RemotingSerializable.toJson(cs, true); ConsumeStatus fromJson = RemotingSerializable.fromJson(json, ConsumeStatus.class); assertThat(fromJson.getPullRT()).isCloseTo(cs.getPullRT(), within(0.0001)); assertThat(fromJson.getPullTPS()).isCloseTo(cs.getPullTPS(), within(0.0001)); assertThat(fromJson.getConsumeFailedTPS()).isCloseTo(cs.getConsumeFailedTPS(), within(0.0001)); }
Example #25
Source File: MonitorServiceTest.java From rocketmq with Apache License 2.0 | 4 votes |
@BeforeClass public static void init() throws NoSuchFieldException, IllegalAccessException, RemotingException, MQClientException, InterruptedException, MQBrokerException { monitorConfig = new MonitorConfig(); monitorListener = new DefaultMonitorListener(); defaultMQPullConsumer = mock(DefaultMQPullConsumer.class); defaultMQPushConsumer = mock(DefaultMQPushConsumer.class); mQClientAPIImpl = mock(MQClientAPIImpl.class); defaultMQAdminExt = new DefaultMQAdminExt(); defaultMQAdminExtImpl = new DefaultMQAdminExtImpl(defaultMQAdminExt, 1000); monitorService = new MonitorService(monitorConfig, monitorListener, null); Field field = DefaultMQAdminExtImpl.class.getDeclaredField("mqClientInstance"); field.setAccessible(true); field.set(defaultMQAdminExtImpl, mqClientInstance); field = MQClientInstance.class.getDeclaredField("mQClientAPIImpl"); field.setAccessible(true); field.set(mqClientInstance, mQClientAPIImpl); field = DefaultMQAdminExt.class.getDeclaredField("defaultMQAdminExtImpl"); field.setAccessible(true); field.set(defaultMQAdminExt, defaultMQAdminExtImpl); field = MonitorService.class.getDeclaredField("defaultMQAdminExt"); field.setAccessible(true); field.set(monitorService, defaultMQAdminExt); field = MonitorService.class.getDeclaredField("defaultMQPullConsumer"); field.setAccessible(true); field.set(monitorService, defaultMQPullConsumer); field = MonitorService.class.getDeclaredField("defaultMQPushConsumer"); field.setAccessible(true); field.set(monitorService, defaultMQPushConsumer); TopicList topicList = new TopicList(); Set<String> topicSet = new HashSet<>(); topicSet.add("topic_one"); topicSet.add("topic_two"); topicList.setTopicList(topicSet); when(mQClientAPIImpl.getTopicListFromNameServer(anyLong())).thenReturn(topicList); TopicRouteData topicRouteData = new TopicRouteData(); List<BrokerData> brokerDatas = new ArrayList<>(); HashMap<Long, String> brokerAddrs = new HashMap<>(); brokerAddrs.put(1234l, "127.0.0.1:10911"); BrokerData brokerData = new BrokerData(); brokerData.setCluster("default-cluster"); brokerData.setBrokerName("default-broker"); brokerData.setBrokerAddrs(brokerAddrs); brokerDatas.add(brokerData); topicRouteData.setBrokerDatas(brokerDatas); topicRouteData.setQueueDatas(new ArrayList<QueueData>()); topicRouteData.setFilterServerTable(new HashMap<String, List<String>>()); when(mQClientAPIImpl.getTopicRouteInfoFromNameServer(anyString(), anyLong())).thenReturn(topicRouteData); ConsumeStats consumeStats = new ConsumeStats(); consumeStats.setConsumeTps(1234); MessageQueue messageQueue = new MessageQueue(); OffsetWrapper offsetWrapper = new OffsetWrapper(); HashMap<MessageQueue, OffsetWrapper> stats = new HashMap<>(); stats.put(messageQueue, offsetWrapper); consumeStats.setOffsetTable(stats); when(mQClientAPIImpl.getConsumeStats(anyString(), anyString(), anyString(), anyLong())).thenReturn(consumeStats); ConsumerConnection consumerConnection = new ConsumerConnection(); consumerConnection.setConsumeType(ConsumeType.CONSUME_PASSIVELY); consumerConnection.setMessageModel(MessageModel.CLUSTERING); HashSet<Connection> connections = new HashSet<>(); Connection connection = new Connection(); connection.setClientId("client_id"); connection.setClientAddr("127.0.0.1:109111"); connection.setLanguage(LanguageCode.JAVA); connection.setVersion(MQVersion.Version.V4_0_0_SNAPSHOT.ordinal()); connections.add(connection); consumerConnection.setConnectionSet(connections); consumerConnection.setSubscriptionTable(new ConcurrentHashMap<String, SubscriptionData>()); consumerConnection.setConsumeFromWhere(ConsumeFromWhere.CONSUME_FROM_FIRST_OFFSET); when(mQClientAPIImpl.getConsumerConnectionList(anyString(), anyString(), anyLong())).thenReturn(consumerConnection); ConsumerRunningInfo consumerRunningInfo = new ConsumerRunningInfo(); consumerRunningInfo.setJstack("test"); consumerRunningInfo.setMqTable(new TreeMap<MessageQueue, ProcessQueueInfo>()); consumerRunningInfo.setStatusTable(new TreeMap<String, ConsumeStatus>()); consumerRunningInfo.setSubscriptionSet(new TreeSet<SubscriptionData>()); Properties properties = new Properties(); properties.put(ConsumerRunningInfo.PROP_CONSUME_TYPE, CONSUME_ACTIVELY); properties.put(ConsumerRunningInfo.PROP_CONSUMER_START_TIMESTAMP, System.currentTimeMillis()); consumerRunningInfo.setProperties(properties); when(mQClientAPIImpl.getConsumerRunningInfo(anyString(), anyString(), anyString(), anyBoolean(), anyLong())).thenReturn(consumerRunningInfo); }
Example #26
Source File: ConsumerStatusSubCommandTest.java From rocketmq with Apache License 2.0 | 4 votes |
@BeforeClass public static void init() throws NoSuchFieldException, IllegalAccessException, InterruptedException, RemotingException, MQClientException, MQBrokerException { mQClientAPIImpl = mock(MQClientAPIImpl.class); defaultMQAdminExt = new DefaultMQAdminExt(); defaultMQAdminExtImpl = new DefaultMQAdminExtImpl(defaultMQAdminExt, 1000); Field field = DefaultMQAdminExtImpl.class.getDeclaredField("mqClientInstance"); field.setAccessible(true); field.set(defaultMQAdminExtImpl, mqClientInstance); field = MQClientInstance.class.getDeclaredField("mQClientAPIImpl"); field.setAccessible(true); field.set(mqClientInstance, mQClientAPIImpl); field = DefaultMQAdminExt.class.getDeclaredField("defaultMQAdminExtImpl"); field.setAccessible(true); field.set(defaultMQAdminExt, defaultMQAdminExtImpl); TopicRouteData topicRouteData = new TopicRouteData(); List<BrokerData> brokerDatas = new ArrayList<>(); HashMap<Long, String> brokerAddrs = new HashMap<>(); brokerAddrs.put(1234l, "127.0.0.1:10911"); BrokerData brokerData = new BrokerData(); brokerData.setCluster("default-cluster"); brokerData.setBrokerName("default-broker"); brokerData.setBrokerAddrs(brokerAddrs); brokerDatas.add(brokerData); topicRouteData.setBrokerDatas(brokerDatas); topicRouteData.setQueueDatas(new ArrayList<QueueData>()); topicRouteData.setFilterServerTable(new HashMap<String, List<String>>()); when(mQClientAPIImpl.getTopicRouteInfoFromNameServer(anyString(), anyLong())).thenReturn(topicRouteData); ConsumerConnection consumerConnection = new ConsumerConnection(); consumerConnection.setConsumeType(ConsumeType.CONSUME_PASSIVELY); consumerConnection.setMessageModel(MessageModel.CLUSTERING); HashSet<Connection> connections = new HashSet<>(); connections.add(new Connection()); consumerConnection.setConnectionSet(connections); consumerConnection.setSubscriptionTable(new ConcurrentHashMap<String, SubscriptionData>()); consumerConnection.setConsumeFromWhere(ConsumeFromWhere.CONSUME_FROM_FIRST_OFFSET); when(mQClientAPIImpl.getConsumerConnectionList(anyString(), anyString(), anyLong())).thenReturn(consumerConnection); ConsumerRunningInfo consumerRunningInfo = new ConsumerRunningInfo(); consumerRunningInfo.setJstack("test"); consumerRunningInfo.setMqTable(new TreeMap<MessageQueue, ProcessQueueInfo>()); consumerRunningInfo.setStatusTable(new TreeMap<String, ConsumeStatus>()); consumerRunningInfo.setSubscriptionSet(new TreeSet<SubscriptionData>()); when(mQClientAPIImpl.getConsumerRunningInfo(anyString(), anyString(), anyString(), anyBoolean(), anyLong())).thenReturn(consumerRunningInfo); }
Example #27
Source File: MonitorServiceTest.java From rocketmq-all-4.1.0-incubating with Apache License 2.0 | 4 votes |
@BeforeClass public static void init() throws NoSuchFieldException, IllegalAccessException, RemotingException, MQClientException, InterruptedException, MQBrokerException { monitorConfig = new MonitorConfig(); monitorListener = new DefaultMonitorListener(); defaultMQPullConsumer = mock(DefaultMQPullConsumer.class); defaultMQPushConsumer = mock(DefaultMQPushConsumer.class); mQClientAPIImpl = mock(MQClientAPIImpl.class); defaultMQAdminExt = new DefaultMQAdminExt(); defaultMQAdminExtImpl = new DefaultMQAdminExtImpl(defaultMQAdminExt, 1000); monitorService = new MonitorService(monitorConfig, monitorListener, null); Field field = DefaultMQAdminExtImpl.class.getDeclaredField("mqClientInstance"); field.setAccessible(true); field.set(defaultMQAdminExtImpl, mqClientInstance); field = MQClientInstance.class.getDeclaredField("mQClientAPIImpl"); field.setAccessible(true); field.set(mqClientInstance, mQClientAPIImpl); field = DefaultMQAdminExt.class.getDeclaredField("defaultMQAdminExtImpl"); field.setAccessible(true); field.set(defaultMQAdminExt, defaultMQAdminExtImpl); field = MonitorService.class.getDeclaredField("defaultMQAdminExt"); field.setAccessible(true); field.set(monitorService, defaultMQAdminExt); field = MonitorService.class.getDeclaredField("defaultMQPullConsumer"); field.setAccessible(true); field.set(monitorService, defaultMQPullConsumer); field = MonitorService.class.getDeclaredField("defaultMQPushConsumer"); field.setAccessible(true); field.set(monitorService, defaultMQPushConsumer); TopicList topicList = new TopicList(); Set<String> topicSet = new HashSet<>(); topicSet.add("topic_one"); topicSet.add("topic_two"); topicList.setTopicList(topicSet); when(mQClientAPIImpl.getTopicListFromNameServer(anyLong())).thenReturn(topicList); TopicRouteData topicRouteData = new TopicRouteData(); List<BrokerData> brokerDatas = new ArrayList<>(); HashMap<Long, String> brokerAddrs = new HashMap<>(); brokerAddrs.put(1234l, "127.0.0.1:10911"); BrokerData brokerData = new BrokerData(); brokerData.setCluster("default-cluster"); brokerData.setBrokerName("default-broker"); brokerData.setBrokerAddrs(brokerAddrs); brokerDatas.add(brokerData); topicRouteData.setBrokerDatas(brokerDatas); topicRouteData.setQueueDatas(new ArrayList<QueueData>()); topicRouteData.setFilterServerTable(new HashMap<String, List<String>>()); when(mQClientAPIImpl.getTopicRouteInfoFromNameServer(anyString(), anyLong())).thenReturn(topicRouteData); ConsumeStats consumeStats = new ConsumeStats(); consumeStats.setConsumeTps(1234); MessageQueue messageQueue = new MessageQueue(); OffsetWrapper offsetWrapper = new OffsetWrapper(); HashMap<MessageQueue, OffsetWrapper> stats = new HashMap<>(); stats.put(messageQueue, offsetWrapper); consumeStats.setOffsetTable(stats); when(mQClientAPIImpl.getConsumeStats(anyString(), anyString(), anyString(), anyLong())).thenReturn(consumeStats); ConsumerConnection consumerConnection = new ConsumerConnection(); consumerConnection.setConsumeType(ConsumeType.CONSUME_PASSIVELY); consumerConnection.setMessageModel(MessageModel.CLUSTERING); HashSet<Connection> connections = new HashSet<>(); Connection connection = new Connection(); connection.setClientId("client_id"); connection.setClientAddr("127.0.0.1:109111"); connection.setLanguage(LanguageCode.JAVA); connection.setVersion(MQVersion.Version.V4_0_0_SNAPSHOT.ordinal()); connections.add(connection); consumerConnection.setConnectionSet(connections); consumerConnection.setSubscriptionTable(new ConcurrentHashMap<String, SubscriptionData>()); consumerConnection.setConsumeFromWhere(ConsumeFromWhere.CONSUME_FROM_FIRST_OFFSET); when(mQClientAPIImpl.getConsumerConnectionList(anyString(), anyString(), anyLong())).thenReturn(consumerConnection); ConsumerRunningInfo consumerRunningInfo = new ConsumerRunningInfo(); consumerRunningInfo.setJstack("test"); consumerRunningInfo.setMqTable(new TreeMap<MessageQueue, ProcessQueueInfo>()); consumerRunningInfo.setStatusTable(new TreeMap<String, ConsumeStatus>()); consumerRunningInfo.setSubscriptionSet(new TreeSet<SubscriptionData>()); Properties properties = new Properties(); properties.put(ConsumerRunningInfo.PROP_CONSUME_TYPE, CONSUME_ACTIVELY); properties.put(ConsumerRunningInfo.PROP_CONSUMER_START_TIMESTAMP, System.currentTimeMillis()); consumerRunningInfo.setProperties(properties); when(mQClientAPIImpl.getConsumerRunningInfo(anyString(), anyString(), anyString(), anyBoolean(), anyLong())).thenReturn(consumerRunningInfo); }
Example #28
Source File: MonitorServiceTest.java From rocketmq with Apache License 2.0 | 4 votes |
@BeforeClass public static void init() throws NoSuchFieldException, IllegalAccessException, RemotingException, MQClientException, InterruptedException, MQBrokerException { monitorConfig = new MonitorConfig(); monitorListener = new DefaultMonitorListener(); defaultMQPullConsumer = mock(DefaultMQPullConsumer.class); defaultMQPushConsumer = mock(DefaultMQPushConsumer.class); mQClientAPIImpl = mock(MQClientAPIImpl.class); defaultMQAdminExt = new DefaultMQAdminExt(); defaultMQAdminExtImpl = new DefaultMQAdminExtImpl(defaultMQAdminExt, 1000); monitorService = new MonitorService(monitorConfig, monitorListener, null); Field field = DefaultMQAdminExtImpl.class.getDeclaredField("mqClientInstance"); field.setAccessible(true); field.set(defaultMQAdminExtImpl, mqClientInstance); field = MQClientInstance.class.getDeclaredField("mQClientAPIImpl"); field.setAccessible(true); field.set(mqClientInstance, mQClientAPIImpl); field = DefaultMQAdminExt.class.getDeclaredField("defaultMQAdminExtImpl"); field.setAccessible(true); field.set(defaultMQAdminExt, defaultMQAdminExtImpl); field = MonitorService.class.getDeclaredField("defaultMQAdminExt"); field.setAccessible(true); field.set(monitorService, defaultMQAdminExt); field = MonitorService.class.getDeclaredField("defaultMQPullConsumer"); field.setAccessible(true); field.set(monitorService, defaultMQPullConsumer); field = MonitorService.class.getDeclaredField("defaultMQPushConsumer"); field.setAccessible(true); field.set(monitorService, defaultMQPushConsumer); TopicList topicList = new TopicList(); Set<String> topicSet = new HashSet<>(); topicSet.add("topic_one"); topicSet.add("topic_two"); topicList.setTopicList(topicSet); when(mQClientAPIImpl.getTopicListFromNameServer(anyLong())).thenReturn(topicList); TopicRouteData topicRouteData = new TopicRouteData(); List<BrokerData> brokerDatas = new ArrayList<>(); HashMap<Long, String> brokerAddrs = new HashMap<>(); brokerAddrs.put(1234l, "127.0.0.1:10911"); BrokerData brokerData = new BrokerData(); brokerData.setCluster("default-cluster"); brokerData.setBrokerName("default-broker"); brokerData.setBrokerAddrs(brokerAddrs); brokerDatas.add(brokerData); topicRouteData.setBrokerDatas(brokerDatas); topicRouteData.setQueueDatas(new ArrayList<QueueData>()); topicRouteData.setFilterServerTable(new HashMap<String, List<String>>()); when(mQClientAPIImpl.getTopicRouteInfoFromNameServer(anyString(), anyLong())).thenReturn(topicRouteData); ConsumeStats consumeStats = new ConsumeStats(); consumeStats.setConsumeTps(1234); MessageQueue messageQueue = new MessageQueue(); OffsetWrapper offsetWrapper = new OffsetWrapper(); HashMap<MessageQueue, OffsetWrapper> stats = new HashMap<>(); stats.put(messageQueue, offsetWrapper); consumeStats.setOffsetTable(stats); when(mQClientAPIImpl.getConsumeStats(anyString(), anyString(), anyString(), anyLong())).thenReturn(consumeStats); ConsumerConnection consumerConnection = new ConsumerConnection(); consumerConnection.setConsumeType(ConsumeType.CONSUME_PASSIVELY); consumerConnection.setMessageModel(MessageModel.CLUSTERING); HashSet<Connection> connections = new HashSet<>(); Connection connection = new Connection(); connection.setClientId("client_id"); connection.setClientAddr("127.0.0.1:109111"); connection.setLanguage(LanguageCode.JAVA); connection.setVersion(MQVersion.Version.V4_0_0_SNAPSHOT.ordinal()); connections.add(connection); consumerConnection.setConnectionSet(connections); consumerConnection.setSubscriptionTable(new ConcurrentHashMap<String, SubscriptionData>()); consumerConnection.setConsumeFromWhere(ConsumeFromWhere.CONSUME_FROM_FIRST_OFFSET); when(mQClientAPIImpl.getConsumerConnectionList(anyString(), anyString(), anyLong())).thenReturn(consumerConnection); ConsumerRunningInfo consumerRunningInfo = new ConsumerRunningInfo(); consumerRunningInfo.setJstack("test"); consumerRunningInfo.setMqTable(new TreeMap<MessageQueue, ProcessQueueInfo>()); consumerRunningInfo.setStatusTable(new TreeMap<String, ConsumeStatus>()); consumerRunningInfo.setSubscriptionSet(new TreeSet<SubscriptionData>()); Properties properties = new Properties(); properties.put(ConsumerRunningInfo.PROP_CONSUME_TYPE, CONSUME_ACTIVELY); properties.put(ConsumerRunningInfo.PROP_CONSUMER_START_TIMESTAMP, System.currentTimeMillis()); consumerRunningInfo.setProperties(properties); when(mQClientAPIImpl.getConsumerRunningInfo(anyString(), anyString(), anyString(), anyBoolean(), anyLong())).thenReturn(consumerRunningInfo); }
Example #29
Source File: ConsumerStatusSubCommandTest.java From rocketmq-all-4.1.0-incubating with Apache License 2.0 | 4 votes |
@BeforeClass public static void init() throws NoSuchFieldException, IllegalAccessException, InterruptedException, RemotingException, MQClientException, MQBrokerException { mQClientAPIImpl = mock(MQClientAPIImpl.class); defaultMQAdminExt = new DefaultMQAdminExt(); defaultMQAdminExtImpl = new DefaultMQAdminExtImpl(defaultMQAdminExt, 1000); Field field = DefaultMQAdminExtImpl.class.getDeclaredField("mqClientInstance"); field.setAccessible(true); field.set(defaultMQAdminExtImpl, mqClientInstance); field = MQClientInstance.class.getDeclaredField("mQClientAPIImpl"); field.setAccessible(true); field.set(mqClientInstance, mQClientAPIImpl); field = DefaultMQAdminExt.class.getDeclaredField("defaultMQAdminExtImpl"); field.setAccessible(true); field.set(defaultMQAdminExt, defaultMQAdminExtImpl); TopicRouteData topicRouteData = new TopicRouteData(); List<BrokerData> brokerDatas = new ArrayList<>(); HashMap<Long, String> brokerAddrs = new HashMap<>(); brokerAddrs.put(1234l, "127.0.0.1:10911"); BrokerData brokerData = new BrokerData(); brokerData.setCluster("default-cluster"); brokerData.setBrokerName("default-broker"); brokerData.setBrokerAddrs(brokerAddrs); brokerDatas.add(brokerData); topicRouteData.setBrokerDatas(brokerDatas); topicRouteData.setQueueDatas(new ArrayList<QueueData>()); topicRouteData.setFilterServerTable(new HashMap<String, List<String>>()); when(mQClientAPIImpl.getTopicRouteInfoFromNameServer(anyString(), anyLong())).thenReturn(topicRouteData); ConsumerConnection consumerConnection = new ConsumerConnection(); consumerConnection.setConsumeType(ConsumeType.CONSUME_PASSIVELY); consumerConnection.setMessageModel(MessageModel.CLUSTERING); HashSet<Connection> connections = new HashSet<>(); connections.add(new Connection()); consumerConnection.setConnectionSet(connections); consumerConnection.setSubscriptionTable(new ConcurrentHashMap<String, SubscriptionData>()); consumerConnection.setConsumeFromWhere(ConsumeFromWhere.CONSUME_FROM_FIRST_OFFSET); when(mQClientAPIImpl.getConsumerConnectionList(anyString(), anyString(), anyLong())).thenReturn(consumerConnection); ConsumerRunningInfo consumerRunningInfo = new ConsumerRunningInfo(); consumerRunningInfo.setJstack("test"); consumerRunningInfo.setMqTable(new TreeMap<MessageQueue, ProcessQueueInfo>()); consumerRunningInfo.setStatusTable(new TreeMap<String, ConsumeStatus>()); consumerRunningInfo.setSubscriptionSet(new TreeSet<SubscriptionData>()); when(mQClientAPIImpl.getConsumerRunningInfo(anyString(), anyString(), anyString(), anyBoolean(), anyLong())).thenReturn(consumerRunningInfo); }
Example #30
Source File: MonitorServiceTest.java From DDMQ with Apache License 2.0 | 4 votes |
@BeforeClass public static void init() throws NoSuchFieldException, IllegalAccessException, RemotingException, MQClientException, InterruptedException, MQBrokerException { monitorConfig = new MonitorConfig(); monitorListener = new DefaultMonitorListener(); defaultMQPullConsumer = mock(DefaultMQPullConsumer.class); defaultMQPushConsumer = mock(DefaultMQPushConsumer.class); mQClientAPIImpl = mock(MQClientAPIImpl.class); defaultMQAdminExt = new DefaultMQAdminExt(); defaultMQAdminExtImpl = new DefaultMQAdminExtImpl(defaultMQAdminExt, 1000); monitorService = new MonitorService(monitorConfig, monitorListener, null); Field field = DefaultMQAdminExtImpl.class.getDeclaredField("mqClientInstance"); field.setAccessible(true); field.set(defaultMQAdminExtImpl, mqClientInstance); field = MQClientInstance.class.getDeclaredField("mQClientAPIImpl"); field.setAccessible(true); field.set(mqClientInstance, mQClientAPIImpl); field = DefaultMQAdminExt.class.getDeclaredField("defaultMQAdminExtImpl"); field.setAccessible(true); field.set(defaultMQAdminExt, defaultMQAdminExtImpl); field = MonitorService.class.getDeclaredField("defaultMQAdminExt"); field.setAccessible(true); field.set(monitorService, defaultMQAdminExt); field = MonitorService.class.getDeclaredField("defaultMQPullConsumer"); field.setAccessible(true); field.set(monitorService, defaultMQPullConsumer); field = MonitorService.class.getDeclaredField("defaultMQPushConsumer"); field.setAccessible(true); field.set(monitorService, defaultMQPushConsumer); TopicList topicList = new TopicList(); Set<String> topicSet = new HashSet<>(); topicSet.add("topic_one"); topicSet.add("topic_two"); topicList.setTopicList(topicSet); when(mQClientAPIImpl.getTopicListFromNameServer(anyLong())).thenReturn(topicList); TopicRouteData topicRouteData = new TopicRouteData(); List<BrokerData> brokerDatas = new ArrayList<>(); HashMap<Long, String> brokerAddrs = new HashMap<>(); brokerAddrs.put(1234l, "127.0.0.1:10911"); BrokerData brokerData = new BrokerData(); brokerData.setCluster("default-cluster"); brokerData.setBrokerName("default-broker"); brokerData.setBrokerAddrs(brokerAddrs); brokerDatas.add(brokerData); topicRouteData.setBrokerDatas(brokerDatas); topicRouteData.setQueueDatas(new ArrayList<QueueData>()); topicRouteData.setFilterServerTable(new HashMap<String, List<String>>()); when(mQClientAPIImpl.getTopicRouteInfoFromNameServer(anyString(), anyLong())).thenReturn(topicRouteData); ConsumeStats consumeStats = new ConsumeStats(); consumeStats.setConsumeTps(1234); MessageQueue messageQueue = new MessageQueue(); OffsetWrapper offsetWrapper = new OffsetWrapper(); HashMap<MessageQueue, OffsetWrapper> stats = new HashMap<>(); stats.put(messageQueue, offsetWrapper); consumeStats.setOffsetTable(stats); when(mQClientAPIImpl.getConsumeStats(anyString(), anyString(), anyString(), anyLong())).thenReturn(consumeStats); ConsumerConnection consumerConnection = new ConsumerConnection(); consumerConnection.setConsumeType(ConsumeType.CONSUME_PASSIVELY); consumerConnection.setMessageModel(MessageModel.CLUSTERING); HashSet<Connection> connections = new HashSet<>(); Connection connection = new Connection(); connection.setClientId("client_id"); connection.setClientAddr("127.0.0.1:109111"); connection.setLanguage(LanguageCode.JAVA); connection.setVersion(MQVersion.Version.V4_0_0_SNAPSHOT.ordinal()); connections.add(connection); consumerConnection.setConnectionSet(connections); consumerConnection.setSubscriptionTable(new ConcurrentHashMap<String, SubscriptionData>()); consumerConnection.setConsumeFromWhere(ConsumeFromWhere.CONSUME_FROM_FIRST_OFFSET); when(mQClientAPIImpl.getConsumerConnectionList(anyString(), anyString(), anyLong())).thenReturn(consumerConnection); ConsumerRunningInfo consumerRunningInfo = new ConsumerRunningInfo(); consumerRunningInfo.setJstack("test"); consumerRunningInfo.setMqTable(new TreeMap<MessageQueue, ProcessQueueInfo>()); consumerRunningInfo.setStatusTable(new TreeMap<String, ConsumeStatus>()); consumerRunningInfo.setSubscriptionSet(new TreeSet<SubscriptionData>()); Properties properties = new Properties(); properties.put(ConsumerRunningInfo.PROP_CONSUME_TYPE, CONSUME_ACTIVELY); properties.put(ConsumerRunningInfo.PROP_CONSUMER_START_TIMESTAMP, System.currentTimeMillis()); consumerRunningInfo.setProperties(properties); when(mQClientAPIImpl.getConsumerRunningInfo(anyString(), anyString(), anyString(), anyBoolean(), anyLong())).thenReturn(consumerRunningInfo); }