@Test public void testListTopicsByPattern() { DefaultMetaService ms = new DefaultMetaService(); assertTrue(ms.isTopicMatch("a", "a")); assertTrue(ms.isTopicMatch("a.b", "a.b")); assertTrue(ms.isTopicMatch("a.b.c", "a.b.c")); assertTrue(ms.isTopicMatch("a.*", "a.bbb")); assertFalse(ms.isTopicMatch("a.*", "a")); assertFalse(ms.isTopicMatch("a.*", "a.b.c")); assertTrue(ms.isTopicMatch("a.#", "a.b")); assertFalse(ms.isTopicMatch("a.#", "a")); assertTrue(ms.isTopicMatch("a.#", "a.bbb")); assertTrue(ms.isTopicMatch("a.#", "a.bbb.ccc")); assertTrue(ms.isTopicMatch("a.*.c", "a.bbb.c")); assertFalse(ms.isTopicMatch("a.*.c", "a.bbb.xxx.c")); assertTrue(ms.isTopicMatch("a.#.c", "a.bbb.c")); assertTrue(ms.isTopicMatch("a.#.c", "a.bbb.xxx.c")); assertFalse(ms.isTopicMatch("a.#.c", "a.bbb.d")); assertFalse(ms.isTopicMatch("a.#.c", "a.bbb.xxx.d")); assertTrue(ms.isTopicMatch("a.*.c", "a.b--c.c")); assertTrue(ms.isTopicMatch("a.#.c", "a.b-c.d-d.c")); assertTrue(ms.isTopicMatch("a.#.c", "a.b-c..c")); assertFalse(ms.isTopicMatch("a.*.c", "a.b-c.dd.c")); assertFalse(ms.isTopicMatch("a.#.c", "a.b-c.d-d.d")); assertFalse(ms.isTopicMatch("a.#.c", "a.b-c..d")); }
@Override public List<Topic> listTopicsByPattern(String topicPattern) { if (StringUtils.isBlank(topicPattern)) { throw new RuntimeException("Topic pattern can not be null or blank"); } topicPattern = StringUtils.trim(topicPattern); Meta meta = getMeta(); List<Topic> matchedTopics = new ArrayList<Topic>(); Collection<Topic> topics = meta.getTopics().values(); for (Topic topic : topics) { if (isTopicMatch(topicPattern, topic.getName())) { matchedTopics.add(topic); } } return matchedTopics; }
DefaultMetaService implements MetaService, Initializable { @Override public List<Topic> listTopicsByPattern(String topicPattern) { if (StringUtils.isBlank(topicPattern)) { throw new RuntimeException("Topic pattern can not be null or blank"); } topicPattern = StringUtils.trim(topicPattern); Meta meta = getMeta(); List<Topic> matchedTopics = new ArrayList<Topic>(); Collection<Topic> topics = meta.getTopics().values(); for (Topic topic : topics) { if (isTopicMatch(topicPattern, topic.getName())) { matchedTopics.add(topic); } } return matchedTopics; } }
DefaultMetaService implements MetaService, Initializable { @Override public List<Topic> listTopicsByPattern(String topicPattern) { if (StringUtils.isBlank(topicPattern)) { throw new RuntimeException("Topic pattern can not be null or blank"); } topicPattern = StringUtils.trim(topicPattern); Meta meta = getMeta(); List<Topic> matchedTopics = new ArrayList<Topic>(); Collection<Topic> topics = meta.getTopics().values(); for (Topic topic : topics) { if (isTopicMatch(topicPattern, topic.getName())) { matchedTopics.add(topic); } } return matchedTopics; }  }
DefaultMetaService implements MetaService, Initializable { @Override public List<Topic> listTopicsByPattern(String topicPattern) { if (StringUtils.isBlank(topicPattern)) { throw new RuntimeException("Topic pattern can not be null or blank"); } topicPattern = StringUtils.trim(topicPattern); Meta meta = getMeta(); List<Topic> matchedTopics = new ArrayList<Topic>(); Collection<Topic> topics = meta.getTopics().values(); for (Topic topic : topics) { if (isTopicMatch(topicPattern, topic.getName())) { matchedTopics.add(topic); } } return matchedTopics; }  @Override List<Partition> listPartitionsByTopic(String topicName); @Override Storage findStorageByTopic(String topicName); @Override Partition findPartitionByTopicAndPartition(String topicName, int partitionId); @Override List<Topic> listTopicsByPattern(String topicPattern); @Override Topic findTopicByName(String topicName); @Override int translateToIntGroupId(String topicName, String groupName); @Override List<Datasource> listAllMysqlDataSources(); @Override int getAckTimeoutSecondsByTopicAndConsumerGroup(String topicName, String groupId); @Override LeaseAcquireResponse tryAcquireConsumerLease(Tpg tpg, String sessionId); @Override LeaseAcquireResponse tryRenewConsumerLease(Tpg tpg, Lease lease, String sessionId); @Override LeaseAcquireResponse tryRenewBrokerLease(String topic, int partition, Lease lease, String sessionId,
	      int brokerPort); @Override LeaseAcquireResponse tryAcquireBrokerLease(String topic, int partition, String sessionId, int brokerPort); @Override void initialize(); @Override synchronized Pair<Endpoint, Long> findEndpointByTopicAndPartition(String topic, int partition); @Override RetryPolicy findRetryPolicyByTopicAndGroup(String topicName, String groupId); @Override boolean containsEndpoint(Endpoint endpoint); @Override boolean containsConsumerGroup(String topicName, String groupId); @Override Offset findMessageOffsetByTime(String topic, int partition, long time); @Override Map<Integer, Offset> findMessageOffsetByTime(String topic, long time); @Override List<ZookeeperEnsemble> listAllZookeeperEnsemble(); @Override Idc getPrimaryIdc(); }
