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_r395358837
##########
File path:
helix-core/src/main/java/org/apache/helix/spectator/RoutingTableProvider.java
##########
@@ -376,50 +658,131 @@ public Object removeRoutingTableChangeListener(
* @return
*/
public Collection<LiveInstance> getLiveInstances() {
- return _routingTableRef.get().getLiveInstances();
+ // Since line instances will be the same across all _routingTableRefMap,
here one of the keys
+ // will be used without considering PropertyType
+ // TODO each table will keep a separate instance list.This can be improve
by only keeping one copy of the data
+ String key = null;
+ Iterator<String> iter = _routingTableRefMap.keySet().iterator();
+ if (iter.hasNext()) {
+ key = iter.next();
+ }
+ if (key == null) {
+ throw new HelixException("There is no key available in this
RoutingTableProvider.");
+ }
+ return _routingTableRefMap.get(key).get().getLiveInstances();
}
/**
* Return all instance's config in this cluster.
* @return
*/
public Collection<InstanceConfig> getInstanceConfigs() {
- return _routingTableRef.get().getInstanceConfigs();
+ // Since line instances will be the same across all _routingTableRefMap,
here one of the keys
+ // will be used without considering PropertyType
+ // TODO each table will keep a separate instance list.This can be improve
by only keeping one copy of the data
+ String key = null;
+ Iterator<String> iter = _routingTableRefMap.keySet().iterator();
+ if (iter.hasNext()) {
+ key = iter.next();
+ }
+ if (key == null) {
+ throw new HelixException("There is no key available in this
RoutingTableProvider.");
+ }
+ return _routingTableRefMap.get(key).get().getInstanceConfigs();
}
/**
- * Return names of all resources (shown in ExternalView) in this cluster.
+ * Return names of all resources (shown in ExternalView or CustomizedView)
in this cluster.
*/
public Collection<String> getResources() {
- return _routingTableRef.get().getResources();
+ String key = getRoutingTableKey(DEFAULT_PROPERTY_TYPE, DEFAULT_STATE_TYPE);
+ return _routingTableRefMap.get(key).get().getResources();
+ }
+
+ /**
+ * For specific RoutingTable associated with {propertyType, stateType}
+ * Return names of all resources (shown in ExternalView or CustomizedView)
in this cluster.
+ * @param propertyType
+ * @param stateType
+ * @return
+ */
+ public Collection<String> getResources(PropertyType propertyType, String
stateType) {
+ String key = getRoutingTableKey(propertyType.name(), stateType);
+ return _routingTableRefMap.get(key).get().getResources();
+ }
+
+ /**
+ * Provide the key associated with specific PropertyType and StateType for
_routingTableRefMap lookup.
+ * @param propertyTypeName
+ * @param stateType
+ * @return
+ */
+ private String getRoutingTableKey(String propertyTypeName, String stateType)
{
Review comment:
Done.
----------------------------------------------------------------
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]