JBoss Community

Re: ServerManager-Server(-ProcessManager) communication

created by Kabir Khan in JBoss AS7 Development - View the full discussion

I have implemented the following but still need to test some corner cases

 

  1. PM starts up and listens on a socket on a port (PPM) for connections from the processes it manages.
  2. PM starts SM passing in PPM, PM’s host address and ‘ServerManager’ as the name
    1. SM opens a socket on a different port (PSM) which listens for connections from the Server processes and from the Domain Controller (DC).
    2. SM initiates communication with PM, by connecting to port PPM. The first command it sends is 'CONNECTED ServerManager', which helps PM associate the socket with the correct ManagedProcess.
    3. For each Server configured in SM:
      1. SM tells PM to add Server
      2. SM tells PM to start Server process
        1. PM launches the Server process, passing in PPM, PM_ADDRESS, PSM, SM_ADDRESS and the SERVER_NAME
        2. Server initiates communication with PM, by connecting to port PPM. The first command it sends is 'CONNECTED <SERVER_NAME>', which helps PM associate the socket with the correct ManagedProcess.
        3. Server starts listening for commands on the PM socket.
        4. Server initiates communication with SM, by connecting to port PSM. The first command it sends is 'CONNECTED <SERVER_NAME>', which helps SM associate the socket with the correct Server proxy.
        5. Server sends the ‘SERVER_AVAILABLE’ command on the SM socket
        6. Server starts listening for commands on the SM socket
      3. SM sends the ‘START_SERVER serverConfig’ message to the server via the Server’s socket
        1. Server parses the serverConfig, starts up and sends to SM either
          1. ‘SERVER_STARTED’ if successful.
          2. ‘SERVER_START_FAILED’ if failed
            1. SM tells PM to stop process
            2. If Server auto-restart=true and number retries is < respawn_policy_max SM repeats 2.3.2 and 2.3.3 - The respawn policy should be configurable (https://jira.jboss.org/browse/JBAS-8390)
            3. Otherwise tell PM to remove process
  3. While a ManagedProcess is registered as started in PM
    1. Processes are connected to the PM socket
    2. The ManagedProcess monitors whether the process is still alive (with a thread doing Process.waitFor())
      1. If a Server process goes down PM stops the process and sends ‘DOWN <SERVER_NAME>’ to SM on the PM-SM connection.
        1. SM respawns the server process according to the rules in 2.3.3.2.
      2. If the ServerManager process goes down PM respawns it as in 6.3
  4. To shut down a server
    1. SM sends ‘STOP_SERVER’ to server.
      1. Server closes down
      2. Server sends ‘SERVER_STOPPED’ to SM.
      3. SM tells PM to stop the Server process
      4. SM tells PM to remove the Server process
  5. Closing down everything
    1. Message to shutdown comes from
      1. SM gets SHUTDOWN command from DC or management interface
      2. Shutdown hook in PM
        1. Send ‘SHUTDOWN_SERVERS’ command to SM
          1. For each server do 4 to close it down
        2. PM sends 'SHUTDOWN' message to SM which closes down SM as in 6
  6. Restarting SM
    1. SM process is stopped by
      1. Message from DC
      2. Process is killed
    2. SM is down...
    3. SM process is started
      1. PM starts SM passing in PPM, PM’s host address and ‘ServerManager’ as the name along with the -restarted-server-manager flag.
      2. See 2.1
      3. See 2.2
      4. SM sends the ‘RECONNECT_SERVERS <SM_ADDRESS> <PSM>’ command to PM
        1. For each Server process PM sends ‘RECONNECT_SERVER_MANAGER <SM_ADDRESS> <PSM>’
          1. Server reconnects to SM as in 2.3.2.4
          2. Server sends ‘SERVER_RECONNECT_STATUS <Current_State>’ to SM
            1. if the server is not in the starting, started, stopping or stopped state (I added some basic state management) SM does 2.3.3

Reply to this message by going to Community

Start a new discussion in JBoss AS7 Development at Community