DefaultMetaService implements MetaService, Initializable { @Override public List<Topic> listTopicsByPattern(String topicPattern) { if (StringUtils.isBlank(topicPattern)) { throw new RuntimeException("Topic pattern can not be null or blank"); } topicPattern = StringUtils.trim(topicPattern); Meta meta = getMeta(); List<Topic> matchedTopics = new ArrayList<Topic>(); Collection<Topic> topics = meta.getTopics().values(); for (Topic topic : topics) { if (isTopicMatch(topicPattern, topic.getName())) { matchedTopics.add(topic); } } return matchedTopics; }  @Override List<Partition> listPartitionsByTopic(String topicName); @Override Storage findStorageByTopic(String topicName); @Override Partition findPartitionByTopicAndPartition(String topicName, int partitionId); @Override List<Topic> listTopicsByPattern(String topicPattern); @Override Topic findTopicByName(String topicName); @Override int translateToIntGroupId(String topicName, String groupName); @Override List<Datasource> listAllMysqlDataSources(); @Override int getAckTimeoutSecondsByTopicAndConsumerGroup(String topicName, String groupId); @Override LeaseAcquireResponse tryAcquireConsumerLease(Tpg tpg, String sessionId); @Override LeaseAcquireResponse tryRenewConsumerLease(Tpg tpg, Lease lease, String sessionId); @Override LeaseAcquireResponse tryRenewBrokerLease(String topic, int partition, Lease lease, String sessionId,
	      int brokerPort); @Override LeaseAcquireResponse tryAcquireBrokerLease(String topic, int partition, String sessionId, int brokerPort); @Override void initialize(); @Override synchronized Pair<Endpoint, Long> findEndpointByTopicAndPartition(String topic, int partition); @Override RetryPolicy findRetryPolicyByTopicAndGroup(String topicName, String groupId); @Override boolean containsEndpoint(Endpoint endpoint); @Override boolean containsConsumerGroup(String topicName, String groupId); @Override Offset findMessageOffsetByTime(String topic, int partition, long time); @Override Map<Integer, Offset> findMessageOffsetByTime(String topic, long time); @Override List<ZookeeperEnsemble> listAllZookeeperEnsemble(); @Override Idc getPrimaryIdc();  }