Package org.apache.ignite.spi.deployment.local

## Class LocalDeploymentSpi

- java.lang.Object
- - org.apache.ignite.spi.IgniteSpiAdapter
  - - org.apache.ignite.spi.deployment.local.LocalDeploymentSpi

- All Implemented Interfaces:
    `DeploymentSpi`, `IgniteSpi`

      @IgniteSpiMultipleInstancesSupport(true)
      @IgnoreIfPeerClassLoadingDisabled
      public class LocalDeploymentSpi
      extends IgniteSpiAdapter
      implements DeploymentSpi

  Local deployment SPI that implements only within VM deployment on local node via `register(ClassLoader, Class)` method. This SPI requires no configuration.

  Note that if peer class loading is enabled (which is default behavior, see `IgniteConfiguration.isPeerClassLoadingEnabled()`), then it is enough to deploy a task only on one node and all other nodes will load required classes from the node that initiated task execution.

  # Configuration

  This SPI requires no configuration.

  ## Example

  There is no point to explicitly configure `GridLocalDeploymentSpi` with `IgniteConfiguration` as it is used by default and has no configuration parameters.
  See Also:
    `DeploymentSpi`

- - ### Field Summary

    Fields
    Modifier and Type | Field | Description
    --- | --- | ---
    `static String` | `IGNITE_DEPLOYMENT_ADDITIONAL_CHECK` | Enables additional check for resource name on resources removal.

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

      `ignite, igniteInstanceName`

  - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `LocalDeploymentSpi()` |

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `@Nullable DeploymentResource` | `findResource​(String rsrcName)` | Finds class loader for the given class.
    `boolean` | `register​(ClassLoader ldr, Class<?> rsrc)` | Registers a class loader with this SPI.
    `void` | `setListener​(DeploymentListener lsnr)` | Sets or unsets deployment event listener.
    `LocalDeploymentSpi` | `setName​(String name)` | Sets SPI name.
    `void` | `spiStart​(@Nullable String igniteInstanceName)` | This method is called to start SPI.
    `void` | `spiStop()` | This method is called to stop SPI.
    `String` | `toString()`
    `boolean` | `unregister​(String rsrcName)` | Unregisters all class loaders that have a class with given name or have a class with give `ComputeTaskName` value.

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

      `addTimeoutObject, assertParameter, checkConfigurationConsistency0, clientFailureDetectionTimeout, configInfo, createSpiAttributeName, failureDetectionTimeout, failureDetectionTimeoutEnabled, failureDetectionTimeoutEnabled, getConsistentAttributeNames, getExceptionRegistry, getLocalNode, getName, getNodeAttributes, getSpiContext, ignite, initFailureDetectionTimeout, injectables, injectResources, isNodeStopping, onBeforeStart, onClientDisconnected, onClientReconnected, onContextDestroyed, onContextDestroyed0, onContextInitialized, onContextInitialized0, registerMBean, removeTimeoutObject, 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

    - #### IGNITE_DEPLOYMENT_ADDITIONAL_CHECK

          @SystemProperty("Enables an additional check of a resource name on resources removal")
          public static final String IGNITE_DEPLOYMENT_ADDITIONAL_CHECK

      Enables additional check for resource name on resources removal.
      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### LocalDeploymentSpi

          public LocalDeploymentSpi()

  - ### Method Detail

    - #### 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.

    - #### 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.

    - #### findResource

          @Nullable
          public @Nullable DeploymentResource findResource​(String rsrcName)

      Finds class loader for the given class.
      Specified by:
        `findResource` in interface `DeploymentSpi`
      Parameters:
        `rsrcName` - Class name or class alias to find class loader for.
      Returns:
        Deployed class loader, or `null` if not deployed.

    - #### register

          public boolean register​(ClassLoader ldr,
                                  Class<?> rsrc)
                           throws IgniteSpiException

      Registers a class loader with this SPI. This method exists to be able to add external class loaders to deployment SPI. Deployment SPI may also have its own class loaders. For example, in case of GAR deployment, every GAR file is loaded and deployed with a separate class loader maintained internally by the SPI.

      The array of classes passed in should be checked for presence of `ComputeTaskName` annotations. The classes that have this annotation should be accessible by this name from `DeploymentSpi.findResource(String)` method.

      Specified by:
        `register` in interface `DeploymentSpi`
      Parameters:
        `ldr` - Class loader to register.
        `rsrc` - Class that should be checked for aliases. Currently the only alias in the system is `ComputeTaskName` for task classes; in future, there may be others.
      Returns:
        `True` if resource was registered.
      Throws:
        `IgniteSpiException` - If registration failed.

    - #### unregister

          public boolean unregister​(String rsrcName)

      Unregisters all class loaders that have a class with given name or have a class with give `ComputeTaskName` value.
      Specified by:
        `unregister` in interface `DeploymentSpi`
      Parameters:
        `rsrcName` - Either class name or `ComputeTaskName` value for a class whose class loader needs to be unregistered.
      Returns:
        `True` if resource was unregistered.

    - #### setListener

          public void setListener​(DeploymentListener lsnr)

      Sets or unsets deployment event listener. Grid implementation will use this listener to properly add and remove various deployments.
      Specified by:
        `setListener` in interface `DeploymentSpi`
      Parameters:
        `lsnr` - Listener for deployment events. `null` to unset the listener.

    - #### setName

          public LocalDeploymentSpi setName​(String name)

      Sets SPI name.
      Overrides:
        `setName` in class `IgniteSpiAdapter`
      Parameters:
        `name` - SPI name.
      Returns:
        `this` for chaining.

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`