Network communication

The design of the network communication is inspired by RMI and relies heavily on the use of proxies, abstracting the actual network communication from the application programmer. We have emphasised that the design uses interfaces heavily, and designed the interfaces so it is easy to extend the system with more efficient implementations.

We use UDP as the underlying network protocol, since UDP saves network resources and avoids the expense of setting up connections. The central class of the network communication is UdpTransmitter which handles all network communication, including fragmentation and exception handling.

Class diagram

We use the classes in package edu.it.xmlstore.rpc.udp, and the relationship between these classes is shown in the following figure:

Classes involved in network communication

Steps involved in a remote method invocation

When an XmlStoreServer A wants to invoke a method on another XmlStoreServer B the following steps occur:

  1. The remote method invocation is performed by A calling a proxy, XmlStoreServerProxy for B.
  2. The proxy creates an OutgoingMessage and forwards this to the real B using a Transmitter.
  3. The call is received by a B's Transmitter.
  4. When the Transmitter of B has received the entire request it creates a new IncomingMessage object and passes it on to the XmlStoreMessageDispatcher, which determines the type of the method, unmarshals the argument and calls the method on XmlStoreServerImpl B.
  5. The XmlStoreMessageDispatcher then creates an OutgoingMessage from the result of the method invocation and passes this message to the Transmitter.
  6. The Outgoingmessage is sent to the Transmitter of A.
  7. When the Transmitter has received the entire request it creates a new IncomingMessage object and passes it on to the XmlStoreProxy, which unmarshals the result and returns it to A.

Sequence diagram for a remote method invocation

The above steps are illustrated in the following sequence diagram:

Sequence diagram for network communication

UdpTransmitter

The UdpTransmitter contains a number of inner classes and uses a constant number of threads for handling the network communication of the XML Store. The following sequence diagram depicts the send method of the UdpTransmitter:

Sequence diagram for UdpTransmitter