org.apache.ignite.spi.discovery.tcp.ipfinder.multicast

## Class TcpDiscoveryMulticastIpFinder

- java.lang.Object
- - org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinderAdapter
  - - org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder
    - - org.apache.ignite.spi.discovery.tcp.ipfinder.multicast.TcpDiscoveryMulticastIpFinder

- All Implemented Interfaces:
    TcpDiscoveryIpFinder

      public class TcpDiscoveryMulticastIpFinder
      extends TcpDiscoveryVmIpFinder

  Multicast-based IP finder.

  When TCP discovery starts this finder sends multicast request and waits for some time when others nodes reply to this request with messages containing their addresses (time IP finder waits for response and number of attempts to re-send multicast request in case if no replies are received can be configured, see `setResponseWaitTime(int)` and `setAddressRequestAttempts(int)`).

  In addition to address received via multicast this finder can work with pre-configured list of addresses specified via `TcpDiscoveryVmIpFinder.setAddresses(Collection)` method.

  # Configuration

  ## Mandatory

  There are no mandatory configuration parameters.

  ## Optional

  - Multicast IP address (see `setMulticastGroup(String)`).
  - Multicast port number (see `setMulticastPort(int)`).
  - Address response wait time (see `setResponseWaitTime(int)`).
  - Address request attempts (see `setAddressRequestAttempts(int)`).
  - Pre-configured addresses (see `TcpDiscoveryVmIpFinder.setAddresses(Collection)`)
  - Local address (see `setLocalAddress(String)`)

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static int` | `DFLT_ADDR_REQ_ATTEMPTS` Default number of attempts to send multicast address request (value is `2`).
    `static String` | `DFLT_MCAST_GROUP` Default multicast IP address (value is `228.1.2.4`).
    `static int` | `DFLT_MCAST_PORT` Default multicast port number (value is `47400`).
    `static int` | `DFLT_RES_WAIT_TIME` Default time IP finder waits for reply to multicast address request (value is `500`).

    - ### Fields inherited from class org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinderAdapter

      `ignite`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `TcpDiscoveryMulticastIpFinder()` Constructs new IP finder.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `close()` Closes this IP finder and releases any system resources associated with it.
    `int` | `getAddressRequestAttempts()` Gets number of attempts to send multicast address request.
    `String` | `getLocalAddress()` Gets local address that multicast IP finder uses.
    `String` | `getMulticastGroup()` Gets IP address of multicast group.
    `int` | `getMulticastPort()` Gets port number which multicast messages are sent to.
    `Collection<InetSocketAddress>` | `getRegisteredAddresses()` Gets all addresses registered in this finder.
    `int` | `getResponseWaitTime()` Gets time in milliseconds IP finder waits for reply to multicast address request.
    `int` | `getTimeToLive()` Set the default time-to-live for multicast packets sent out on this IP finder.
    `void` | `initializeLocalAddresses(Collection<InetSocketAddress> addrs)` Initializes addresses discovery SPI binds to.
    `void` | `onSpiContextInitialized(IgniteSpiContext spiCtx)` Callback invoked when SPI context is initialized after `TcpDiscoverySpi.spiStart(String)` method is completed, SPI context can be stored for future access.
    `TcpDiscoveryMulticastIpFinder` | `setAddressRequestAttempts(int addrReqAttempts)` Sets number of attempts to send multicast address request.
    `TcpDiscoveryMulticastIpFinder` | `setLocalAddress(String locAddr)` Sets local host address used by this IP finder.
    `TcpDiscoveryMulticastIpFinder` | `setMulticastGroup(String mcastGrp)` Sets IP address of multicast group.
    `TcpDiscoveryMulticastIpFinder` | `setMulticastPort(int mcastPort)` Sets port number which multicast messages are sent to.
    `TcpDiscoveryMulticastIpFinder` | `setResponseWaitTime(int resWaitTime)` Sets time in milliseconds IP finder waits for reply to multicast address request.
    `TcpDiscoveryMulticastIpFinder` | `setShared(boolean shared)` Sets shared flag.
    `TcpDiscoveryMulticastIpFinder` | `setTimeToLive(int ttl)` Set the default time-to-live for multicast packets sent out on this IP finder in order to control the scope of the multicast.
    `String` | `toString()`

    - ### Methods inherited from class org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder

      `registerAddresses, setAddresses, unregisterAddresses`

    - ### Methods inherited from class org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinderAdapter

      `discoveryClientMode, isShared, onSpiContextDestroyed, spiContext`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Field Detail

    - #### DFLT_MCAST_GROUP

          public static final String DFLT_MCAST_GROUP

      Default multicast IP address (value is `228.1.2.4`).
      See Also:
        Constant Field Values

    - #### DFLT_MCAST_PORT

          public static final int DFLT_MCAST_PORT

      Default multicast port number (value is `47400`).
      See Also:
        Constant Field Values

    - #### DFLT_RES_WAIT_TIME

          public static final int DFLT_RES_WAIT_TIME

      Default time IP finder waits for reply to multicast address request (value is `500`).
      See Also:
        Constant Field Values

    - #### DFLT_ADDR_REQ_ATTEMPTS

          public static final int DFLT_ADDR_REQ_ATTEMPTS

      Default number of attempts to send multicast address request (value is `2`).
      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### TcpDiscoveryMulticastIpFinder

          public TcpDiscoveryMulticastIpFinder()

      Constructs new IP finder.

  - ### Method Detail

    - #### setMulticastGroup

          @IgniteSpiConfiguration(optional=true)
          public TcpDiscoveryMulticastIpFinder setMulticastGroup(String mcastGrp)

      Sets IP address of multicast group.

      If not provided, default value is `DFLT_MCAST_GROUP`.

      Parameters:
        `mcastGrp` - Multicast IP address.
      Returns:
        `this` for chaining.

    - #### getMulticastGroup

          public String getMulticastGroup()

      Gets IP address of multicast group.
      Returns:
        Multicast IP address.

    - #### setMulticastPort

          @IgniteSpiConfiguration(optional=true)
          public TcpDiscoveryMulticastIpFinder setMulticastPort(int mcastPort)

      Sets port number which multicast messages are sent to.

      If not provided, default value is `DFLT_MCAST_PORT`.

      Parameters:
        `mcastPort` - Multicast port number.
      Returns:
        `this` for chaining.

    - #### getMulticastPort

          public int getMulticastPort()

      Gets port number which multicast messages are sent to.
      Returns:
        Port number.

    - #### setResponseWaitTime

          @IgniteSpiConfiguration(optional=true)
          public TcpDiscoveryMulticastIpFinder setResponseWaitTime(int resWaitTime)

      Sets time in milliseconds IP finder waits for reply to multicast address request.

      If not provided, default value is `DFLT_RES_WAIT_TIME`.

      Parameters:
        `resWaitTime` - Time IP finder waits for reply to multicast address request.
      Returns:
        `this` for chaining.

    - #### getResponseWaitTime

          public int getResponseWaitTime()

      Gets time in milliseconds IP finder waits for reply to multicast address request.
      Returns:
        Time IP finder waits for reply to multicast address request.

    - #### setAddressRequestAttempts

          @IgniteSpiConfiguration(optional=true)
          public TcpDiscoveryMulticastIpFinder setAddressRequestAttempts(int addrReqAttempts)

      Sets number of attempts to send multicast address request. IP finder re-sends request only in case if no reply for previous request is received.

      If not provided, default value is `DFLT_ADDR_REQ_ATTEMPTS`.

      Parameters:
        `addrReqAttempts` - Number of attempts to send multicast address request.
      Returns:
        `this` for chaining.

    - #### getAddressRequestAttempts

          public int getAddressRequestAttempts()

      Gets number of attempts to send multicast address request. IP finder re-sends request only in case if no reply for previous request is received.
      Returns:
        Number of attempts to send multicast address request.

    - #### setLocalAddress

          @IgniteSpiConfiguration(optional=true)
          public TcpDiscoveryMulticastIpFinder setLocalAddress(String locAddr)

      Sets local host address used by this IP finder. If provided address is non-loopback then multicast socket is bound to this interface. If local address is not set or is any local address then IP finder creates multicast sockets for all found non-loopback addresses.

      If not provided then this property is initialized by the local address set in `TcpDiscoverySpi` configuration.

      Parameters:
        `locAddr` - Local host address.
      Returns:
        `this` for chaining.
      See Also:
        `TcpDiscoverySpi.setLocalAddress(String)`

    - #### getLocalAddress

          public String getLocalAddress()

      Gets local address that multicast IP finder uses.
      Returns:
        Local address.

    - #### setTimeToLive

          @IgniteSpiConfiguration(optional=true)
          public TcpDiscoveryMulticastIpFinder setTimeToLive(int ttl)

      Set the default time-to-live for multicast packets sent out on this IP finder in order to control the scope of the multicast.

      The TTL has to be in the range `0 <= TTL <= 255`.

      If TTL is `0`, packets are not transmitted on the network, but may be delivered locally.

      Default value is `-1` which corresponds to system default value.

      Parameters:
        `ttl` - Time to live.
      Returns:
        `this` for chaining.

    - #### getTimeToLive

          public int getTimeToLive()

      Set the default time-to-live for multicast packets sent out on this IP finder.
      Returns:
        Time to live.

    - #### initializeLocalAddresses

          public void initializeLocalAddresses(Collection<InetSocketAddress> addrs)
                                        throws IgniteSpiException

      Initializes addresses discovery SPI binds to.
      Specified by:
        `initializeLocalAddresses` in interface `TcpDiscoveryIpFinder`
      Overrides:
        `initializeLocalAddresses` in class `TcpDiscoveryIpFinderAdapter`
      Parameters:
        `addrs` - Addresses discovery SPI binds to.
      Throws:
        `IgniteSpiException` - In case of error.

    - #### onSpiContextInitialized

          public void onSpiContextInitialized(IgniteSpiContext spiCtx)
                                       throws IgniteSpiException

      Callback invoked when SPI context is initialized after `TcpDiscoverySpi.spiStart(String)` method is completed, SPI context can be stored for future access.
      Specified by:
        `onSpiContextInitialized` in interface `TcpDiscoveryIpFinder`
      Overrides:
        `onSpiContextInitialized` in class `TcpDiscoveryIpFinderAdapter`
      Parameters:
        `spiCtx` - Spi context.
      Throws:
        `IgniteSpiException` - In case of error.

    - #### getRegisteredAddresses

          public Collection<InetSocketAddress> getRegisteredAddresses()

      Gets all addresses registered in this finder.
      Specified by:
        `getRegisteredAddresses` in interface `TcpDiscoveryIpFinder`
      Overrides:
        `getRegisteredAddresses` in class `TcpDiscoveryVmIpFinder`
      Returns:
        All known addresses, potentially empty, but never `null`.

    - #### close

          public void close()

      Closes this IP finder and releases any system resources associated with it.
      Specified by:
        `close` in interface `TcpDiscoveryIpFinder`
      Overrides:
        `close` in class `TcpDiscoveryIpFinderAdapter`

    - #### setShared

          public TcpDiscoveryMulticastIpFinder setShared(boolean shared)

      Sets shared flag. If `true` then it is expected that IP addresses registered with IP finder will be seen by IP finders on all other nodes.
      Overrides:
        `setShared` in class `TcpDiscoveryVmIpFinder`
      Parameters:
        `shared` - `true` if this IP finder is shared.
      Returns:
        `this` for chaining.

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `TcpDiscoveryVmIpFinder`

2022 Copyright © Apache Software Foundation
| Follow @ApacheIgnite
Ignite Database and Caching Platform | : ver. 2.12.0
Release Date | : January 10 2022