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.
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final Logprotected static booleanprotected final ProtocolStack -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) static voidaddPropertyToDependencyList(List<AccessibleObject> orderedList, Map<String, AccessibleObject> props, Deque<AccessibleObject> stack, AccessibleObject obj) DFS of dependency graph formed by Property annotations and dependsUpon parameter This is used to create a list of Properties in dependency order(package private) static voidcheckDependencyReferencesPresent(List<AccessibleObject> objects, Map<String, AccessibleObject> props) (package private) static AccessibleObject[]computePropertyDependencies(Object obj, Map<String, String> properties) This method creates a list of all properties (field or method) in dependency order, where dependencies are specified using the dependsUpon specifier of the Property annotation.static 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) static ProtocolcreateProtocol(String prot_spec, ProtocolStack stack, boolean init_attrs) Creates a new protocol given the protocol specification.createProtocols(List<ProtocolConfiguration> protocol_configs, ProtocolStack stack) Takes a list of configurations, creates a protocol for each and returns all protocols in a list.static 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> Returns all inet addresses foundstatic List<InetAddress> getInetAddresses(List<Protocol> protocols) static Map<String, InetAddress> getInetAddresses2(List<Protocol> protocols) Returns a map of protocol.attr/InetAddress tuplesstatic <T> TgetValueFromObject(Object obj, Field field) static <T> TgetValueFromObject(Object obj, String field_name) private static StringgrabSystemProp(Property annotation) static voidstatic voidinitializeAttrs(Protocol prot, ProtocolConfiguration config, StackType ip_version) Sets the attributes in a given protocol from propertiesstatic booleanstatic booleanisSetPropertyMethod(Method method, Class<?> enclosing_clazz) (package private) static List<AccessibleObject> orderFieldsAndMethodsByDependency(List<AccessibleObject> unorderedList, Map<String, AccessibleObject> propertiesMap) protected static StringprintEvents(List<Integer> events) protected static voidremoveProvidedDownServices(Protocol protocol, List<Integer> events) Removes all events provided by the protocol above protocol from eventsprotected static voidremoveProvidedUpServices(Protocol protocol, List<Integer> events) Removes all events provided by the protocol below protocol from eventsstatic voidstatic voidstatic voidresolveAndInvokePropertyMethod(Object obj, Method method, Map<String, String> props, StackType ip_version) static voidstatic voidsanityCheck(List<Protocol> protocols) Throws an exception if sanity check fails.static voidsetDefaultAddressValues(Object obj, StackType ip_version) static voidsetDefaultAddressValues(List<Protocol> protocols, StackType ip_version) Processes fields and methods which are inet address related, and assigns them default values defined by (Property.defaultValueIPv4()andProperty.defaultValueIPv6()).protected static voidsetDefaultAddressValuesFields(Object obj, StackType ip_version, InetAddress default_ip_address) protected static voidsetDefaultAddressValuesMethods(Object obj, StackType ip_version, InetAddress default_ip_address) setupProtocolStack(List<ProtocolConfiguration> config) static ProtocolsetupProtocolStack(List<ProtocolConfiguration> protocol_configs, ProtocolStack st) Sets up the protocol stack.static booleanstatic voidskipSettingDefaultValues(boolean f)
-
Field Details
-
log
-
skip_setting_default_values
protected static boolean skip_setting_default_values -
stack
-
-
Constructor Details
-
Configurator
public Configurator() -
Configurator
-
-
Method Details
-
skipSettingDefaultValues
public static boolean skipSettingDefaultValues() -
skipSettingDefaultValues
public static void skipSettingDefaultValues(boolean f) -
setupProtocolStack
- Throws:
Exception
-
setupProtocolStack
public static Protocol setupProtocolStack(List<ProtocolConfiguration> protocol_configs, ProtocolStack st) throws Exception Sets up the protocol stack. EachProtocolConfigurationhas the protocol name and a map of attribute names and values (strings). Reflection is used to find the right fields (or setters) based on attribute names, and set them (by converting the attribute value to the proper object).- Throws:
Exception
-
createProtocol
- Throws:
Exception
-
createProtocol
public static Protocol createProtocol(String prot_spec, ProtocolStack stack, boolean init_attrs) throws 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 specifiedstack- The protocol stack- Returns:
- Protocol The newly created protocol
- Throws:
Exception- Will be thrown when the new protocol cannot be created
-
createProtocolsAndInitializeAttrs
public static List<Protocol> createProtocolsAndInitializeAttrs(List<ProtocolConfiguration> cfgs, ProtocolStack st) throws Exception - Throws:
Exception
-
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
- Throws:
Exception
-
createProtocols
public static List<Protocol> createProtocols(List<ProtocolConfiguration> protocol_configs, ProtocolStack stack) throws Exception Takes a list of configurations, creates a protocol for each and returns all protocols in a list.- Parameters:
protocol_configs- A list of ProtocolConfigurationsstack- The protocol stack- Returns:
- List of Protocols
- Throws:
Exception
-
createLayer
protected static Protocol createLayer(ProtocolStack stack, ProtocolConfiguration config) throws Exception - Throws:
Exception
-
initializeAttrs
public static void initializeAttrs(Protocol prot, ProtocolConfiguration config, StackType ip_version) throws Exception Sets the attributes in a given protocol from properties- Throws:
Exception
-
initializeAttrs
public static void initializeAttrs(Object obj, Map<String, String> properties, StackType ip_version) throws Exception- Throws:
Exception
-
sanityCheck
Throws an exception if sanity check fails. Possible sanity check is uniqueness of all protocol names- Throws:
Exception
-
printEvents
-
removeProvidedUpServices
Removes all events provided by the protocol below protocol from events- Parameters:
protocol-events-
-
removeProvidedDownServices
Removes all events provided by the protocol above protocol from events- Parameters:
protocol-events-
-
getAddresses
public static Collection<InetAddress> getAddresses(Map<String, Map<String, throws ExceptionConfigurator.InetAddressInfo>> map) Returns all inet addresses found- 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
-
getInetAddresses2
Returns a map of protocol.attr/InetAddress tuples -
isInetAddressOrCompatibleType
-
setDefaultAddressValues
public static void setDefaultAddressValues(List<Protocol> protocols, StackType ip_version) throws Exception Processes fields and methods which are inet address related, and assigns them default values defined by (Property.defaultValueIPv4()andProperty.defaultValueIPv6()). This method does the following: - find all properties which have no value assigned - generate a value for the field using the property converter for that property and assign it to the field- Throws:
Exception
-
setDefaultAddressValues
- Throws:
Exception
-
setDefaultAddressValuesMethods
protected static void setDefaultAddressValuesMethods(Object obj, StackType ip_version, InetAddress default_ip_address) throws Exception - Throws:
Exception
-
setDefaultAddressValuesFields
protected static void setDefaultAddressValuesFields(Object obj, StackType ip_version, InetAddress default_ip_address) 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- Throws:
Exception
-
getValueFromObject
- Throws:
IllegalAccessException
-
getValueFromObject
- Throws:
IllegalAccessException
-
computePropertyDependencies
This method creates a list of all properties (field or method) in dependency order, where dependencies are specified using the dependsUpon specifier of the Property annotation. In particular, it does the following: (i) creates a master list of properties (ii) checks that all dependency references are present (iii) creates a copy of the master list in dependency order -
orderFieldsAndMethodsByDependency
static List<AccessibleObject> orderFieldsAndMethodsByDependency(List<AccessibleObject> unorderedList, Map<String, AccessibleObject> propertiesMap) -
addPropertyToDependencyList
static void addPropertyToDependencyList(List<AccessibleObject> orderedList, Map<String, AccessibleObject> props, Deque<AccessibleObject> stack, AccessibleObject obj) DFS of dependency graph formed by Property annotations and dependsUpon parameter This is used to create a list of Properties in dependency order -
checkDependencyReferencesPresent
static void checkDependencyReferencesPresent(List<AccessibleObject> objects, Map<String, AccessibleObject> props) -
resolveAndInvokePropertyMethods
public static void resolveAndInvokePropertyMethods(Object obj, Map<String, String> props, StackType ip_version) throws Exception- Throws:
Exception
-
resolveAndInvokePropertyMethod
public static void resolveAndInvokePropertyMethod(Object obj, Method method, Map<String, String> props, StackType ip_version) throws Exception- Throws:
Exception
-
resolveAndAssignFields
public static void resolveAndAssignFields(Object obj, Map<String, String> props, StackType ip_version) throws Exception- Throws:
Exception
-
resolveAndAssignField
public static void resolveAndAssignField(Object obj, Field field, Map<String, String> props, StackType ip_version) throws Exception- Throws:
Exception
-
isSetPropertyMethod
-
grabSystemProp
-