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.
- Author:
- Bela Ban, Richard Achmatowicz
-
Nested Class Summary
Nested Classes -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic ProtocolconnectProtocols(List<Protocol> protocol_list) Creates a protocol stack by iterating through the protocol list and connecting adjacent layers.static Map<String, Map<String, Configurator.InetAddressInfo>> createInetAddressMap(List<ProtocolConfiguration> protocol_configs, List<Protocol> protocols) protected static ProtocolcreateLayer(ProtocolStack stack, ProtocolConfiguration config) static ProtocolcreateProtocol(String prot_spec, ProtocolStack stack) Creates a new protocol given the protocol specification.static StackTypeThis method takes a set of InetAddresses, represented by an inetAddressmap, and: - if the resulting set is non-empty, goes through to see if all InetAddress-related user settings have a consistent IP version: v4 or v6, and throws an exception if not - if the resulting set is empty, sets the default IP version based on available stacks and if a dual stack, stack preferences - sets the IP version to be used in the JGroups sessionstatic voidensureValidBindAddresses(List<Protocol> protocols) Makes sure that all fields annotated with @LocalAddress is (1) an InetAddress and (2) a valid address on any local network interfacestatic Collection<InetAddress> getAddresses(Map<String, Map<String, Configurator.InetAddressInfo>> inetAddressMap) Returns all inet addresses foundstatic Objectstatic List<InetAddress> getInetAddresses(List<Protocol> protocols) static ObjectgetValueFromProtocol(Protocol protocol, Field field) static ObjectgetValueFromProtocol(Protocol protocol, String field_name) static booleanisSetPropertyMethod(Method method) static List<ProtocolConfiguration> parseConfigurations(String configuration) Return a number of ProtocolConfigurations in a vectorstatic Stringstatic voidremoveDeprecatedProperties(Object obj, Map<String, String> props) static voidstatic voidresolveAndAssignFields(Object obj, Map<String, String> props) static voidstatic voidresolveAndInvokePropertyMethods(Object obj, Map<String, String> props) static voidsanityCheck(List<Protocol> protocols) Throws an exception if sanity check fails.static voidsetDefaultValues(List<ProtocolConfiguration> protocol_configs, List<Protocol> protocols, StackType ip_version) static voidsetDefaultValues(List<Protocol> protocols) static voidsetDefaultValues(List<Protocol> protocols, StackType ip_version) static voidsetupProtocolStack(List<ProtocolConfiguration> config) setupProtocolStack(ProtocolStack copySource)
-
Field Details
-
log
-
-
Constructor Details
-
Configurator
public Configurator() -
Configurator
-
-
Method Details
-
setupProtocolStack
- Throws:
Exception
-
setupProtocolStack
- Throws:
Exception
-
setDefaultValues
- Throws:
Exception
-
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
-
connectProtocols
Creates a protocol stack by iterating through the protocol list and connecting adjacent layers. The list starts with the topmost layer and has the bottommost layer at the tail.- Parameters:
protocol_list- List of Protocol elements (from top to bottom)- Returns:
- Protocol stack
-
parseConfigurations
public static List<ProtocolConfiguration> parseConfigurations(String configuration) throws Exception Return a number of ProtocolConfigurations in a vector- Parameters:
configuration- protocol-stack configuration string- Returns:
- List of ProtocolConfigurations
- Throws:
Exception
-
printConfigurations
-
createLayer
protected static Protocol createLayer(ProtocolStack stack, ProtocolConfiguration config) throws Exception - Throws:
Exception
-
sanityCheck
Throws an exception if sanity check fails. Possible sanity check is uniqueness of all protocol names- Throws:
Exception
-
getAddresses
public static Collection<InetAddress> getAddresses(Map<String, Map<String, throws ExceptionConfigurator.InetAddressInfo>> inetAddressMap) Returns all inet addresses found- Throws:
Exception
-
determineIpVersionFromAddresses
public static StackType determineIpVersionFromAddresses(Collection<InetAddress> addrs) throws Exception This method takes a set of InetAddresses, represented by an inetAddressmap, and: - if the resulting set is non-empty, goes through to see if all InetAddress-related user settings have a consistent IP version: v4 or v6, and throws an exception if not - if the resulting set is empty, sets the default IP version based on available stacks and if a dual stack, stack preferences - sets the IP version to be used in the JGroups session- Returns:
- StackType.IPv4 for IPv4, StackType.IPv6 for IPv6, StackType.Unknown if the version cannot be determined
- Throws:
Exception
-
createInetAddressMap
public static Map<String,Map<String, createInetAddressMapConfigurator.InetAddressInfo>> (List<ProtocolConfiguration> protocol_configs, List<Protocol> protocols) throws Exception - Throws:
Exception
-
getInetAddresses
- Throws:
Exception
-
setDefaultValues
public static void setDefaultValues(List<ProtocolConfiguration> protocol_configs, List<Protocol> protocols, StackType ip_version) throws Exception - Throws:
Exception
-
setDefaultValues
public static void setDefaultValues(List<Protocol> protocols, StackType ip_version) throws Exception - Throws:
Exception
-
ensureValidBindAddresses
Makes sure that all fields annotated with @LocalAddress is (1) an InetAddress and (2) a valid address on any local network interface- Parameters:
protocols-- Throws:
Exception
-
getValueFromProtocol
public static Object getValueFromProtocol(Protocol protocol, Field field) throws IllegalAccessException - Throws:
IllegalAccessException
-
getValueFromProtocol
public static Object getValueFromProtocol(Protocol protocol, String field_name) throws IllegalAccessException - Throws:
IllegalAccessException
-
resolveAndInvokePropertyMethods
public static void resolveAndInvokePropertyMethods(Object obj, Map<String, String> props) throws Exception- Throws:
Exception
-
resolveAndInvokePropertyMethod
public static void resolveAndInvokePropertyMethod(Object obj, Method method, Map<String, String> props) throws Exception- Throws:
Exception
-
resolveAndAssignFields
- Throws:
Exception
-
resolveAndAssignField
public static void resolveAndAssignField(Object obj, Field field, Map<String, String> props) throws Exception- Throws:
Exception
-
removeDeprecatedProperties
public static void removeDeprecatedProperties(Object obj, Map<String, String> props) throws Exception- Throws:
Exception
-
isSetPropertyMethod
-
setField
-
getField
-