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, LocalDeploymentSpiMBean, IgniteSpi, IgniteSpiManagementMBean

    @IgniteSpiMultipleInstancesSupport(value=true)
    @IgniteSpiConsistencyChecked(optional=false)
    @IgnoreIfPeerClassLoadingDisabled
    public class LocalDeploymentSpi
    extends IgniteSpiAdapter
    implements DeploymentSpi, LocalDeploymentSpiMBean

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 inherited from class org.apache.ignite.spi.IgniteSpiAdapter

`gridName, ignite, nodeId`

### Constructor Summary

Constructors
Constructor and Description
`LocalDeploymentSpi()`

### Method Summary

Methods
`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.
`void` `spiStart(String gridName)` 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, configInfo, createSpiAttributeName, getConsistentAttributeNames, getExceptionRegistry, getIgniteHome, getLocalNodeId, getName, getNodeAttributes, getSpiContext, getStartTimestamp, getStartTimestampFormatted, getUpTime, getUpTimeFormatted, injectables, injectResources, isNodeStopping, onContextDestroyed, onContextDestroyed0, onContextInitialized, onContextInitialized0, registerMBean, removeTimeoutObject, setName, 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, onContextDestroyed, onContextInitialized`

### Methods inherited from interface org.apache.ignite.spi.IgniteSpiManagementMBean

`getIgniteHome, getLocalNodeId, getName, getStartTimestamp, getStartTimestampFormatted, getUpTime, getUpTimeFormatted`

### Constructor Detail

#### LocalDeploymentSpi

    public LocalDeploymentSpi()

### Method Detail

#### spiStart

    public void spiStart(@Nullable
                String gridName)
                  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:
  `gridName` - Name of grid instance this SPI is being started for (`null` for default grid).
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 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.

#### toString

    public String toString()

Overrides:
  `toString` in class `Object`

2015 Copyright © Apache Software Foundation

Follow @ApacheIgnite

Ignite Fabric | : ver. 1.3.0-incubating
Release Date | : July 10 2015