Package org.jgroups.stack
Class Configurator
java.lang.Object
org.jgroups.stack.Configurator
The task if this class is to setup and configure the protocol stack. A string describing
the desired setup, which is both the layering and the configuration of each layer, is
given to the configurator which creates and configures the protocol stack and returns
a reference to the top layer (Protocol).
Future functionality will include the capability to dynamically modify the layering of the protocol stack and the properties of each layer.
- Version:
- $Id: Configurator.java,v 1.28.4.8.2.1 2009/03/31 16:34:13 belaban Exp $
- Author:
- Bela Ban
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
Parses and encapsulates the specification for 1 protocol of the protocol stack, e.g. -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic Protocol
createProtocol
(String prot_spec, ProtocolStack stack) Creates a new protocol given the protocol specification.static void
destroyProtocolStack
(List<Protocol> protocols) static Protocol
findProtocol
(Protocol prot_stack, String name) static Protocol
getBottommostProtocol
(Protocol prot_stack) static void
initProtocolStack
(List<Protocol> protocols) static void
insertProtocol
(Protocol prot, int position, Class<? extends Protocol> neighbor_prot, ProtocolStack stack) static void
insertProtocol
(Protocol prot, int position, String neighbor_prot, ProtocolStack stack) Inserts an already created (and initialized) protocol into the protocol list.static void
insertProtocol
(Protocol prot, int position, Protocol neighbor, ProtocolStack stack) protected static void
insertProtocol
(Protocol prot, Protocol neighbor, int position) parseConfigurations
(String configuration) Return a number of ProtocolConfigurations in a vectorparseProtocols
(String config_str) Get a string of the form "P1(config_str1):P2:P3(config_str3)" and return ProtocolConfigurations for it.static Protocol
removeProtocol
(Protocol top_prot, String prot_name) Removes a protocol from the stack.static void
sanityCheck
(Vector<Protocol> protocols) Throws an exception if sanity check fails.static Protocol
setupProtocolStack
(String configuration, ProtocolStack st) The configuration string has a number of entries, separated by a ':' (colon).static void
startProtocolStack
(List<Protocol> protocols, String cluster_name, Map<String, Tuple<TP, Short>> singletons) static void
stopProtocolStack
(List<Protocol> protocols, String cluster_name, Map<String, Tuple<TP, Short>> singletons)
-
Field Details
-
log
protected static final org.apache.commons.logging.Log log
-
-
Constructor Details
-
Configurator
public Configurator()
-
-
Method Details
-
setupProtocolStack
The configuration string has a number of entries, separated by a ':' (colon). Each entry consists of the name of the protocol, followed by an optional configuration of that protocol. The configuration is enclosed in parentheses, and contains entries which are name/value pairs connected with an assignment sign (=) and separated by a semicolon.UDP(in_port=5555;out_port=4445):FRAG(frag_size=1024)
The first entry defines the bottommost layer, the string is parsed left to right and the protocol stack constructed bottom up. Example: the string "UDP(in_port=5555):FRAG(frag_size=32000):DEBUG" results is the following stack:
----------------------- | DEBUG | |-----------------------| | FRAG frag_size=32000 | |-----------------------| | UDP in_port=32000 | -----------------------
- Throws:
Exception
-
initProtocolStack
- Throws:
Exception
-
startProtocolStack
public static void startProtocolStack(List<Protocol> protocols, String cluster_name, Map<String, Tuple<TP, throws ExceptionShort>> singletons) - Throws:
Exception
-
stopProtocolStack
-
destroyProtocolStack
-
findProtocol
-
getBottommostProtocol
-
createProtocol
Creates a new protocol given the protocol specification. Initializes the properties and starts the up and down handler threads.- Parameters:
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 specifiedstack
- The protocol stack- Returns:
- Protocol The newly created protocol
- Throws:
Exception
- Will be thrown when the new protocol cannot be created
-
insertProtocol
public static void insertProtocol(Protocol prot, int position, String neighbor_prot, ProtocolStack stack) 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. This should be done before starting the stack.- Parameters:
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 foundstack
- The protocol stack- Throws:
Exception
- Will be thrown when the new protocol cannot be created, or inserted.
-
insertProtocol
public static void insertProtocol(Protocol prot, int position, Protocol neighbor, ProtocolStack stack) throws Exception - Throws:
Exception
-
insertProtocol
public static void insertProtocol(Protocol prot, int position, Class<? extends Protocol> neighbor_prot, ProtocolStack stack) throws Exception - Throws:
Exception
-
insertProtocol
-
removeProtocol
Removes a protocol from the stack. Stops the protocol and readjusts the linked lists of protocols.- Parameters:
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.- Throws:
Exception
- Thrown if the protocol cannot be stopped correctly.
-
parseProtocols
Get a string of the form "P1(config_str1):P2:P3(config_str3)" and return ProtocolConfigurations for it. That means, parse "P1(config_str1)", "P2" and "P3(config_str3)"- Parameters:
config_str
- Configuration string- Returns:
- Vector of strings
- Throws:
IOException
-
parseConfigurations
public static Vector<Configurator.ProtocolConfiguration> parseConfigurations(String configuration) throws Exception Return a number of ProtocolConfigurations in a vector- Parameters:
configuration
- protocol-stack configuration string- Returns:
- Vector of ProtocolConfigurations
- Throws:
Exception
-
sanityCheck
Throws an exception if sanity check fails. Possible sanity check is uniqueness of all protocol names- Throws:
Exception
-