Github user bitblender commented on a diff in the pull request:

    https://github.com/apache/drill/pull/921#discussion_r148685835
  
    --- 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()))) {
    +          endpointsMap.put(new 
MultiKey(endpoint.getAddress(),endpoint.getUserPort()),endpoint);
    +        }
    +        else {
    +          registeredBits.add(endpoint);
    +          endpointsMap.put(new 
MultiKey(endpoint.getAddress(),endpoint.getUserPort()),endpoint);
    +        }
    +      }
    +//      Iterator<MultiKey> iterator = endpointsMap.keySet().iterator() ;
    +//      while(iterator.hasNext()) {
    +//        MultiKey key = iterator.next();
    +//        if(!newDrillbitSet.contains(endpointsMap.get(key))) {
    +//          unregisteredBits.add(endpointsMap.get(key));
    +//          iterator.remove();
    +//        }
    +//      }
    +
    +//       Remove all the endpoints that are newly dead
    +      for ( MultiKey key: endpointsMap.keySet())
    +      {
    --- End diff --
    
    open-brace placement for the for-loop is inconsistent with other instances


---

Reply via email to