public class ProtocolStack extends Protocol
The ProtocolStack makes use of the Configurator to setup and initialize stacks, and to destroy them again when not needed anymore
Modifier and Type | Class and Description |
---|---|
static class |
ProtocolStack.Position |
Modifier and Type | Field and Description |
---|---|
protected Protocol |
bottom_prot |
protected JChannel |
channel |
protected static String |
max_list_print_size |
protected DiagnosticsHandler.ProbeHandler |
props_handler |
protected boolean |
stopped |
protected Protocol |
top_prot |
after_creation_hook, down_prot, ergonomics, id, log, stack, stats, up_prot
Constructor and Description |
---|
ProtocolStack()
Used for programmatic creation of ProtocolStack
|
ProtocolStack(JChannel channel) |
Modifier and Type | Method and Description |
---|---|
ProtocolStack |
addProtocol(Protocol prot)
Adds a protocol at the tail of the protocol list
|
ProtocolStack |
addProtocols(List<Protocol> prots)
Adds a list of protocols
|
ProtocolStack |
addProtocols(Protocol... prots)
Adds a list of protocols
|
ProtocolStack |
bottomProtocol(Protocol bottom) |
protected static void |
callAfterCreationHook(Protocol prot,
String classname) |
List<Protocol> |
copyProtocols(ProtocolStack targetStack) |
protected Protocol |
createProtocol(String classname) |
void |
destroy()
This method is called on a
JChannel.close() . |
Object |
down(Event evt)
An event is to be sent down the stack.
|
Object |
down(Message msg)
A message is sent down the stack.
|
Map<String,Object> |
dumpStats() |
protected static void |
dumpStats(Object obj,
Map<String,Object> map,
Log log) |
Map<String,Object> |
dumpStats(String protocol_name,
List<String> attrs) |
<T extends Protocol> |
findProtocol(Class<? extends Protocol>... classes)
Finds the first protocol of a list and returns it.
|
<T extends Protocol> |
findProtocol(Class<? extends Protocol> clazz) |
<T extends Protocol> |
findProtocol(String name)
Returns a given protocol or null if not found
|
<T extends Protocol> |
findProtocols(String regexp) |
<T extends Protocol> |
getBottomProtocol() |
JChannel |
getChannel() |
String |
getName() |
List<Protocol> |
getProtocols()
Returns all protocols in a list, from top to bottom.
|
Protocol |
getTopProtocol() |
TP |
getTransport()
Returns the bottom most protocol
|
void |
init()
Called after instance has been created (null constructor) and before protocol is started.
|
void |
initProtocolStack() |
void |
insertProtocol(Protocol prot,
ProtocolStack.Position position,
Class<? extends Protocol>... neighbor_prots) |
void |
insertProtocol(Protocol prot,
ProtocolStack.Position position,
Class<? extends Protocol> neighbor_prot) |
void |
insertProtocol(Protocol prot,
ProtocolStack.Position position,
String neighbor_prot)
Inserts an already created (and initialized) protocol into the protocol list.
|
void |
insertProtocolAtTop(Protocol prot) |
void |
insertProtocolInStack(Protocol prot,
Protocol neighbor,
ProtocolStack.Position position) |
String |
printProtocolSpec(boolean include_properties)
Prints the names of the protocols, from the bottom to top.
|
String |
printProtocolSpecAsPlainString() |
String |
printProtocolSpecAsXML() |
<T extends Protocol> |
removeProtocol(Class<? extends Protocol>... protocols) |
<T extends Protocol> |
removeProtocol(Class<? extends Protocol> prot) |
<T extends Protocol> |
removeProtocol(String prot_name)
Removes a protocol from the stack.
|
<T extends Protocol> |
removeProtocol(T prot) |
ProtocolStack |
removeProtocols(String... protocols) |
void |
replaceProtocol(Protocol existing_prot,
Protocol new_prot)
Replaces one protocol instance with another.
|
ProtocolStack |
setChannel(JChannel ch) |
void |
setup(List<ProtocolConfiguration> configs) |
void |
setup(ProtocolStack stack) |
void |
startStack()
Start all layers.
|
void |
stopStack(String cluster)
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
|
ProtocolStack |
topProtocol(Protocol top) |
Object |
up(Event evt)
An event was received from the protocol below.
|
Object |
up(Message msg)
A single message was received.
|
void |
up(MessageBatch batch)
Sends up a multiple messages in a
MessageBatch . |
accept, afterCreationHook, enableStats, getConfigurableObjects, getDownProtocol, getDownServices, getId, getIdsAbove, getLevel, getLog, getProtocolStack, getSocketFactory, getThreadFactory, getUpProtocol, getUpServices, getValue, isErgonomics, level, parse, providedDownServices, providedUpServices, requiredDownServices, requiredUpServices, resetStatistics, resetStats, setDownProtocol, setErgonomics, setId, setLevel, setProperties, setProtocolStack, setSocketFactory, setUpProtocol, setValue, start, statsEnabled, stop
protected static final String max_list_print_size
protected Protocol top_prot
protected Protocol bottom_prot
protected JChannel channel
protected volatile boolean stopped
protected final DiagnosticsHandler.ProbeHandler props_handler
public ProtocolStack()
public ProtocolStack topProtocol(Protocol top)
public ProtocolStack bottomProtocol(Protocol bottom)
public JChannel getChannel()
public ProtocolStack setChannel(JChannel ch)
public List<Protocol> getProtocols()
public List<Protocol> copyProtocols(ProtocolStack targetStack) throws IllegalAccessException, InstantiationException
public TP getTransport()
getTransport
in class Protocol
public String printProtocolSpec(boolean include_properties)
public String printProtocolSpecAsXML()
public String printProtocolSpecAsPlainString()
public void setup(List<ProtocolConfiguration> configs) throws Exception
Exception
public void setup(ProtocolStack stack) throws Exception
Exception
public ProtocolStack addProtocol(Protocol prot)
prot
- public ProtocolStack addProtocols(Protocol... prots)
prots
- public ProtocolStack addProtocols(List<Protocol> prots)
prots
- public void insertProtocol(Protocol prot, ProtocolStack.Position position, String neighbor_prot) throws 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 foundException
- Will be thrown when the new protocol cannot be created, or inserted.public void insertProtocolInStack(Protocol prot, Protocol neighbor, ProtocolStack.Position position)
public void insertProtocol(Protocol prot, ProtocolStack.Position position, Class<? extends Protocol> neighbor_prot) throws Exception
Exception
@SafeVarargs public final void insertProtocol(Protocol prot, ProtocolStack.Position position, Class<? extends Protocol>... neighbor_prots) throws Exception
Exception
public void insertProtocolAtTop(Protocol prot)
public <T extends Protocol> T removeProtocol(String prot_name)
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.Exception
- Thrown if the protocol cannot be stopped correctly.public ProtocolStack removeProtocols(String... protocols)
@SafeVarargs public final <T extends Protocol> T removeProtocol(Class<? extends Protocol>... protocols)
public <T extends Protocol> T removeProtocol(T prot)
public <T extends Protocol> T findProtocol(String name)
public <T extends Protocol> T getBottomProtocol()
public Protocol getTopProtocol()
@SafeVarargs public final <T extends Protocol> T findProtocol(Class<? extends Protocol>... classes)
classes
- A list of protocol classes to findpublic void replaceProtocol(Protocol existing_prot, Protocol new_prot) throws Exception
existing_prot
- new_prot
- Exception
protected Protocol createProtocol(String classname) throws Exception
Exception
public void init() throws Exception
Protocol
public void destroy()
Protocol
JChannel.close()
.
Does some cleanup; after the call the VM will terminatepublic void startStack() throws Exception
Protocol.start()
method is called in each protocol,
from top to bottom.
Each layer can perform some initialization, e.g. create a multicast socketException
public void stopStack(String cluster)
public Object up(Event evt)
Protocol
down_prot.down()
or c) the event (or another event) is sent up the stack using up_prot.up()
.public Object up(Message msg)
Protocol
public void up(MessageBatch batch)
Protocol
MessageBatch
. The sender of the batch is always the same, and so is the
destination (null == multicast messages). Messages in a batch can be OOB messages, regular messages, or mixed
messages, although the transport itself will create initial MessageBatches that contain only either OOB or
regular messages.
The default processing below sends messages up the stack individually, based on a matching criteria
(calling Protocol.accept(org.jgroups.Message)
), and - if true - calls Protocol.up(org.jgroups.Event)
for that message and removes the message. If the batch is not empty, it is passed up, or else it is dropped.
Subclasses should check if there are any messages destined for them (e.g. using
MessageBatch.getMatchingMessages(short,boolean)
), then possibly remove and process them and finally pass
the batch up to the next protocol. Protocols can also modify messages in place, e.g. ENCRYPT could decrypt all
encrypted messages in the batch, not remove them, and pass the batch up when done.public Object down(Event evt)
Protocol
down_prot.down()
.public Object down(Message msg)
Protocol
Copyright © 2018 JBoss, a division of Red Hat. All rights reserved.