public class cMsgNameServer extends java.lang.Thread implements IExecutorThread
cMsgServerBridge
and cMsg
).Modifier and Type | Field and Description |
---|---|
(package private) java.util.concurrent.CountDownLatch |
allowConnectionsCloudSignal
Use this to signal the point at which other servers and clients
are allowed to connect to this server due to server cloud issues.
|
(package private) java.util.List<cMsgDomainServerSelect> |
availableDomainServers
List of all cMsgDomainServerSelect objects that have room for more clients.
|
(package private) static byte |
BECOMINGCLOUD
Server is in the process of becoming a part of the server cloud.
|
(package private) cMsgServerBridge |
bridgeBeingCreated
Server this name server is in the middle of or starting to connect to.
|
(package private) java.util.concurrent.ConcurrentHashMap<java.lang.String,cMsgServerBridge> |
bridges
Keep track of all the cMsgServerBridge objects in the cMsg subdomain.
|
(package private) java.lang.String |
clientPassword
Password that clients need to match before being allowed to connect.
|
(package private) java.lang.String |
cloudPassword
Password that this server needs to join a cloud and the password that
another server needs to join this one.
|
(package private) static int |
domainPortMax
The maximum value for the cMsgDomainServer's listening port number.
|
(package private) static int |
domainServerPort
The value of the TCP listening port for establishing permanent client connections.
|
(package private) java.util.concurrent.ConcurrentHashMap<cMsgDomainServer,java.lang.String> |
domainServers
Set of all active cMsgDomainServer objects.
|
(package private) java.util.concurrent.ConcurrentHashMap<cMsgDomainServerSelect,java.lang.String> |
domainServersSelect
Set of all active cMsgDomainServerSelect objects.
|
(package private) java.lang.String |
fullMonitorXML
String which contains the entire monitor data of the server cloud (xml format).
|
(package private) static byte |
INCLOUD
Server is in the server cloud.
|
(package private) java.util.concurrent.CountDownLatch |
listeningThreadsStartedSignal
Use this to signal that this server's listening threads have been started
so bridges may be created and clients may connect.
|
(package private) boolean |
monitoringOff
If true, this server does NOT send an XML string containing its state to all clients.
|
(package private) java.util.concurrent.ConcurrentHashMap<java.lang.String,cMsgClientData> |
nameServers
Keep track of all name servers which have connected to this server.
|
(package private) static byte |
NONCLOUD
Server is NOT in the server cloud.
|
(package private) java.lang.String |
nsMonitorXML
String which contains the monitor data of this particular name server (xml format).
|
(package private) java.util.concurrent.CountDownLatch |
postConnectionThreadsStartedSignal
There are 2 threads which must be running before client connections are allowed.
|
(package private) java.util.concurrent.CountDownLatch |
preConnectionThreadsStartedSignal
There are 3 threads which must be running before client connections are allowed.
|
(package private) java.lang.String |
serverName
This server's name.
|
(package private) boolean |
standAlone
Does this server stand alone and NOT allow bridges
to/from other cMsg subdomain servers?
|
(package private) java.util.concurrent.locks.ReentrantLock |
subscribeLock
Lock to ensure all access to
subscriptions is sequential. |
(package private) java.util.HashSet<cMsgServerSubscribeInfo> |
subscriptions
Set of all subscriptions (including the subAndGets) of all clients
on this server.
|
(package private) static byte |
UNKNOWNCLOUD
Server cloud status is unknown.
|
Constructor and Description |
---|
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.
|
Modifier and Type | Method and Description |
---|---|
void |
cleanUp()
Implement IExecutorThread interface so cMsgNameServer can be
run using the Commander/Executor framework.
|
(package private) void |
cloudLock()
This method locks a lock used in adding servers to the server cloud and in adding
clients to servers.
|
(package private) boolean |
cloudLock(int delay)
This method locks a lock used in adding servers to the server cloud and in adding
clients to servers.
|
(package private) void |
cloudUnlock()
This method unlocks a lock used in adding servers to the server cloud and in adding
clients to servers.
|
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.
|
(package private) void |
setCloudStatus(int status)
Set the status of the relationship of this server to the cMsg subdomain
server cloud.
|
(package private) void |
shutdown()
Method to gracefully shutdown all threads associated with this server
and to clean up.
|
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.
|
activeCount, checkAccess, clone, 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
java.lang.String serverName
static int domainPortMax
static int domainServerPort
java.util.concurrent.CountDownLatch preConnectionThreadsStartedSignal
startServer()
) .java.util.concurrent.CountDownLatch postConnectionThreadsStartedSignal
startServer()
) .java.util.concurrent.ConcurrentHashMap<cMsgDomainServer,java.lang.String> domainServers
java.util.concurrent.ConcurrentHashMap<cMsgDomainServerSelect,java.lang.String> domainServersSelect
java.util.List<cMsgDomainServerSelect> availableDomainServers
java.util.HashSet<cMsgServerSubscribeInfo> subscriptions
subscribeLock
.final java.util.concurrent.locks.ReentrantLock subscribeLock
subscriptions
is sequential.java.lang.String fullMonitorXML
java.lang.String nsMonitorXML
boolean monitoringOff
java.lang.String clientPassword
java.lang.String cloudPassword
boolean standAlone
volatile cMsgServerBridge bridgeBeingCreated
java.util.concurrent.CountDownLatch listeningThreadsStartedSignal
java.util.concurrent.CountDownLatch allowConnectionsCloudSignal
static final byte INCLOUD
static final byte NONCLOUD
static final byte BECOMINGCLOUD
static final byte UNKNOWNCLOUD
java.util.concurrent.ConcurrentHashMap<java.lang.String,cMsgClientData> nameServers
java.util.concurrent.ConcurrentHashMap<java.lang.String,cMsgServerBridge> bridges
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)
port
- TCP listening port for communication from clientsdomainPort
- listening port for receiving 2 permanent connections from each clientudpPort
- UDP listening port for receiving multicasts from clientsstandAlone
- if true no other cMsg servers are allowed to attached to this one and form a cloudmonitoringOff
- if true clients are NOT sent monitoring dataclientPassword
- password client needs to provide to connect to this servercloudPassword
- password server needs to provide to connect to this server to become part of a cloudserverToJoin
- server whose cloud this server is to be joined todebug
- desired level of debug outputclientsMax
- max number of clients per cMsgDomainServerSelect object for regime = lowvoid cloudLock()
boolean cloudLock(int delay)
delay
- time in milliseconds to wait for the lock before timing outvoid cloudUnlock()
public int getCloudStatus()
INCLOUD
, NONCLOUD
,
or BECOMINGCLOUD
void setCloudStatus(int status)
INCLOUD
, NONCLOUD
,
or BECOMINGCLOUD
.status
- status of the relationship of this server to the cMsg subdomain
server cloudpublic java.lang.String getServerName()
public java.lang.String getHost()
public int getPort()
public int getDomainPort()
public int getMulticastPort()
public void printSizes()
public static void main(java.lang.String[] args)
args
- arguments.public void startItUp()
IExecutorThread
startItUp
in interface IExecutorThread
public void shutItDown()
IExecutorThread
shutItDown
in interface IExecutorThread
public void waitUntilDone() throws java.lang.InterruptedException
IExecutorThread
waitUntilDone
in interface IExecutorThread
java.lang.InterruptedException
- if thread interrupted.public void startServer()
public void cleanUp()
void shutdown()
public void run()
run
in interface java.lang.Runnable
run
in class java.lang.Thread