Record Class Configurator

java.lang.Object
java.lang.Record
org.jgroups.stack.Configurator
Record Components:
stack - The protocol stack

public record Configurator(ProtocolStack stack) extends Record
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
  • Constructor Details

    • Configurator

      public Configurator(ProtocolStack stack)
      Creates an instance of a Configurator record class.
      Parameters:
      stack - the value for the stack record 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. Each ProtocolConfiguration has 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

      public static Protocol createProtocol(String prot_spec, ProtocolStack stack) throws Exception
      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 specified
      stack - 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

      public static Protocol connectProtocols(List<Protocol> protocol_list) throws 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:
      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 ProtocolConfigurations
      stack - 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

      public static void initializeAttrs(Object obj, Map<String,String> properties, StackType ip_version) throws Exception
      Throws:
      Exception
    • sanityCheck

      public static void sanityCheck(List<Protocol> protocols) throws Exception
      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, Configurator.InetAddressInfo>> map) throws Exception
      Returns all inet addresses found
      Throws:
      Exception
    • createInetAddressMap

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

      public static List<InetAddress> getInetAddresses(List<Protocol> protocols) throws Exception
      Throws:
      Exception
    • getInetAddresses2

      public static Map<String, InetAddress> getInetAddresses2(List<Protocol> protocols)
      Returns a map of protocol.attr/InetAddress tuples
    • isInetAddressOrCompatibleType

      public static boolean isInetAddressOrCompatibleType(Class<?> c)
    • 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() and Property.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

      public static void setDefaultAddressValues(Object obj, StackType ip_version) throws Exception
      Throws:
      Exception
    • ensureValidBindAddresses

      public static void ensureValidBindAddresses(List<Protocol> protocols) throws Exception
      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

      public static <T> T getValueFromObject(Object obj, Field field) throws IllegalAccessException
      Throws:
      IllegalAccessException
    • getValueFromObject

      public static <T> T getValueFromObject(Object obj, String field_name) throws IllegalAccessException
      Throws:
      IllegalAccessException
    • 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

      public static boolean isSetPropertyMethod(Method method, Class<?> enclosing_clazz)
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      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 with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • stack

      public ProtocolStack stack()
      Returns the value of the stack record component.
      Returns:
      the value of the stack record component