All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class JavaGroups.JavaStack.Protocols.FLUSH

java.lang.Object
   |
   +----JavaGroups.JavaStack.Protocol
           |
           +----JavaGroups.JavaStack.MessageProtocol
                   |
                   +----JavaGroups.JavaStack.RpcProtocol
                           |
                           +----JavaGroups.JavaStack.Protocols.FLUSH

public class FLUSH
extends RpcProtocol
The task of the FLUSH protocol is to flush all pending messages out of the system. This is done before a view change by stopping all senders and then agreeing on what messages should be delivered in the current view (before switching to the new view). A coordinator broadcasts a FLUSH message. The message contains an array of the highest sequence number for each member as seen by the coordinator so far. Each member responds with its highest sequence numbers seen so far (for each member): if its sequence number for a member P is higher than the one sent by the coordinator, it will append the messages apparently not received by the coordinator to its reply. The coordinator (when all replies have been received), computes for each member the lowest and highest sequence number and re-broadcasts messages accordingly (using ACKs rather then NAKs to ensure reliable delivery).

Example:

FLUSH  ---> (p=10, q=22, r=7)
<-- (p=10, q=20, r=7)    (did not receive 2 messages from q)
<-- (p=12, q=23, r=7)    (attached are messages p11, p12, and q23)
<-- (p=10, q=22, r=8)    (attached is message r8)
---------------------
min:   11    21    8
max:   12    23    8
The coordinator now computes the range for each member and re-broadcasts messages p11, p12, q21, q22, q23 and r8. This is essentially the exclusive min and inclusive max of all replies. Note that messages p11, p12 and q23 were not received by the coordinator itself before. They were only returned as result of the FLUSH replies and the coordinator now re-broadcasts them.


Constructor Index

 o FLUSH()

Method Index

 o GetName()
 o HandleDownEvent(Event)
Callback.
 o HandleFlush(long[])
Called by coordinator running the FLUSH protocol.
 o HandleUpEvent(Event)
Callback.
 o ProvidedUpServices()
List of events that are provided to layers above (they will be handled when sent down from above).
 o ReceiveDownEvent(Event)
The default handling adds the event to the down-queue where events are handled in order of addition by a thread.
 o RequiredDownServices()
List of events that are required to be answered by some layer below.
 o SetProperties(Properties)
Configures the protocol initially.

Constructors

 o FLUSH
 public FLUSH()

Methods

 o GetName
 public String GetName()
Overrides:
GetName in class RpcProtocol
 o ProvidedUpServices
 public Vector ProvidedUpServices()
List of events that are provided to layers above (they will be handled when sent down from above).

Overrides:
ProvidedUpServices in class Protocol
 o RequiredDownServices
 public Vector RequiredDownServices()
List of events that are required to be answered by some layer below.

Overrides:
RequiredDownServices in class Protocol
 o HandleFlush
 public Digest HandleFlush(long highest_seqnos[])
Called by coordinator running the FLUSH protocol. Argument is an array of the highest seqnos as seen by the coordinator (for each member). HandleFlush() checks for each member its own highest seqno seen for that member. If it is higher than the one seen by the coordinator, all higher messages are attached to the return value (a message digest).

Parameters:
highest_seqnos - The highest sequence numbers (order corresponding to membership) as seen by coordinator.
Returns:
Digest An array of the highest seqnos for each member, as seen by this member. If this member's seqno for a member P is higher than the one in highest_seqnos, the missing messages are added to the message digest as well. This allows the coordinator to re-broadcast missing messages.
 o HandleUpEvent
 public boolean HandleUpEvent(Event evt)
Callback. Called by superclass when event may be handled.

Do not use PassUp in this method as the event is passed up by default by the superclass after this method returns !

Returns:
boolean Defaults to true. If false, event will not be passed up the stack.
Overrides:
HandleUpEvent in class RpcProtocol
 o HandleDownEvent
 public boolean HandleDownEvent(Event evt)
Callback. Called by superclass when event may be handled.

Do not use PassDown in this method as the event is passed down by default by the superclass after this method returns !

Returns:
boolean Defaults to true. If false, event will not be passed down the stack.
Overrides:
HandleDownEvent in class RpcProtocol
 o ReceiveDownEvent
 public void ReceiveDownEvent(Event evt)
The default handling adds the event to the down-queue where events are handled in order of addition by a thread. However, there exists a deadlock between the FLUSH and BLOCK_OK down events: when a FLUSH event is received, a BLOCK is sent up, which triggers a BLOCK_OK event to be sent down to be handled by the FLUSH layer. However, the FLUSH layer's thread is still processing the FLUSH down event and is therefore blocked, waiting for a BLOCK_OK event. Therefore, the BLOCK_OK event has to 'preempt' the FLUSH event processing. This is done by overriding this method: when a BLOCK_OK event is received, it is processed immediately (in parallel to the FLUSH event), which causes the FLUSH event processing to return.

Overrides:
ReceiveDownEvent in class Protocol
 o SetProperties
 public boolean SetProperties(Properties props)
Configures the protocol initially.

Overrides:
SetProperties in class Protocol

All Packages  Class Hierarchy  This Package  Previous  Next  Index