Server Module Specification

Author: Travis Emmitt
Date: 14-DEC-1998
Version: 3.1

Contents:

Server Overview

Server Architecture

Server Module Descriptions


Return to main Software Specification page

Server Overview

The Server is a standalone application. It reads in a Map file from...



Server Architecture

Our system is broken into modules and structured as in the diagram below. The vertical and horizontal bars represent interfaces.

                [...]
            ClientRMIIface
                  |
. . . . . . . . . | . . . . . . . . . . . . . . . . . . . . . . . .
                  |                               .
                  |                               .
        ServerRMItoClientIface                    .
                  |                               .
              ServerRMI----ServerRMItoDemonIface-----DemonRMIIface
SERVER            |                               .      [...]
(single)     ServerThread                         .
                  |                               .
             ServerEngine                         .
                  |                               .
                Server                            .
                  |                               .
. . . . . . . . . | . . . . . . . . . . . . . . . . . . . . . . . .
                  |
               OS SHELL



Server Module Descriptions

This section describes the different modules in the Server. It focuses on their duties and interfaces.



Server

The Server is an application, and initiates program execution on the server side of the system.

Server Interfaces
Method Throws Invoker Purpose
Server(String file_name, int port)   main This is called to instantiate an object of type Server and starts the execution of the server side of the system. A private member of type ServerEngine is instantiated here passing "this" as an argument. The file_name and port arguments are also passed to the ServerEngine constructor.
void PrintMessage (String s)   ServerEngine This call prints the indicated string to the screen.
void Error (Exception e)   ServerEngine This call prints the stack trace for the passed exception.
void ShutDown ()   ServerEngine Kills the currently running application.




ServerEngine

The ServerEngine handles the logic for:

ServerEngine Interfaces
Method Throws Invoker Purpose
ServerEngine (Server s, String file_name, int port) MapReadException Server By passing a reference to itself when calling the ServerEngine construtor, Server gives ServerEngine a way to invoke the Server methods, enabling two-way communication between the Server and the engine. This constructor then creates a ServerRMI using the port value passed, establishing a similar two-way interface. It also reads in a Map using the given file_name, and tells the ServerRMI to get ready to accept connections from the same number of clients as there are Modules in the Map. It then performs any other needed initialization.
void UpdateMap (Module m, int client_id)   ServerRMI Whenever the server receives a changed module from the client, those changes need to be handled in the ServerEngine via this method.
void BeginSimulation (int p, int long d)   ServerRMI This method sets the propagation method and delay variables before starting the simulation by creating and starting a new ServerThread.
void PrintMessage (String s)   ServerThread, ServerRMI This function prints the indicated message via the Server.
void Error (Exception e)   ServerThread, ServerRMI This function passes the exception on to Server's Error method to print a stack trace.
Map GetMap ()   ServerThread, ServerRMI This function returns the current Map.
int GetNumClients ()   ServerThread This function returns the current number of clients.
long GetDelay ()   ServerThread This function returns the current delay.
int GetPropagationMethod ()   ServerThread This function returns the current propagation method.
int GetMode ()   ServerThread This function returns the current mode as an int corresponding to either automatic or manual mode.
int GetIterations ()   ServerThread This function returns the number of requested iterations for the current run of the simulation.
void ShutDown ()   ServerRMI Kills the currently running application via the Server.
void SubmitMode (int m, int runs)   ServerRMI This function ets the mode to automatic or manual according to the passed value. It also sets the iterations value to 1 if manual has been selected and equal to "runs" if automatic has been selected.
void Abort ()   ServerRMI This method kills the currently running ServerThread in order to stop the simulation. The map is stabilzed in preparation to be sent back out to the clients and the demon.




ServerThread

A ServerThread is in charge of stabilizing the modified Map and sending out the modifications to the clients.

ServerThread Interfaces
Method Throws Invoker Purpose
ServerThread(ServerRMI r, ServerEngine se)   ServerEngine This constructor gives the ServerThread the hooks it needs to modify the current Map and send copies to clients.
void run()   ServerEngine This function contains the code for stabilizing and sending out copies of the Map.




SendInitialMapThread

A SendInitialMapThread is created and run to send out the initial version of the map.
DEPRECATED

SendInitialMapThread Interfaces
Method Throws Invoker Purpose
SendInitialMapThread(ServerRMI r, ServerEngine se)   ServerEngine This constructor gives the SendInitialMapThread the hooks it needs to send out a copy of the current map to all clients and the demon.
void run()   ServerEngine This function contains the code for sending out the initial copy of the Map.




ServerRMI

The ServerRMI module handles the server's side of the communication with the clients. It talks to the clients via the ClientRMI module, to the demon using the DemonRMI module, and to the ServerEngine.

