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

java.lang.Object
  extended by org.jlab.coda.cMsg.cMsgDomain.server.cMsgServerBridge

public class cMsgServerBridge
extends java.lang.Object

This class acts to bridge two cMsg domain servers by existing in one server and becoming a client of another cMsg domain server.


Constructor Summary
cMsgServerBridge(cMsgNameServer nameServer, java.lang.String serverName, int thisNameServerPort)
          Constructor.
 
Method Summary
 java.util.Set<java.lang.String> connect(boolean isOriginator, java.lang.String cloudPassword)
          Method to connect to server.
static cMsgCallbackAdapter getSendAndGetCallback(int id, int sysMsgId)
          Get a callback for a sendAndGet call.
static cMsgCallbackAdapter getSubAndGetCallback()
          This method returns a reference to the one callback needed for subscribes and subAndGets to propogate messages back to original client.
 void printSizes()
          This method prints sizes of maps for debugging purposes.
 void sendAndGet(cMsgMessage msg, java.lang.String namespace, cMsgCallbackInterface cb)
          Method to do a sendAndGet of a message of subject and type to another cMsg server.
 void shutdownClients(java.lang.String clientName, boolean includeMe)
          Method to shutdown the given clients.
 void shutdownServer()
          Method to shutdown the given server this client is connected to.
 void subscribe(java.lang.String subject, java.lang.String type, java.lang.String namespace)
          Method for a server to subscribe to receive messages of a subject and type from another cMsg server.
 void subscribeAndGet(java.lang.String subject, java.lang.String type, java.lang.String namespace, cMsgCallbackInterface cb)
          Method for a subscribeAndGet (a one-time subscribe) on another cMsg server.
 void unSendAndGet(int id)
          Method to remove a previous sendAndGet to receive a message of a subject and type from the domain server.
 void unsubscribe(java.lang.String subject, java.lang.String type, java.lang.String namespace)
          Method for a server to unsubscribe for messages of a subject and type from another cMsg server.
 void unsubscribeAndGet(java.lang.String subject, java.lang.String type, java.lang.String namespace, cMsgCallbackInterface cb)
          Method to remove a previous subscribeAndGet ton another cMsg server.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

cMsgServerBridge

public cMsgServerBridge(cMsgNameServer nameServer,
                        java.lang.String serverName,
                        int thisNameServerPort)
                 throws cMsgException
Constructor.

Parameters:
nameServer - THIS name server (the one using this object)
serverName - name of server to connect to in the form "host:port"
thisNameServerPort - the port THIS name server is listening on
Throws:
cMsgException
Method Detail

printSizes

public void printSizes()
This method prints sizes of maps for debugging purposes.


getSubAndGetCallback

public static cMsgCallbackAdapter getSubAndGetCallback()
This method returns a reference to the one callback needed for subscribes and subAndGets to propogate messages back to original client.

Returns:
callback object for propogating messages back to original client

getSendAndGetCallback

public static cMsgCallbackAdapter getSendAndGetCallback(int id,
                                                        int sysMsgId)
Get a callback for a sendAndGet call.


connect

public java.util.Set<java.lang.String> connect(boolean isOriginator,
                                               java.lang.String cloudPassword)
                                        throws cMsgException
Method to connect to server.

Parameters:
isOriginator - 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 cloud
Returns:
set of servers (names of form "host:port") that the server we're connecting to is already connected with
Throws:
cMsgException - if there are problems parsing the UDL or communication problems with the server

subscribe

public void subscribe(java.lang.String subject,
                      java.lang.String type,
                      java.lang.String namespace)
               throws java.io.IOException
Method for a server to subscribe to receive messages of a subject and type from another cMsg server. The combination of arguments must be unique. In other words, only 1 subscription is allowed for a given set of subject, type, callback, and userObj.

Parameters:
subject - message subject
type - message type
namespace - message namespace
Throws:
java.io.IOException - there are communication problems with the server

unsubscribe

public void unsubscribe(java.lang.String subject,
                        java.lang.String type,
                        java.lang.String namespace)
                 throws java.io.IOException
Method for a server to unsubscribe for messages of a subject and type from another cMsg server.

Parameters:
subject - message subject
type - message type
namespace - message namespace
Throws:
java.io.IOException - there are communication problems with the server

sendAndGet

public void sendAndGet(cMsgMessage msg,
                       java.lang.String namespace,
                       cMsgCallbackInterface cb)
                throws java.io.IOException
Method to do a sendAndGet of a message of subject and type to another cMsg server.

Parameters:
msg - message sent to server
namespace - message namespace
cb - callback for response to sendAndGet request
Throws:
java.io.IOException - if there are communication problems with the server

unSendAndGet

public void unSendAndGet(int id)
                  throws java.io.IOException
Method to remove a previous sendAndGet to receive a message of a subject and type from the domain server. This method is only called when a sendAndGet times out and the server must be told to forget about the get.

Parameters:
id - receiverSubscribeId of original message sent in sendAndGet
Throws:
java.io.IOException - if there are communication problems with the server

subscribeAndGet

public void subscribeAndGet(java.lang.String subject,
                            java.lang.String type,
                            java.lang.String namespace,
                            cMsgCallbackInterface cb)
                     throws java.io.IOException
Method for a subscribeAndGet (a one-time subscribe) on another cMsg server.

Parameters:
subject - subject of message desired from server
type - type of message desired from server
namespace - message namespace
Throws:
java.io.IOException - there are communication problems with the server

unsubscribeAndGet

public void unsubscribeAndGet(java.lang.String subject,
                              java.lang.String type,
                              java.lang.String namespace,
                              cMsgCallbackInterface cb)
                       throws java.io.IOException
Method to remove a previous subscribeAndGet ton another cMsg server. This method is only called when a subscribeAndGet times out and the server must be told to forget about the subscribeAndGet call.

Parameters:
subject - subject of message desired from server
type - type of message desired from server
namespace - message namespace
Throws:
java.io.IOException - there are communication problems with the server

shutdownClients

public void shutdownClients(java.lang.String clientName,
                            boolean includeMe)
                     throws java.io.IOException
Method to shutdown the given clients. Wildcards used to match client names with the given string.

Parameters:
clientName - client(s) to be shutdown
includeMe - if true, it is permissible to shutdown calling client
Throws:
java.io.IOException - if there are communication problems with the server

shutdownServer

public void shutdownServer()
                    throws java.io.IOException
Method to shutdown the given server this client is connected to.

Throws:
java.io.IOException - if there are communication problems with the server