public class

HelixIPCMessageManager

extends Object
implements HelixIPCService
java.lang.Object
   ↳ org.apache.helix.ipc.HelixIPCMessageManager

Class Overview

A wrapper around a base IPC service that manages message retries / timeouts.

This class manages retries and timeouts, and can be used in the same way as a HelixIPCService.

A message will be sent until the max number of retries has been reached (i.e. timed out), or it is acknowledged by the recipient. If the max number of retries is -1, it will be retried forever.

A callback should be registered for every acknowledgement message type associated with any original message type sent by this class.

For example, consider we have the two message types defined: DATA_REQ = 1, DATA_ACK = 2. One would do the following:

 messageManager.registerCallback(DATA_ACK, new HelixIPCCallback() {
   public void onMessage(HelixMessageScope scope, UUID messageId, ByteBuf message) {
     // Process ACK
   }
 
   public void onError(HelixMessageScope scope, UUID messageId, Throwable cause) {
     // Message error or timeout
   }
 });
 
 messageManager.send(destinations, DATA_REQ, messageId, data);
 

In send, we note messageId, and retry until we get a DATA_ACK for the same messageId. The callback registered with the message manager will only be called once, even if the message is acknowledged several times.

Summary

[Expand]
Inherited Constants
From interface org.apache.helix.ipc.HelixIPCService
Public Constructors
HelixIPCMessageManager(ScheduledExecutorService scheduler, HelixIPCService baseIpcService, long messageTimeoutMillis, int maxNumRetries)
Public Methods
void registerCallback(int messageType, HelixIPCCallback callback)
Registers a callback for a given message type
void send(HelixAddress destination, int messageType, UUID messageId, ByteBuf message)
Sends a message to one or more instances that map to a cluster scope.
void shutdown()
Shuts down service and releases any resources
void start()
Starts service (must call before send(HelixAddress, int, UUID, ByteBuf))
[Expand]
Inherited Methods
From class java.lang.Object
From interface org.apache.helix.ipc.HelixIPCService

Public Constructors

public HelixIPCMessageManager (ScheduledExecutorService scheduler, HelixIPCService baseIpcService, long messageTimeoutMillis, int maxNumRetries)

Public Methods

public void registerCallback (int messageType, HelixIPCCallback callback)

Registers a callback for a given message type

public void send (HelixAddress destination, int messageType, UUID messageId, ByteBuf message)

Sends a message to one or more instances that map to a cluster scope.

public void shutdown ()

Shuts down service and releases any resources

Throws
Exception

public void start ()

Starts service (must call before send(HelixAddress, int, UUID, ByteBuf))

Throws
Exception