Package com.tangosol.net
Class SimpleServiceMonitor
java.lang.Object
com.tangosol.net.SimpleServiceMonitor
- All Implemented Interfaces:
 Disposable,ServiceMonitor,AutoCloseable
The 
SimpleServiceMonitor starts and monitors services that are
 registered for monitoring.- Since:
 - Coherence 12.1.2
 - Author:
 - cf 2011.05.24, hr 2012.06.28, gh 2022.11.22
 
- 
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final IntegerThe default time interval by which we check the alive status.protected ConfigurableCacheFactoryAConfigurableCacheFactoryinstance used to start the service.protected final longThe number of milliseconds between checking the status of the services.protected booleanIndicates that thisServiceMonitorhas been disposed.protected booleanIndicates that theServiceMonitorhas started.A map ofServices to be monitored with values being non-scoped service names.protected ThreadTheThreadwe are using for monitoring the services periodically. - 
Constructor Summary
ConstructorsConstructorDescriptionConstruct a SimpleServiceMonitor with the default interval to check that the registered services are running (DEFAULT_WAIT_MILLIS).SimpleServiceMonitor(long cWaitMillis) Construct a SimpleServiceMonitor with the provided interval to check that the registered services are running. - 
Method Summary
Modifier and TypeMethodDescriptionprotected voidThrowsIllegalStateExceptionif this monitor has been disposed via invocation ofdispose().voiddispose()Invoked when all resources owned by the implementer can safely be released.Return the thread used by this ServiceMonitor.protected booleanReturn true if thisServiceMonitorhas been disposed via invocation ofdispose().booleanReturns true iff the ServiceMonitor is monitoring a number of services.protected voidmonitorServices(long cWaitMillis) Check the service status periodically (keep alive interval), restarting any stopped services.voidregisterServices(Map<Service, String> mapServices) Adds a set ofServices to be monitored providing life support.voidSet theConfigurableCacheFactoryaServiceMonitorcan operate with.protected voidstart()Start monitoring the services.voidStop monitoring all registered services.voidunregisterServices(Set<Service> setServices) Removes the supplied set ofServices from monitoring.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.oracle.coherence.common.base.Disposable
close 
- 
Field Details
- 
DEFAULT_WAIT_MILLIS
The default time interval by which we check the alive status. - 
m_fStarted
protected volatile boolean m_fStartedIndicates that theServiceMonitorhas started. - 
m_thread
TheThreadwe are using for monitoring the services periodically. - 
m_fDisposed
protected boolean m_fDisposedIndicates that thisServiceMonitorhas been disposed. - 
m_ccf
AConfigurableCacheFactoryinstance used to start the service. - 
m_mapServices
A map ofServices to be monitored with values being non-scoped service names. - 
m_cWaitMillis
protected final long m_cWaitMillisThe number of milliseconds between checking the status of the services. 
 - 
 - 
Constructor Details
- 
SimpleServiceMonitor
public SimpleServiceMonitor()Construct a SimpleServiceMonitor with the default interval to check that the registered services are running (DEFAULT_WAIT_MILLIS). - 
SimpleServiceMonitor
public SimpleServiceMonitor(long cWaitMillis) Construct a SimpleServiceMonitor with the provided interval to check that the registered services are running.- Parameters:
 cWaitMillis- the number of milliseconds in between checking that the registered services are running
 
 - 
 - 
Method Details
- 
registerServices
Adds a set ofServices to be monitored providing life support. If any of the services are not running they are started either via the configuredConfigurableCacheFactoryiff provided or the providedService.- Specified by:
 registerServicesin interfaceServiceMonitor- Parameters:
 mapServices- a map ofServices where values are non-scoped service names
 - 
unregisterServices
Removes the supplied set ofServices from monitoring. Note that the services are not being stopped; they are just removed from the list ofServices that are being monitored.- Specified by:
 unregisterServicesin interfaceServiceMonitor- Parameters:
 setServices- the set ofServices to be removed from monitoring
 - 
stopMonitoring
public void stopMonitoring()Stop monitoring all registered services. Note that the services are not being stopped; they are just removed from the list ofServices that are being monitored.- Specified by:
 stopMonitoringin interfaceServiceMonitor
 - 
isMonitoring
public boolean isMonitoring()Returns true iff the ServiceMonitor is monitoring a number of services.- Specified by:
 isMonitoringin interfaceServiceMonitor- Returns:
 - returns true iff the ServiceMonitor is monitoring a number of services
 
 - 
setConfigurableCacheFactory
Set theConfigurableCacheFactoryaServiceMonitorcan operate with. Setting theConfigurableCacheFactoryshould be performed prior to registering services or requires aServiceMonitor.stopMonitoring()andServiceMonitor.registerServices(Map)call.- Specified by:
 setConfigurableCacheFactoryin interfaceServiceMonitor- Parameters:
 ccf- theConfigurableCacheFactoryused to start the service
 - 
getThread
Return the thread used by this ServiceMonitor.- Specified by:
 getThreadin interfaceServiceMonitor
 - 
dispose
public void dispose()Invoked when all resources owned by the implementer can safely be released.Once disposed of the object should no longer be considered to be usable.
Note the Disposable interface is compatible with try-with-resources which will automatically invoke this method.
- Specified by:
 disposein interfaceDisposable
 - 
start
protected void start()Start monitoring the services. - 
monitorServices
protected void monitorServices(long cWaitMillis) Check the service status periodically (keep alive interval), restarting any stopped services.- Parameters:
 cWaitMillis- the number of milliseconds between checks
 - 
isDisposed
protected boolean isDisposed()Return true if thisServiceMonitorhas been disposed via invocation ofdispose().- Returns:
 - true if this monitor has been disposed
 
 - 
assertNotDisposed
protected void assertNotDisposed()ThrowsIllegalStateExceptionif this monitor has been disposed via invocation ofdispose().- Throws:
 IllegalStateException- if this monitor has been disposed
 
 -