jiajunwang commented on a change in pull request #834: Complete the Routing
Table Provider for CustomizedView
URL: https://github.com/apache/helix/pull/834#discussion_r392535936
##########
File path:
helix-core/src/main/java/org/apache/helix/spectator/RoutingTableProvider.java
##########
@@ -529,68 +791,95 @@ private void
updateCurrentStatesListeners(List<LiveInstance> liveInstances,
private void reset() {
logger.info("Resetting the routing table.");
- RoutingTable newRoutingTable = new RoutingTable();
- _routingTableRef.set(newRoutingTable);
+ for (String key: _routingTableRefMap.keySet()) {
+ PropertyType propertyType =
_routingTableRefMap.get(key).get().getPropertyType();
+ if (propertyType == PropertyType.CUSTOMIZEDVIEW) {
+ String type =
_routingTableRefMap.get(key).get().getCustomizedStateType();
+ RoutingTable newRoutingTable = new
CustomizedViewRoutingTable(propertyType, type);
+ _routingTableRefMap.get(key).set(newRoutingTable);
+ } else {
+ RoutingTable newRoutingTable = new RoutingTable(propertyType);
+ _routingTableRefMap.get(key).set(newRoutingTable);
+ }
+ }
}
- protected void refresh(List<ExternalView> externalViewList,
NotificationContext changeContext) {
+ protected void refresh(List<ExternalView> externalViewList,
+ List<CustomizedView> customizedViewList, NotificationContext
changeContext,
+ String referenceKey) {
HelixDataAccessor accessor =
changeContext.getManager().getHelixDataAccessor();
PropertyKey.Builder keyBuilder = accessor.keyBuilder();
List<InstanceConfig> configList =
accessor.getChildValues(keyBuilder.instanceConfigs());
List<LiveInstance> liveInstances =
accessor.getChildValues(keyBuilder.liveInstances());
- refresh(externalViewList, configList, liveInstances);
+ refresh(externalViewList, customizedViewList, configList, liveInstances,
referenceKey);
}
protected void refresh(Collection<ExternalView> externalViews,
- Collection<InstanceConfig> instanceConfigs, Collection<LiveInstance>
liveInstances) {
+ Collection<CustomizedView> customizedViews, Collection<InstanceConfig>
instanceConfigs,
+ Collection<LiveInstance> liveInstances, String referenceKey) {
long startTime = System.currentTimeMillis();
- RoutingTable newRoutingTable = new RoutingTable(externalViews,
instanceConfigs, liveInstances);
- resetRoutingTableAndNotify(startTime, newRoutingTable);
+ PropertyType propertyType =
_routingTableRefMap.get(referenceKey).get().getPropertyType();
+ if (propertyType == PropertyType.CUSTOMIZEDVIEW) {
+ String customizedStateType =
_routingTableRefMap.get(referenceKey).get().getCustomizedStateType();
+ RoutingTable newRoutingTable = new
CustomizedViewRoutingTable(customizedViews,
+ instanceConfigs, liveInstances, propertyType, customizedStateType);
+ resetRoutingTableAndNotify(startTime, newRoutingTable, referenceKey);
+ } else {
+ RoutingTable newRoutingTable = new RoutingTable(externalViews,
instanceConfigs,
+ liveInstances, propertyType);
+ resetRoutingTableAndNotify(startTime, newRoutingTable, referenceKey);
+ }
}
protected void refresh(Map<String, Map<String, Map<String, CurrentState>>>
currentStateMap,
- Collection<InstanceConfig> instanceConfigs, Collection<LiveInstance>
liveInstances) {
+ Collection<InstanceConfig> instanceConfigs, Collection<LiveInstance>
liveInstances,
+ String referenceKey) {
long startTime = System.currentTimeMillis();
RoutingTable newRoutingTable =
new RoutingTable(currentStateMap, instanceConfigs, liveInstances);
- resetRoutingTableAndNotify(startTime, newRoutingTable);
+ resetRoutingTableAndNotify(startTime, newRoutingTable, referenceKey);
Review comment:
Isn't is fixed for current state? Why need to pass it in?
----------------------------------------------------------------
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]