Class SimpleServiceMonitor

    • Field Detail

      • DEFAULT_WAIT_MILLIS

        protected static final Integer DEFAULT_WAIT_MILLIS
        The default time interval by which we check the alive status.
      • m_fStarted

        protected volatile boolean m_fStarted
        Indicates that the ServiceMonitor has started.
      • m_thread

        protected Thread m_thread
        The Thread we are using for monitoring the services periodically.
      • m_fDisposed

        protected boolean m_fDisposed
        Indicates that this ServiceMonitor has been disposed.
      • m_mapServices

        protected Map<Service,​String> m_mapServices
        A map of Services to be monitored with values being non-scoped service names.
      • m_cWaitMillis

        protected final long m_cWaitMillis
        The number of milliseconds between checking the status of the services.
    • Constructor Detail

      • 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 Detail

      • unregisterServices

        public void unregisterServices​(Set<Service> setServices)
        Removes the supplied set of Services from monitoring. Note that the services are not being stopped; they are just removed from the list of Services that are being monitored.
        Specified by:
        unregisterServices in interface ServiceMonitor
        Parameters:
        setServices - the set of Services 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 of Services that are being monitored.
        Specified by:
        stopMonitoring in interface ServiceMonitor
      • isMonitoring

        public boolean isMonitoring()
        Returns true iff the ServiceMonitor is monitoring a number of services.
        Specified by:
        isMonitoring in interface ServiceMonitor
        Returns:
        returns true iff the ServiceMonitor is monitoring a number of services
      • 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:
        dispose in interface Disposable
      • 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 this ServiceMonitor has been disposed via invocation of dispose().
        Returns:
        true if this monitor has been disposed