org.jgroups.stack
Class Configurator

java.lang.Object
  extended by org.jgroups.stack.Configurator

public class Configurator
extends java.lang.Object

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
static class Configurator.InetAddressInfo
           
 
Field Summary
protected static Log log
           
 
Constructor Summary
Configurator()
           
Configurator(ProtocolStack protocolStack)
           
 
Method Summary
static Protocol connectProtocols(java.util.List<Protocol> protocol_list)
          Creates a protocol stack by iterating through the protocol list and connecting adjacent layers.
static java.util.Map<java.lang.String,java.util.Map<java.lang.String,Configurator.InetAddressInfo>> createInetAddressMap(java.util.List<ProtocolConfiguration> protocol_configs, java.util.List<Protocol> protocols)
           
protected static Protocol createLayer(ProtocolStack stack, ProtocolConfiguration config)
           
static Protocol createProtocol(java.lang.String prot_spec, ProtocolStack stack)
          Creates a new protocol given the protocol specification.
static StackType determineIpVersionFromAddresses(java.util.Collection<java.net.InetAddress> addrs)
          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
static void ensureValidBindAddresses(java.util.List<Protocol> protocols)
          Makes sure that all fields annotated with @LocalAddress is (1) an InetAddress and (2) a valid address on any local network interface
static java.util.Collection<java.net.InetAddress> getAddresses(java.util.Map<java.lang.String,java.util.Map<java.lang.String,Configurator.InetAddressInfo>> inetAddressMap)
          Returns all inet addresses found
static java.util.List<java.net.InetAddress> getInetAddresses(java.util.List<Protocol> protocols)
           
static java.lang.Object getValueFromProtocol(Protocol protocol, java.lang.reflect.Field field)
           
static java.lang.Object getValueFromProtocol(Protocol protocol, java.lang.String field_name)
           
static boolean isSetPropertyMethod(java.lang.reflect.Method method)
           
static java.util.List<ProtocolConfiguration> parseConfigurations(java.lang.String configuration)
          Return a number of ProtocolConfigurations in a vector
static java.lang.String printConfigurations(java.util.Collection<ProtocolConfiguration> configs)
           
protected static java.lang.String printEvents(java.util.List<java.lang.Integer> events)
           
static void removeDeprecatedProperties(java.lang.Object obj, java.util.Map<java.lang.String,java.lang.String> props)
           
protected static void removeProvidedDownServices(Protocol protocol, java.util.List<java.lang.Integer> events)
          Removes all events provided by the protocol above protocol from events
protected static void removeProvidedUpServices(Protocol protocol, java.util.List<java.lang.Integer> events)
          Removes all events provided by the protocol below protocol from events
static void resolveAndAssignField(java.lang.Object obj, java.lang.reflect.Field field, java.util.Map<java.lang.String,java.lang.String> props)
           
static void resolveAndAssignFields(java.lang.Object obj, java.util.Map<java.lang.String,java.lang.String> props)
           
static void resolveAndInvokePropertyMethod(java.lang.Object obj, java.lang.reflect.Method method, java.util.Map<java.lang.String,java.lang.String> props)
           
static void resolveAndInvokePropertyMethods(java.lang.Object obj, java.util.Map<java.lang.String,java.lang.String> props)
           
static void sanityCheck(java.util.List<Protocol> protocols)
          Throws an exception if sanity check fails.
static void setDefaultValues(java.util.List<Protocol> protocols)
           
static void setDefaultValues(java.util.List<Protocol> protocols, StackType ip_version)
           
static void setDefaultValues(java.util.List<ProtocolConfiguration> protocol_configs, java.util.List<Protocol> protocols, StackType ip_version)
           
 Protocol setupProtocolStack(java.util.List<ProtocolConfiguration> config)
           
 Protocol setupProtocolStack(ProtocolStack copySource)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

protected static final Log log
Constructor Detail

Configurator

public Configurator()

Configurator

public Configurator(ProtocolStack protocolStack)
Method Detail

setupProtocolStack

public Protocol setupProtocolStack(java.util.List<ProtocolConfiguration> config)
                            throws java.lang.Exception
Throws:
java.lang.Exception

setupProtocolStack

public Protocol setupProtocolStack(ProtocolStack copySource)
                            throws java.lang.Exception
Throws:
java.lang.Exception

setDefaultValues

public static void setDefaultValues(java.util.List<Protocol> protocols)
                             throws java.lang.Exception
Throws:
java.lang.Exception

createProtocol

public static Protocol createProtocol(java.lang.String prot_spec,
                                      ProtocolStack stack)
                               throws java.lang.Exception
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 specified
stack - The protocol stack
Returns:
Protocol The newly created protocol
Throws:
java.lang.Exception - Will be thrown when the new protocol cannot be created

connectProtocols

public static Protocol connectProtocols(java.util.List<Protocol> protocol_list)
                                 throws java.lang.Exception
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
Throws:
java.lang.Exception

parseConfigurations

