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 !
-
Protocol()
-
-
Down(Event)
- An event is to be sent down the stack.
-
GetDownProtocol()
-
-
GetName()
-
-
GetProperties()
-
-
GetUpProtocol()
-
-
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).
-
PassUp(Event)
- Causes the event to be forwarded to the next layer up in the hierarchy.
-
ProvidedDownServices()
- List of events that are provided to layers below (they will be handled when sent down from
below)
-
ProvidedUpServices()
- List of events that are provided to layers above (they will be handled when sent down from
above)
-
RequiredDownServices()
- List of events that are required to be answered by some layer below
-
RequiredUpServices()
- List of events that are required to be answered by some layer above
-
Reset()
- Used when new member joins (new stack needs to start from a defined point),
typically just resetting its state.
-
SetDownProtocol(Protocol)
-
-
SetProperties(Properties)
- Configures the protocol initially.
-
SetProtocolStack(ProtocolStack)
-
-
SetUpProtocol(Protocol)
-
-
StartInternal()
- Used internally.
-
StopInternal()
- Used internally.
-
Up(Event)
- An event was received from the layer below.
Protocol
public Protocol()
SetProperties
public boolean 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"
GetProperties
public Properties GetProperties()
RequiredUpServices
public Vector RequiredUpServices()
- List of events that are required to be answered by some layer above
RequiredDownServices
public Vector RequiredDownServices()
- List of events that are required to be answered by some layer below
ProvidedUpServices
public Vector ProvidedUpServices()
- List of events that are provided to layers above (they will be handled when sent down from
above)
ProvidedDownServices
public Vector ProvidedDownServices()
- List of events that are provided to layers below (they will be handled when sent down from
below)
GetName
public abstract String GetName()
GetUpProtocol
public Protocol GetUpProtocol()
GetDownProtocol
public Protocol GetDownProtocol()
SetUpProtocol
public void SetUpProtocol(Protocol up_prot)
SetDownProtocol
public void SetDownProtocol(Protocol down_prot)
SetProtocolStack
public void SetProtocolStack(ProtocolStack stack)
StartInternal
public void StartInternal()
- Used internally. If overridden, call parent's method first
StopInternal
public void StopInternal()
- Used internally. If overridden, call parent's method first
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.
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).
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).
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
.
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