|
Default Implementation for TCP
In Distributed Mediation Server, the TCPProbeCommInit implementation
takes care of establishing the connection with the Central Server. This
class implements the SPPCommInitIfc
and the open()
method is used to establish the connection by opening a new socket as
shown below:
|
... ... String serverName = NOCServerCommAPI.getInstance().getNOCServerName(); int port = NOCServerCommAPI.getInstance().getNOCServerPort(); Socket socket = new Socket(serverName, port); ... ... |
At the Central Server, the TCPServerCommInit implementation takes care of establishing the connection with the Distributed Mediation Server. This class implements the SPPCommInitIfc and the init() parameter creates the server socket for initializing the communication, as shown below:
|
... ... int port = Integer.parseInt(SPPCommParser.getInstance().getUserProperty("ListenPort")); ... ssocket = new ServerSocket(port); ... ... |
The open() method waits and accepts the connection from the Distributed Mediation Server, as shown below:
|
... ... Socket socket = null; try { socket = ssocket.accept(); } catch(Exception ex) { throw new CommunicationException(ex.toString()); }
return new TCPSessionCommImpl(socket); ... ... |
The shutdown() method releases the server socket when the server is shutdown.
The TCPSessionCommImpl implementation takes care of the actual operations
once the connection is established. This class implements the SPPRegionalCommIfc
and contains
the logic for read and write operations. The initialize()
method gets the instance of the read and write streams and returns true
if the instance has been successfully obtained. The
read() method reads the data by reading from the socket and the
write() method writes the data
to the socket, as shown below:
|
... Object object = readStream.readObject(); dataObject = (DataObject)object; ... writeStream.writeObject(dataObject); ... |
Sample Entries in CommunicationInfo.xml
In Central Server
|
... <Communication> <MainProps Mode="2" InitImpl="com.adventnet.nms.extranet.remote.communication.tcp.server.TCPServerCommInit" MaxBufferSize="25" WriteInterval="1" ReadInterval="1" /> <UserProps> <Property Name="ListenPort" Value="7777"/> </UserProps> </Communication> ... |
In Distributed Mediation Server
|
... <Communication> <MainProps Mode="2" InitImpl="com.adventnet.nms.extranet.remote.communication.tcp.probe.TCPProbeCommInit" MaxBufferSize="25" WriteInterval="1" ReadInterval="1" /> <UserProps> </UserProps> </Communication> ... |
|