org.jlab.coda.cMsg.cMsgDomain.server
Class cMsgNameServer

java.lang.Object
  extended by java.lang.Thread
      extended by org.jlab.coda.cMsg.cMsgDomain.server.cMsgNameServer
All Implemented Interfaces:
java.lang.Runnable, org.jlab.coda.cMsg.remoteExec.IExecutorThread

public class cMsgNameServer
extends java.lang.Thread
implements org.jlab.coda.cMsg.remoteExec.IExecutorThread

This class implements a cMsg name server in the cMsg domain. A word of caution. If multiple cMsgNameServer objects exist in a single JVM and they both service clients in the cMsg subdomain, then there will be undesirable effects. In other words, the cMsg subdomain uses static data in some of its implementing classes (cMsgServerBridge & cMsg).

Version:
1.0
Author:
Carl Timmer

Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler
 
Field Summary
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
cMsgNameServer(int port, int domainPort, int udpPort, boolean standAlone, boolean monitoringOff, java.lang.String clientPassword, java.lang.String cloudPassword, java.lang.String serverToJoin, int debug, int clientsMax)
          Constructor which reads environmental variables and opens listening sockets.
 
Method Summary
 void cleanUp()
          Implement IExecutorThread interface so cMsgNameServer can be run using the Commander/Executor framework.
 int getCloudStatus()
          Get the status of the relationship of this server to the cMsg subdomain server cloud.
 int getDomainPort()
          Get the domain server's listening port.
 java.lang.String getHost()
          Get the host this server is running on.
 int getMulticastPort()
          Get name server's multicast listening port.
 int getPort()
          Get the name server's listening port.
 java.lang.String getServerName()
          Get this server's name (host:port).
static void main(java.lang.String[] args)
          Run as a stand-alone application.
 void printSizes()
          This method prints out the sizes of all objects which store other objects.
 void run()
          This method is executed as a thread.
 void shutItDown()
          When a class implementing this interface is run by an Executor, eventually a Commander may want to stop it.
 void startItUp()
          When a class implementing this interface is run by an Executor, it calls this method to do so.
 void startServer()
          Method to start up this server and join the cMsg server cloud that serverToJoin is a part of.
 void waitUntilDone()
          When a class implementing this interface is run by an Executor, a Commander may want to wait until it finished running.
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

cMsgNameServer

public cMsgNameServer(int port,
                      int domainPort,
                      int udpPort,
                      boolean standAlone,
                      boolean monitoringOff,
                      java.lang.String clientPassword,
                      java.lang.String cloudPassword,
                      java.lang.String serverToJoin,
                      int debug,
                      int clientsMax)
Constructor which reads environmental variables and opens listening sockets.

Parameters:
port - TCP listening port for communication from clients
domainPort - listening port for receiving 2 permanent connections from each client
udpPort - UDP listening port for receiving multicasts from clients
standAlone - if true no other cMsg servers are allowed to attached to this one and form a cloud
monitoringOff - if true clients are NOT sent monitoring data
clientPassword - password client needs to provide to connect to this server
cloudPassword - password server needs to provide to connect to this server to become part of a cloud
serverToJoin - server whose cloud this server is to be joined to
debug - desired level of debug output
clientsMax - max number of clients per cMsgDomainServerSelect object for regime = low
Method Detail

getCloudStatus

public int getCloudStatus()
Get the status of the relationship of this server to the cMsg subdomain server cloud.

Returns:
status which is one of INCLOUD, NONCLOUD, or BECOMINGCLOUD

getServerName

public java.lang.String getServerName()
Get this server's name (host:port).

Returns:
server's name

getHost

public java.lang.String getHost()
Get the host this server is running on.

Returns:
server's name

getPort

public int getPort()
Get the name server's listening port.

Returns:
name server's listening port

getDomainPort

public int getDomainPort()
Get the domain server's listening port.

Returns:
domain server's listening port

getMulticastPort

public int getMulticastPort()
Get name server's multicast listening port.

Returns:
name server's multicast listening port

printSizes

public void printSizes()
This method prints out the sizes of all objects which store other objects.


main

public static void main(java.lang.String[] args)
Run as a stand-alone application.


startItUp

public void startItUp()
Description copied from interface: org.jlab.coda.cMsg.remoteExec.IExecutorThread
When a class implementing this interface is run by an Executor, it calls this method to do so. This method does everything that needs doing in order to get this application running. In a Thread object, this can be used to wrap start();

Specified by:
startItUp in interface org.jlab.coda.cMsg.remoteExec.IExecutorThread

shutItDown

public void shutItDown()
Description copied from interface: org.jlab.coda.cMsg.remoteExec.IExecutorThread
When a class implementing this interface is run by an Executor, eventually a Commander may want to stop it. In that case, this method can be run so things can be shut down and cleaned up. In a Thread object, this can be used to wrap some user method to gracefully shut the thread down;

Specified by:
shutItDown in interface org.jlab.coda.cMsg.remoteExec.IExecutorThread

waitUntilDone

public void waitUntilDone()
                   throws java.lang.InterruptedException
Description copied from interface: org.jlab.coda.cMsg.remoteExec.IExecutorThread
When a class implementing this interface is run by an Executor, a Commander may want to wait until it finished running. In that case, this method can be run so things to wait for it to finish. In a Thread object, this can be used to wrap join();

Specified by:
waitUntilDone in interface org.jlab.coda.cMsg.remoteExec.IExecutorThread
Throws:
java.lang.InterruptedException

startServer

public void startServer()
Method to start up this server and join the cMsg server cloud that serverToJoin is a part of. If the serverToJoin is null, this server is the nucleas of a new server cloud.


cleanUp

public void cleanUp()
Implement IExecutorThread interface so cMsgNameServer can be run using the Commander/Executor framework.


run

public void run()
This method is executed as a thread.

Specified by:
run in interface java.lang.Runnable
Overrides:
run in class java.lang.Thread