public class RunControl extends cMsgDomainAdapter
Modifier and Type | Class and Description |
---|---|
(package private) class |
RunControl.Multicaster
This class defines a thread to multicast a UDP packet to the
RC Multicast server every second.
|
Modifier and Type | Field and Description |
---|---|
(package private) boolean |
abandonConnection
Quit a connection in progress if true.
|
(package private) java.util.concurrent.CountDownLatch |
connectCompletion
Signal to coordinate the finishing of the 3-leg connect method.
|
(package private) java.io.DataOutputStream |
domainOut
Output TCP data stream from this client to the RC server.
|
(package private) java.net.InetAddress |
rcServerAddress
RunControl server's net addresses obtained from multicast response.
|
(package private) int |
rcTcpServerPort
RunControl server's TCP listening port obtained from
connect() . |
(package private) int |
rcUdpServerPort
RunControl server's UDP listening port obtained from
connect() . |
java.util.Set<cMsgSubscription> |
subscriptions
Collection of all of this client's message subscriptions which are
cMsgSubscription objects. |
(package private) java.net.Socket |
tcpSocket
Socket over which to send messages to the RC server over TCP.
|
connected, debug, description, domain, host, name, receiving, shutdownHandler, UDL, UDLremainder
Constructor and Description |
---|
RunControl()
Constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
connect()
Method to connect to the codaComponent server from this client.
|
void |
disconnect()
Method to close the connection to the domain server.
|
void |
flush(int timeout)
Does nothing in this domain.
|
java.lang.String |
getServerHost()
Get the host of the RC server that this client is connected to.
|
int |
getServerPort()
Get the TCP port of the RC server that this client is connected to.
|
cMsgMessage |
monitor(java.lang.String command)
This method is a synchronous call to receive a message containing monitoring data
from the rc multicast server specified in the UDL.
|
(package private) void |
parseUDL(java.lang.String udlRemainder)
Method to parse the Universal Domain Locator (UDL) into its various components.
|
void |
send(cMsgMessage message)
Method to send a message to the domain server for further distribution.
|
cMsgSubscriptionHandle |
subscribe(java.lang.String subject,
java.lang.String type,
cMsgCallbackInterface cb,
java.lang.Object userObj)
Method to subscribe to receive messages of a subject and type from the rc server.
|
void |
unsubscribe(cMsgSubscriptionHandle obj)
Method to unsubscribe a previous subscription to receive messages of a subject and type
from the rc server.
|
getCurrentUDL, getDebug, getDescription, getDomain, getHost, getInfo, getName, getShutdownHandler, getUDL, getUDLRemainder, isConnected, isReceiving, sendAndGet, setDebug, setDescription, setName, setShutdownHandler, setUDL, setUDLRemainder, shutdownClients, shutdownServers, start, stop, subscribeAndGet, syncSend
volatile boolean abandonConnection
volatile java.net.InetAddress rcServerAddress
volatile int rcUdpServerPort
connect()
.volatile int rcTcpServerPort
connect()
.java.net.Socket tcpSocket
java.io.DataOutputStream domainOut
public java.util.Set<cMsgSubscription> subscriptions
cMsgSubscription
objects. This set is synchronized.java.util.concurrent.CountDownLatch connectCompletion
public java.lang.String getServerHost()
getServerHost
in interface cMsgDomainInterface
getServerHost
in class cMsgDomainAdapter
public int getServerPort()
getServerPort
in interface cMsgDomainInterface
getServerPort
in class cMsgDomainAdapter
public void flush(int timeout) throws cMsgException
flush
in interface cMsgDomainInterface
flush
in class cMsgDomainAdapter
timeout
- time in milliseconds to wait for completioncMsgException
- never thrownpublic void connect() throws cMsgException
connect
in interface cMsgDomainInterface
connect
in class cMsgDomainAdapter
cMsgException
- if there are problems parsing the UDL or
communication problems with the server(s)public cMsgMessage monitor(java.lang.String command) throws cMsgException
cMsgMessage.getSenderHost()
method of the returned message.
Get the whole list of server IP addresses in the
String array payload item called "IpAddresses". This is useful when trying to find
the location of a particular AFECS (runcontrol) platform.monitor
in interface cMsgDomainInterface
monitor
in class cMsgDomainAdapter
command
- time in milliseconds to wait for a response to multicasts (1000 default)cMsgException
- if cMsg error.void parseUDL(java.lang.String udlRemainder) throws cMsgException
Runcontrol domain UDL is of the form:
cMsg:rc://<host>:<port>/<expid>?connectTO=<timeout>&ip=<address>
Remember that for this domain:host is required and may also be "multicast", "localhost", or in dotted decimal form
port is optional with a default of cMsgNetworkConstants.rcMulticastPort
the experiment id or expid is required, it is NOT taken from the environmental variable EXPID
connectTO (optional) is the time to wait in seconds before connect returns a timeout while waiting for the rc server to send a special (tcp) concluding connect message. Defaults to 30 seconds.
ip (optional) is ip address in dot-decimal format which the rc server or agent must use to connect to this rc client.
udlRemainder
- partial UDL to parsecMsgException
- if udlRemainder is nullpublic void disconnect()
disconnect
in interface cMsgDomainInterface
disconnect
in class cMsgDomainAdapter
public void send(cMsgMessage message) throws cMsgException
send
in interface cMsgDomainInterface
send
in class cMsgDomainAdapter
message
- message to sendcMsgException
- if there are communication problems with the server;
subject and/or type is nullpublic cMsgSubscriptionHandle subscribe(java.lang.String subject, java.lang.String type, cMsgCallbackInterface cb, java.lang.Object userObj) throws cMsgException
subscribe
in interface cMsgDomainInterface
subscribe
in class cMsgDomainAdapter
subject
- message subjecttype
- message typecb
- 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 argumentcMsgException
- if the callback, subject and/or type is null or blank;
an identical subscription already exists; there are
communication problems with the serverpublic void unsubscribe(cMsgSubscriptionHandle obj) throws cMsgException
unsubscribe
in interface cMsgDomainInterface
unsubscribe
in class cMsgDomainAdapter
obj
- the object returned from a subscribe callcMsgException
- if there are communication problems with the server; object arg is null