egor-ryashin commented on a change in pull request #6606: Simplify
DruidNodeDiscoveryProvider; add
DruidNodeDiscovery.Listener.nodeViewInitialized()
URL: https://github.com/apache/incubator-druid/pull/6606#discussion_r237251792
##########
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:
`Currently it's just nodeTypesToWatch.size() passed, hard to imagine how a
mistake could be made.` Instead of one line someone should check two lines of
code. Further on, those lines can be separated into different methods.
Moreover, I think, if something can be done automatically it should be done
that way.
And I don't see a good separation of concern here, it creates a possible
situation when you add 2 listeners, but can specify in the constructor 1 as
types count, does that makes sense at all?
----------------------------------------------------------------
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]