org.apache.ignite.spi.discovery.zk

## Class ZookeeperDiscoverySpi

- java.lang.Object
- - org.apache.ignite.spi.IgniteSpiAdapter
  - - org.apache.ignite.spi.discovery.zk.ZookeeperDiscoverySpi

- All Implemented Interfaces:
    org.apache.ignite.internal.managers.discovery.IgniteDiscoverySpi, DiscoverySpi, IgniteSpi

      @IgniteSpiMultipleInstancesSupport(value=true)
       @DiscoverySpiOrderSupport(value=true)
       @DiscoverySpiHistorySupport(value=true)
       @DiscoverySpiMutableCustomMessageSupport(value=false)
      public class ZookeeperDiscoverySpi
      extends IgniteSpiAdapter
      implements org.apache.ignite.internal.managers.discovery.IgniteDiscoverySpi

  Zookeeper Discovery Spi.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static long` | `DFLT_JOIN_TIMEOUT`
    `static String` | `DFLT_ROOT_PATH`

    - ### Fields inherited from class org.apache.ignite.spi.IgniteSpiAdapter

      `ignite, igniteInstanceName`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `ZookeeperDiscoverySpi()`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `allNodesSupport(org.apache.ignite.internal.IgniteFeatures feature)`
    `void` | `clientReconnect()`
    `boolean` | `clientReconnectSupported()`
    `@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.
    `DiscoverySpiNodeAuthenticator` | `getAuthenticator()`
    `long` | `getGridStartTime()` Gets start time of the very first node in the grid.
    `long` | `getJoinTimeout()`
    `ClusterNode` | `getLocalNode()` Gets local node.
    `Map<String,Object>` | `getLocNodeAttrs()`
    `@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.
    `long` | `getSessionTimeout()`
    `String` | `getZkConnectionString()`
    `String` | `getZkRootPath()`
    `boolean` | `isClientMode()` Whether or not discovery is started in client mode.
    `boolean` | `isClientReconnectDisabled()` If `true` client does not try to reconnect.
    `boolean` | `knownNode(UUID nodeId)`
    `protected void` | `onContextInitialized0(IgniteSpiContext spiCtx)` Method to be called in the end of onContextInitialized method.
    `boolean` | `pingNode(UUID nodeId)` Pings the remote node to see if it's alive.
    `void` | `resolveCommunicationFailure(ClusterNode node, Exception err)`
    `void` | `sendCustomEvent(DiscoverySpiCustomMessage msg)` Sends custom message across the ring.
    `void` | `setAuthenticator(DiscoverySpiNodeAuthenticator auth)` Sets discovery SPI node authenticator.
    `ZookeeperDiscoverySpi` | `setClientReconnectDisabled(boolean clientReconnectDisabled)` Sets client reconnect disabled flag.
    `void` | `setDataExchange(DiscoverySpiDataExchange exchange)` Sets a handler for initial data exchange between Ignite nodes.
    `void` | `setInternalListener(org.apache.ignite.internal.managers.discovery.IgniteDiscoverySpiInternalListener lsnr)` For TESTING only.
    `ZookeeperDiscoverySpi` | `setJoinTimeout(long joinTimeout)`
    `void` | `setListener(@Nullable DiscoverySpiListener lsnr)` Sets a listener for discovery events.
    `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.
    `ZookeeperDiscoverySpi` | `setSessionTimeout(long sesTimeout)`
    `ZookeeperDiscoverySpi` | `setZkConnectionString(String zkConnectionString)`
    `ZookeeperDiscoverySpi` | `setZkRootPath(String zkRootPath)`
    `void` | `simulateNodeFailure()` For TESTING only.
    `void` | `spiStart(@Nullable String igniteInstanceName)` This method is called to start SPI.
    `void` | `spiStop()` This method is called to stop SPI.
    `boolean` | `supportsCommunicationFailureResolve()`
    `String` | `toString()`

    - ### Methods inherited from class org.apache.ignite.spi.IgniteSpiAdapter

      `addTimeoutObject, assertParameter, checkConfigurationConsistency0, clientFailureDetectionTimeout, configInfo, createSpiAttributeName, failureDetectionTimeout, failureDetectionTimeoutEnabled, failureDetectionTimeoutEnabled, getConsistentAttributeNames, getExceptionRegistry, getName, getNodeAttributes, getSpiContext, ignite, initFailureDetectionTimeout, injectables, injectResources, isNodeStopping, onBeforeStart, onClientDisconnected, onClientReconnected, onContextDestroyed, onContextDestroyed0, onContextInitialized, registerMBean, removeTimeoutObject, setName, started, startInfo, startStopwatch, stopInfo, unregisterMBean`

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

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

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

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

