use of org.apache.helix.model.ParticipantHistory in project helix by apache.
the class ClusterDataCache method updateOfflineInstanceHistory.
private void updateOfflineInstanceHistory(HelixDataAccessor accessor) {
List<String> offlineNodes = new ArrayList<>(_instanceConfigMap.keySet());
offlineNodes.removeAll(_liveInstanceMap.keySet());
_instanceOfflineTimeMap = new HashMap<>();
for (String instance : offlineNodes) {
Builder keyBuilder = accessor.keyBuilder();
PropertyKey propertyKey = keyBuilder.participantHistory(instance);
ParticipantHistory history = accessor.getProperty(propertyKey);
if (history == null) {
history = new ParticipantHistory(instance);
}
if (history.getLastOfflineTime() == ParticipantHistory.ONLINE) {
history.reportOffline();
// persist history back to ZK.
if (!accessor.setProperty(propertyKey, history)) {
LOG.error("Fails to persist participant online history back to ZK!");
}
}
_instanceOfflineTimeMap.put(instance, history.getLastOfflineTime());
}
_updateInstanceOfflineTime = false;
}
use of org.apache.helix.model.ParticipantHistory in project helix by apache.
the class ParticipantManager method getHistory.
private ParticipantHistory getHistory() {
PropertyKey propertyKey = _keyBuilder.participantHistory(_instanceName);
ParticipantHistory history = _dataAccessor.getProperty(propertyKey);
if (history == null) {
history = new ParticipantHistory(_instanceName);
}
return history;
}
Aggregations