jgroup.relacs.gm
Class MulticastLayer

java.lang.Object
  extended by jgroup.relacs.gm.MulticastLayer
All Implemented Interfaces:
Layer, MulticastService, EventTags, DispatcherListener

public final class MulticastLayer
extends java.lang.Object
implements MulticastService, DispatcherListener, EventTags

The MulticastLayer class implements the multicast service.

Since:
Jgroup 2.2
Author:
Alberto Montresor, Hein Meling

Nested Class Summary
 
Nested classes/interfaces inherited from interface jgroup.core.Layer
Layer.FinalizeLayer
 
Field Summary
 
Fields inherited from interface jgroup.relacs.events.EventTags
DAEMON_FAILURE_EVENT, DELIVERY_ACK, DELIVERY_EVENT, INSTALL_ACK, INSTALL_EVENT, JOIN_REQUEST, LEAVE_REQUEST, MEMBER_LEFT_EVENT, MULTICAST_REQUEST, PREPARE_ACK, PREPARE_EVENT
 
Method Summary
 void addListener(java.lang.Object listener)
          Add a listener object for this layer to provide upcalls to in response to multicast events.
 int[] eventTypes()
          Returns the set of event types supported by this listener.
static MulticastLayer getLayer(DispatcherService ds, MembershipService pgms)
           
 java.io.OutputStream getMessage(java.lang.String protocol)
          Returns an output stream to be used to encode a message.
 void mcast(java.io.OutputStream stream, AckListener ackl)
          Multicast a message enclosed in the stream out to the members of the current view of the group.
 void mcast(java.io.OutputStream out, AckListener ackl, ChainIdentifier chId)
          Multicast a message enclosed in the stream out to the members of the current view of the group.
 void mcast(java.lang.String protocol, java.lang.Object obj, AckListener ackl)
          Multicast a serializable object to the members of the current view of a group.
 void notifyEvent(Event event)
          This method is invoked by a dispatcher to notify a listener about an event.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getLayer

public static MulticastLayer getLayer(DispatcherService ds,
                                      MembershipService pgms)
                               throws JgroupException
Throws:
JgroupException

addListener

public void addListener(java.lang.Object listener)
Add a listener object for this layer to provide upcalls to in response to multicast events.

Specified by:
addListener in interface Layer
Parameters:
listener - An Object representation of the listener interface. This will typically be cast to the appropriate listener interface type after checking the type with the instanceof operator.

mcast

public void mcast(java.io.OutputStream out,
                  AckListener ackl,
                  ChainIdentifier chId)
           throws JgroupException
Description copied from interface: MulticastService
Multicast a message enclosed in the stream out to the members of the current view of the group.

The invoker may specify an AckListener object, which will be notified when objects returned by members delivering this message, are received.

Specified by:
mcast in interface MulticastService
Parameters:
out - The stream message to be multicast.
ackl - Acknowledgement listener to be notified; if null, no listener will be notified.
chId - Identifier of a previous message (delivered through a deliverStream). This is only required for multicast messages that relate to some previous multicast message. It will only be used in extremely rare cases, to avoid that the membership service delays the message while running the agreement protocol, which would otherwise prevent the agreement protocol from concluding.
Throws:
JgroupException - Rasied if the group manager receives a request to multicast a message after having joined a group, but before having received the first view for it; or after having requested to leave the group.

mcast

public void mcast(java.io.OutputStream stream,
                  AckListener ackl)
           throws JgroupException
Description copied from interface: MulticastService
Multicast a message enclosed in the stream out to the members of the current view of the group.

The invoker may specify an AckListener object, which will be notified when objects returned by members delivering this message, are received.

Specified by:
mcast in interface MulticastService
Parameters:
stream - The stream message to be multicast.
ackl - Acknowledgement listener to be notified; if null, no listener will be notified.
Throws:
JgroupException - Rasied if the group manager receives a request to multicast a message after having joined a group, but before having received the first view for it; or after having requested to leave the group.

mcast

public void mcast(java.lang.String protocol,
                  java.lang.Object obj,
                  AckListener ackl)
           throws JgroupException,
                  java.io.IOException
Description copied from interface: MulticastService
Multicast a serializable object to the members of the current view of a group.

The invoker may specify an AckListener object, which will be notified when objects returned by members delivering this message are received.

Specified by:
mcast in interface MulticastService
Parameters:
protocol - The protocol for the message object to be multicast.
obj - The message object to be multicast.
ackl - Acknowledgement listener to be notified; if null, no listener will be notified.
Throws:
JgroupException - Rasied if the group manager receives a request to multicast a message after having joined a group, but before having received the first view for it; or after having requested to leave the group.
java.io.IOException - Raised if the object to be multicast could not be serialized.

getMessage

public java.io.OutputStream getMessage(java.lang.String protocol)
                                throws java.io.IOException
Description copied from interface: MulticastService
Returns an output stream to be used to encode a message. Method mcast(OutputStream, AckListener) accepts only multicast messages obtained through this method. The provided output stream is a memory data structure optimized to avoid useless data copies.

Specified by:
getMessage in interface MulticastService
Parameters:
protocol - The protocol name used for the OutputStream message object to be multicast.
Throws:
java.io.IOException

eventTypes

public int[] eventTypes()
Description copied from interface: DispatcherListener
Returns the set of event types supported by this listener. Legal event types are given in the EventTags interface.

Specified by:
eventTypes in interface DispatcherListener

notifyEvent

public void notifyEvent(Event event)
Description copied from interface: DispatcherListener
This method is invoked by a dispatcher to notify a listener about an event.

Specified by:
notifyEvent in interface DispatcherListener
Parameters:
event - The Event object to be processed.


Copyright © 1998-2006 The Jgroup/ARM development team. All Rights Reserved.