alirezazamani commented on a change in pull request #834: Complete the Routing 
Table Provider for CustomizedView
URL: https://github.com/apache/helix/pull/834#discussion_r387345860
 
 

 ##########
 File path: 
helix-core/src/main/java/org/apache/helix/spectator/RoutingTableProvider.java
 ##########
 @@ -376,62 +610,158 @@ public Object removeRoutingTableChangeListener(
    * @return
    */
   public Collection<LiveInstance> getLiveInstances() {
-    return _routingTableRef.get().getLiveInstances();
+    String key = getRoutingTableKey();
+    return _routingTableRef.get(key).get().getLiveInstances();
+  }
+
+  public Collection<LiveInstance> getLiveInstances(PropertyType propertyType) {
+    String key = getRoutingTableKey(propertyType);
+    return _routingTableRef.get(key).get().getLiveInstances();
+  }
+
+  public Collection<LiveInstance> getLiveInstances(PropertyType propertyType, 
String type) {
+    String key = getRoutingTableKey(propertyType, type);
+    return _routingTableRef.get(key).get().getLiveInstances();
   }
 
   /**
    * Return all instance's config in this cluster.
    * @return
    */
   public Collection<InstanceConfig> getInstanceConfigs() {
-    return _routingTableRef.get().getInstanceConfigs();
+    String key = getRoutingTableKey();
+    return _routingTableRef.get(key).get().getInstanceConfigs();
+  }
+
+  public Collection<InstanceConfig> getInstanceConfigs(PropertyType 
propertyType) {
+    String key = getRoutingTableKey(propertyType);
+    return _routingTableRef.get(key).get().getInstanceConfigs();
+  }
+
+  public Collection<InstanceConfig> getInstanceConfigs(PropertyType 
propertyType, String type) {
+    String key = getRoutingTableKey(propertyType, type);
+    return _routingTableRef.get(key).get().getInstanceConfigs();
   }
 
   /**
    * Return names of all resources (shown in ExternalView) in this cluster.
    */
   public Collection<String> getResources() {
-    return _routingTableRef.get().getResources();
+    String key = getRoutingTableKey();
+    return _routingTableRef.get(key).get().getResources();
+  }
+
+  public Collection<String> getResources(PropertyType propertyType) {
+    String key = getRoutingTableKey(propertyType);
+    return _routingTableRef.get(key).get().getResources();
+  }
+
+  public Collection<String> getResources(PropertyType propertyType, String 
type) {
+    String key = getRoutingTableKey(propertyType, type);
+    return _routingTableRef.get(key).get().getResources();
+  }
+
+  /**
+   * Function that returns the key associated with the specific 
_routingTableRef
+   * @return
+   */
+  private String getRoutingTableKey() {
+    // Check whether there exist only one snapshot (_routingTableRef)
+    if (_routingTableRef.keySet().size() == 1) {
+      return _routingTableRef.keySet().iterator().next();
+    } else {
+      throw new HelixException("There is none or more than one 
RoutingTableSnapshot");
+    }
+  }
+
+  private String getRoutingTableKey(PropertyType propertyType) {
+    if (propertyType == PropertyType.CUSTOMIZEDVIEW) {
+      throw new HelixException("Specific type needs to be used for 
CUSTOMIZEDVIEW PropertyType");
+    } else {
+      return getRoutingTableKey(propertyType, null);
+    }
+  }
+
+  private String getRoutingTableKey(PropertyType propertyType, String 
aggregationType) {
+    if (propertyType == PropertyType.CUSTOMIZEDVIEW) {
+      if (aggregationType == null) {
 
 Review comment:
   Addressed.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to 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]

Reply via email to