Class ControlServer

  • All Implemented Interfaces:
    org.apache.commons.io.input.TailerListener

    public class ControlServer
    extends java.lang.Object
    implements org.apache.commons.io.input.TailerListener
    The control server watches the daemon control file for changes and reacts on certain commands.

    Although it is not a real socket, it can be seen as a cross-platform unix-like socket. Due to the nature of the commands in the control file (shutdown/reload), a normal TCP socket is not possible.

    The central method is enterLoop(): This method tails file changes in the daemon control file in the currently active thread. It does not fork a new thread. It blocks and waits for commands until shutdown is received.

    • Constructor Summary

      Constructors 
      Constructor Description
      ControlServer()  
      ControlServer​(java.io.File ctrlFile, org.apache.commons.io.input.Tailer ctrTailer, LocalEventBus eventBus)
      Deprecated.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void enterLoop()  
      void fileNotFound()
      Functions that handle tailing the control file.
      void fileRotated()  
      void handle​(java.lang.Exception e)  
      void handle​(java.lang.String command)  
      void init​(org.apache.commons.io.input.Tailer tailer)  
      • Methods inherited from class java.lang.Object

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

      • ControlServer

        @Deprecated
        public ControlServer​(java.io.File ctrlFile,
                             org.apache.commons.io.input.Tailer ctrTailer,
                             LocalEventBus eventBus)
        Deprecated.
        Constructor required for unit testing, as you can inject mocks in this way.
    • Method Detail

      • fileNotFound

        public void fileNotFound()
        Functions that handle tailing the control file.
        Specified by:
        fileNotFound in interface org.apache.commons.io.input.TailerListener
      • handle

        public void handle​(java.lang.String command)
        Specified by:
        handle in interface org.apache.commons.io.input.TailerListener
      • handle

        public void handle​(java.lang.Exception e)
        Specified by:
        handle in interface org.apache.commons.io.input.TailerListener
      • init

        public void init​(org.apache.commons.io.input.Tailer tailer)
        Specified by:
        init in interface org.apache.commons.io.input.TailerListener
      • fileRotated

        public void fileRotated()
        Specified by:
        fileRotated in interface org.apache.commons.io.input.TailerListener