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

    https://github.com/apache/helix/pull/31#discussion_r33892286
  
    --- Diff: 
helix-core/src/main/java/org/apache/helix/spectator/RoutingTableProvider.java 
---
    @@ -91,6 +160,52 @@ public RoutingTableProvider() {
         return instanceSet;
       }
     
    +  /**
    +   * returns all instances for all resources from {resource} group that 
are in a specific {state}
    +   *
    +   * @param resource
    +   * @param state
    +   * @param groupingEnabled
    +   *
    +   * @return empty list if there is no instance in a given state
    +   */
    +  public Set<InstanceConfig> getInstances(String resource, String state, 
boolean groupingEnabled) {
    +    if (!groupingEnabled) {
    +      return getInstances(resource, state);
    +    }
    +
    +    Set<InstanceConfig> instanceSet = null;
    +    RoutingTable _routingTable = _routingTableRef.get();
    +    ResourceGroupInfo resourceGroupInfo = 
_routingTable.getResourceGroup(resource);
    +    if (resourceGroupInfo != null) {
    +      instanceSet = resourceGroupInfo.getInstances(state);
    +    }
    +    if (instanceSet == null) {
    +      instanceSet = Collections.emptySet();
    +    }
    +    return instanceSet;
    +  }
    +
    +  public Set<InstanceConfig> getInstances(String resource, String state,
    +      List<String> resourceTags) {
    +    Set<InstanceConfig> instanceSet = null;
    --- End diff --
    
    Can you refactor these methods to increase the code reuse? They all seem to 
follow the same general pattern.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to