org.apache.ignite.spi

## Class IgniteSpiAdapter

- java.lang.Object
- - org.apache.ignite.spi.IgniteSpiAdapter

- All Implemented Interfaces:
    IgniteSpi
  Direct Known Subclasses:
    AdaptiveLoadBalancingSpi, AlwaysFailoverSpi, CacheCheckpointSpi, FifoQueueCollisionSpi, IsolatedDiscoverySpi, JdbcCheckpointSpi, JmxMetricExporterSpi, JobStealingCollisionSpi, JobStealingFailoverSpi, KeystoreEncryptionSpi, LocalDeploymentSpi, MemoryEventStorageSpi, NeverFailoverSpi, NoopCheckpointSpi, NoopCollisionSpi, NoopEncryptionSpi, NoopEventStorageSpi, NoopIndexingSpi, NoopMetricExporterSpi, NoopTracingSpi, OpenCensusTracingSpi, PriorityQueueCollisionSpi, org.apache.ignite.internal.processors.metric.PushMetricsExporterAdapter, RoundRobinLoadBalancingSpi, S3CheckpointSpi, SharedFsCheckpointSpi, org.apache.ignite.spi.communication.tcp.internal.TcpCommunicationConfigInitializer, TcpDiscoverySpi, UriDeploymentSpi, WeightedRandomLoadBalancingSpi, ZookeeperDiscoverySpi

      public abstract class IgniteSpiAdapter
      extends Object
      implements IgniteSpi

  This class provides convenient adapter for SPI implementations.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected Ignite` | `ignite` Ignite instance.
    `protected String` | `igniteInstanceName` Ignite instance name.
    `protected IgniteLogger` | `log`

  - ### Constructor Summary

    Constructors
    Modifier | Constructor and Description
    --- | ---
    `protected` | `IgniteSpiAdapter()` Creates new adapter and initializes it from the current (this) class.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected void` | `addTimeoutObject(IgniteSpiTimeoutObject obj)`
    `protected void` | `assertParameter(boolean cond, String condDesc)` Throws exception with uniform error message if given parameter's assertion condition is `false`.
    `protected void` | `checkConfigurationConsistency0(IgniteSpiContext spiCtx, ClusterNode node, boolean starting)` Method which is called in the end of checkConfigurationConsistency() method.
    `long` | `clientFailureDetectionTimeout()` Returns client failure detection timeout set to use for network related operations.
    `protected String` | `configInfo(String name, Object val)` Gets uniformed string for configuration parameter.
    `protected String` | `createSpiAttributeName(String attrName)` Creates new name for the given attribute.
    `long` | `failureDetectionTimeout()` Returns failure detection timeout set to use for network related operations.
    `boolean` | `failureDetectionTimeoutEnabled()` Checks whether failure detection timeout is enabled for this `IgniteSpi`.
    `void` | `failureDetectionTimeoutEnabled(boolean enabled)` Enables or disables failure detection timeout.
    `protected List<String>` | `getConsistentAttributeNames()` Returns back a list of attributes that should be consistent for this SPI.
    `org.apache.ignite.internal.util.IgniteExceptionRegistry` | `getExceptionRegistry()` Gets Exception registry.
    `protected ClusterNode` | `getLocalNode()`
    `String` | `getName()` Gets SPI name.
    `Map<String,Object>` | `getNodeAttributes()` This method is called before SPI starts (before method `IgniteSpi.spiStart(String)` is called).
    `IgniteSpiContext` | `getSpiContext()` Gets SPI context.
    `Ignite` | `ignite()` Gets ignite instance.
    `protected void` | `initFailureDetectionTimeout()` Initiates and checks failure detection timeout value.
    `Collection<Object>` | `injectables()` This method returns SPI internal instances that need to be injected as well.
    `protected void` | `injectResources(Ignite ignite)` Inject ignite instance.
    `protected boolean` | `isNodeStopping()`
    `void` | `onBeforeStart()` This method is called by built-in managers implementation to avoid repeating SPI start attempts.
    `void` | `onClientDisconnected(IgniteFuture<?> reconnectFut)` Client node disconnected callback.
    `void` | `onClientReconnected(boolean clusterRestarted)` Client node reconnected callback.
    `void` | `onContextDestroyed()` Callback invoked prior to stopping grid before SPI context is destroyed.
    `protected void` | `onContextDestroyed0()` Method to be called in the beginning of onContextDestroyed() method.
    `void` | `onContextInitialized(IgniteSpiContext spiCtx)` Callback invoked when SPI context is initialized.
    `protected void` | `onContextInitialized0(IgniteSpiContext spiCtx)` Method to be called in the end of onContextInitialized method.
    `protected <T extends IgniteSpiManagementMBean> void` | `registerMBean(String igniteInstanceName, T impl, Class<T> mbeanItf)` Registers SPI MBean.
    `protected void` | `removeTimeoutObject(IgniteSpiTimeoutObject obj)`
    `IgniteSpiAdapter` | `setName(String name)` Sets SPI name.
    `boolean` | `started()` Checks if `onBeforeStart()` has been called on this SPI instance.
    `protected String` | `startInfo()` Gets uniformly formatted message for SPI start.
    `protected void` | `startStopwatch()` Starts startup stopwatch.
    `protected String` | `stopInfo()` Gets uniformly format message for SPI stop.
    `protected void` | `unregisterMBean()` Unregisters MBean.

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

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

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

      `spiStart, spiStop`

