You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@helix.apache.org by GitBox <gi...@apache.org> on 2020/09/25 23:07:37 UTC

[GitHub] [helix] NealSun96 commented on a change in pull request #1413: Feature: Offline Node Timeout During Maintenance Mode

NealSun96 commented on a change in pull request #1413:
URL: https://github.com/apache/helix/pull/1413#discussion_r495305614



##########
File path: helix-core/src/main/java/org/apache/helix/controller/dataproviders/BaseControllerDataProvider.java
##########
@@ -253,9 +254,34 @@ private void refreshIdealState(final HelixDataAccessor accessor,
   private void refreshLiveInstances(final HelixDataAccessor accessor,
       Set<HelixConstants.ChangeType> refreshedType) {
     if (_propertyDataChangedMap.get(HelixConstants.ChangeType.LIVE_INSTANCE).getAndSet(false)) {
+      // Keep a copy of old live instances in case of maintenance mode
+      Map<String, LiveInstance> oldLiveInstances = getLiveInstances();
       _liveInstanceCache.refresh(accessor);
       _updateInstanceOfflineTime = true;
       refreshedType.add(HelixConstants.ChangeType.LIVE_INSTANCE);
+
+      // If maintenance mode is enabled and timeout window is specified, filter 'new' live nodes
+      // for timed-out nodes
+      long timeOutWindow = _clusterConfig.getMaintenanceOfflineNodeTimeOut();
+      if (timeOutWindow >= 0 && isMaintenanceModeEnabled()) {
+        for (String instance : _liveInstanceCache.getPropertyMap().keySet()) {
+          // For every 'new' live node, check if it's timed-out
+          if (!oldLiveInstances.containsKey(instance) && isInstanceTimedOutDuringMaintenance(

Review comment:
       It needs to be here. The reason is that we need the old snapshot; see line 258. Once refresh happens, the old snapshot will be lost, and we wouldn't be able to compute the 'new' live nodes delta. 
   
   In terms of history update, it's updateOfflineInstanceHistory() down below. You can see that I also handled that case. 




----------------------------------------------------------------
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org