org.apache.ignite.spi.discovery

## Interface DiscoverySpi

- All Superinterfaces:
    IgniteSpi
  All Known Implementing Classes:
    IsolatedDiscoverySpi, TcpDiscoverySpi, ZookeeperDiscoverySpi

      public interface DiscoverySpi
      extends IgniteSpi

  Grid discovery SPI allows to discover remote nodes in grid.

  The default discovery SPI is `TcpDiscoverySpi` with default configuration which allows all nodes in local network (with enabled multicast) to discover each other.

  Ignite provides the following `GridDeploymentSpi` implementation:

  - `TcpDiscoverySpi`
  NOTE: this SPI (i.e. methods in this interface) should never be used directly. SPIs provide internal view on the subsystem and is used internally by Ignite kernal. In rare use cases when access to a specific implementation of this SPI is required - an instance of this SPI can be obtained via `Ignite.configuration()` method to check its configuration properties or call other non-SPI methods. Note again that calling methods from this interface on the obtained instance can lead to undefined behavior and explicitly not supported.

- - ### Method Summary

    All Methods Instance Methods Abstract Methods Deprecated Methods
    Modifier and Type | Method and Description
    --- | ---
    `@Nullable Serializable` | `consistentId()` Gets consistent ID.
    `void` | `disconnect()` Tells discovery SPI to disconnect from topology.
    `void` | `failNode(UUID nodeId, @Nullable String warning)` Initiates failure of provided node.
    `long` | `getGridStartTime()` Gets start time of the very first node in the grid.
    `ClusterNode` | `getLocalNode()` Gets local node.
    `@Nullable ClusterNode` | `getNode(UUID nodeId)` Gets node by ID.
    `Collection<ClusterNode>` | `getRemoteNodes()` Gets collection of remote nodes in grid or empty collection if no remote nodes found.
    `boolean` | `isClientMode()` Whether or not discovery is started in client mode.
    `boolean` | `pingNode(UUID nodeId)` Pings the remote node to see if it's alive.
    `void` | `sendCustomEvent(DiscoverySpiCustomMessage msg)` Sends custom message across the ring.
    `void` | `setAuthenticator(DiscoverySpiNodeAuthenticator auth)` Sets discovery SPI node authenticator.
    `void` | `setDataExchange(DiscoverySpiDataExchange exchange)` Sets a handler for initial data exchange between Ignite nodes.
    `void` | `setListener(@Nullable DiscoverySpiListener lsnr)` Deprecated.
    `void` | `setMetricsProvider(DiscoveryMetricsProvider metricsProvider)` Sets discovery metrics provider.
    `void` | `setNodeAttributes(Map<String,Object> attrs, IgniteProductVersion ver)` Sets node attributes and node version which will be distributed in grid during join process.

    - ### Methods inherited from interface org.apache.ignite.spi.IgniteSpi

      `getName, getNodeAttributes, onClientDisconnected, onClientReconnected, onContextDestroyed, onContextInitialized, spiStart, spiStop`

- - ### Method Detail

    - #### consistentId

          @Nullable
          @Nullable Serializable consistentId()
                                                 throws IgniteSpiException

      Gets consistent ID.
      Returns:
        Consistent ID of this Ignite instance or `null` if not applicable.
      Throws:
        `IgniteSpiException` - If failed.

    - #### getRemoteNodes

          Collection<ClusterNode> getRemoteNodes()

      Gets collection of remote nodes in grid or empty collection if no remote nodes found.
      Returns:
        Collection of remote nodes.

    - #### getLocalNode

          ClusterNode getLocalNode()

      Gets local node.
      Returns:
        Local node.

    - #### getNode

          @Nullable
          @Nullable ClusterNode getNode(UUID nodeId)

      Gets node by ID.
      Parameters:
        `nodeId` - Node ID.
      Returns:
        Node with given ID or `null` if node is not found.

    - #### pingNode

          boolean pingNode(UUID nodeId)

      Pings the remote node to see if it's alive.
      Parameters:
        `nodeId` - Node Id.
      Returns:
        `true` if node alive, `false` otherwise.

    - #### setNodeAttributes

          void setNodeAttributes(Map<String,Object> attrs,
                                 IgniteProductVersion ver)

      Sets node attributes and node version which will be distributed in grid during join process. Note that these attributes cannot be changed and set only once. set
      Parameters:
        `attrs` - Map of node attributes.
        `ver` - Product version.

    - #### setListener

          @Deprecated
          void setListener(@Nullable
                                       @Nullable DiscoverySpiListener lsnr)

      Deprecated.
      Sets a listener for discovery events. Refer to `DiscoveryEvent` for a set of all possible discovery events.

      TODO: This method should be removed from public API in Apache Ignite 3.0

      Parameters:
        `lsnr` - Listener to discovery events or `null` to unset the listener.

    - #### setDataExchange

          void setDataExchange(DiscoverySpiDataExchange exchange)

      Sets a handler for initial data exchange between Ignite nodes.
      Parameters:
        `exchange` - Discovery data exchange handler.

    - #### setMetricsProvider

          void setMetricsProvider(DiscoveryMetricsProvider metricsProvider)

      Sets discovery metrics provider. Use metrics provided by `DiscoveryMetricsProvider.metrics()` method to exchange dynamic metrics between nodes.
      Parameters:
        `metricsProvider` - Provider of metrics data.

    - #### disconnect

          void disconnect()
                   throws IgniteSpiException

      Tells discovery SPI to disconnect from topology. This is very close to calling `IgniteSpi.spiStop()` with accounting that it is not a full stop, but disconnect due to segmentation.
      Throws:
        `IgniteSpiException` - If any error occurs.

    - #### setAuthenticator

          void setAuthenticator(DiscoverySpiNodeAuthenticator auth)

      Sets discovery SPI node authenticator. This method is called before SPI start() method.
      Parameters:
        `auth` - Discovery SPI authenticator.

    - #### getGridStartTime

          long getGridStartTime()

      Gets start time of the very first node in the grid. This value should be the same on all nodes in the grid and it should not change even if very first node fails of leaves grid.
      Returns:
        Start time of the first node in grid or `0` if SPI implementation does not support this method.

    - #### sendCustomEvent

          void sendCustomEvent(DiscoverySpiCustomMessage msg)
                        throws IgniteException

      Sends custom message across the ring.
      Parameters:
        `msg` - Custom message.
      Throws:
        `IgniteException` - if failed to sent the event message.

    - #### failNode

          void failNode(UUID nodeId,
                        @Nullable
                        @Nullable String warning)

      Initiates failure of provided node.
      Parameters:
        `nodeId` - Node ID.
        `warning` - Warning to be shown on all cluster nodes.

    - #### isClientMode

          boolean isClientMode()
                        throws IllegalStateException

      Whether or not discovery is started in client mode.
      Returns:
        `true` if node is in client mode.
      Throws:
        `IllegalStateException` - If discovery SPI has not started.

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