|
||||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.javagroups.stack.Protocol | +--org.javagroups.stack.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
Field Summary | |
---|---|
static int |
ABOVE
|
static int |
BELOW
|
TimeScheduler |
timer
|
Fields inherited from class org.javagroups.stack.Protocol |
---|
down_handler, down_prot, down_queue, down_thread, down_thread_prio, observer, props, stack, up_handler, up_prot, up_queue, up_thread, up_thread_prio |
Constructor Summary | |
---|---|
ProtocolStack(JChannel channel,
java.lang.String setup_string)
|
Method Summary | |
---|---|
Protocol |
createProtocol(java.lang.String prot_spec)
Creates a new protocol given the protocol specification. |
void |
destroy()
This method is called on a Channel.close() . |
void |
down(Event evt)
An event is to be sent down the stack. |
Protocol |
findProtocol(java.lang.String name)
Returns a given protocol or null if not found |
java.lang.String |
getName()
|
java.util.Vector |
getProtocols()
Returns all protocols in a list, from top to bottom. |
void |
insertProtocol(Protocol prot,
int position,
java.lang.String neighbor_prot)
Inserts an already created (and initialized) protocol into the protocol list. |
java.lang.String |
printProtocolSpec(boolean include_properties)
Prints the names of the protocols, from the bottom to top. |
java.lang.Object |
receive(long timeout)
|
protected void |
receiveUpEvent(Event evt)
Internal method, should not be called by clients. |
void |
removeProtocol(java.lang.String prot_name)
Removes a protocol from the stack. |
void |
send(Message msg)
|
void |
setup()
|
void |
start()
Start all layers. |
void |
startDownHandler()
Used internally. |
void |
startUpHandler()
Used internally. |
void |
startWork()
Override with null functionality: we don't need any threads to be started ! |
void |
stop()
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 |
void |
stopInternal()
Used internally. |
void |
stopWork()
Override with null functionality: we don't need any threads to be started ! |
void |
up(Event evt)
An event was received from the layer below. |
Methods inherited from class org.javagroups.stack.Protocol |
---|
getDownProtocol, getDownQueue, getProperties, getUpProtocol, getUpQueue, init, passDown, passUp, providedDownServices, providedUpServices, receiveDownEvent, requiredDownServices, requiredUpServices, setDownProtocol, setObserver, setProperties, setPropertiesInternal, setProtocolStack, setUpProtocol |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public TimeScheduler timer
public static final int ABOVE
public static final int BELOW
Constructor Detail |
public ProtocolStack(JChannel channel, java.lang.String setup_string)
Method Detail |
public java.util.Vector getProtocols()
public java.lang.String printProtocolSpec(boolean include_properties)
public void setup() throws java.lang.Exception
java.lang.Exception
public Protocol createProtocol(java.lang.String prot_spec) throws java.lang.Exception
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
java.lang.Exception
- Will be thrown when the new protocol cannot be createdpublic void insertProtocol(Protocol prot, int position, java.lang.String neighbor_prot) throws java.lang.Exception
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
java.lang.Exception
- Will be thrown when the new protocol cannot be created, or inserted.public void removeProtocol(java.lang.String prot_name) throws java.lang.Exception
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.
java.lang.Exception
- Thrown if the protocol cannot be stopped correctly.public Protocol findProtocol(java.lang.String name)
public void destroy()
Protocol
Channel.close()
.
Does some cleanup; after the call the VM will terminate
destroy
in class Protocol
public void start() throws java.lang.Exception
Protocol.start()
method is called in each protocol,
from top to bottom.
Each layer can perform some initialization, e.g. create a multicast socket
start
in class Protocol
java.lang.Exception
- Thrown if protocol cannot be started successfully. This will cause the ProtocolStack
to fail, so Channel.connect(String)
will throw an exceptionpublic void startUpHandler()
Protocol
startUpHandler
in class Protocol
public void startDownHandler()
Protocol
startDownHandler
in class Protocol
public void stop()
stop
in class Protocol
public void stopInternal()
Protocol
stopInternal
in class Protocol
public void send(Message msg) throws java.lang.Exception
send
in interface Transport
java.lang.Exception
public java.lang.Object receive(long timeout) throws java.lang.Exception
receive
in interface Transport
java.lang.Exception
public java.lang.String getName()
getName
in class Protocol
public void up(Event evt)
Protocol
passDown()
or c) the event (or another event) is sent up
the stack using passUp()
.
up
in class Protocol
public void down(Event evt)
Protocol
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()
.
down
in class Protocol
protected void receiveUpEvent(Event evt)
Protocol
receiveUpEvent
in class Protocol
public void startWork()
public void stopWork()
|
||||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |