org.objectweb.tribe.adapters
Class MulticastRequestAdapter

java.lang.Object
  extended byorg.objectweb.tribe.adapters.MulticastRequestAdapter
All Implemented Interfaces:
MessageListener

public class MulticastRequestAdapter
extends java.lang.Object
implements MessageListener

This class defines a MulticastRequestAdapter which is similar to JGroups MessageDispatcher. It is a sort of multicast RPC (Remote Procedure Call) where a message is multicasted and each member return a response.

Version:
1.0
Author:
Emmanuel Cecchet

Field Summary
static int WAIT_ALL
          Wait for all responses before returning of a multicast send
static int WAIT_FIRST
          Wait for the first reponse before returning of a multicast send
static int WAIT_MAJORITY
          Wait for a majority of responses before returning of a multicast send
static int WAIT_NONE
          Do not wait for any response when multicasting a message (asynchronous)
 
Constructor Summary
MulticastRequestAdapter(ReliableGroupChannel channel, MessageListener msgListener, MulticastRequestListener dispatcherListener)
          Creates a new MulticastRequestAdapter object
 
Method Summary
 ReliableGroupChannel getChannel()
          Returns the channel value.
 MulticastResponse multicastMessage(java.util.ArrayList dests, java.io.Serializable msg, int waitMode, long timeout)
          Multicast a message to the given list of member.
 void receive(java.io.Serializable msg)
          Callback when a message is received.
 void stop()
          Stop this MulticastRequestAdapter.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

WAIT_NONE

public static final int WAIT_NONE
Do not wait for any response when multicasting a message (asynchronous)

See Also:
Constant Field Values

WAIT_FIRST

public static final int WAIT_FIRST
Wait for the first reponse before returning of a multicast send

See Also:
Constant Field Values

WAIT_MAJORITY

public static final int WAIT_MAJORITY
Wait for a majority of responses before returning of a multicast send

See Also:
Constant Field Values

WAIT_ALL

public static final int WAIT_ALL
Wait for all responses before returning of a multicast send

See Also:
Constant Field Values
Constructor Detail

MulticastRequestAdapter

public MulticastRequestAdapter(ReliableGroupChannel channel,
                               MessageListener msgListener,
                               MulticastRequestListener dispatcherListener)
Creates a new MulticastRequestAdapter object

Method Detail

getChannel

public ReliableGroupChannel getChannel()
Returns the channel value.

Returns:
Returns the channel.

stop

public void stop()
Stop this MulticastRequestAdapter. This does not close the underlying channel but terminates the PullPushAdapter create for this MulticastRequestAdapter.


receive

public void receive(java.io.Serializable msg)
Description copied from interface: MessageListener
Callback when a message is received.

Specified by:
receive in interface MessageListener
Parameters:
msg - Message received.
See Also:
MessageListener.receive(java.io.Serializable)

multicastMessage

public MulticastResponse multicastMessage(java.util.ArrayList dests,
                                          java.io.Serializable msg,
                                          int waitMode,
                                          long timeout)
                                   throws TimeoutException,
                                          ChannelException,
                                          NotConnectedException
Multicast a message to the given list of member.

Parameters:
dests - members to send the message to1
msg - message to send
waitMode - one of WAIT_NONE, WAIT_FIRST, WAIT_MAJORITY or WAIT_ALL
timeout - time in ms to wait for responses (0 means no timeout)
Returns:
the response list
Throws:
TimeoutException - if the timeout expires
NotConnectedException - if the underlying channel is not connected to a group
ChannelException - if an error occurs during transmission


Copyright © 2004 - ObjectWeb Consortium - All Rights Reserved.