public interface

ClusterMessagingService

org.apache.helix.ClusterMessagingService
Known Indirect Subclasses

Class Overview

Provides the ability to

  • Send message to a specific component in the cluster[ participant, controller, Spectator(probably not needed) ]
  • Broadcast message to all participants
  • Send message to instances that hold a specific resource
  • Asynchronous request response api. Send message with a co-relation id and invoke a method when there is a response. Can support timeout.
  • Summary

    Public Methods
    abstract Map<InstanceTypeList<Message>> generateMessage(Criteria recipientCriteria, Message messageTemplate)
    This will generate all messages to be sent given the recipientCriteria and MessageTemplate, the messages are not sent.
    abstract void registerMessageHandlerFactory(String type, MessageHandlerFactory factory)
    This will register a message handler factory to create handlers for message.
    abstract int send(Criteria receipientCriteria, Message message, AsyncCallback callbackOnReply, int timeOut, int retryCount)
    abstract int send(Criteria receipientCriteria, Message message, AsyncCallback callbackOnReply, int timeOut)
    This will send the message to all instances matching the criteria
    When there is a reply to the message sent AsyncCallback.onReply will be invoked.
    abstract int send(Criteria recipientCriteria, Message message)
    Send message matching the specifications mentioned in recipientCriteria.
    abstract int sendAndWait(Criteria receipientCriteria, Message message, AsyncCallback callbackOnReply, int timeOut, int retryCount)
    abstract int sendAndWait(Criteria receipientCriteria, Message message, AsyncCallback callbackOnReply, int timeOut)
    This will send the message to all instances matching the criteria
    When there is a reply to the message sent AsynCallback.onReply will be invoked.

    Public Methods

    public abstract Map<InstanceTypeList<Message>> generateMessage (Criteria recipientCriteria, Message messageTemplate)

    This will generate all messages to be sent given the recipientCriteria and MessageTemplate, the messages are not sent.

    Parameters
    messageTemplate the Message on which to base the messages to send
    Returns
    • messages to be sent, grouped by the type of instance to send the message to

    public abstract void registerMessageHandlerFactory (String type, MessageHandlerFactory factory)

    This will register a message handler factory to create handlers for message. In case client code defines its own message type, it can define a message handler factory to create handlers to process those messages. Messages are processed in a threadpool which is hosted by cluster manager, and cluster manager will call the factory to create handler, and the handler is called in the threadpool. Note that only one message handler factory can be registered with one message type.

    Parameters
    type The message type that the factory will create handler for
    factory The per-type message factory

    public abstract int send (Criteria receipientCriteria, Message message, AsyncCallback callbackOnReply, int timeOut, int retryCount)

    Parameters
    retryCount maximum number of times to retry the send
    Returns
    • the number of messages that were successfully sent

    public abstract int send (Criteria receipientCriteria, Message message, AsyncCallback callbackOnReply, int timeOut)

    This will send the message to all instances matching the criteria
    When there is a reply to the message sent AsyncCallback.onReply will be invoked. Application can specify a timeout on AsyncCallback. After every reply is processed AsyncCallback.isDone will be invoked.
    This method will return after sending the messages.
    This is useful when message need to be sent and current thread need not wait for response since processing will be done in another thread.

    Parameters
    callbackOnReply callback to trigger on completion
    timeOut Time to wait before failing the send
    Returns
    • the number of messages that were successfully sent

    public abstract int send (Criteria recipientCriteria, Message message)

    Send message matching the specifications mentioned in recipientCriteria.

    Parameters
    message message to be sent. Some attributes of this message will be changed as required
    Returns
    • the number of messages that were successfully sent.

    public abstract int sendAndWait (Criteria receipientCriteria, Message message, AsyncCallback callbackOnReply, int timeOut, int retryCount)

    Returns
    • the number of messages that were successfully sent

    public abstract int sendAndWait (Criteria receipientCriteria, Message message, AsyncCallback callbackOnReply, int timeOut)

    This will send the message to all instances matching the criteria
    When there is a reply to the message sent AsynCallback.onReply will be invoked. Application can specify a timeout on AsyncCallback. After every reply is processed AsyncCallback.isDone will be invoked.
    This method will return only after the AsyncCallback.isDone() returns true
    This is useful when message need to be sent and current thread has to wait for response.
    The current thread can use callbackOnReply instance to store application specific data.

    Returns
    • the number of messages that were successfully sent