org.jgroups.stack

Class ProtocolStack

public class ProtocolStack extends Protocol implements Transport

A ProtocolStack manages a number of protocols layered above each other. It creates all protocol classes, initializes them and, when ready, starts all of them, beginning with the bottom most protocol. It also dispatches messages received from the stack to registered objects (e.g. channel, GMP) and sends messages sent by those objects down the stack.

The ProtocolStack makes use of the Configurator to setup and initialize stacks, and to destroy them again when not needed anymore

Author: Bela Ban

Field Summary
static intABOVE
static intBELOW
TimeSchedulertimer
Constructor Summary
ProtocolStack(JChannel channel, String setup_string)
ProtocolStack()
Only used by Simulator; don't use
Method Summary
ProtocolcreateProtocol(String prot_spec)
Creates a new protocol given the protocol specification.
voiddestroy()
voiddown(Event evt)
MapdumpStats()
StringdumpTimerQueue()
ProtocolfindProtocol(String name)
Returns a given protocol or null if not found
voidflushEvents()
Not needed anymore, just left in here for backwards compatibility with JBoss AS
ChannelgetChannel()
StringgetName()
VectorgetProtocols()
Returns all protocols in a list, from top to bottom.
voidinsertProtocol(Protocol prot, int position, String neighbor_prot)
Inserts an already created (and initialized) protocol into the protocol list.
StringprintProtocolSpec(boolean include_properties)
Prints the names of the protocols, from the bottom to top.
StringprintProtocolSpecAsXML()
Objectreceive(long timeout)
protected voidreceiveUpEvent(Event evt)
voidremoveProtocol(String prot_name)
Removes a protocol from the stack.
voidsend(Message msg)
voidsetup()
voidstartDownHandler()
voidstartStack()
Start all layers.
voidstartUpHandler()
voidstartWork()
Override with null functionality: we don't need any threads to be started !
voidstopInternal()
voidstopStack()
Iterates through all the protocols from top to bottom and does the following:
  1. Waits until all messages in the down queue have been flushed (ie., size is 0)
  2. Calls stop() on the protocol
voidstopWork()
Override with null functionality: we don't need any threads to be started !
voidup(Event evt)

Field Detail

ABOVE

public static final int ABOVE

BELOW

public static final int BELOW

timer

public final TimeScheduler timer

Constructor Detail

ProtocolStack

public ProtocolStack(JChannel channel, String setup_string)

ProtocolStack

public ProtocolStack()
Only used by Simulator; don't use

Method Detail

createProtocol

public Protocol createProtocol(String prot_spec)
Creates a new protocol given the protocol specification.

Parameters: prot_spec The specification of the protocol. Same convention as for specifying a protocol stack. An exception will be thrown if the class cannot be created. Example:

"VERIFY_SUSPECT(timeout=1500)"
Note that no colons (:) have to be specified

Returns: Protocol The newly created protocol

Throws: Exception Will be thrown when the new protocol cannot be created

destroy

public void destroy()

down

public void down(Event evt)

dumpStats

public Map dumpStats()

Returns: Map>

dumpTimerQueue

public String dumpTimerQueue()

findProtocol

public Protocol findProtocol(String name)
Returns a given protocol or null if not found

flushEvents

public void flushEvents()

Deprecated:

Not needed anymore, just left in here for backwards compatibility with JBoss AS

getChannel

public Channel getChannel()

getName

public String getName()

getProtocols

public Vector getProtocols()
Returns all protocols in a list, from top to bottom. These are not copies of protocols, so modifications will affect the actual instances !

insertProtocol

public void insertProtocol(Protocol prot, int position, String neighbor_prot)
Inserts an already created (and initialized) protocol into the protocol list. Sets the links to the protocols above and below correctly and adjusts the linked list of protocols accordingly. Note that this method may change the value of top_prot or bottom_prot.

Parameters: prot The protocol to be inserted. Before insertion, a sanity check will ensure that none of the existing protocols have the same name as the new protocol. position Where to place the protocol with respect to the neighbor_prot (ABOVE, BELOW) neighbor_prot The name of the neighbor protocol. An exception will be thrown if this name is not found

Throws: Exception Will be thrown when the new protocol cannot be created, or inserted.

printProtocolSpec

public String printProtocolSpec(boolean include_properties)
Prints the names of the protocols, from the bottom to top. If include_properties is true, the properties for each protocol will also be printed.

printProtocolSpecAsXML

public String printProtocolSpecAsXML()

receive

public Object receive(long timeout)

receiveUpEvent

protected void receiveUpEvent(Event evt)

removeProtocol

public void removeProtocol(String prot_name)
Removes a protocol from the stack. Stops the protocol and readjusts the linked lists of protocols.

Parameters: prot_name The name of the protocol. Since all protocol names in a stack have to be unique (otherwise the stack won't be created), the name refers to just 1 protocol.

Throws: Exception Thrown if the protocol cannot be stopped correctly.

send

public void send(Message msg)

setup

public void setup()

startDownHandler

public void startDownHandler()

startStack

public void startStack()
Start all layers. The start method is called in each protocol, from top to bottom. Each layer can perform some initialization, e.g. create a multicast socket

startUpHandler

public void startUpHandler()

startWork

public void startWork()
Override with null functionality: we don't need any threads to be started !

stopInternal

public void stopInternal()

stopStack

public void stopStack()
Iterates through all the protocols from top to bottom and does the following:
  1. Waits until all messages in the down queue have been flushed (ie., size is 0)
  2. Calls stop() on the protocol

stopWork

public void stopWork()
Override with null functionality: we don't need any threads to be started !

up

public void up(Event evt)
Copyright ? 1998-2005 Bela Ban. All Rights Reserved.