public class ProtocolStack extends Protocol implements Transport
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.RefCounter
Keeps track of the number os times init()/destroy() and start()/stop have been called.
|
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
|
List<Protocol> |
copyProtocols(ProtocolStack targetStack) |
protected Protocol |
createProtocol(String classname) |
void |
destroy()
This method is called on a
Channel.close() . |
Object |
down(Event evt)
An event is to be sent down the stack.
|
Map<String,Object> |
dumpStats() |
Map<String,Object> |
dumpStats(String protocol_name) |
Map<String,Object> |
dumpStats(String protocol_name,
List<String> attrs) |
String |
dumpTimerQueue()
Deprecated.
Use
TP.getTimer() instead to fetch the timer from the
transport and then invoke the method on it |
Protocol |
findProtocol(Class<?>... classes)
Finds the first protocol of a list and returns it.
|
Protocol |
findProtocol(Class<?> clazz) |
Protocol |
findProtocol(String name)
Returns a given protocol or null if not found
|
void |
flushEvents()
Deprecated.
|
Protocol |
getBottomProtocol() |
JChannel |
getChannel() |
String |
getName()
All protocol names have to be unique !
|
List<Protocol> |
getProtocols()
Returns all protocols in a list, from top to bottom.
|
static ConcurrentMap<String,Tuple<TP,ProtocolStack.RefCounter>> |
getSingletonTransports() |
ThreadFactory |
getThreadFactory()
Deprecated.
Use
Protocol.getThreadFactory() instead |
static ThreadFactory |
getTimerThreadFactory()
Deprecated.
|
int |
getTimerThreads()
Deprecated.
Use
TP.getTimer() to fetch the timer and call getCorePoolSize() directly |
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,
int position,
Class<? extends Protocol>... neighbor_prots) |
void |
insertProtocol(Protocol prot,
int position,
Class<? extends Protocol> neighbor_prot) |
void |
insertProtocol(Protocol prot,
int 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,
int position) |
String |
printProtocolSpec(boolean include_properties)
Prints the names of the protocols, from the bottom to top.
|
String |
printProtocolSpecAsPlainString() |
String |
printProtocolSpecAsXML() |
Object |
receive(long timeout) |
Protocol |
removeProtocol(Class... protocols) |
Protocol |
removeProtocol(Class prot) |
Protocol |
removeProtocol(String prot_name)
Removes a protocol from the stack.
|
void |
send(Message msg) |
void |
setChannel(JChannel ch) |
void |
setThreadFactory(ThreadFactory f)
Deprecated.
Use
Protocol.getThreadFactory() instead |
static void |
setTimerThreadFactory(ThreadFactory f)
Deprecated.
|
void |
setup(List<ProtocolConfiguration> configs) |
void |
setup(ProtocolStack stack) |
void |
startStack(String cluster_name,
Address local_addr)
Start all layers.
|
void |
stopStack(String cluster_name)
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
|
Object |
up(Event evt)
An event was received from the layer below.
|
downThreadEnabled, enableStats, getConfigurableObjects, getDownProtocol, getId, getLevel, getProperties, getProtocolStack, getSocketFactory, getUpProtocol, getValue, isErgonomics, printStats, providedDownServices, providedUpServices, requiredDownServices, requiredUpServices, resetStats, setDownProtocol, setErgonomics, setId, setLevel, setProperties, setPropertiesInternal, setProperty, setProtocolStack, setSocketFactory, setUpProtocol, setValue, setValues, start, statsEnabled, stop, upThreadEnabled
public static final int ABOVE
public static final int BELOW
public ProtocolStack(JChannel channel) throws ChannelException
ChannelException
public ProtocolStack()
public JChannel getChannel()
public void setChannel(JChannel ch)
public ThreadFactory getThreadFactory()
Protocol.getThreadFactory()
insteadProtocol
getThreadFactory
in class Protocol
@Deprecated public static ThreadFactory getTimerThreadFactory()
public void setThreadFactory(ThreadFactory f)
Protocol.getThreadFactory()
insteadf
- public static void setTimerThreadFactory(ThreadFactory f)
TP.setTimerThreadFactory(org.jgroups.util.ThreadFactory)
insteadf
- public int getTimerThreads()
TP.getTimer()
to fetch the timer and call getCorePoolSize() directlypublic List<Protocol> getProtocols()
public List<Protocol> copyProtocols(ProtocolStack targetStack) throws IllegalAccessException, InstantiationException
public TP getTransport()
getTransport
in class Protocol
public static ConcurrentMap<String,Tuple<TP,ProtocolStack.RefCounter>> getSingletonTransports()
public String dumpTimerQueue()
TP.getTimer()
instead to fetch the timer from the
transport and then invoke the method on itpublic 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, int 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, int position)
public void insertProtocol(Protocol prot, int position, Class<? extends Protocol> neighbor_prot) throws Exception
Exception
public void insertProtocol(Protocol prot, int position, Class<? extends Protocol>... neighbor_prots) throws Exception
Exception
public void insertProtocolAtTop(Protocol prot)
public Protocol removeProtocol(String prot_name) throws 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.Exception
- Thrown if the protocol cannot be stopped correctly.public Protocol findProtocol(String name)
public Protocol getBottomProtocol()
public Protocol getTopProtocol()
public Protocol findProtocol(Class<?>... classes)
classes
- A list of protocol classes to findprotected Protocol createProtocol(String classname) throws Exception
Exception
public void init() throws Exception
Protocol
public void destroy()
Protocol
Channel.close()
.
Does some cleanup; after the call the VM will terminatepublic void startStack(String cluster_name, Address local_addr) 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_name)
public void flushEvents()
public String getName()
Protocol
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 down(Event evt)
Protocol
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()
.Copyright © 2013 JBoss, a division of Red Hat. All Rights Reserved.