public static java.util.List<ProtocolConfiguration> parseConfigurations(java.lang.String configuration)
                                                                 throws java.lang.Exception
Return a number of ProtocolConfigurations in a vector

Parameters:
configuration - protocol-stack configuration string
Returns:
List of ProtocolConfigurations
Throws:
java.lang.Exception

printConfigurations

public static java.lang.String printConfigurations(java.util.Collection<ProtocolConfiguration> configs)

createLayer

protected static Protocol createLayer(ProtocolStack stack,
                                      ProtocolConfiguration config)
                               throws java.lang.Exception
Throws:
java.lang.Exception

sanityCheck

public static void sanityCheck(java.util.List<Protocol> protocols)
                        throws java.lang.Exception
Throws an exception if sanity check fails. Possible sanity check is uniqueness of all protocol names

Throws:
java.lang.Exception

printEvents

protected static java.lang.String printEvents(java.util.List<java.lang.Integer> events)

removeProvidedUpServices

protected static void removeProvidedUpServices(Protocol protocol,
                                               java.util.List<java.lang.Integer> events)
Removes all events provided by the protocol below protocol from events

Parameters:
protocol -
events -

removeProvidedDownServices

protected static void removeProvidedDownServices(Protocol protocol,
                                                 java.util.List<java.lang.Integer> events)
Removes all events provided by the protocol above protocol from events

Parameters:
protocol -
events -

getAddresses

public static java.util.Collection<java.net.InetAddress> getAddresses(java.util.Map<java.lang.String,java.util.Map<java.lang.String,Configurator.InetAddressInfo>> inetAddressMap)
                                                               throws java.lang.Exception
Returns all inet addresses found

Throws:
java.lang.Exception

determineIpVersionFromAddresses

public static StackType determineIpVersionFromAddresses(java.util.Collection<java.net.InetAddress> addrs)
                                                 throws java.lang.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:
java.lang.Exception

createInetAddressMap

public static java.util.Map<java.lang.String,java.util.Map<java.lang.String,Configurator.InetAddressInfo>> createInetAddressMap(java.util.List<ProtocolConfiguration> protocol_configs,
                                                                                                                                java.util.List<Protocol> protocols)
                                                                                                                         throws java.lang.Exception
Throws:
java.lang.Exception

getInetAddresses

public static java.util.List<java.net.InetAddress> getInetAddresses(java.util.List<Protocol> protocols)
                                                             throws java.lang.Exception
Throws:
java.lang.Exception

setDefaultValues

public static void setDefaultValues(java.util.List<ProtocolConfiguration> protocol_configs,
                                    java.util.List<Protocol> protocols,
                                    StackType ip_version)
                             throws java.lang.Exception
Throws:
java.lang.Exception

setDefaultValues

public static void setDefaultValues(java.util.List<Protocol> protocols,
                                    StackType ip_version)
                             throws java.lang.Exception
Throws:
java.lang.Exception

ensureValidBindAddresses

public static void ensureValidBindAddresses(java.util.List<Protocol> protocols)
                                     throws java.lang.Exception
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:
java.lang.Exception

getValueFromProtocol

public static java.lang.Object getValueFromProtocol(Protocol protocol,
                                                    java.lang.reflect.Field field)
                                             throws java.lang.IllegalAccessException
Throws:
java.lang.IllegalAccessException

getValueFromProtocol

public static java.lang.Object getValueFromProtocol(Protocol protocol,
                                                    java.lang.String field_name)
                                             throws java.lang.IllegalAccessException
Throws:
java.lang.IllegalAccessException

resolveAndInvokePropertyMethods

public static void resolveAndInvokePropertyMethods(java.lang.Object obj,
                                                   java.util.Map<java.lang.String,java.lang.String> props)
                                            throws java.lang.Exception
Throws:
java.lang.Exception

resolveAndInvokePropertyMethod

public static void resolveAndInvokePropertyMethod(java.lang.Object obj,
                                                  java.lang.reflect.Method method,
                                                  java.util.Map<java.lang.String,java.lang.String> props)
                                           throws java.lang.Exception
Throws:
java.lang.Exception

resolveAndAssignFields

public static void resolveAndAssignFields(java.lang.Object obj,
                                          java.util.Map<java.lang.String,java.lang.String> props)
                                   throws java.lang.Exception
Throws:
java.lang.Exception

resolveAndAssignField

public static void resolveAndAssignField(java.lang.Object obj,
                                         java.lang.reflect.Field field,
                                         java.util.Map<java.lang.String,java.lang.String> props)
                                  throws java.lang.Exception
Throws:
java.lang.Exception

removeDeprecatedProperties

public static void removeDeprecatedProperties(java.lang.Object obj,
                                              java.util.Map<java.lang.String,java.lang.String> props)
                                       throws java.lang.Exception
Throws:
java.lang.Exception

isSetPropertyMethod

public static boolean isSetPropertyMethod(java.lang.reflect.Method method)


Copyright © 1998-2012 Bela Ban / Red Hat. All Rights Reserved.