AgE 2.6 : Inter-node communication

On this page:

Communication between AgE nodes can be realised by using the communication service. It consists of four components:

  1. Communication manager.
  2. Neighbourhood scanner.
  3. Communication protocol.
  4. Address cache.

Components that want to use communication service should use following interfaces:

  • CommunicationService for sending messages and receiving them asynchronously.
  • IncomingMessageListener for receiving messages synchronously.

The following diagram shows all components comprising the communication service.

The next diagram shows the communication that occurs when a message is sent.

Communication manager

The communication manager is the central point of the communication service. It provides actual methods for other components to use for sending and receiving messages from other nodes.

There is one implementation of the communication manager available — PollingCommunicationManager.

Neighbourhood scanner

A neighbourhood scanner makes it possible to discover other nodes available for communication. It works by filling the address cache (shared with the communication manager) with available remote nodes. The actual discovery is implementation-dependent and usually is strictly related to the implementation of the communication protocol.

There is one implementation of the neighbourhood scanner available: Hazelcast neighbourhood scanner (available in the Maven module org.jage.services.communication-hazelcast).

Communication protocol

A communication protocol provides means for the communication manager to communicate with other nodes. It is usually implemented using some third-party libraries or standards.

Each implemented protocol needs to provide two mechanisms:

  • sending standard AgE messages (they are always serializable),
  • delivering received messages through the observer pattern (listeners implement the IMessageReceivedListener interface).

Messages going to or from the communication manager will always be "pure" AgE messages to components, i.e. they will be of the type: IMessage<? extends IComponentAddress, ? extends Serializable>. Additionally, the receiver selector will be an unicast selector.

You can obtain the target node address from the message using the following code:

MessageUtils.getOnlyReceiverAddress(message).getNodeAddress()

There are two implementations of the communication protocol available:

  1. Hazelcast Publish-Subscribe protocol,
  2. Hazelcast Send-Receive protocol.

Both available in the Maven module org.jage.services.communication-hazelcast.

Address cache

The address cache is a database containing addresses of found remote nodes. It is filled by the neighbourhood scanner. The name "cache" was chosen to remember that information found in it is transient and it may not reflect the physical world.

There are two types of the cache:

  • Set of node addresses.
  • Map of node addresses to their physical representation.

The second version was needed to support all possible protocols that require usage of any kind of a "physical" address (e.g. IP address).

Attachments: