org.apache.cassandra.net
Interface IMessagingService

All Known Implementing Classes:
MessagingService

public interface IMessagingService

An IMessagingService provides the methods for sending messages to remote endpoints. IMessagingService enables the sending of request-response style messages and fire-forget style messages. Author : Avinash Lakshman ( alakshman@facebook.com) & Prashant Malik ( pmalik@facebook.com )


Method Summary
 void deregisterAllVerbHandlers(EndPoint localEndPoint)
          Deregister all verbhandlers corresponding to localEndPoint.
 void deregisterVerbHandlers(java.lang.String type)
          Deregister a verbhandler corresponding to the verb from the Messaging Service.
 IVerbHandler getVerbHandler(java.lang.String verb)
          This method returns the verb handler associated with the registered verb.
 void listen(EndPoint ep, boolean isHttp)
          Listen on the specified port.
 void listenUDP(EndPoint ep)
          Listen on the specified port.
 void registerVerbHandlers(java.lang.String type, IVerbHandler verbHandler)
          Register a verb and the corresponding verb handler with the Messaging Service.
 void sendOneWay(Message message, EndPoint to)
          Send a message to a given endpoint.
 java.lang.String sendRR(Message[][] messages, EndPoint[][] to, IAsyncCallback cb)
          Send a message to a given endpoint.
 IAsyncResult sendRR(Message[] messages, EndPoint[] to)
          Send a message to a given endpoint.
 java.lang.String sendRR(Message[] messages, EndPoint[] to, IAsyncCallback cb)
          Send a message to a given endpoint.
 IAsyncResult sendRR(Message message, EndPoint to)
          Send a message to a given endpoint.
 java.lang.String sendRR(Message message, EndPoint[] to, IAsyncCallback cb)
          Send a message to the given set of endpoints and informs the MessagingService to wait for at least howManyResults responses to determine success of failure.
 java.lang.String sendRR(Message message, EndPoint to, IAsyncCallback cb)
          Send a message to a given endpoint.
 void sendUdpOneWay(Message message, EndPoint to)
          Send a message to a given endpoint.
 void stream(java.lang.String file, long startPosition, long total, EndPoint from, EndPoint to)
          Stream a file from source to destination.
 

Method Detail

registerVerbHandlers

void registerVerbHandlers(java.lang.String type,
                          IVerbHandler verbHandler)
Register a verb and the corresponding verb handler with the Messaging Service.

Parameters:
type - name of the verb.
verbHandler - handler for the specified verb

deregisterAllVerbHandlers

void deregisterAllVerbHandlers(EndPoint localEndPoint)
Deregister all verbhandlers corresponding to localEndPoint.

Parameters:
localEndPoint -

deregisterVerbHandlers

void deregisterVerbHandlers(java.lang.String type)
Deregister a verbhandler corresponding to the verb from the Messaging Service.

Parameters:
type - name of the verb.

listen

void listen(EndPoint ep,
            boolean isHttp)
            throws java.io.IOException
Listen on the specified port.

Parameters:
ep - EndPoint whose port to listen on.
isHttp - specify if the port is an Http port.
Throws:
java.io.IOException

listenUDP

void listenUDP(EndPoint ep)
Listen on the specified port.

Parameters:
ep - EndPoint whose port to listen on.

sendRR

IAsyncResult sendRR(Message message,
                    EndPoint to)
Send a message to a given endpoint.

Parameters:
message - message to be sent.
to - endpoint to which the message needs to be sent
Returns:
an reference to an IAsyncResult which can be queried for the response

sendRR

java.lang.String sendRR(Message message,
                        EndPoint[] to,
                        IAsyncCallback cb)
Send a message to the given set of endpoints and informs the MessagingService to wait for at least howManyResults responses to determine success of failure.

Parameters:
message - message to be sent.
to - endpoints to which the message needs to be sent
cb - callback interface which is used to pass the responses
Returns:
an reference to message id used to match with the result

sendRR

java.lang.String sendRR(Message message,
                        EndPoint to,
                        IAsyncCallback cb)
Send a message to a given endpoint. This method specifies a callback which is invoked with the actual response.

Parameters:
message - message to be sent.
to - endpoint to which the message needs to be sent
cb - callback interface which is used to pass the responses or suggest that a timeout occured to the invoker of the send(). suggest that a timeout occured to the invoker of the send().
Returns:
an reference to message id used to match with the result

sendRR

java.lang.String sendRR(Message[] messages,
                        EndPoint[] to,
                        IAsyncCallback cb)
Send a message to a given endpoint. The ith element in the messages array is sent to the ith element in the to array.This method assumes there is a one-one mapping between the messages array and the to array. Otherwise an IllegalArgumentException will be thrown. This method also informs the MessagingService to wait for at least howManyResults responses to determine success of failure.

Parameters:
messages - messages to be sent.
to - endpoints to which the message needs to be sent
cb - callback interface which is used to pass the responses or suggest that a timeout occured to the invoker of the send().
Returns:
an reference to message id used to match with the result

sendRR

IAsyncResult sendRR(Message[] messages,
                    EndPoint[] to)
Send a message to a given endpoint. The ith element in the messages array is sent to the ith element in the to array.This method assumes there is a one-one mapping between the messages array and the to array. Otherwise an IllegalArgumentException will be thrown. This method also informs the MessagingService to wait for at least howManyResults responses to determine success of failure.

Parameters:
messages - messages to be sent.
to - endpoints to which the message needs to be sent
Returns:
an reference to IAsyncResult

sendRR

java.lang.String sendRR(Message[][] messages,
                        EndPoint[][] to,
                        IAsyncCallback cb)
Send a message to a given endpoint. The ith element in the messages array is sent to the ith element in the to array.This method assumes there is a one-one mapping between the messages array and the to array. Otherwise an IllegalArgumentException will be thrown. The idea is that multi-groups of messages are grouped as one logical message whose results are harnessed via the IAsyncResult

Parameters:
messages - groups of grouped messages.
to - destination for the groups of messages
cb - the callback handler to be invoked for the responses
Returns:
the group id which is basically useless - it is only returned for API's to look compatible.

sendOneWay

void sendOneWay(Message message,
                EndPoint to)
Send a message to a given endpoint. This method adheres to the fire and forget style messaging.

Parameters:
message - messages to be sent.
to - endpoint to which the message needs to be sent

sendUdpOneWay

void sendUdpOneWay(Message message,
                   EndPoint to)
Send a message to a given endpoint. This method adheres to the fire and forget style messaging.

Parameters:
message - messages to be sent.
to - endpoint to which the message needs to be sent

stream

void stream(java.lang.String file,
            long startPosition,
            long total,
            EndPoint from,
            EndPoint to)
Stream a file from source to destination. This is highly optimized to not hold any of the contents of the file in memory.

Parameters:
file - name of file to stream. param start position inside the file param total number of bytes to stream param to endpoint to which we need to stream the file.

getVerbHandler

IVerbHandler getVerbHandler(java.lang.String verb)
This method returns the verb handler associated with the registered verb. If no handler has been registered then null is returned.

Parameters:
verb - for which the verb handler is sought
Returns:
a reference to IVerbHandler which is the handler for the specified verb


Copyright © 2009 The Apache Software Foundation