lei-xia commented on a change in pull request #1413:
URL: https://github.com/apache/helix/pull/1413#discussion_r499821088
##########
File path:
helix-core/src/main/java/org/apache/helix/controller/dataproviders/BaseControllerDataProvider.java
##########
@@ -728,6 +782,100 @@ 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) {
+ ParticipantHistory history =
+
accessor.getProperty(accessor.keyBuilder().participantHistory(instance));
+ long currentTime = System.currentTimeMillis();
+
+ // Parse online timestamps from online list
+ List<Long> onlineTimestamps = new ArrayList<>();
+ List<String> historyOnlineList = history.getHistory();
+ if (historyOnlineList != null) {
+ long tailOnlineTime;
+ for (int i = historyOnlineList.size() - 1; i >= 0; i--) {
+ tailOnlineTime =
+
ParticipantHistory.extractTimeFromSessionHistoryString(historyOnlineList.get(i));
+ // Ignore bad format case
+ if (tailOnlineTime != -1) {
+ onlineTimestamps.add(0, tailOnlineTime);
+ // We only need one online timestamp before maintenance mode starts
+ if (tailOnlineTime <= _maintenanceSignal.getTimestamp()) {
+ break;
+ }
+ }
Review comment:
Can we wrap up the logic here into a method in ParticipantHistory, such
as getAllOnlineHistory()?
----------------------------------------------------------------
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]