Version 5

    In 2.8, handling of system properties has changed, and is described below.

     

    This focuses on inet addresses and how we pick IPv4 or IPv6 addresses.

     

    All inet address related properties are annotated with @Property, e.g. in MPING:

     

     

    @Property(systemProperty="jgroups.mping.mcast_addr", 
              defaultValueIPv4="230.5.6.7",
              defaultValueIPv6="ff0e::5:6:7")
    InetAddress mcast_addr=null;

    @Property(systemProperty="jgroups.bind_addr",
              defaultValueIPv4="NON_LOOPBACK_ADDRESS",
              defaultValueIPv6="NON_LOOPBACK_ADDRESS")
    InetAddress bind_addr=null;

     

     

    Here, we have 2 properties, mcast_addr and bind_addr. We'll use these in the discussion below as example.

     

    The corresponding XML config might look like this:

     

    <MPING bind_addr="${jgroups.bind_addr,jboss.bind.address}" 
           mcast_addr="${jgroups.mping.mcast_addr:230.1.1.1}" mcast_port="7890" />

     


    When a stack is created, JGroups first assigns all values from the XML config to properties, e.g. MPING.mcast_port will be assigned the value of 7890.

     

    Then, system property substitution assigns (and overrides) all proprties which have corresponding system props, e.g. if jgroups.bind_addr is set, its value will be assigned to MPING.bind_addr. If not, then if jboss.bind.address is set, it will be assigned toMPING.bind_addr. If neither of these properties are defined bind_addr remains null.

     

    After the initial property processing, a next phase ensues, which attempts to determine the type of stack (IPv4 versus IPv6) and sets correct defaults.


    The following steps are taken to do this:

    • We look at the inet addresses associated with all network interfaces
      • If we have only IPv4 addresses, the stack type is IPv4
      • If we have only IPv6 addresses, the stack type is IPv6
      • If we have both types, we defer the decision to the next step
    • Now we iterate through all inet addresses (or related, e.g. IpAddresses, orlists of InetAddresses)
      • If we found some, we determine their types
      • If some are IPv4 and others IPv6, we throw an exception and terminate (the stack won't start)
      • If all of them are of the same type, we compare the type to the previously determined type
        • If the stack if of the same type as the addresses (or we found both stacks), we continue
        • Else we throw an exception and terminate
      • If we didn't find any addresses, and have both stacks available, we default to IPv6 (IPv4 on Windows)
    • Now we iterate through all protocols and try to set 'inet-related' properties which don't have a value yet to the stack-compliant defaults defined in @Property
      • In the above exampe, MPING.mcast_addr is set to the correct default value, based on the type of the stack
      • MPING.bind_addr has a special default, "NON_LOOPBACK_ADDRESS".  This means that the stack configurator should pick the first, non-loopback address of *any* interface, which has the same IP type.