Github user bitblender commented on a diff in the pull request:
https://github.com/apache/drill/pull/921#discussion_r148669660
--- Diff:
exec/java-exec/src/main/java/org/apache/drill/exec/coord/zk/ZKClusterCoordinator.java
---
@@ -229,27 +272,52 @@ public DrillbitEndpoint
apply(ServiceInstance<DrillbitEndpoint> input) {
});
// set of newly dead bits : original bits - new set of active bits.
- Set<DrillbitEndpoint> unregisteredBits = new HashSet<>(endpoints);
- unregisteredBits.removeAll(newDrillbitSet);
-
+ Set<DrillbitEndpoint> unregisteredBits = new HashSet<>();
// Set of newly live bits : new set of active bits - original bits.
- Set<DrillbitEndpoint> registeredBits = new HashSet<>(newDrillbitSet);
- registeredBits.removeAll(endpoints);
-
- endpoints = newDrillbitSet;
+ Set<DrillbitEndpoint> registeredBits = new HashSet<>();
+ // Update the endpoints map with change in state of the endpoint or
with the addition
+ // of new drillbit endpoints. Registered endpoints is set to newly
live drillbit endpoints.
+ for ( DrillbitEndpoint endpoint : newDrillbitSet) {
+ if (endpointsMap.containsKey(new
MultiKey(endpoint.getAddress(),endpoint.getUserPort()))) {
--- End diff --
I would recommend extracting endpoint.getAddress() and
endpoint.getUserPort() into locals
---