jgroup.relacs.gm
Class TotalOrderLayer

java.lang.Object
  extended by jgroup.relacs.gm.TotalOrderLayer
All Implemented Interfaces:
Layer, MembershipListener, MulticastListener, MulticastService

public final class TotalOrderLayer
extends java.lang.Object
implements MulticastService, MulticastListener, MembershipListener

The TotalOrderLayer class implements the multicast service, and uses the underlying reliable multicast service. Total ordering is accomplished using distributed agreement protocol similar to that of [Birman and Joseph 1987].

Since:
Jgroup 2.2
Author:
Hein Meling

Nested Class Summary
 
Nested classes/interfaces inherited from interface jgroup.core.Layer
Layer.FinalizeLayer
 
Nested classes/interfaces inherited from interface jgroup.core.MembershipListener
MembershipListener.AllowDuplicateViews
 
Method Summary
 void addListener(java.lang.Object listener)
          Add a listener object for this layer to provide upcalls to in response to multicast events.
 java.lang.Object deliverObject(java.lang.Object msg, MemberId id, int seq)
          Upcall that is invoked by Jgroup to deliver a message msg, corresponding to a single serialized object.
 java.lang.Object deliverStream(java.io.InputStream msg, MemberId sender, int seq)
          Upcall that is invoked by Jgroup to deliver a message msg, corresponding to an input stream from which the message may be read.
static TotalOrderLayer getLayer(MembershipService pgms, MulticastService mcast)
           
 java.io.OutputStream getMessage(java.lang.String protocol)
          Returns an output stream to be used to encode a message.
 java.lang.String getProtocolName()
          Returns a string naming the protocol implemented by this multicast listener.
 void hasLeft()
          Upcall that is invoked by Jgroup to acknowledge the fact that this object has left the group.
static void main(java.lang.String[] args)
           
 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 prepareChange()
          Upcall that is invoked by the group membership service to notify that the current view is not valid any more, and the group membership service is trying to reach an agreement on a new view.
 void viewChange(View view)
          Upcall invoked on members implementing the MembershipListener interface, when a view change occurs.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getLayer

public static TotalOrderLayer getLayer(MembershipService pgms,
                                       MulticastService mcast)
                                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.

viewChange

public void viewChange(View view)
Description copied from interface: MembershipListener
Upcall invoked on members implementing the MembershipListener interface, when a view change occurs.

Specified by:
viewChange in interface MembershipListener
Parameters:
view - The new view that has been installed.
See Also:
MembershipService

prepareChange

public void prepareChange()
Description copied from interface: MembershipListener
Upcall that is invoked by the group membership service to notify that the current view is not valid any more, and the group membership service is trying to reach an agreement on a new view.

Specified by:
prepareChange in interface MembershipListener
See Also:
MembershipService

hasLeft

public void hasLeft()
Description copied from interface: MembershipListener
Upcall that is invoked by Jgroup to acknowledge the fact that this object has left the group. This method is only invoked after the leave method has been invoked on the group membership service.

Specified by:
hasLeft in interface MembershipListener
See Also:
MembershipService

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

getProtocolName

public java.lang.String getProtocolName()
Description copied from interface: MulticastListener
Returns a string naming the protocol implemented by this multicast listener.

Specified by:
getProtocolName in interface MulticastListener

deliverStream

public java.lang.Object deliverStream(java.io.InputStream msg,
                                      MemberId sender,
                                      int seq)
Description copied from interface: MulticastListener
Upcall that is invoked by Jgroup to deliver a message msg, corresponding to an input stream from which the message may be read.

Specified by:
deliverStream in interface MulticastListener
Parameters:
msg - the input stream from which the message can be read.
sender - the sender of the multicast message
seq - the sequence number of this multicast message
Returns:
an object that will be delivered to the invoker through the AckListener object specified when multicasting the message.

deliverObject

public java.lang.Object deliverObject(java.lang.Object msg,
                                      MemberId id,
                                      int seq)
Description copied from interface: MulticastListener
Upcall that is invoked by Jgroup to deliver a message msg, corresponding to a single serialized object.

Specified by:
deliverObject in interface MulticastListener
Parameters:
msg - the object that was multicasted.
id - the sender of the multicast message
seq - the sequence number of this multicast message
Returns:
an object that will be delivered to the invoker through the AckListener object specified when multicasting the message.

main

public static void main(java.lang.String[] args)


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