leventov commented on a change in pull request #6606: Simplify 
DruidNodeDiscoveryProvider; add 
DruidNodeDiscovery.Listener.nodeViewInitialized()
URL: https://github.com/apache/incubator-druid/pull/6606#discussion_r237253644
 
 

 ##########
 File path: 
server/src/main/java/org/apache/druid/discovery/DruidNodeDiscoveryProvider.java
 ##########
 @@ -66,10 +65,11 @@ public DruidNodeDiscovery getForService(String serviceName)
           if (nodeTypesToWatch == null) {
             throw new IAE("Unknown service [%s].", service);
           }
-
-          ServiceDruidNodeDiscovery serviceDiscovery = new 
ServiceDruidNodeDiscovery(service);
+          ServiceDruidNodeDiscovery serviceDiscovery = new 
ServiceDruidNodeDiscovery(service, nodeTypesToWatch.size());
+          DruidNodeDiscovery.Listener filteringGatheringUpstreamListener =
+              serviceDiscovery.filteringUpstreamListener();
           for (NodeType nodeType : nodeTypesToWatch) {
-            
getForNodeType(nodeType).registerListener(serviceDiscovery.nodeTypeListener());
+            
getForNodeType(nodeType).registerListener(filteringGatheringUpstreamListener);
           }
 
 Review comment:
   I don't understand about what one like you are talking here. I spent 
literally several hours wrapping my head around the former code.
   
   You cannot just increment the `uninitializedNodeTypes` counter each time 
`registerListener()` is called, because this class it exposed to third-party 
users via `getForService()` method and they could add their own listeners. The 
initialization setup happens in `serviceDiscoveryMap.computeIfAbsent()` lambda 
and it set the fixed number of `uninitializedNodeTypes`.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to