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



##########
File path: 
helix-core/src/main/java/org/apache/helix/controller/dataproviders/BaseControllerDataProvider.java
##########
@@ -728,6 +756,41 @@ private void updateDisabledInstances() {
     }
   }
 
+  /*
+   * Check if the instance is timed-out during maintenance mode. An instance 
is timed-out if it has
+   * been offline for longer than the user defined timeout window.
+   * @param timeOutWindow - the timeout window; guaranteed to be non-negative
+   */
+  private boolean isInstanceTimedOutDuringMaintenance(HelixDataAccessor 
accessor, String instance,
+      long timeOutWindow) {
+    PropertyKey.Builder keyBuilder = accessor.keyBuilder();
+    PropertyKey propertyKey = keyBuilder.participantHistory(instance);
+    ParticipantHistory history = accessor.getProperty(propertyKey);
+
+    // Cannot use _instanceOfflineTimeMap. _instanceOfflineTimeMap is last 
updated in the previous
+    // pipeline execution; it is possible a new offline timestamp is updated 
after the previous
+    // pipeline execution, so we need the most updated timestamp.
+    long lastOfflineTime = history.getLastTimeInOfflineHistory();
+    // lastOfflineTime is only negative if there is no offline history or the 
time format is wrong.
+    // Since this instance is a 'new' live instance, not having offline 
history = first time created
+    // instance; during maintenance mode, no partition will be assigned to 
such a new instance,
+    // therefore it's okay to no time it out. The wrong format case shouldn't 
happen at all and will
+    // not be handled either.
+    if (lastOfflineTime < 0) {
+      return false;
+    }
+
+    long currentTime = System.currentTimeMillis();
+    if (currentTime - lastOfflineTime > timeOutWindow) {
+      LogUtil.logWarn(logger, getClusterEventId(), String.format(
+          "During maintenance mode, instance %s is timed-out due to its 
offline time. Current time: "

Review comment:
       Why is that? This calculation is only done during the maintenance mode. 




----------------------------------------------------------------
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]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to