@Test public void clusterNodeChangeTest() { Assert.assertEquals(null, clusterNameServiceStub.getTopicConfig(TopicName.parse("test0"))); Assert.assertEquals(-1, (int) clusterNameServiceStub.getTopicConfig(TopicName.parse("test1")).getPartitionGroups().get(0).getLeader()); brokerEventBusStub.publishEvent(new StoreNodeChangeEvent("test1", 0, new StoreNodes(new StoreNode(1, false, true)))); Assert.assertEquals(-1, (int) clusterNameServiceStub.getTopicConfig(TopicName.parse("test1")).getPartitionGroups().get(0).getLeader()); brokerEventBusStub.publishEvent(new StoreNodeChangeEvent("test1", 0, new StoreNodes(new StoreNode(1, true, true)))); Assert.assertEquals(1, (int) clusterNameServiceStub.getTopicConfig(TopicName.parse("test1")).getPartitionGroups().get(0).getLeader()); propertySupplierMap.put(ClusterConfigKey.GET_TOPIC_DYNAMIC_ENABLE.getName(), false); Assert.assertEquals(-1, (int) clusterNameServiceStub.getTopicConfig(TopicName.parse("test1")).getPartitionGroups().get(0).getLeader()); propertySupplierMap.put(ClusterConfigKey.GET_TOPIC_DYNAMIC_ENABLE.getName(), true); PartitionGroup newPartitionGroup = clusterNameServiceStub.getTopicConfig(TopicName.parse("test1")).getPartitionGroups().get(0).clone(); newPartitionGroup.getReplicas().remove(1); nameServiceStub.addEvent(new NameServerEvent(new UpdatePartitionGroupEvent(TopicName.parse("test1"), clusterNameServiceStub.getTopicConfig(TopicName.parse("test1")).getPartitionGroups().get(0), newPartitionGroup), null)); Assert.assertEquals(-1, (int) clusterNameServiceStub.getTopicConfig(TopicName.parse("test1")).getPartitionGroups().get(0).getLeader()); newPartitionGroup.getReplicas().add(1); nameServiceStub.addEvent(new NameServerEvent(new UpdatePartitionGroupEvent(TopicName.parse("test1"), clusterNameServiceStub.getTopicConfig(TopicName.parse("test1")).getPartitionGroups().get(0), newPartitionGroup), null)); brokerEventBusStub.publishEvent(new StoreNodeChangeEvent("test1", 0, new StoreNodes(new StoreNode(1, true, true)))); Assert.assertEquals(1, (int) clusterNameServiceStub.getTopicConfig(TopicName.parse("test1")).getPartitionGroups().get(0).getLeader()); nameServiceStub.addEvent(new NameServerEvent(new RemovePartitionGroupEvent(TopicName.parse("test1"), clusterNameServiceStub.getTopicConfig(TopicName.parse("test1")).getPartitionGroups().get(0)), null)); Assert.assertEquals(-1, (int) clusterNameServiceStub.getTopicConfig(TopicName.parse("test1")).getPartitionGroups().get(0).getLeader()); }
public TopicConfig getTopicConfig(TopicName topicName) { TopicConfig topicConfig = nameService.getTopicConfig(topicName); if (topicConfig == null) { return null; } return doGetTopicConfig(topicConfig); }
ClusterNameService extends Service { public TopicConfig getTopicConfig(TopicName topicName) { TopicConfig topicConfig = nameService.getTopicConfig(topicName); if (topicConfig == null) { return null; } return doGetTopicConfig(topicConfig); } }
ClusterNameService extends Service { public TopicConfig getTopicConfig(TopicName topicName) { TopicConfig topicConfig = nameService.getTopicConfig(topicName); if (topicConfig == null) { return null; } return doGetTopicConfig(topicConfig); } ClusterNameService(NameService nameService, BrokerEventBus eventBus, PropertySupplier propertySupplier); }
ClusterNameService extends Service { public TopicConfig getTopicConfig(TopicName topicName) { TopicConfig topicConfig = nameService.getTopicConfig(topicName); if (topicConfig == null) { return null; } return doGetTopicConfig(topicConfig); } ClusterNameService(NameService nameService, BrokerEventBus eventBus, PropertySupplier propertySupplier); void setBroker(Broker broker); ClusterNode getTopicGroupNode(TopicName topicName, int group); ClusterNode getTopicGroupNode(String topic, int group); Map<TopicName, TopicConfig> getTopicConfigByApp(String subscribeApp, Subscription.Type subscribe); Map<String, TopicConfig> getTopicConfigs(List<String> topics); TopicConfig getTopicConfig(TopicName topicName); TopicConfig doGetTopicConfig(TopicConfig topicConfig); NameService getNameService(); }
ClusterNameService extends Service { public TopicConfig getTopicConfig(TopicName topicName) { TopicConfig topicConfig = nameService.getTopicConfig(topicName); if (topicConfig == null) { return null; } return doGetTopicConfig(topicConfig); } ClusterNameService(NameService nameService, BrokerEventBus eventBus, PropertySupplier propertySupplier); void setBroker(Broker broker); ClusterNode getTopicGroupNode(TopicName topicName, int group); ClusterNode getTopicGroupNode(String topic, int group); Map<TopicName, TopicConfig> getTopicConfigByApp(String subscribeApp, Subscription.Type subscribe); Map<String, TopicConfig> getTopicConfigs(List<String> topics); TopicConfig getTopicConfig(TopicName topicName); TopicConfig doGetTopicConfig(TopicConfig topicConfig); NameService getNameService();  }