Class ServiceManager.ServiceManagerState

    • Constructor Detail

      • ServiceManagerState

        ServiceManagerState​(ImmutableCollection<Service> services)
        It is implicitly assumed that all the services are NEW and that they will all remain NEW until all the Listeners are installed and markReady() is called. It is our caller's responsibility to only call markReady() if all services were new at the time this method was called and when all the listeners were installed.
    • Method Detail

      • tryStartTiming

        void tryStartTiming​(Service service)
        Attempts to start the timer immediately prior to the service being started via Service.startAsync().
      • markReady

        void markReady()
        Marks the Service.State as ready to receive transitions. Returns true if no transitions have been observed yet.
      • awaitHealthy

        void awaitHealthy()
      • awaitHealthy

        void awaitHealthy​(long timeout,
                          java.util.concurrent.TimeUnit unit)
                   throws java.util.concurrent.TimeoutException
        Throws:
        java.util.concurrent.TimeoutException
      • awaitStopped

        void awaitStopped()
      • awaitStopped

        void awaitStopped​(long timeout,
                          java.util.concurrent.TimeUnit unit)
                   throws java.util.concurrent.TimeoutException
        Throws:
        java.util.concurrent.TimeoutException
      • transitionService

        void transitionService​(Service service,
                               Service.State from,
                               Service.State to)
        Updates the state with the given service transition.

        This method performs the main logic of ServiceManager in the following steps.

        1. Update the servicesByState()
        2. Update the startupTimers
        3. Based on the new state queue listeners to run
        4. Run the listeners (outside of the lock)
      • enqueueStoppedEvent

        void enqueueStoppedEvent()
      • enqueueHealthyEvent

        void enqueueHealthyEvent()
      • enqueueFailedEvent

        void enqueueFailedEvent​(Service service)
      • dispatchListenerEvents

        void dispatchListenerEvents()
        Attempts to execute all the listeners in listeners.
      • checkHealthy

        void checkHealthy()