org.jgroups.stack
Class ProtocolStack
- Transport
public class ProtocolStack
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
down_handler , down_prot , down_queue , down_thread , down_thread_prio , log , observer , props , stack , up_handler , up_prot , up_queue , up_thread , up_thread_prio |
destroy , down , getDownProtocol , getDownQueue , getName , getProperties , getUpProtocol , getUpQueue , handleSpecialDownEvent , init , passDown , passUp , providedDownServices , providedUpServices , receiveDownEvent , receiveUpEvent , requiredDownServices , requiredUpServices , setDownProtocol , setObserver , setProperties , setPropertiesInternal , setProtocolStack , setUpProtocol , start , startDownHandler , startUpHandler , stop , stopInternal , up |
ABOVE
public static final int ABOVE
BELOW
public static final int BELOW
ProtocolStack
public ProtocolStack(JChannel channel,
String setup_string)
createProtocol
public Protocol createProtocol(String prot_spec)
throws Exception
Creates a new protocol given the protocol specification.
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
- Protocol The newly created protocol
findProtocol
public Protocol findProtocol(String name)
Returns a given protocol or null if not found
flushEvents
public void flushEvents()
Flushes all events currently in the down queues and returns when done. This guarantees
that all events sent before this call will have been handled.
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)
throws Exception
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.
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
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.
receive
public Object receive(long timeout)
throws Exception
- receive in interface Transport
removeProtocol
public void removeProtocol(String prot_name)
throws Exception
Removes a protocol from the stack. Stops the protocol and readjusts the linked lists of
protocols.
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.
setup
public void setup()
throws Exception
startStack
public void startStack()
throws Exception
Start all layers. The
Protocol.start()
method is called in each protocol,
from top to bottom.
Each layer can perform some initialization, e.g. create a multicast socket
startWork
public void startWork()
Override with null functionality: we don't need any threads to be started !
stopStack
public void stopStack()
Iterates through all the protocols
from top to bottom and does the following:
- Waits until all messages in the down queue have been flushed (ie., size is 0)
- Calls stop() on the protocol
stopWork
public void stopWork()
Override with null functionality: we don't need any threads to be started !
Copyright B) 2001,2002 www.jgroups.com . All Rights Reserved.