distrit.server
Class MultiServerDaemon
java.lang.Object
|
+--distrit.server.MultiServerDaemon
- All Implemented Interfaces:
- InteractiveTaskServer, java.rmi.Remote
- public class MultiServerDaemon
- extends java.lang.Object
- implements InteractiveTaskServer
MultiServerDaemon allocates multiple clients between multiple servers in real-time.
An XML configuration file is regularly checked for changes to the allocation scheme. All
clients connect to the same RMI server (same host, port and binding name) which is this
MultiServerDaemon. MultiServerDaemon then decides which server to allocate each
client to. Control over which client gets allocated to what server is defined in an XML
file. This file also defines the classes for the internal servers to load and with what
parameters. The current implementation allows the following allocation policies to be
defined in the configuration file:
- Specific: A server can be defined so that clients with a specified name will always
connect to it. The name of the client is taken from the first String in the Vector sent as a
parameter to the getID() method.
- Public: Clients are allocated to public servers in a round-robin fashion.
When the XML configuration file is changed during operation the server will force
clients to reconnect to fit the new allocation policy. Following is a sample XML configuration
file:
<?xml version='1.0' encoding='utf-8'?>
<MSCFG>
<server>
<class>package.name.ClassName</class>
<args>arg0 arg1 passed ClassName constructor in ArrayList</args>
<name>MyFirstServer</name>
<client>Cruncher</client>
</server>
<server>
<class>other.package.name.OtherClassName</class>
<args>more args</args>
<name>MySecondServer</name>
</server>
<server>
<class>jaga.pj.circuits.control.EvoRepair</class>
<args>/home/username/log/ server0.txt C17 C All TP 5 0 1</args>
<name>evoRep</name>
<client>BANK</client>
</server>
<server>
<class>jaga.pj.circuits.control.EvoBIST</class>
<args>/home/mmg20/log/test/ evob.txt nologging</args>
<name>evoBIST</name>
</server>
</MSCFG>
This XML file defines two servers with specific clients and two public servers. All
clients with name Cruncher and BANK will be allocated to servers MyFirstServer and
evoRep respectively. All other clients will be shared between MySecondServer and
evoBIST.
Constructor Summary |
MultiServerDaemon(java.util.ArrayList args)
Creates a new instance of MultiServerStage2 |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
REFRESH_SECONDS
public static final int REFRESH_SECONDS
- Number of seconds to wait between re-reading configuration file.
serverPool
protected java.util.HashSet serverPool
serverPoolI
protected java.util.Iterator serverPoolI
nameServer
protected java.util.Hashtable nameServer
clientRecords
protected java.util.ArrayList clientRecords
clientsToDisconnect
protected java.util.HashSet clientsToDisconnect
configRefreshDaemon
protected java.lang.Thread configRefreshDaemon
configFileName
protected java.lang.String configFileName
currGeneratedID
protected int currGeneratedID
MultiServerDaemon
public MultiServerDaemon(java.util.ArrayList args)
throws java.lang.Exception
- Creates a new instance of MultiServerStage2
- Parameters:
args
- Element 0 of this arraylist is a String holding the file name of the configuration file.
Element 1 is a String holding the file name of the log file.
startReadConfigDaemon
protected void startReadConfigDaemon()
readXMLConfig
protected void readXMLConfig(java.lang.String configFileName)
throws java.lang.Exception
addToDisconnectList
protected void addToDisconnectList(java.lang.String clientName)
clientRecordsForName
protected java.util.HashSet clientRecordsForName(java.lang.String clientName)
findSpecificServer
protected ServerRecord findSpecificServer(java.lang.String clientName)
getID
public java.lang.Object getID(java.lang.Object initialParameters)
throws java.rmi.RemoteException
- Called by clients the first time they connect.
- Specified by:
getID
in interface InteractiveTaskServer
- Parameters:
initialParameters
- Initial parameters from client local configuration.
The current client implementation, see
InteractiveTaskClient, provides the ip address of
the client and the command line paramaters used to
launch the client. These are packaged in a Vector.- Returns:
- The ID of this client will from now on used for
interaction with the server.
disconnectClient
protected void disconnectClient()
throws java.rmi.RemoteException
checkAndDisconnectClient
protected void checkAndDisconnectClient(java.lang.Object id)
throws java.rmi.RemoteException
getTask
public InteractiveTask getTask(java.lang.Object id)
throws java.rmi.RemoteException
- This will provide the client with the InteractiveTask
it should run.
- Specified by:
getTask
in interface InteractiveTaskServer
- Parameters:
id
- The ID provided by the getID method by which the
client will always refer to itself.- Returns:
- The task this client should run. This could be
exactly the same as the one all other clients are
running or tailored to this particular client.
interact
public java.lang.Object interact(java.lang.Object id,
java.lang.Object clientTaskOutput)
throws java.rmi.RemoteException
- Called by clients when they wish to interact.
- Specified by:
interact
in interface InteractiveTaskServer
- Parameters:
id
- the client's IDclientTaskOutput
- the outputs of the client obtained by task.get( null ) on the client task- Returns:
- whatever should be sent into the client through task.set( )
println
protected void println(java.lang.String text)