Record Class Configurator
java.lang.Object
java.lang.Record
org.jgroups.stack.Configurator
- Record Components:
stack- The protocol stack
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 -
Constructor Summary
ConstructorsConstructorDescriptionConfigurator(ProtocolStack stack) Creates an instance of aConfiguratorrecord class. -
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) 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 interfacefinal booleanIndicates whether some other object is "equal to" this one.static 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) final inthashCode()Returns a hash code value for this object.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) static 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()).static ProtocolsetupProtocolStack(List<ProtocolConfiguration> protocol_configs, ProtocolStack st) Sets up the protocol stack.static booleanstatic voidskipSettingDefaultValues(boolean f) stack()Returns the value of thestackrecord component.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
Configurator
Creates an instance of aConfiguratorrecord class.- Parameters:
stack- the value for thestackrecord component
-
-
Method Details
-
skipSettingDefaultValues
public static boolean skipSettingDefaultValues() -
skipSettingDefaultValues
public static void skipSettingDefaultValues(boolean f) -
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
-
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
-
sanityCheck
-
getAddresses
public static Collection<InetAddress> getAddresses(Map<String, Map<String, Configurator.InetAddressInfo>> map) throws Exception Returns all inet addresses found- Throws:
Exception
-
createInetAddressMap
-
getInetAddresses
-
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
-
ensureValidBindAddresses
-
getValueFromObject
- Throws:
IllegalAccessException
-
getValueFromObject
- Throws:
IllegalAccessException
-
resolveAndInvokePropertyMethods
-
resolveAndInvokePropertyMethod
-
resolveAndAssignFields
-
resolveAndAssignField
-
isSetPropertyMethod
-
toString
-
hashCode
-
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared withObjects::equals(Object,Object). -
stack
-