Interface DeploymentSpi
-
- All Superinterfaces:
IgniteSpi
- All Known Implementing Classes:
LocalDeploymentSpi,UriDeploymentSpi
public interface DeploymentSpi extends IgniteSpi
Grid deployment SPI is in charge of deploying tasks and classes from different sources.Class loaders that are in charge of loading task classes (and other classes) can be deployed directly by calling
register(ClassLoader, Class)method or by SPI itself, for example by asynchronously scanning some folder for new tasks. When methodfindResource(String)is called by the system, SPI must return a class loader associated with given class. Every time a class loader gets (re)deployed or released, callbacksDeploymentListener.onUnregistered(ClassLoader)} must be called by SPI.If peer class loading is enabled (which is default behavior, see
IgniteConfiguration.isPeerClassLoadingEnabled()), then it is usually enough to deploy class loader only on one grid node. Once a task starts executing on the grid, all other nodes will automatically load all task classes from the node that initiated the execution. Hot redeployment is also supported with peer class loading. Every time a task changes and gets redeployed on a node, all other nodes will detect it and will redeploy this task as well. Note that peer class loading comes into effect only if a task was not locally deployed, otherwise, preference will always be given to local deployment.Ignite provides following
NOTE: SPI methods should never be used directly. SPIs provide internal view on the subsystem and is used internally by Ignite. In rare use cases when access to a specific implementation of this SPI is required - an instance of this SPI can be obtained viaGridDeploymentSpiimplementations out of the box: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 Modifier and Type Method Description DeploymentResourcefindResource(String rsrcName)Finds class loader for the given class.booleanregister(ClassLoader ldr, Class<?> rsrc)Registers a class loader with this SPI.voidsetListener(@Nullable DeploymentListener lsnr)Sets or unsets deployment event listener.booleanunregister(String rsrcName)Unregisters all class loaders that have a class with given name or have a class with giveComputeTaskNamevalue.-
Methods inherited from interface org.apache.ignite.spi.IgniteSpi
getName, getNodeAttributes, onClientDisconnected, onClientReconnected, onContextDestroyed, onContextInitialized, spiStart, spiStop
-
-
-
-
Method Detail
-
findResource
DeploymentResource findResource(String rsrcName)
Finds class loader for the given class.- Parameters:
rsrcName- Class name or class alias to find class loader for.- Returns:
- Deployed class loader, or
nullif not deployed.
-
register
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
ComputeTaskNameannotations. The classes that have this annotation should be accessible by this name fromfindResource(String)method.- Parameters:
ldr- Class loader to register.rsrc- Class that should be checked for aliases. Currently the only alias in the system isComputeTaskNamefor task classes; in future, there may be others.- Returns:
Trueif resource was registered.- Throws:
IgniteSpiException- If registration failed.
-
unregister
boolean unregister(String rsrcName)
Unregisters all class loaders that have a class with given name or have a class with giveComputeTaskNamevalue.- Parameters:
rsrcName- Either class name orComputeTaskNamevalue for a class whose class loader needs to be unregistered.- Returns:
Trueif resource was unregistered.
-
setListener
void setListener(@Nullable @Nullable DeploymentListener lsnr)Sets or unsets deployment event listener. Grid implementation will use this listener to properly add and remove various deployments.- Parameters:
lsnr- Listener for deployment events.nullto unset the listener.
-
-