|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.jgroups.stack.Protocol
public abstract class Protocol
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.
Note that each class implementing interface Protocol MUST provide an empty, public constructor !
Field Summary | |
---|---|
protected Protocol |
down_prot
|
protected org.apache.commons.logging.Log |
log
|
protected java.util.Properties |
props
|
protected ProtocolStack |
stack
|
protected boolean |
stats
|
protected Protocol |
up_prot
|
Constructor Summary | |
---|---|
Protocol()
|
Method Summary | |
---|---|
void |
destroy()
This method is called on a Channel.close() . |
java.lang.Object |
down(Event evt)
An event is to be sent down the stack. |
boolean |
downThreadEnabled()
Deprecated. down thread was removed |
java.util.Map<java.lang.String,java.lang.Object> |
dumpStats()
|
void |
enableStats(boolean flag)
|
Protocol |
getDownProtocol()
|
abstract java.lang.String |
getName()
|
java.util.Properties |
getProperties()
|
ProtocolStack |
getProtocolStack()
|
ThreadFactory |
getThreadFactory()
Supposed to be overwritten by subclasses. |
protected TP |
getTransport()
|
Protocol |
getUpProtocol()
|
void |
init()
Called after instance has been created (null constructor) and before protocol is started. |
java.lang.String |
printStats()
|
java.util.Vector<java.lang.Integer> |
providedDownServices()
List of events that are provided to layers below (they will be handled when sent down from below). |
java.util.Vector<java.lang.Integer> |
providedUpServices()
List of events that are provided to layers above (they will be handled when sent down from above). |
java.util.Vector<java.lang.Integer> |
requiredDownServices()
List of events that are required to be answered by some layer below. |
java.util.Vector<java.lang.Integer> |
requiredUpServices()
List of events that are required to be answered by some layer above. |
void |
resetStats()
|
void |
setDownProtocol(Protocol down_prot)
|
boolean |
setProperties(java.util.Properties props)
Configures the protocol initially. |
boolean |
setPropertiesInternal(java.util.Properties props)
Called by Configurator. |
void |
setProtocolStack(ProtocolStack stack)
|
void |
setUpProtocol(Protocol up_prot)
|
void |
start()
This method is called on a Channel.connect(String) . |
boolean |
statsEnabled()
|
void |
stop()
This method is called on a Channel.disconnect() . |
java.lang.Object |
up(Event evt)
An event was received from the layer below. |
boolean |
upThreadEnabled()
Deprecated. up_thread was removed |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected final java.util.Properties props
protected Protocol up_prot
protected Protocol down_prot
protected ProtocolStack stack
protected boolean stats
protected final org.apache.commons.logging.Log log
Constructor Detail |
---|
public Protocol()
Method Detail |
---|
public boolean setProperties(java.util.Properties props)
"loopback=false;unicast_inport=4444"
public boolean setPropertiesInternal(java.util.Properties props)
public java.util.Properties getProperties()
public ProtocolStack getProtocolStack()
protected TP getTransport()
public ThreadFactory getThreadFactory()
public boolean upThreadEnabled()
public boolean downThreadEnabled()
public boolean statsEnabled()
public void enableStats(boolean flag)
public void resetStats()
public java.lang.String printStats()
public java.util.Map<java.lang.String,java.lang.Object> dumpStats()
public void init() throws java.lang.Exception
java.lang.Exception
- Thrown if protocol cannot be initialized successfully. This will cause the
ProtocolStack to fail, so the channel constructor will throw an exceptionpublic void start() throws java.lang.Exception
Channel.connect(String)
. Starts work.
Protocols are connected and queues are ready to receive events.
Will be called from bottom to top. This call will replace
the START and START_OK events.
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 stop()
Channel.disconnect()
. Stops work (e.g. by closing multicast socket).
Will be called from top to bottom. This means that at the time of the method invocation the
neighbor protocol below is still working. This method will replace the
STOP, STOP_OK, CLEANUP and CLEANUP_OK events. The ProtocolStack guarantees that
when this method is called all messages in the down queue will have been flushed
public void destroy()
Channel.close()
.
Does some cleanup; after the call the VM will terminate
public java.util.Vector<java.lang.Integer> requiredUpServices()
public java.util.Vector<java.lang.Integer> requiredDownServices()
public java.util.Vector<java.lang.Integer> providedUpServices()
public java.util.Vector<java.lang.Integer> providedDownServices()
public abstract java.lang.String getName()
public Protocol getUpProtocol()
public Protocol getDownProtocol()
public void setUpProtocol(Protocol up_prot)
public void setDownProtocol(Protocol down_prot)
public void setProtocolStack(ProtocolStack stack)
public java.lang.Object up(Event evt)
down_prot.down()
or c) the event (or another event) is sent up
the stack using up_prot.up()
.
public java.lang.Object down(Event evt)
down_prot.down()
. 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 up_prot.up()
.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |