Class Graceful.Shutdown

  • All Implemented Interfaces:
    Graceful
    Enclosing interface:
    Graceful

    public abstract static class Graceful.Shutdown
    extends java.lang.Object
    implements Graceful
    A utility class to assist implementing the Graceful interface. The isShutdownDone() method should be implemented to check if the CompletableFuture returned by shutdown() should be completed or not. The check() method should be called when any state is changed which may complete the shutdown.
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected Shutdown​(java.lang.Object component)  
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      void cancel()  
      void check()
      This method should be called whenever the components state has been updated.
      boolean isShutdown()  
      abstract boolean isShutdownDone()  
      java.util.concurrent.CompletableFuture<java.lang.Void> shutdown()
      Shutdown the component.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • Shutdown

        protected Shutdown​(java.lang.Object component)
    • Method Detail

      • shutdown

        public java.util.concurrent.CompletableFuture<java.lang.Void> shutdown()
        Description copied from interface: Graceful
        Shutdown the component. When this method returns, the component should not accept any new load.
        Specified by:
        shutdown in interface Graceful
        Returns:
        A future that is completed once all load on the component is completed
      • check

        public void check()
        This method should be called whenever the components state has been updated. If shutdown() has been called, then isShutdownDone() is called by this method and if it returns true then the Future returned by shutdown() is completed.
      • cancel

        public void cancel()
      • isShutdownDone

        public abstract boolean isShutdownDone()
        Returns:
        True if the component is shutdown and has no remaining load.