@Test public void testTranslateToIntGroupId() throws Exception { assertEquals(1, m_metaService.translateToIntGroupId("test_broker", "group1")); assertEquals(2, m_metaService.translateToIntGroupId("test_broker", "group2")); assertEquals(3, m_metaService.translateToIntGroupId("test_broker", "group3")); try { m_metaService.translateToIntGroupId("topic_not_found", "group3"); fail(); } catch (RuntimeException e) { } catch (Exception e) { fail(); } try { m_metaService.translateToIntGroupId("test_broker", "group_not_found"); fail(); } catch (RuntimeException e) { } catch (Exception e) { fail(); } }
@Override public int translateToIntGroupId(String topicName, String groupName) { Topic topic = findTopic(topicName, getMeta()); if (containsConsumerGroup(topicName, groupName)) { ConsumerGroup consumerGroup = topic.findConsumerGroup(groupName); return consumerGroup.getId(); } else { throw new RuntimeException(String.format("Consumer group not found for topic %s and group %s", topicName, groupName)); } }
DefaultMetaService implements MetaService, Initializable { @Override public int translateToIntGroupId(String topicName, String groupName) { Topic topic = findTopic(topicName, getMeta()); if (containsConsumerGroup(topicName, groupName)) { ConsumerGroup consumerGroup = topic.findConsumerGroup(groupName); return consumerGroup.getId(); } else { throw new RuntimeException(String.format("Consumer group not found for topic %s and group %s", topicName, groupName)); } } }
DefaultMetaService implements MetaService, Initializable { @Override public int translateToIntGroupId(String topicName, String groupName) { Topic topic = findTopic(topicName, getMeta()); if (containsConsumerGroup(topicName, groupName)) { ConsumerGroup consumerGroup = topic.findConsumerGroup(groupName); return consumerGroup.getId(); } else { throw new RuntimeException(String.format("Consumer group not found for topic %s and group %s", topicName, groupName)); } }  }
DefaultMetaService implements MetaService, Initializable { @Override public int translateToIntGroupId(String topicName, String groupName) { Topic topic = findTopic(topicName, getMeta()); if (containsConsumerGroup(topicName, groupName)) { ConsumerGroup consumerGroup = topic.findConsumerGroup(groupName); return consumerGroup.getId(); } else { throw new RuntimeException(String.format("Consumer group not found for topic %s and group %s", topicName, groupName)); } }  @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 int translateToIntGroupId(String topicName, String groupName) { Topic topic = findTopic(topicName, getMeta()); if (containsConsumerGroup(topicName, groupName)) { ConsumerGroup consumerGroup = topic.findConsumerGroup(groupName); return consumerGroup.getId(); } else { throw new RuntimeException(String.format("Consumer group not found for topic %s and group %s", topicName, groupName)); } }  @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();  }