ServerRMI
Method Throws Invoker Purpose
ServerRMI (ServerEngine engine)   ServerEngine () By passing a reference to itself when calling the ServerRMI construtor, ServerEngine gives ServerRMI a way to invoke the ServerEngine methods, enabling two-way communication between the engine and the RMI. This constructor then sets the SecurityManager, creates the registry, and binds itself to it under the name of "ServerRMI".
Map ConnectClient () RemoteException, Exception ClientRMI (RMI call) Receives a request from a client for an initial map. A map is returned, based on which the client picks its module number.
boolean RegisterClient (int module, ClientRMIIface obj) RemoteException, Exception ClientRMI (RMI call) Receives a request from a client to register for a module. If the module is not taken, the client's interface is stored, and it is given an affirmative answer.
boolean RegisterDemon (DemonRMIIface obj) RemoteException, Exception DemonRMI (RMI call) Recieves a request from the Demon to register. Due to the current implementation, this can only be done once, and the demon is given an affirmative answer.
void ReceiveModule(Module m, int client_id) RemoteException, Exception ClientRMI (RMI call) The client passes the server its modified module through this call. ServerEngine's UpdateMap() method is invoked.
boolean SubmitMode(int mode, int runs) RemoteException, Exception DemonRMI (RMI call) The demon passes the server the way this simulation will be run. ServerEngine's SubmitMode() method is invoked, and a new (editable) map is sent to all the clients.
boolean StartRun(int propagation, long delay) RemoteException, Exception DemonRMI (RMI call) The demon passes the two simulation variables, propagation method, and delay. ServerEngine's BeginSimulation() is called.
boolean Abort() RemoteException, Exception DemonRMI (RMI call) Receives a request from the demon for the single run to be stopped. The engine is notified, and all maps re-sent.
boolean Shutdown() RemoteException, Exception DemonRMI (RMI call) Receives a request from the demon for all the clients to be shut down. Each client is notified of the shutdown, and then we return to the demon.
boolean ClientQuit() RemoteException, Exception ClientRMI (RMI call) This is the last call the client makes before it is manually shut down. The serverRMI's internal object (Connections) is updated. Proper authorization (client's iface) is needed.
boolean DemonQuit() RemoteException, Exception DemonRMI (RMI call) Same as ClientQuit().
int SendMapAll(Map m) RemoteException ServerEngine, internal This method sends the map to all present clients, as well as the demon.
int SendMapClient(Map m, int client_id) RemoteException ServerEngine ServerEngine sends the map to a specific client through its RMIIface.
int SendMapDemon(Map m) RemoteException ServerEngine Just like previous call, only to demon.
int SendStatsClient(Stats stats, int client_id) RemoteException ServerEngine Stats object is passed to a given client thorugh its RMIIface.
int SendStatsDemon(Stats stats) RemoteException ServerEngine Just like previous call, only to demon.




ServerRMItoClientIface

Interface exposed to the clients. For notes on each method, please see ServerRMI, where these methods are actually implemented.

ServerRMItoClientIface Interfaces
Method Throws Invoker Purpose
Map ConnectClient () RemoteException, Exception ClientRMI (RMI call) (see same method in ServerRMI)
boolean RegisterClient (int module_num, ClientRMIIface obj) RemoteException, Exception ClientRMI (RMI call) (see same method in ServerRMI)
void ReceiveModule (Module m, int client_id) RemoteException, Exception ClientRMI (RMI call) (see same method in ServerRMI)
void ClientQuit () RemoteException, Exception ClientRMI (RMI call) (see same method in ServerRMI)




ServerRMItoDemonIface

Interface exposed to the demon. For notes on each method, please see ServerRMI, where these methods are actually implemented.

ServerRMItoDemonIface Interfaces
Method Throws Invoker Purpose
boolean RegisterDemon (DemonRMIIface obj) RemoteException, Exception DemonRMI (RMI call) (see same method in ServerRMI)
boolean StartRun (int propagation, long delay) RemoteException, Exception DemonRMI (RMI call) (see same method in ServerRMI)
boolean Shutdown () RemoteException, Exception DemonRMI (RMI call) (see same method in ServerRMI)
void DemonQuit () RemoteException, Exception DemonRMI (RMI call) (see same method in ServerRMI)



Return to the main Software Specification page
Revision history:

Version 3.1 - 14-DEC-1998 txe
Fixed format, dates, version numbers, table of contents, diagram

Version 3.0 - 14-DEC-1998 smg
Added and modified methods of Server, ServerEngine. Deprecated SentInitialMapThread.

Version 2.2 - 20-NOV-1998 smg
Added prototype 2 info for Server, ServerEngine, ServerThread. Added SendInitialMapThread.

Version 2.1 - 18-NOV-1998 Orim
Added ServerRMI, ServerRMI*Iface information

Version 2.0 - 16-NOV-1998 txe
Initial creation (split from spec.html)