public class cMsgServerClient extends cMsg
Modifier and Type | Class and Description |
---|---|
(package private) class |
cMsgServerClient.RejectHandler
Class for telling a thread pool what to do for rejected requests to start a new
thread (when the pool already is using its maximum number of threads.
|
cMsg.KeepAlive, cMsg.Multicaster, cMsg.ParsedUDL, cMsg.UdpReceiver, cMsg.UpdateServer
Modifier and Type | Field and Description |
---|---|
(package private) java.lang.String[] |
clientNamesAndNamespaces
String array filled in by calling
getClientNamesAndNamespaces() . |
(package private) cMsgGetHelper |
clientNamesHelper
Helper object used in
getClientNamesAndNamespaces() . |
(package private) cMsgGetHelper |
cloudLockHelper
Helper object used in
cloudLock(int) . |
(package private) java.util.concurrent.atomic.AtomicBoolean |
gotCloudLock
Did we successfully grab the cloud-joining lock of the
server in the cloud we are trying to join?
|
(package private) java.util.concurrent.atomic.AtomicBoolean |
gotRegistrationLock
Did we successfully grab the client-joining lock of the
server in the cloud we are trying to join? This lock is
necessary to ensure that each client joining a server that
is part of a cloud has a unique name.
|
(package private) cMsgGetHelper |
registrationLockHelper
Helper object used in
registrationLock(int) . |
(package private) java.util.concurrent.ConcurrentHashMap<java.lang.Integer,java.util.concurrent.Future<java.lang.Boolean>> |
serverSendAndGetCancel
Collection of all Future objects from this server client's
serverSendAndGet(org.jlab.coda.cMsg.cMsgMessage, java.lang.String, org.jlab.coda.cMsg.cMsgCallbackInterface)
calls. |
(package private) java.util.concurrent.ConcurrentHashMap<java.lang.Integer,cMsgSendAndGetCallbackThread> |
serverSendAndGets
Collection of all of this server client's
cMsgSendAndGetCallbackThread objects
which are threads waiting for results of a serverSendAndGet(org.jlab.coda.cMsg.cMsgMessage, java.lang.String, org.jlab.coda.cMsg.cMsgCallbackInterface) on a connected server. |
broadList, connectLock, currentParsedUDL, domainOut, domainOutSocket, domainServerHost, domainServerPort, hasSend, hasSendAndGet, hasShutdown, hasSubscribe, hasSubscribeAndGet, hasSyncSend, hasUnsubscribe, ipList, keepAliveSocket, keepAliveThread, listeningThread, monitorXML, notConnectLock, sendAndGets, socketLock, subscribeAndGets, subscribeLock, subscriptions, syncSends, uniqueClientKey, uniqueId, updateServerThread, useFailovers
connected, debug, description, domain, host, name, receiving, shutdownHandler, UDL, UDLremainder
Constructor and Description |
---|
cMsgServerClient(cMsgNameServer nameServer)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
cleanup()
Method to clean up after this object.
|
boolean |
cloudLock(int delay)
Lock the server (in cMsg subdomain) so that no other servers may
simultaneously join the cMsg subdomain server cloud or register a client.
|
void |
cloudUnlock()
Unlock the server enabling other servers to join the
cMsg subdomain server cloud or register a client.
|
java.util.HashSet<java.lang.String> |
connect(int fromNsTcpPort,
int fromNsMulticastPort,
boolean isOriginator,
java.lang.String cloudPassword,
java.lang.String clientPassword,
boolean multicasting)
Method to connect to the domain server from a cMsg server acting as a bridge.
|
java.lang.String[] |
getClientNamesAndNamespaces()
This method gets the names and namespaces of all the local clients (not servers)
of another cMsg domain server.
|
void |
printSizes()
This method prints sizes of maps for debugging purposes.
|
boolean |
registrationLock(int delay)
Grab the registration lock (for adding a client) of another cMsg domain server.
|
void |
registrationUnlock()
Release the registration lock (when adding a client)
of another cMsg domain server.
|
int |
serverSendAndGet(cMsgMessage message,
java.lang.String namespace,
cMsgCallbackInterface cb)
The message is sent by a server client to another server as it would be in the
cMsg.send(org.jlab.coda.cMsg.cMsgMessage) method. |
void |
serverShutdown()
Method to shutdown the server connected to.
|
void |
serverShutdownClients(java.lang.String client,
boolean includeMe)
Method to shutdown the given clients.
|
void |
serverSubscribe(java.lang.String subject,
java.lang.String type,
java.lang.String namespace,
cMsgCallbackInterface cb,
java.lang.Object userObj)
Method for a server to subscribe to receive messages of a subject
and type from another domain server.
|
void |
serverUnSendAndGet(int id)
Method to remove a previous serverSendAndGet.
|
void |
serverUnsubscribe(java.lang.String subject,
java.lang.String type,
java.lang.String namespace,
cMsgCallbackInterface cb,
java.lang.Object userObj)
Method for a server to unsubscribe a previous subscription to receive messages of a subject and type
from another domain server.
|
(package private) java.util.HashSet<java.lang.String> |
talkToNameServerFromServer(java.net.Socket socket,
int cloudStatus,
int fromNSTcpPort,
int fromNSMulticastPort,
boolean isOriginator,
java.lang.String cloudPassword,
java.lang.String clientPassword)
This method gets the host and port of the domain server from the name server.
|
void |
thisServerCloudStatus(int status)
This method tells the server this server is connected to,
what cloud status this server has.
|
connect, connectWithMulticast, disconnect, flush, getCurrentUDL, getInfo, getServerHost, getServerPort, monitor, parseUDL, send, sendAndGet, setUDL, shutdownClients, shutdownServers, subscribe, subscribeAndGet, syncSend, talkToNameServerFromClient, unsubscribe
getDebug, getDescription, getDomain, getHost, getName, getShutdownHandler, getUDL, getUDLRemainder, isConnected, isReceiving, setDebug, setDescription, setName, setShutdownHandler, setUDLRemainder, start, stop
java.util.concurrent.ConcurrentHashMap<java.lang.Integer,cMsgSendAndGetCallbackThread> serverSendAndGets
cMsgSendAndGetCallbackThread
objects
which are threads waiting for results of a serverSendAndGet(org.jlab.coda.cMsg.cMsgMessage, java.lang.String, org.jlab.coda.cMsg.cMsgCallbackInterface)
on a connected server.
Key is senderToken object, value is cMsgSendAndGetCallbackThread
object.java.util.concurrent.ConcurrentHashMap<java.lang.Integer,java.util.concurrent.Future<java.lang.Boolean>> serverSendAndGetCancel
serverSendAndGet(org.jlab.coda.cMsg.cMsgMessage, java.lang.String, org.jlab.coda.cMsg.cMsgCallbackInterface)
calls. These objects allow the cancellation of such a call currently in execution.
Interrupting these threads directly seems to cause problems with the thread pool
executor.
Key is senderToken object, value is Future
object.cMsgGetHelper clientNamesHelper
getClientNamesAndNamespaces()
.java.lang.String[] clientNamesAndNamespaces
getClientNamesAndNamespaces()
.cMsgGetHelper cloudLockHelper
cloudLock(int)
.java.util.concurrent.atomic.AtomicBoolean gotCloudLock
cMsgGetHelper registrationLockHelper
registrationLock(int)
.java.util.concurrent.atomic.AtomicBoolean gotRegistrationLock
public cMsgServerClient(cMsgNameServer nameServer) throws cMsgException
nameServer
- nameServer this client is running incMsgException
- if local host name cannot be foundpublic void printSizes()
public void cleanup()
public java.util.HashSet<java.lang.String> connect(int fromNsTcpPort, int fromNsMulticastPort, boolean isOriginator, java.lang.String cloudPassword, java.lang.String clientPassword, boolean multicasting) throws cMsgException
fromNsTcpPort
- TCP listening port of name server calling this methodfromNsMulticastPort
- UDP multicast listening port of name server calling this methodisOriginator
- true if originating the connection between the 2 servers and
false if this is the response or reciprocal connectioncloudPassword
- password for connecting to a server in a particular cloudclientPassword
- password for a client connecting to this servermulticasting
- true if multicasting to find server since host unknowncMsgException
- if there are problems parsing the UDL or
communication problems with the serverpublic int serverSendAndGet(cMsgMessage message, java.lang.String namespace, cMsgCallbackInterface cb) throws java.io.IOException
cMsg.send(org.jlab.coda.cMsg.cMsgMessage)
method. The receiving server notes
the fact that a response to it is expected, and sends it to all subscribed to its
subject and type. When a marked response is received from a client, it sends that
first response back to the original sender regardless of its subject or type.message
- message sent to servernamespace
- namespace of message sentcb
- callback to run on receipt of response messagejava.io.IOException
- if there are communication problems with the serverpublic void serverUnSendAndGet(int id) throws java.io.IOException
id
- unique id of serverSendAndGet request to deletejava.io.IOException
- if there are communication problems with the serverpublic void serverSubscribe(java.lang.String subject, java.lang.String type, java.lang.String namespace, cMsgCallbackInterface cb, java.lang.Object userObj) throws java.io.IOException
subject
- message subjecttype
- message typenamespace
- message namespacecb
- callback object whose single method is called upon receiving a message
of subject and typeuserObj
- any user-supplied object to be given to the callback method as an argumentjava.io.IOException
- there are communication problems with the serverpublic void serverUnsubscribe(java.lang.String subject, java.lang.String type, java.lang.String namespace, cMsgCallbackInterface cb, java.lang.Object userObj) throws java.io.IOException
subject
- message subjecttype
- message typenamespace
- message namespacecb
- callback object whose single method is called upon receiving a message
of subject and typeuserObj
- any user-supplied object to be given to the callback method as an argumentjava.io.IOException
- there are communication problems with the serverpublic void serverShutdownClients(java.lang.String client, boolean includeMe) throws java.io.IOException
client
- client(s) to be shutdownincludeMe
- if true, it is permissible to shutdown calling clientjava.io.IOException
- if there are communication problems with the serverpublic void serverShutdown() throws java.io.IOException
java.io.IOException
- if there are communication problems with the serverjava.util.HashSet<java.lang.String> talkToNameServerFromServer(java.net.Socket socket, int cloudStatus, int fromNSTcpPort, int fromNSMulticastPort, boolean isOriginator, java.lang.String cloudPassword, java.lang.String clientPassword) throws java.io.IOException, cMsgException
socket
- socket communication to servercloudStatus
- relationship this server has to server cloud.
Can be INCLOUD, NONCLOUD, or BECOMINGCLOUD.fromNSTcpPort
- TCP listening port of name server calling this methodfromNSMulticastPort
- UDP multicast listening port of name server calling this methodisOriginator
- true if originating the connection between the 2 servers and
false if this is the response or reciprocal connection.cloudPassword
- password for connecting to a server in a particular cloudclientPassword
- password for a client connecting to this servercMsgException
- error returned from serverjava.io.IOException
- if there are communication problems with the name serverpublic boolean cloudLock(int delay) throws java.io.IOException
delay
- time in milliseconds to wait for locked to be grabbed before timing outjava.io.IOException
- if there are communication problems with the name serverpublic void cloudUnlock() throws java.io.IOException
java.io.IOException
- if there are communication problems with the name serverpublic boolean registrationLock(int delay) throws java.io.IOException
delay
- time in milliseconds to wait for the lock before timing outjava.io.IOException
- if there are communication problems with the name serverpublic void registrationUnlock() throws java.io.IOException
java.io.IOException
- if communication error with serverpublic void thisServerCloudStatus(int status) throws java.io.IOException
status
- cMsgNameServer.INCLOUD, .NONCLOUD, or .BECOMINGCLOUDjava.io.IOException
- if communication error with serverpublic java.lang.String[] getClientNamesAndNamespaces() throws java.io.IOException
java.io.IOException
- if communication error with server