All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class JavaGroups.JavaStack.Protocol

java.lang.Object
   |
   +----JavaGroups.JavaStack.Protocol

public abstract class Protocol
extends Object
The Protocol class provides a set of common services for protocol layers. Each layer has to be a subclass of Protocol and override a number of methods (typically just Up, Down and GetName. Layers are stacked in a certain order to form a protocol stack. Events are passed from lower layers to upper ones and vice versa. E.g. a Message received by the UDP layer at the bottom will be passed to its higher layer as an Event. That layer will in turn pass the Event to its layer and so on, until a layer handles the Message and sends a response or discards it, the former resulting in another Event being passed down the stack.

Each layer has 2 FIFO queues, one for up Events and one for down Events. When an Event is received by a layer (calling the internal upcall ReceiveUpEvent), it is placed in the up-queue where it will be retrieved by the up-handler thread which will invoke method Up of the layer. The same applies for Events traveling down the stack. Handling of the up-handler and down-handler threads and the 2 FIFO queues is donw by the Protocol class, subclasses will almost never have to override this behavior.

The important thing to bear in mind is that Events have to passed on between layers in FIFO order which is guaranteed by the Protocol implementation and must be guranteed by subclasses implementing their on Event queuing.

Note that each class implementing interface Protocol MUST provide an empty, public constructor !


Constructor Index

 o Protocol()

Method Index

 o Down(Event)
An event is to be sent down the stack.
 o GetDownProtocol()
 o GetName()
 o GetProperties()
 o GetUpProtocol()
 o PassDown(Event)
Causes the event to be forwarded to the next layer down in the hierarchy.Typically called by the implementation of Down (when done).
 o PassUp(Event)
Causes the event to be forwarded to the next layer up in the hierarchy.
 o Reset()
Used when new member joins (new stack needs to start from a defined point), typically just resetting its state.
 o SetDownProtocol(Protocol)
 o SetProperties(Properties)
Configures the protocol initially.
 o SetProtocolStack(ProtocolStack)
 o SetUpProtocol(Protocol)
 o StartInternal()
Used internally.
 o StartWork()
Initialize data structures, start own threads etc.
 o StopInternal()
Used internally.
 o StopWork()
Delete data structures, stop own threads etc.
 o Up(Event)
An event was received from the layer below.

Constructors

 o Protocol
 public Protocol()

Methods

 o SetProperties
 public void SetProperties(Properties props)
Configures the protocol initially. A configuration string consists of name=value items, separated by a ';' (semicolon), e.g.:
 "loopback=false;unicast_inport=4444"
 

 o GetProperties
 public Properties GetProperties()
 o GetName
 public abstract String GetName()
 o GetUpProtocol
 public Protocol GetUpProtocol()
 o GetDownProtocol
 public Protocol GetDownProtocol()
 o SetUpProtocol
 public void SetUpProtocol(Protocol up_prot)
 o SetDownProtocol
 public void SetDownProtocol(Protocol down_prot)
 o SetProtocolStack
 public void SetProtocolStack(ProtocolStack stack)
 o StartInternal
 public void StartInternal()
Used internally. If overridden, call parent's method first

 o StopInternal
 public void StopInternal()
Used internally. If overridden, call parent's method first

 o StartWork
 public void StartWork()
Initialize data structures, start own threads etc.

 o StopWork
 public void StopWork()
Delete data structures, stop own threads etc.

 o Reset
 public void Reset()
Used when new member joins (new stack needs to start from a defined point), typically just resetting its state. For example, a sliding window protocol used for negative acknowledgement would reset its lower mark to 0 again.

 o PassUp
 public void PassUp(Event evt)
Causes the event to be forwarded to the next layer up in the hierarchy. Typically called by the implementation of Up (when done).

 o PassDown
 public void PassDown(Event evt)
Causes the event to be forwarded to the next layer down in the hierarchy.Typically called by the implementation of Down (when done).

 o Up
 public void Up(Event evt)
An event was received from the layer below. Usually the current layer will want to examine the event type and - depending on its type - perform some computation (e.g. removing headers from a MSG event type, or updating the internal membership list when receiving a VIEW_CHANGE event). Finally the event is either a) discarded, or b) an event is sent down the stack using PassDown or c) the event (or another event) is sent up the stack using PassUp.

 o Down
 public void Down(Event evt)
An event is to be sent down the stack. The layer may want to examine its type and perform some action on it, depending on the event's type. If the event is a message MSG, then the layer may need to add a header to it (or do nothing at all) before sending it down the stack using PassDown. In case of a GET_ADDRESS event (which tries to retrieve the stack's address from one of the bottom layers), the layer may need to send a new response event back up the stack using PassUp.


All Packages  Class Hierarchy  This Package  Previous  Next  Index