<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<body link="#355491" alink="#4262a1" vlink="#355491" style="background: #e2e2e2; margin: 0; padding: 20px;">

<div>
        <table cellpadding="0" bgcolor="#FFFFFF" border="0" cellspacing="0" style="border: 1px solid #dadada; margin-bottom: 30px; width: 100%; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
                <tbody>
                        <tr>

                                <td>

                                        <table border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF" style="border: solid 2px #ccc; background: #dadada; width: 100%; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
                                                <tbody>
                                                        <tr>
                                                                <td bgcolor="#000000" valign="middle" height="58px" style="border-bottom: 1px solid #ccc; padding: 20px; -moz-border-radius-topleft: 3px; -moz-border-radius-topright: 3px; -webkit-border-top-right-radius: 5px; -webkit-border-top-left-radius: 5px;">
                                                                        <h1 style="color: #333333; font: bold 22px Arial, Helvetica, sans-serif; margin: 0; display: block !important;">
                                                                        <!-- To have a header image/logo replace the name below with your img tag -->
                                                                        <!-- Email clients will render the images when the message is read so any image -->
                                                                        <!-- must be made available on a public server, so that all recipients can load the image. -->
                                                                        <a href="http://community.jboss.org/index.jspa" style="text-decoration: none; color: #E1E1E1">JBoss Community</a></h1>
                                                                </td>

                                                        </tr>
                                                        <tr>
                                                                <td bgcolor="#FFFFFF" style="font: normal 12px Arial, Helvetica, sans-serif; color:#333333; padding: 20px;  -moz-border-radius-bottomleft: 4px; -moz-border-radius-bottomright: 4px; -webkit-border-bottom-right-radius: 5px; -webkit-border-bottom-left-radius: 5px;"><h3 style="margin: 10px 0 5px; font-size: 17px; font-weight: normal;">
    Re: ServerManager-Server(-ProcessManager) communication
</h3>
<span style="margin-bottom: 10px;">
    created by <a href="http://community.jboss.org/people/kabir.khan%40jboss.com">Kabir Khan</a> in <i>JBoss AS7 Development</i> - <a href="http://community.jboss.org/message/561605#561605">View the full discussion</a>
</span>
<hr style="margin: 20px 0; border: none; background-color: #dadada; height: 1px;">

