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

    https://github.com/apache/drill/pull/921#discussion_r151003788
  
    --- Diff: 
exec/java-exec/src/main/java/org/apache/drill/exec/server/DrillbitContext.java 
---
    @@ -157,10 +157,29 @@ public DrillConfig getConfig() {
         return context.getConfig();
       }
     
    -  public Collection<DrillbitEndpoint> getBits() {
    +  public Collection<DrillbitEndpoint> getAvailableBits() {
         return coord.getAvailableEndpoints();
       }
     
    +  public Collection<DrillbitEndpoint> getBits() {
    +    return coord.getOnlineEndPoints();
    +  }
    +  
    +  public boolean isOnline(DrillbitEndpoint endpoint) { return 
endpoint.getState().equals(DrillbitEndpoint.State.ONLINE); }
    +
    +  public boolean isForemanOnline() {
    +    DrillbitEndpoint foreman = getEndpoint();
    +    Collection<DrillbitEndpoint> dbs = getAvailableBits();
    +    for( DrillbitEndpoint db : dbs) {
    +      if( db.getAddress().equals(foreman.getAddress()) && db.getUserPort() 
== foreman.getUserPort()) {
    --- End diff --
    
    Can you please explain the logic in isForemanOnline(). Why do you have to 
get the list of endpoints from ZK and then check for foreman in that list 
before making the isOnline test ? Why can't it be done on the foreman object? 
Is this to make sure that the state is updated in ZK before refusing to take 
queries ?
    Why do you assume that the foreman is online if the foreman is not found in 
the list of endPoints? 
    i.e. if it is not in the dbs list
    why do you return true in that case ?


---

Reply via email to