- - ### Field Detail

    - #### log

          @LoggerResource
          protected IgniteLogger log

    - #### ignite

          protected Ignite ignite

      Ignite instance.

    - #### igniteInstanceName

          protected String igniteInstanceName

      Ignite instance name.

  - ### Constructor Detail

    - #### IgniteSpiAdapter

          protected IgniteSpiAdapter()

      Creates new adapter and initializes it from the current (this) class. SPI name will be initialized to the simple name of the class (see `Class.getSimpleName()`).

  - ### Method Detail

    - #### startStopwatch

          protected void startStopwatch()

      Starts startup stopwatch.

    - #### onBeforeStart

          public final void onBeforeStart()

      This method is called by built-in managers implementation to avoid repeating SPI start attempts.

    - #### started

          public final boolean started()

      Checks if `onBeforeStart()` has been called on this SPI instance.
      Returns:
        `True` if `onBeforeStart()` has already been called.

    - #### getLocalNode

          protected ClusterNode getLocalNode()

      Returns:
        Local node.

    - #### getName

          public String getName()

      Gets SPI name.
      Specified by:
        `getName` in interface `IgniteSpi`
      Returns:
        SPI name.

    - #### ignite

          public Ignite ignite()

      Gets ignite instance.
      Returns:
        Ignite instance.

    - #### setName

          @IgniteSpiConfiguration(optional=true)
          public IgniteSpiAdapter setName(String name)

      Sets SPI name.
      Parameters:
        `name` - SPI name.
      Returns:
        `this` for chaining.

    - #### onContextInitialized

          public final void onContextInitialized(IgniteSpiContext spiCtx)
                                          throws IgniteSpiException

      Callback invoked when SPI context is initialized. SPI implementation may store SPI context for future access.

      This method is invoked after `IgniteSpi.spiStart(String)` method is completed, so SPI should be fully functional at this point. Use this method for post-start initialization, such as subscribing a discovery listener, sending a message to remote node, etc...

      Specified by:
        `onContextInitialized` in interface `IgniteSpi`
      Parameters:
        `spiCtx` - Spi context.
      Throws:
        `IgniteSpiException` - If context initialization failed (grid will be stopped).

    - #### onContextInitialized0

          protected void onContextInitialized0(IgniteSpiContext spiCtx)
                                        throws IgniteSpiException

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

    - #### onContextDestroyed

          public final void onContextDestroyed()

      Callback invoked prior to stopping grid before SPI context is destroyed. Once this method is complete, grid will begin shutdown sequence. Use this callback for de-initialization logic that may involve SPI context. Note that invoking SPI context after this callback is complete is considered illegal and may produce unknown results.

      If `IgniteSpiAdapter` is used for SPI implementation, then it will replace actual context with dummy no-op context which is usually good-enough since grid is about to shut down.

      Specified by:
        `onContextDestroyed` in interface `IgniteSpi`

    - #### onClientDisconnected

          public void onClientDisconnected(IgniteFuture<?> reconnectFut)

      Client node disconnected callback.
      Specified by:
        `onClientDisconnected` in interface `IgniteSpi`
      Parameters:
        `reconnectFut` - Future that will be completed when client reconnected.

    - #### onClientReconnected

          public void onClientReconnected(boolean clusterRestarted)

      Client node reconnected callback.
      Specified by:
        `onClientReconnected` in interface `IgniteSpi`
      Parameters:
        `clusterRestarted` - `True` if all cluster nodes restarted while client was disconnected.

    - #### injectResources

          @IgniteInstanceResource
          protected void injectResources(Ignite ignite)

      Inject ignite instance.
      Parameters:
        `ignite` - Ignite instance.

    - #### onContextDestroyed0

          protected void onContextDestroyed0()

      Method to be called in the beginning of onContextDestroyed() method.

    - #### injectables

          public Collection<Object> injectables()

      This method returns SPI internal instances that need to be injected as well. Usually these will be instances provided to SPI externally by user, e.g. during SPI configuration.
      Returns:
        Internal SPI objects that also need to be injected.

    - #### getSpiContext

          public IgniteSpiContext getSpiContext()

      Gets SPI context.
      Returns:
        SPI context.

    - #### getExceptionRegistry

          public org.apache.ignite.internal.util.IgniteExceptionRegistry getExceptionRegistry()

      Gets Exception registry.
      Returns:
        Exception registry.

    - #### getNodeAttributes

          public Map<String,Object> getNodeAttributes()
                                               throws IgniteSpiException

      This method is called before SPI starts (before method `IgniteSpi.spiStart(String)` is called). It allows SPI implementation to add attributes to a local node. Kernal collects these attributes from all SPI implementations loaded up and then passes it to discovery SPI so that they can be exchanged with other nodes.
      Specified by:
        `getNodeAttributes` in interface `IgniteSpi`
      Returns:
        Map of local node attributes this SPI wants to add.
      Throws:
        `IgniteSpiException` - Throws in case of any error.

    - #### assertParameter

          protected final void assertParameter(boolean cond,
                                               String condDesc)
                                        throws IgniteSpiException

      Throws exception with uniform error message if given parameter's assertion condition is `false`.
      Parameters:
        `cond` - Assertion condition to check.
        `condDesc` - Description of failed condition. Note that this description should include JavaBean name of the property (not a variable name) as well condition in Java syntax like, for example:

                  ...
                  assertParameter(dirPath != null, "dirPath != null");
                  ...

        Note that in case when variable name is the same as JavaBean property you can just copy Java condition expression into description as a string.
      Throws:
        `IgniteSpiException` - Thrown if given condition is `false`

    - #### startInfo

          protected final String startInfo()

      Gets uniformly formatted message for SPI start.
      Returns:
        Uniformly formatted message for SPI start.

    - #### stopInfo

          protected final String stopInfo()

      Gets uniformly format message for SPI stop.
      Returns:
        Uniformly format message for SPI stop.

    - #### configInfo

          protected final String configInfo(String name,
                                            Object val)

      Gets uniformed string for configuration parameter.
      Parameters:
        `name` - Parameter name.
        `val` - Parameter value.
      Returns:
        Uniformed string for configuration parameter.

    - #### registerMBean

          protected final <T extends IgniteSpiManagementMBean> void registerMBean(String igniteInstanceName,
                                                                                  T impl,
                                                                                  Class<T> mbeanItf)
                                                                           throws IgniteSpiException

      Registers SPI MBean. Note that SPI can only register one MBean.
      Type Parameters:
        `T` - Type of the MBean
      Parameters:
        `igniteInstanceName` - Ignite instance name. If null, then name will be empty.
        `impl` - MBean implementation.
        `mbeanItf` - MBean interface (if `null`, then standard JMX naming conventions are used.
      Throws:
        `IgniteSpiException` - If registration failed.

    - #### unregisterMBean

          protected final void unregisterMBean()
                                        throws IgniteSpiException

      Unregisters MBean.
      Throws:
        `IgniteSpiException` - If bean could not be unregistered.

    - #### isNodeStopping

          protected final boolean isNodeStopping()

      Returns:
        `True` if node is stopping.

    - #### checkConfigurationConsistency0

          protected void checkConfigurationConsistency0(IgniteSpiContext spiCtx,
                                                        ClusterNode node,
                                                        boolean starting)
                                                 throws IgniteSpiException

      Method which is called in the end of checkConfigurationConsistency() method. May be overriden in SPIs.
      Parameters:
        `spiCtx` - SPI context.
        `node` - Remote node.
        `starting` - If this node is starting or not.
      Throws:
        `IgniteSpiException` - in case of errors.

    - #### getConsistentAttributeNames

          protected List<String> getConsistentAttributeNames()

      Returns back a list of attributes that should be consistent for this SPI. Consistency means that remote node has to have the same attribute with the same value.
      Returns:
        List or attribute names.

    - #### createSpiAttributeName

          protected String createSpiAttributeName(String attrName)

      Creates new name for the given attribute. Name contains SPI name prefix.
      Parameters:
        `attrName` - SPI attribute name.
      Returns:
        New name with SPI name prefix.

    - #### addTimeoutObject

          protected void addTimeoutObject(IgniteSpiTimeoutObject obj)

      Parameters:
        `obj` - Timeout object.
      See Also:
        `IgniteSpiContext.addTimeoutObject(IgniteSpiTimeoutObject)`

    - #### removeTimeoutObject

          protected void removeTimeoutObject(IgniteSpiTimeoutObject obj)

      Parameters:
        `obj` - Timeout object.
      See Also:
        `IgniteSpiContext.removeTimeoutObject(IgniteSpiTimeoutObject)`

    - #### initFailureDetectionTimeout

          protected void initFailureDetectionTimeout()

      Initiates and checks failure detection timeout value.

    - #### failureDetectionTimeoutEnabled

          public void failureDetectionTimeoutEnabled(boolean enabled)

      Enables or disables failure detection timeout.
      Parameters:
        `enabled` - `true` if enable, `false` otherwise.

    - #### failureDetectionTimeoutEnabled

          public boolean failureDetectionTimeoutEnabled()

      Checks whether failure detection timeout is enabled for this `IgniteSpi`.
      Returns:
        `true` if enabled, `false` otherwise.

    - #### clientFailureDetectionTimeout

          public long clientFailureDetectionTimeout()

      Returns client failure detection timeout set to use for network related operations.
      Returns:
        client failure detection timeout in milliseconds or `0` if the timeout is disabled.

    - #### failureDetectionTimeout

          public long failureDetectionTimeout()

      Returns failure detection timeout set to use for network related operations.
      Returns:
        failure detection timeout in milliseconds or `0` if the timeout is disabled.

2021 Copyright © Apache Software Foundation
| Follow @ApacheIgnite
Ignite Database and Caching Platform | : ver. 2.11.0
Release Date | : September 11 2021