Class ControlServer

  • All Implemented Interfaces:

    public class ControlServer
    extends java.lang.Object
    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

      Constructor Description
      ControlServer​( ctrlFile, ctrTailer, LocalEventBus eventBus)
    • 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​( tailer)  
      • Methods inherited from class java.lang.Object

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

      • ControlServer

        public ControlServer​( ctrlFile,
                             LocalEventBus eventBus)
        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
      • handle

        public void handle​(java.lang.String command)
        Specified by:
        handle in interface
      • handle

        public void handle​(java.lang.Exception e)
        Specified by:
        handle in interface
      • init

        public void init​( tailer)
        Specified by:
        init in interface
      • fileRotated

        public void fileRotated()
        Specified by:
        fileRotated in interface