@IgniteSpiMultipleInstancesSupport(value=true) @IgniteSpiConsistencyChecked(optional=false) public class UriDeploymentSpi extends IgniteSpiAdapter implements DeploymentSpi
DeploymentSpi which can deploy tasks from
different sources like file system folders, email and HTTP.
When SPI establishes a connection with an URI, it downloads deployable units
to the temporary directory in order to prevent it from any changes while
scanning. Use method setTemporaryDirectoryPath(String))
to set custom temporary folder for downloaded deployment units. SPI will
create folder under the path with name identical to local node ID.
SPI tracks all changes of every given URI. This means that if any file is
changed or deleted, SPI will re-deploy or delete corresponding tasks.
Note that the very first apply to findResource(String)
is blocked until SPI finishes scanning all URI's at least once.
There are several deployable unit types supported:
'.jar' or '.gar' extension.
Package structure:
META-INF/
|
- ignite.xml
- ...
lib/
|
-some-lib.jar
- ...
xyz.class
...
META-INF/ entry may contain ignite.xml file which is a
task descriptor file. The purpose of task descriptor XML file is to specify
all tasks to be deployed. This file is a regular
Spring XML
definition file. META-INF/ entry may also contain any other file
specified by JAR format.
lib/ entry contains all library dependencies.
ComputeTask interface. In that case, all grid task classes must have a
public no-argument constructor. Use ComputeTaskAdapter adapter for
convenience when creating grid tasks.
By default, all downloaded packages that have digital signature in META-INF
folder will be verified and deployed only if signature is valid.
java.net.URI documentation.
[scheme:][//authority][path][?query][#fragment]
Every URI defines its own deployment repository which will be scanned for any changes. URI itself has all information about protocol, connectivity, scan intervals and other parameters.
URI's may contain special characters, like spaces. If encodeUri
flag is set to true (see setEncodeUri(boolean)), then
URI 'path' field will be automatically encoded. By default this flag is
set to true.
IgniteConfiguration cfg = new IgniteConfiguration();
DeploymentSpi deploymentSpi = new UriDeploymentSpi();
deploymentSpi.setUriList(Arrays.asList("file:///home/username/ignite/work/my_deployment/file"));
cfg.setDeploymentSpi(deploymentSpi);
try (Ignite ignite = Ignition.start(cfg)) {
ignite.compute().execute("myproject.HelloWorldTask", "my args");
}
UriDeploymentSpi has the following optional configuration
parameters (there are no mandatory parameters):
UriDeploymentScanner-s which will be used to deploy resources
(see setScanners(UriDeploymentScanner...)). If not specified, preconfigured UriDeploymentFileScanner
and UriDeploymentHttpScanner are used. You can implement your own scanner
by implementing UriDeploymentScanner interface.
setTemporaryDirectoryPath(String)).
setUriList(List)). If not
specified, then URI specified by DFLT_DEPLOY_DIR is used.
'path' portion of URI
(see setEncodeUri(boolean)).
You can add support for additional protocols if needed. To do this implement UriDeploymentScanner interface and
plug your implementation into the SPI via setScanners(UriDeploymentScanner...) method.
In addition to SPI configuration parameters, all necessary configuration
parameters for selected URI should be defined in URI. Different protocols
have different configuration parameters described below. Parameters are
separated by ';' character.
file.
Following parameters are supported:
| Parameter | Description | Optional | Default |
|---|---|---|---|
| freq | Scanning frequency in milliseconds. | Yes | 5000 ms specified in UriDeploymentFileScanner.DFLT_SCAN_FREQ. |
'c:/Program files/ignite/deployment'
folder on local box every '1000' milliseconds. Note that since path
has spaces, setEncodeUri(boolean) parameter must
be set to true (which is default behavior).
file://freq=2000@localhost/c:/Program files/ignite/deployment
URLConnection.getLastModified() method to check if there were any changes since last
iteration for each deployment file before redeploying.
Following parameters are supported:
| Parameter | Description | Optional | Default |
|---|---|---|---|
| freq | Scanning frequency in milliseconds. | Yes | 300000 ms specified in UriDeploymentHttpScanner.DFLT_SCAN_FREQ. |
'username:password' every '10000' milliseconds (only new/updated packages).
http://username:password;freq=10000@www.mysite.com:110/ignite/deployment
UriDeploymentSpi deploySpi = new UriDeploymentSpi();
IgniteConfiguration cfg = new IgniteConfiguration();
// Set URIs.
deploySpi.setUriList(Arrays.asList("http://www.site.com/tasks",
"file://freq=20000@localhost/c:/Program files/gg-deployment"));
// Override temporary directory path.
deploySpi.setTemporaryDirectoryPath("c:/tmp/grid");
// Override default deployment SPI.
cfg.setDeploymentSpi(deploySpi);
// Start grid.
Ignition.start(cfg);
<bean id="grid.custom.cfg" class="org.apache.ignite.configuration.IgniteConfiguration" singleton="true">
...
<property name="deploymentSpi">
<bean class="org.apache.ignite.grid.spi.deployment.uri.UriDeploymentSpi">
<property name="temporaryDirectoryPath" value="c:/tmp/grid"/>
<property name="uriList">
<list>
<value>http://www.site.com/tasks</value>
<value>file://freq=20000@localhost/c:/Program files/gg-deployment</value>
</list>
</property>
</bean>
</property>
...
</bean>
For information about Spring framework visit www.springframework.org
DeploymentSpi| Modifier and Type | Field and Description |
|---|---|
static String |
DEPLOY_TMP_ROOT_NAME
Default temporary directory name relative to file path
setTemporaryDirectoryPath(String)} (value is gg.uri.deployment.tmp). |
static String |
DFLT_DEPLOY_DIR
Default deployment directory where SPI will pick up packages.
|
static String |
XML_DESCRIPTOR_PATH
Default task description file path and name (value is
META-INF/ignite.xml). |
ignite, igniteInstanceName| Constructor and Description |
|---|
UriDeploymentSpi() |
| Modifier and Type | Method and Description |
|---|---|
@Nullable DeploymentResource |
findResource(String rsrcName) |
UriDeploymentScanner[] |
getScanners()
Gets scanners.
|
String |
getTemporaryDirectoryPath()
Gets temporary directory path.
|
List<String> |
getUriList()
Gets list of URIs that are processed by SPI.
|
boolean |
isCheckMd5()
Gets
checkMd5 property. |
boolean |
register(ClassLoader ldr,
Class<?> rsrc) |
UriDeploymentSpi |
setCheckMd5(boolean checkMd5)
If set to
true then SPI should exclude files with same md5s from deployment. |
UriDeploymentSpi |
setEncodeUri(boolean encodeUri)
Indicates that URI must be encoded before usage.
|
void |
setListener(@Nullable DeploymentListener lsnr) |
IgniteSpiAdapter |
setName(String name) |
UriDeploymentSpi |
setScanners(UriDeploymentScanner... scanners)
Sets scanners.
|
UriDeploymentSpi |
setTemporaryDirectoryPath(String tmpDirPath)
Sets absolute path to temporary directory which will be used by
deployment SPI to keep all deployed classes in.
|
UriDeploymentSpi |
setUriList(List<String> uriList)
Sets list of URI which point to a directory with packages and which should be
scanned by SPI for the new tasks.
|
void |
spiStart(String igniteInstanceName) |
void |
spiStop() |
String |
toString() |
boolean |
unregister(String rsrcName) |
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, unregisterMBeanclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitgetName, getNodeAttributes, onClientDisconnected, onClientReconnected, onContextDestroyed, onContextInitializedpublic static final String DFLT_DEPLOY_DIR
IGNITE_HOME/work folder if IGNITE_HOME system or environment variable specified,
otherwise it is relative to work folder under system java.io.tmpdir folder.public static final String XML_DESCRIPTOR_PATH
META-INF/ignite.xml).public static final String DEPLOY_TMP_ROOT_NAME
setTemporaryDirectoryPath(String)} (value is gg.uri.deployment.tmp).@IgniteSpiConfiguration(optional=true) public UriDeploymentSpi setTemporaryDirectoryPath(String tmpDirPath)
If not provided, default value is java.io.tmpdir system property value.
tmpDirPath - Temporary directory path.this for chaining.@IgniteSpiConfiguration(optional=true) public UriDeploymentSpi setUriList(List<String> uriList)
If not provided, default value is list with
file://${IGNITE_HOME}/work/deployment/file element.
Note that system property IGNITE_HOME must be set.
For unknown IGNITE_HOME list of URI must be provided explicitly.
uriList - Package file URIs.this for chaining.@IgniteSpiConfiguration(optional=true) public UriDeploymentSpi setCheckMd5(boolean checkMd5)
true then SPI should exclude files with same md5s from deployment.
Otherwise it should try to load new unit regardless to possible file duplication.checkMd5 - new value for the propertythis for chaining.public boolean isCheckMd5()
checkMd5 property.checkMd5 property.@IgniteSpiConfiguration(optional=true) public UriDeploymentSpi setEncodeUri(boolean encodeUri)
If not provided, default value is true.
encodeUri - true if every URI should be encoded and
false otherwise.this for chaining.public String getTemporaryDirectoryPath()
public List<String> getUriList()
public void setListener(@Nullable
@Nullable DeploymentListener lsnr)
setListener in interface DeploymentSpipublic UriDeploymentScanner[] getScanners()
@IgniteSpiConfiguration(optional=true) public UriDeploymentSpi setScanners(UriDeploymentScanner... scanners)
scanners - Scanners.this for chaining.public void spiStop()
throws IgniteSpiException
spiStop in interface IgniteSpiIgniteSpiExceptionpublic void spiStart(String igniteInstanceName) throws IgniteSpiException
spiStart in interface IgniteSpiIgniteSpiException@Nullable public @Nullable DeploymentResource findResource(String rsrcName)
findResource in interface DeploymentSpipublic boolean register(ClassLoader ldr, Class<?> rsrc) throws IgniteSpiException
register in interface DeploymentSpiIgniteSpiExceptionpublic boolean unregister(String rsrcName)
unregister in interface DeploymentSpipublic IgniteSpiAdapter setName(String name)
setName in class IgniteSpiAdapter
Follow @ApacheIgnite
Ignite Database and Caching Platform : ver. 8.9.30 Release Date : February 17 2026