Rice Pastry API

rice.pastry.messaging
Class MessageDispatch

java.lang.Object
  extended byrice.pastry.messaging.MessageDispatch

public class MessageDispatch
extends java.lang.Object

An object which remembers the mapping from names to MessageReceivers and dispatches messages by request. For consistent routing, modified to only deliver messages to applications if the PastryNode.isReady(). It will still deliver messages to any non-PastryAppl because these "services" may be needed to boot the node into the ring. Any messages to a PastryAppl will be buffered until the node goes ready. TODO: We need to make it explicit which apps can receive messages before PastryNode.isReady().

Version:
$Id: MessageDispatch.java,v 1.21 2005/08/09 14:45:12 jeffh Exp $
Author:
Jeff Hoye, Andrew Ladd

Field Summary
static java.lang.String BUFFER_IF_NOT_READY_PARAM
          DESCRIBE THE FIELD
static java.lang.String BUFFER_SIZE_PARAM
          DESCRIBE THE FIELD
protected  PastryNode localNode
          DESCRIBE THE FIELD
 
Constructor Summary
MessageDispatch(PastryNode pn)
          Constructor.
 
Method Summary
 void deliverAllBufferedMessages()
          Called when PastryNode.isReady() becomes true.
protected  void deliverBuffered(Address address)
          Deliveres all buffered messages for the address.
 void destroy()
          DESCRIBE THE METHOD
 boolean dispatchMessage(Message msg)
          Dispatches a message to the appropriate receiver.
 MessageReceiver getDestination(Message msg)
          Gets the Destination attribute of the MessageDispatch object
 MessageReceiver getDestinationByAddress(Address addr)
          Gets the DestinationByAddress attribute of the MessageDispatch object
 void registerReceiver(Address address, MessageReceiver receiver)
          Registers a receiver with the mail service.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

localNode

protected PastryNode localNode
DESCRIBE THE FIELD


BUFFER_IF_NOT_READY_PARAM

public static final java.lang.String BUFFER_IF_NOT_READY_PARAM
DESCRIBE THE FIELD

See Also:
Constant Field Values

BUFFER_SIZE_PARAM

public static final java.lang.String BUFFER_SIZE_PARAM
DESCRIBE THE FIELD

See Also:
Constant Field Values
Constructor Detail

MessageDispatch

public MessageDispatch(PastryNode pn)
Constructor.

Parameters:
pn - DESCRIBE THE PARAMETER
Method Detail

getDestination

public MessageReceiver getDestination(Message msg)
Gets the Destination attribute of the MessageDispatch object

Parameters:
msg - DESCRIBE THE PARAMETER
Returns:
The Destination value

getDestinationByAddress

public MessageReceiver getDestinationByAddress(Address addr)
Gets the DestinationByAddress attribute of the MessageDispatch object

Parameters:
addr - DESCRIBE THE PARAMETER
Returns:
The DestinationByAddress value

registerReceiver

public void registerReceiver(Address address,
                             MessageReceiver receiver)
Registers a receiver with the mail service.

Parameters:
receiver - the receiver.
address - DESCRIBE THE PARAMETER

dispatchMessage

public boolean dispatchMessage(Message msg)
Dispatches a message to the appropriate receiver. It will buffer the message under the following conditions: 1) The MessageReceiver is not yet registered. 2) The MessageReceiver is a PastryAppl, and localNode.isReady() == false

Parameters:
msg - the message.
Returns:
true if message could be dispatched, false otherwise.

deliverBuffered

protected void deliverBuffered(Address address)
Deliveres all buffered messages for the address. Unless: 1) The MR for the address is still null. 2) The MR is a PastryAppl and localNode.isReady() == false

Parameters:
address -

deliverAllBufferedMessages

public void deliverAllBufferedMessages()
Called when PastryNode.isReady() becomes true. Delivers all buffered messages.


destroy

public void destroy()
DESCRIBE THE METHOD


Rice Pastry API

Copyright © 2001-2005 - Rice Pastry.


Imprint-Dataprotection