<div class="jive-rendered-content"><p>I have implemented the following but still need to test some corner cases</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><ol style="list-style-type: decimal;"><li style="margin: 0.0px 0.0px 2.0px 0.0px; font: 12.0px 'Lucida Grande'; color: #5b5b5b;">PM starts up and listens on a socket on a port (PPM) for connections from the processes it manages.</li><li style="margin: 0.0px 0.0px 2.0px 0.0px; font: 12.0px 'Lucida Grande'; color: #5b5b5b;">PM starts SM passing in PPM, PM&rsquo;s host address and &#8216;ServerManager&rsquo; as the name<ol style="list-style-type: decimal;"><li style="margin: 0.0px 0.0px 2.0px 0.0px; font: 12.0px 'Lucida Grande'; color: #5b5b5b;">SM opens a socket on a different port (PSM) which listens for connections from the Server processes and from the Domain Controller (DC).</li><li style="margin: 0.0px 0.0px 2.0px 0.0px; font: 12.0px 'Lucida Grande'; color: #5b5b5b;">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.</li><li style="margin: 0.0px 0.0px 2.0px 0.0px; font: 12.0px 'Lucida Grande'; color: #5b5b5b;">For each Server configured in SM:<ol style="list-style-type: decimal;"><li style="margin: 0.0px 0.0px 2.0px 0.0px; font: 12.0px 'Lucida Grande'; color: #5b5b5b;">SM tells PM to add Server</li><li style="margin: 0.0px 0.0px 2.0px 0.0px; font: 12.0px 'Lucida Grande'; color: #5b5b5b;">SM tells PM to start Server process<ol style="list-style-type: decimal;"><li style="margin: 0.0px 0.0px 2.0px 0.0px; font: 12.0px 'Lucida Grande'; color: #5b5b5b;">PM launches the Server process, passing in PPM, PM_ADDRESS, PSM, SM_ADDRESS and the SERVER_NAME</li><li style="margin: 0.0px 0.0px 2.0px 0.0px; font: 12.0px 'Lucida Grande'; color: #5b5b5b;">Server initiates communication with PM, by connecting to port PPM. The first command it sends is 'CONNECTED &lt;SERVER_NAME&gt;', which helps PM associate the socket with the correct ManagedProcess.</li><li style="margin: 0.0px 0.0px 2.0px 0.0px; font: 12.0px 'Lucida Grande'; color: #5b5b5b;">Server starts listening for commands on the PM socket.</li><li style="margin: 0.0px 0.0px 2.0px 0.0px; font: 12.0px 'Lucida Grande'; color: #5b5b5b;">Server initiates communication with SM, by connecting to port PSM. The first command it sends is 'CONNECTED &lt;SERVER_NAME&gt;', which helps SM associate the socket with the correct Server proxy.</li><li style="margin: 0.0px 0.0px 2.0px 0.0px; font: 12.0px 'Lucida Grande'; color: #5b5b5b;">Server sends the &#8216;SERVER_AVAILABLE&rsquo; command on the SM socket</li><li style="margin: 0.0px 0.0px 2.0px 0.0px; font: 12.0px 'Lucida Grande'; color: #5b5b5b;">Server starts listening for commands on the SM socket</li></ol></li><li style="margin: 0.0px 0.0px 2.0px 0.0px; font: 12.0px 'Lucida Grande'; color: #5b5b5b;">SM sends the &#8216;START_SERVER serverConfig&rsquo; message to the server via the Server&rsquo;s socket<ol style="list-style-type: decimal;"><li style="margin: 0.0px 0.0px 2.0px 0.0px; font: 12.0px 'Lucida Grande'; color: #5b5b5b;">Server parses the serverConfig, starts up and sends to SM either<ol style="list-style-type: decimal;"><li style="margin: 0.0px 0.0px 2.0px 0.0px; font: 12.0px 'Lucida Grande'; color: #5b5b5b;">&#8216;SERVER_STARTED&rsquo; if successful.</li><li style="margin: 0.0px 0.0px 2.0px 0.0px; font: 12.0px 'Lucida Grande'; color: #5b5b5b;">&#8216;SERVER_START_FAILED&rsquo; if failed<ol style="list-style-type: decimal;"><li style="margin: 0.0px 0.0px 2.0px 0.0px; font: 12.0px 'Lucida Grande'; color: #5b5b5b;">SM tells PM to stop process</li><li style="margin: 0.0px 0.0px 2.0px 0.0px; font: 12.0px 'Lucida Grande'; color: #5b5b5b;">If Server auto-restart=true and number retries is &lt; respawn_policy_max SM repeats 2.3.2 and 2.3.3 <strong>- The respawn policy should be configurable (</strong><a class="jive-link-external-small" href="https://jira.jboss.org/browse/JBAS-8390"><strong>https://jira.jboss.org/browse/JBAS-8390</strong></a><strong>)</strong></li><li style="margin: 0.0px 0.0px 2.0px 0.0px; font: 12.0px 'Lucida Grande'; color: #5b5b5b;">Otherwise tell PM to remove process</li></ol></li></ol></li></ol></li></ol></li></ol></li><li style="margin: 0.0px 0.0px 2.0px 0.0px; font: 12.0px 'Lucida Grande'; color: #5b5b5b;">While a ManagedProcess is registered as started in PM<ol style="list-style-type: decimal;"><li style="margin: 0.0px 0.0px 2.0px 0.0px; font: 12.0px 'Lucida Grande'; color: #5b5b5b;">Processes are connected to the PM socket</li><li style="margin: 0.0px 0.0px 2.0px 0.0px; font: 12.0px 'Lucida Grande'; color: #5b5b5b;">The ManagedProcess monitors whether the process is still alive (with a thread doing Process.waitFor())<ol style="list-style-type: decimal;"><li style="margin: 0.0px 0.0px 2.0px 0.0px; font: 12.0px 'Lucida Grande'; color: #5b5b5b;">If a Server process goes down PM stops the process and sends &#8216;DOWN &lt;SERVER_NAME&gt;&rsquo; to SM on the PM-SM connection.<ol style="list-style-type: decimal;"><li style="margin: 0.0px 0.0px 2.0px 0.0px; font: 12.0px 'Lucida Grande'; color: #5b5b5b;">SM respawns the server process according to the rules in 2.3.3.2.</li></ol></li><li style="margin: 0.0px 0.0px 2.0px 0.0px; font: 12.0px 'Lucida Grande'; color: #5b5b5b;">If the ServerManager process goes down PM respawns it as in 6.3</li></ol></li></ol></li><li style="margin: 0.0px 0.0px 2.0px 0.0px; font: 12.0px 'Lucida Grande'; color: #5b5b5b;">To shut down a server<ol style="list-style-type: decimal;"><li style="margin: 0.0px 0.0px 2.0px 0.0px; font: 12.0px 'Lucida Grande'; color: #5b5b5b;">SM sends &#8216;STOP_SERVER&rsquo; to server.<ol style="list-style-type: decimal;"><li style="margin: 0.0px 0.0px 2.0px 0.0px; font: 12.0px 'Lucida Grande'; color: #5b5b5b;">Server closes down</li><li style="margin: 0.0px 0.0px 2.0px 0.0px; font: 12.0px 'Lucida Grande'; color: #5b5b5b;">Server sends &#8216;SERVER_STOPPED&rsquo; to SM.</li><li style="margin: 0.0px 0.0px 2.0px 0.0px; font: 12.0px 'Lucida Grande'; color: #5b5b5b;">SM tells PM to stop the Server process</li><li style="margin: 0.0px 0.0px 2.0px 0.0px; font: 12.0px 'Lucida Grande'; color: #5b5b5b;">SM tells PM to remove the Server process</li></ol></li></ol></li><li style="margin: 0.0px 0.0px 2.0px 0.0px; font: 12.0px 'Lucida Grande'; color: #5b5b5b;">Closing down everything<ol style="list-style-type: decimal;"><li style="margin: 0.0px 0.0px 2.0px 0.0px; font: 12.0px 'Lucida Grande'; color: #5b5b5b;">Message to shutdown comes from<ol style="list-style-type: decimal;"><li style="margin: 0.0px 0.0px 2.0px 0.0px; font: 12.0px 'Lucida Grande'; color: #5b5b5b;">SM gets SHUTDOWN command from DC or management interface</li><li style="margin: 0.0px 0.0px 2.0px 0.0px; font: 12.0px 'Lucida Grande'; color: #5b5b5b;">Shutdown hook in PM<ol style="list-style-type: decimal;"><li style="margin: 0.0px 0.0px 2.0px 0.0px; font: 12.0px 'Lucida Grande'; color: #5b5b5b;">Send &#8216;SHUTDOWN_SERVERS&rsquo; command to SM<ol style="list-style-type: decimal;"><li style="margin: 0.0px 0.0px 2.0px 0.0px; font: 12.0px 'Lucida Grande'; color: #5b5b5b;">For each server do 4 to close it down</li></ol></li><li style="margin: 0.0px 0.0px 2.0px 0.0px; font: 12.0px 'Lucida Grande'; color: #5b5b5b;">PM sends 'SHUTDOWN' message to SM which closes down SM as in 6</li></ol></li></ol></li></ol></li><li style="margin: 0.0px 0.0px 2.0px 0.0px; font: 12.0px 'Lucida Grande'; color: #5b5b5b;">Restarting SM<ol style="list-style-type: decimal;"><li style="margin: 0.0px 0.0px 2.0px 0.0px; font: 12.0px 'Lucida Grande'; color: #5b5b5b;">SM process is stopped by<ol style="list-style-type: decimal;"><li style="margin: 0.0px 0.0px 2.0px 0.0px; font: 12.0px 'Lucida Grande'; color: #5b5b5b;">Message from DC</li><li style="margin: 0.0px 0.0px 2.0px 0.0px; font: 12.0px 'Lucida Grande'; color: #5b5b5b;">Process is killed</li></ol></li><li style="margin: 0.0px 0.0px 2.0px 0.0px; font: 12.0px 'Lucida Grande'; color: #5b5b5b;">SM is down...</li><li style="margin: 0.0px 0.0px 2.0px 0.0px; font: 12.0px 'Lucida Grande'; color: #5b5b5b;">SM process is started<ol style="list-style-type: decimal;"><li style="margin: 0.0px 0.0px 2.0px 0.0px; font: 12.0px 'Lucida Grande'; color: #5b5b5b;"><strong> </strong>PM starts SM passing in PPM, PM&rsquo;s host address and &#8216;ServerManager&rsquo; as the name along with the -restarted-server-manager flag. </li><li style="margin: 0.0px 0.0px 2.0px 0.0px; font: 12.0px 'Lucida Grande'; color: #5b5b5b;">See 2.1</li><li style="margin: 0.0px 0.0px 2.0px 0.0px; font: 12.0px 'Lucida Grande'; color: #5b5b5b;">See 2.2</li><li style="margin: 0.0px 0.0px 2.0px 0.0px; font: 12.0px 'Lucida Grande'; color: #5b5b5b;">SM sends the &#8216;RECONNECT_SERVERS &lt;SM_ADDRESS&gt; &lt;PSM&gt;&rsquo; command to PM<ol style="list-style-type: decimal;"><li style="margin: 0.0px 0.0px 2.0px 0.0px; font: 12.0px 'Lucida Grande'; color: #5b5b5b;">For each Server process PM sends &#8216;RECONNECT_SERVER_MANAGER &lt;SM_ADDRESS&gt; &lt;PSM&gt;&rsquo;<ol style="list-style-type: decimal;"><li style="margin: 0.0px 0.0px 2.0px 0.0px; font: 12.0px 'Lucida Grande'; color: #5b5b5b;">Server reconnects to SM as in 2.3.2.4</li><li style="margin: 0.0px 0.0px 2.0px 0.0px; font: 12.0px 'Lucida Grande'; color: #5b5b5b;">Server sends &#8216;SERVER_RECONNECT_STATUS &lt;Current_State&gt;&rsquo; to SM<ol style="list-style-type: decimal;"><li style="margin: 0.0px 0.0px 2.0px 0.0px; font: 12.0px 'Lucida Grande'; color: #5b5b5b;">if the server is not in the starting, started, stopping or stopped state (I added some basic state management) SM does 2.3.3 </li></ol></li></ol></li></ol></li></ol></li></ol></li></ol></div>

<div style="background-color: #f4f4f4; padding: 10px; margin-top: 20px;">
    <p style="margin: 0;">Reply to this message by <a href="http://community.jboss.org/message/561605#561605">going to Community</a></p>
        <p style="margin: 0;">Start a new discussion in JBoss AS7 Development at <a href="http://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2225">Community</a></p>
</div></td>
                        </tr>
                    </tbody>
                </table>


                </td>
            </tr>
        </tbody>
    </table>

</div>

</body>
</html>