@Test public void testAnalyzeSubscription(){ boolean result = ConsumerRunningInfo.analyzeSubscription(criTable); assertThat(result).isTrue(); }
public static boolean analyzeSubscription(final TreeMap<String, ConsumerRunningInfo> criTable) { ConsumerRunningInfo prev = criTable.firstEntry().getValue(); boolean push = false; { String property = prev.getProperties().getProperty(ConsumerRunningInfo.PROP_CONSUME_TYPE); if (property == null) { property = ((ConsumeType) prev.getProperties().get(ConsumerRunningInfo.PROP_CONSUME_TYPE)).name(); } push = ConsumeType.valueOf(property) == ConsumeType.CONSUME_PASSIVELY; } boolean startForAWhile = false; { String property = prev.getProperties().getProperty(ConsumerRunningInfo.PROP_CONSUMER_START_TIMESTAMP); if (property == null) { property = String.valueOf(prev.getProperties().get(ConsumerRunningInfo.PROP_CONSUMER_START_TIMESTAMP)); } startForAWhile = (System.currentTimeMillis() - Long.parseLong(property)) > (1000 * 60 * 2); } if (push && startForAWhile) { { Iterator<Entry<String, ConsumerRunningInfo>> it = criTable.entrySet().iterator(); while (it.hasNext()) { Entry<String, ConsumerRunningInfo> next = it.next(); ConsumerRunningInfo current = next.getValue(); boolean equals = current.getSubscriptionSet().equals(prev.getSubscriptionSet()); if (!equals) { return false; } prev = next.getValue(); } if (prev != null) { if (prev.getSubscriptionSet().isEmpty()) { return false; } } } } return true; }
ConsumerRunningInfo extends RemotingSerializable { public static boolean analyzeSubscription(final TreeMap<String, ConsumerRunningInfo> criTable) { ConsumerRunningInfo prev = criTable.firstEntry().getValue(); boolean push = false; { String property = prev.getProperties().getProperty(ConsumerRunningInfo.PROP_CONSUME_TYPE); if (property == null) { property = ((ConsumeType) prev.getProperties().get(ConsumerRunningInfo.PROP_CONSUME_TYPE)).name(); } push = ConsumeType.valueOf(property) == ConsumeType.CONSUME_PASSIVELY; } boolean startForAWhile = false; { String property = prev.getProperties().getProperty(ConsumerRunningInfo.PROP_CONSUMER_START_TIMESTAMP); if (property == null) { property = String.valueOf(prev.getProperties().get(ConsumerRunningInfo.PROP_CONSUMER_START_TIMESTAMP)); } startForAWhile = (System.currentTimeMillis() - Long.parseLong(property)) > (1000 * 60 * 2); } if (push && startForAWhile) { { Iterator<Entry<String, ConsumerRunningInfo>> it = criTable.entrySet().iterator(); while (it.hasNext()) { Entry<String, ConsumerRunningInfo> next = it.next(); ConsumerRunningInfo current = next.getValue(); boolean equals = current.getSubscriptionSet().equals(prev.getSubscriptionSet()); if (!equals) { return false; } prev = next.getValue(); } if (prev != null) { if (prev.getSubscriptionSet().isEmpty()) { return false; } } } } return true; } }
ConsumerRunningInfo extends RemotingSerializable { public static boolean analyzeSubscription(final TreeMap<String, ConsumerRunningInfo> criTable) { ConsumerRunningInfo prev = criTable.firstEntry().getValue(); boolean push = false; { String property = prev.getProperties().getProperty(ConsumerRunningInfo.PROP_CONSUME_TYPE); if (property == null) { property = ((ConsumeType) prev.getProperties().get(ConsumerRunningInfo.PROP_CONSUME_TYPE)).name(); } push = ConsumeType.valueOf(property) == ConsumeType.CONSUME_PASSIVELY; } boolean startForAWhile = false; { String property = prev.getProperties().getProperty(ConsumerRunningInfo.PROP_CONSUMER_START_TIMESTAMP); if (property == null) { property = String.valueOf(prev.getProperties().get(ConsumerRunningInfo.PROP_CONSUMER_START_TIMESTAMP)); } startForAWhile = (System.currentTimeMillis() - Long.parseLong(property)) > (1000 * 60 * 2); } if (push && startForAWhile) { { Iterator<Entry<String, ConsumerRunningInfo>> it = criTable.entrySet().iterator(); while (it.hasNext()) { Entry<String, ConsumerRunningInfo> next = it.next(); ConsumerRunningInfo current = next.getValue(); boolean equals = current.getSubscriptionSet().equals(prev.getSubscriptionSet()); if (!equals) { return false; } prev = next.getValue(); } if (prev != null) { if (prev.getSubscriptionSet().isEmpty()) { return false; } } } } return true; }  }
ConsumerRunningInfo extends RemotingSerializable { public static boolean analyzeSubscription(final TreeMap<String, ConsumerRunningInfo> criTable) { ConsumerRunningInfo prev = criTable.firstEntry().getValue(); boolean push = false; { String property = prev.getProperties().getProperty(ConsumerRunningInfo.PROP_CONSUME_TYPE); if (property == null) { property = ((ConsumeType) prev.getProperties().get(ConsumerRunningInfo.PROP_CONSUME_TYPE)).name(); } push = ConsumeType.valueOf(property) == ConsumeType.CONSUME_PASSIVELY; } boolean startForAWhile = false; { String property = prev.getProperties().getProperty(ConsumerRunningInfo.PROP_CONSUMER_START_TIMESTAMP); if (property == null) { property = String.valueOf(prev.getProperties().get(ConsumerRunningInfo.PROP_CONSUMER_START_TIMESTAMP)); } startForAWhile = (System.currentTimeMillis() - Long.parseLong(property)) > (1000 * 60 * 2); } if (push && startForAWhile) { { Iterator<Entry<String, ConsumerRunningInfo>> it = criTable.entrySet().iterator(); while (it.hasNext()) { Entry<String, ConsumerRunningInfo> next = it.next(); ConsumerRunningInfo current = next.getValue(); boolean equals = current.getSubscriptionSet().equals(prev.getSubscriptionSet()); if (!equals) { return false; } prev = next.getValue(); } if (prev != null) { if (prev.getSubscriptionSet().isEmpty()) { return false; } } } } return true; }  static boolean analyzeSubscription(final TreeMap<String/* clientId */, ConsumerRunningInfo> criTable); static boolean analyzeRebalance(final TreeMap<String/* clientId */, ConsumerRunningInfo> criTable); static String analyzeProcessQueue(final String clientId, ConsumerRunningInfo info); Properties getProperties(); void setProperties(Properties properties); TreeSet<SubscriptionData> getSubscriptionSet(); void setSubscriptionSet(TreeSet<SubscriptionData> subscriptionSet); TreeMap<MessageQueue, ProcessQueueInfo> getMqTable(); void setMqTable(TreeMap<MessageQueue, ProcessQueueInfo> mqTable); TreeMap<String, ConsumeStatus> getStatusTable(); void setStatusTable(TreeMap<String, ConsumeStatus> statusTable); String formatString(); String getJstack(); void setJstack(String jstack); }
ConsumerRunningInfo extends RemotingSerializable { public static boolean analyzeSubscription(final TreeMap<String, ConsumerRunningInfo> criTable) { ConsumerRunningInfo prev = criTable.firstEntry().getValue(); boolean push = false; { String property = prev.getProperties().getProperty(ConsumerRunningInfo.PROP_CONSUME_TYPE); if (property == null) { property = ((ConsumeType) prev.getProperties().get(ConsumerRunningInfo.PROP_CONSUME_TYPE)).name(); } push = ConsumeType.valueOf(property) == ConsumeType.CONSUME_PASSIVELY; } boolean startForAWhile = false; { String property = prev.getProperties().getProperty(ConsumerRunningInfo.PROP_CONSUMER_START_TIMESTAMP); if (property == null) { property = String.valueOf(prev.getProperties().get(ConsumerRunningInfo.PROP_CONSUMER_START_TIMESTAMP)); } startForAWhile = (System.currentTimeMillis() - Long.parseLong(property)) > (1000 * 60 * 2); } if (push && startForAWhile) { { Iterator<Entry<String, ConsumerRunningInfo>> it = criTable.entrySet().iterator(); while (it.hasNext()) { Entry<String, ConsumerRunningInfo> next = it.next(); ConsumerRunningInfo current = next.getValue(); boolean equals = current.getSubscriptionSet().equals(prev.getSubscriptionSet()); if (!equals) { return false; } prev = next.getValue(); } if (prev != null) { if (prev.getSubscriptionSet().isEmpty()) { return false; } } } } return true; }  static boolean analyzeSubscription(final TreeMap<String/* clientId */, ConsumerRunningInfo> criTable); static boolean analyzeRebalance(final TreeMap<String/* clientId */, ConsumerRunningInfo> criTable); static String analyzeProcessQueue(final String clientId, ConsumerRunningInfo info); Properties getProperties(); void setProperties(Properties properties); TreeSet<SubscriptionData> getSubscriptionSet(); void setSubscriptionSet(TreeSet<SubscriptionData> subscriptionSet); TreeMap<MessageQueue, ProcessQueueInfo> getMqTable(); void setMqTable(TreeMap<MessageQueue, ProcessQueueInfo> mqTable); TreeMap<String, ConsumeStatus> getStatusTable(); void setStatusTable(TreeMap<String, ConsumeStatus> statusTable); String formatString(); String getJstack(); void setJstack(String jstack); static final String PROP_NAMESERVER_ADDR; static final String PROP_THREADPOOL_CORE_SIZE; static final String PROP_CONSUME_ORDERLY; static final String PROP_CONSUME_TYPE; static final String PROP_CLIENT_VERSION; static final String PROP_CONSUMER_START_TIMESTAMP; }