use of com.iplanet.dpro.session.service.cluster.ClusterMonitor in project OpenAM by OpenRock.
the class SessionService method getClusterMonitor.
/**
* The ClusterMonitor state depends on whether the system is configured for
* SFO or not. As such, this method is aware of the change in SFO state
* and triggers a re-initialisation of the ClusterMonitor as required.
*
* Note, this method also acts as the lazy initialiser for the ClusterMonitor.
*
* Thread Safety: Uses atomic reference to ensure only one thread can modify
* the reference at any one time.
*
* @return A non null instance of the current ClusterMonitor.
* @throws SessionException If there was an error initialising the ClusterMonitor.
*/
private ClusterMonitor getClusterMonitor() throws SessionException {
if (!isClusterMonitorValid()) {
try {
ClusterMonitor previous = clusterMonitor.getAndSet(resolveClusterMonitor());
if (previous != null) {
sessionDebug.message("Previous ClusterMonitor shutdown: {}", previous.getClass().getSimpleName());
previous.shutdown();
}
sessionDebug.message("ClusterMonitor initialised: {}", clusterMonitor.get().getClass().getSimpleName());
} catch (Exception e) {
sessionDebug.error("Failed to initialise ClusterMonitor", e);
}
}
ClusterMonitor monitor = clusterMonitor.get();
if (monitor == null) {
throw new SessionException("Failed to initialise ClusterMonitor");
}
return monitor;
}
Aggregations