- - ### Field Detail

    - #### DFLT_ROOT_PATH

          public static final String DFLT_ROOT_PATH

      See Also:
        Constant Field Values

    - #### DFLT_JOIN_TIMEOUT

          public static final long DFLT_JOIN_TIMEOUT

      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### ZookeeperDiscoverySpi

          public ZookeeperDiscoverySpi()

  - ### Method Detail

    - #### getZkRootPath

          public String getZkRootPath()

      Returns:
        Base path in ZK for znodes created by SPI.

    - #### setZkRootPath

          @IgniteSpiConfiguration(optional=true)
          public ZookeeperDiscoverySpi setZkRootPath(String zkRootPath)

      Parameters:
        `zkRootPath` - Base path in ZooKeeper for znodes created by SPI.
      Returns:
        `this` for chaining.

    - #### getSessionTimeout

          public long getSessionTimeout()

      Returns:
        ZooKeeper session timeout.

    - #### setSessionTimeout

          @IgniteSpiConfiguration(optional=true)
          public ZookeeperDiscoverySpi setSessionTimeout(long sesTimeout)

      Parameters:
        `sesTimeout` - ZooKeeper session timeout.
      Returns:
        `this` for chaining.

    - #### getJoinTimeout

          public long getJoinTimeout()

      Returns:
        Cluster join timeout.

    - #### setJoinTimeout

          @IgniteSpiConfiguration(optional=true)
          public ZookeeperDiscoverySpi setJoinTimeout(long joinTimeout)

      Parameters:
        `joinTimeout` - Cluster join timeout (`0` means wait forever).
      Returns:
        `this` for chaining.

    - #### getZkConnectionString

          public String getZkConnectionString()

      Returns:
        ZooKeeper connection string

    - #### setZkConnectionString

          @IgniteSpiConfiguration(optional=false)
          public ZookeeperDiscoverySpi setZkConnectionString(String zkConnectionString)

      Parameters:
        `zkConnectionString` - ZooKeeper connection string
      Returns:
        `this` for chaining.

    - #### isClientReconnectDisabled

          public boolean isClientReconnectDisabled()

      If `true` client does not try to reconnect.
      Returns:
        Client reconnect disabled flag.

    - #### setClientReconnectDisabled

          @IgniteSpiConfiguration(optional=true)
          public ZookeeperDiscoverySpi setClientReconnectDisabled(boolean clientReconnectDisabled)

      Sets client reconnect disabled flag.
      Parameters:
        `clientReconnectDisabled` - Client reconnect disabled flag.
      Returns:
        `this` for chaining.

    - #### clientReconnectSupported

          public boolean clientReconnectSupported()

      Specified by:
        `clientReconnectSupported` in interface `org.apache.ignite.internal.managers.discovery.IgniteDiscoverySpi`
      Returns:
        `True` if SPI supports client reconnect.

    - #### clientReconnect

          public void clientReconnect()

      Specified by:
        `clientReconnect` in interface `org.apache.ignite.internal.managers.discovery.IgniteDiscoverySpi`

    - #### knownNode

          public boolean knownNode(UUID nodeId)

      Specified by:
        `knownNode` in interface `org.apache.ignite.internal.managers.discovery.IgniteDiscoverySpi`
      Parameters:
        `nodeId` - Node ID.
      Returns:
        `True` if node joining or already joined topology.

    - #### supportsCommunicationFailureResolve

          public boolean supportsCommunicationFailureResolve()

      Specified by:
        `supportsCommunicationFailureResolve` in interface `org.apache.ignite.internal.managers.discovery.IgniteDiscoverySpi`
      Returns:
        `True` if supports communication error resolve.

    - #### resolveCommunicationFailure

          public void resolveCommunicationFailure(ClusterNode node,
                                                  Exception err)

      Specified by:
        `resolveCommunicationFailure` in interface `org.apache.ignite.internal.managers.discovery.IgniteDiscoverySpi`
      Parameters:
        `node` - Problem node.
        `err` - Connection error.

    - #### consistentId

          @Nullable
          public @Nullable Serializable consistentId()
                                                        throws IgniteSpiException

      Gets consistent ID.
      Specified by:
        `consistentId` in interface `DiscoverySpi`
      Returns:
        Consistent ID of this Ignite instance or `null` if not applicable.
      Throws:
        `IgniteSpiException` - If failed.

    - #### getRemoteNodes

          public Collection<ClusterNode> getRemoteNodes()

      Gets collection of remote nodes in grid or empty collection if no remote nodes found.
      Specified by:
        `getRemoteNodes` in interface `DiscoverySpi`
      Returns:
        Collection of remote nodes.

    - #### allNodesSupport

          public boolean allNodesSupport(org.apache.ignite.internal.IgniteFeatures feature)

      Specified by:
        `allNodesSupport` in interface `org.apache.ignite.internal.managers.discovery.IgniteDiscoverySpi`
      Parameters:
        `feature` - Feature to check.
      Returns:
        `true` if all nodes support the given feature.

    - #### getLocalNode

          public ClusterNode getLocalNode()

      Gets local node.
      Specified by:
        `getLocalNode` in interface `DiscoverySpi`
      Overrides:
        `getLocalNode` in class `IgniteSpiAdapter`
      Returns:
        Local node.

    - #### getNode

          @Nullable
          public @Nullable ClusterNode getNode(UUID nodeId)

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

    - #### pingNode

          public boolean pingNode(UUID nodeId)

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

    - #### setNodeAttributes

          public 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
      Specified by:
        `setNodeAttributes` in interface `DiscoverySpi`
      Parameters:
        `attrs` - Map of node attributes.
        `ver` - Product version.

    - #### setListener

          public void setListener(@Nullable
                                  @Nullable DiscoverySpiListener lsnr)

      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

      Specified by:
        `setListener` in interface `DiscoverySpi`
      Parameters:
        `lsnr` - Listener to discovery events or `null` to unset the listener.

    - #### setDataExchange

          public void setDataExchange(DiscoverySpiDataExchange exchange)

      Sets a handler for initial data exchange between Ignite nodes.
      Specified by:
        `setDataExchange` in interface `DiscoverySpi`
      Parameters:
        `exchange` - Discovery data exchange handler.

    - #### setMetricsProvider

          public void setMetricsProvider(DiscoveryMetricsProvider metricsProvider)

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

    - #### disconnect

          public 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.
      Specified by:
        `disconnect` in interface `DiscoverySpi`
      Throws:
        `IgniteSpiException` - If any error occurs.

    - #### setAuthenticator

          public void setAuthenticator(DiscoverySpiNodeAuthenticator auth)

      Sets discovery SPI node authenticator. This method is called before SPI start() method.
      Specified by:
        `setAuthenticator` in interface `DiscoverySpi`
      Parameters:
        `auth` - Discovery SPI authenticator.

    - #### getAuthenticator

          public DiscoverySpiNodeAuthenticator getAuthenticator()

      Returns:
        Authenticator.

    - #### getGridStartTime

          public 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.
      Specified by:
        `getGridStartTime` in interface `DiscoverySpi`
      Returns:
        Start time of the first node in grid or `0` if SPI implementation does not support this method.

    - #### sendCustomEvent

          public void sendCustomEvent(DiscoverySpiCustomMessage msg)

      Sends custom message across the ring.
      Specified by:
        `sendCustomEvent` in interface `DiscoverySpi`
      Parameters:
        `msg` - Custom message.

    - #### failNode

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

      Initiates failure of provided node.
      Specified by:
        `failNode` in interface `DiscoverySpi`
      Parameters:
        `nodeId` - Node ID.
        `warning` - Warning to be shown on all cluster nodes.

    - #### isClientMode

          public boolean isClientMode()
                               throws IllegalStateException

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

    - #### spiStart

          public void spiStart(@Nullable
                               @Nullable String igniteInstanceName)
                        throws IgniteSpiException

      This method is called to start SPI. After this method returns successfully kernel assumes that SPI is fully operational.
      Specified by:
        `spiStart` in interface `IgniteSpi`
      Parameters:
        `igniteInstanceName` - Name of Ignite instance this SPI is being started for (`null` for default Ignite instance).
      Throws:
        `IgniteSpiException` - Throws in case of any error during SPI start.

    - #### onContextInitialized0

          protected void onContextInitialized0(IgniteSpiContext spiCtx)
                                        throws IgniteSpiException

      Method to be called in the end of onContextInitialized method.
      Overrides:
        `onContextInitialized0` in class `IgniteSpiAdapter`
      Parameters:
        `spiCtx` - SPI context.
      Throws:
        `IgniteSpiException` - In case of errors.

    - #### setInternalListener

          public void setInternalListener(org.apache.ignite.internal.managers.discovery.IgniteDiscoverySpiInternalListener lsnr)

      For TESTING only.
      Specified by:
        `setInternalListener` in interface `org.apache.ignite.internal.managers.discovery.IgniteDiscoverySpi`
      Parameters:
        `lsnr` - Listener.

    - #### simulateNodeFailure

          public void simulateNodeFailure()

      For TESTING only.
      Specified by:
        `simulateNodeFailure` in interface `org.apache.ignite.internal.managers.discovery.IgniteDiscoverySpi`

    - #### spiStop

          public void spiStop()
                       throws IgniteSpiException

      This method is called to stop SPI. After this method returns kernel assumes that this SPI is finished and all resources acquired by it are released.

      Note that this method can be called at any point including during recovery of failed start. It should make no assumptions on what state SPI will be in when this method is called.

      Specified by:
        `spiStop` in interface `IgniteSpi`
      Throws:
        `IgniteSpiException` - Thrown in case of any error during SPI stop.

    - #### getLocNodeAttrs

          public Map<String,Object> getLocNodeAttrs()

      Returns:
        Local node attributes

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`

2022 Copyright © Apache Software Foundation
| Follow @ApacheIgnite
Ignite Database and Caching Platform | : ver. 2.13.0
Release Date | : April 20 2022