public enum DeploymentMode extends Enum<DeploymentMode>
IgniteConfiguration.getDeploymentMode()
configuration property
(it can also be specified in Spring XML configuration file). The main
difference between all deployment modes is how classes are loaded on remote nodes via peer-class-loading mechanism.
The following deployment modes are supported:
SHARED
or CONTINUOUS
modes. By default, Ignite will
automatically detect if class-loader changed or a node is restarted. However,
if you would like to change and redeploy code on a subset of nodes, or in
case of CONTINUOUS
mode to kill the ever living deployment, you should
change the user version.
User version is specified in META-INF/ignite.xml
file as follows:
<!-- User version. --> <bean id="userVersion" class="java.lang.String"> <constructor-arg value="0"/> </bean>By default, all ignite startup scripts (
ignite.sh
or ignite.bat
)
pick up user version from IGNITE_HOME/config/userversion
folder. Usually, it
is just enough to update user version under that folder, however, in case of GAR
or JAR
deployment, you should remember to provide META-INF/ignite.xml
file with desired user version in it.
ComputeJob
, then you can
the following:
IGNITE_HOME/ignite.{sh|bat}
scripts.
Enum Constant and Description |
---|
CONTINUOUS
Same as
SHARED deployment mode, but resources will not be undeployed even after all master
nodes left grid. |
ISOLATED
Unlike
PRIVATE mode, where different deployed tasks will
never use the same instance of resources, in ISOLATED
mode, tasks or classes deployed within the same class loader
will share the same instances of resources. |
PRIVATE
In this mode deployed classes do not share resources.
|
SHARED
Same as
ISOLATED , but now tasks from
different master nodes with the same user version and same
class loader will share the same class loader on remote
nodes. |
Modifier and Type | Method and Description |
---|---|
static @Nullable DeploymentMode |
fromOrdinal(int ord)
Efficiently gets enumerated value from its ordinal.
|
static DeploymentMode |
valueOf(String name)
Returns the enum constant of this type with the specified name.
|
static DeploymentMode[] |
values()
Returns an array containing the constants of this enum type, in
the order they are declared.
|
public static final DeploymentMode PRIVATE
Note that classes deployed within the same class loader on master node, will still share the same class loader remotely on worker nodes. However, tasks deployed from different master nodes will not share the same class loader on worker nodes, which is useful in development when different developers can be working on different versions of the same classes.
Also note that resources are associated with task deployment, not task execution. If the same deployed task gets executed multiple times, then it will keep reusing the same user resources every time.
public static final DeploymentMode ISOLATED
PRIVATE
mode, where different deployed tasks will
never use the same instance of resources, in ISOLATED
mode, tasks or classes deployed within the same class loader
will share the same instances of resources.
This means that if multiple tasks classes are loaded by the same
class loader on master node, then they will share instances
of resources on worker nodes. In other words, user resources
get initialized once per class loader and then get reused for all
consecutive executions.
Note that classes deployed within the same class loader on master node, will still share the same class loader remotely on worker nodes. However, tasks deployed from different master nodes will not share the same class loader on worker nodes, which is especially useful when different developers can be working on different versions of the same classes.
public static final DeploymentMode SHARED
ISOLATED
, but now tasks from
different master nodes with the same user version and same
class loader will share the same class loader on remote
nodes. Classes will be undeployed whenever all master
nodes leave grid or user version changes.
The advantage of this approach is that it allows tasks coming from different master nodes share the same instances of resources on worker nodes. This allows for all tasks executing on remote nodes to reuse, for example, the same instances of connection pools or caches. When using this mode, you can startup multiple stand-alone Ignite worker nodes, define resources on master nodes and have them initialize once on worker nodes regardless of which master node they came from.
This method is specifically useful in production as, in comparison
to ISOLATED
deployment mode, which has a scope of single
class loader on a single master node, this mode broadens the
deployment scope to all master nodes.
Note that classes deployed in this mode will be undeployed if
all master nodes left grid or if user version changed. User version can
be specified in META-INF/ignite.xml
file as a Spring bean
property with name userVersion
. This file has to be in the class
path of the class used for task execution.
SHARED
deployment mode is default mode used by the grid.
public static final DeploymentMode CONTINUOUS
SHARED
deployment mode, but resources will not be undeployed even after all master
nodes left grid. Tasks from different master nodes with the same user
version and same class loader will share the same class loader on remote
worker nodes. Classes will be undeployed whenever user version changes.
The advantage of this approach is that it allows tasks coming from different master nodes share the same instances of resources on worker nodes. This allows for all tasks executing on remote nodes to reuse, for example, the same instances of connection pools or caches. When using this mode, you can startup multiple stand-alone Ignite worker nodes, define resources on master nodes and have them initialize once on worker nodes regardless of which master node they came from.
This method is specifically useful in production as, in comparison
to ISOLATED
deployment mode, which has a scope of single
class loader on a single master node, CONTINUOUS mode broadens
the deployment scope to all master nodes.
Note that classes deployed in CONTINUOUS mode will be undeployed
only if user version changes. User version can be specified in
META-INF/ignite.xml
file as a Spring bean property with name
userVersion
. This file has to be in the class
path of the class used for task execution.
public static DeploymentMode[] values()
for (DeploymentMode c : DeploymentMode.values()) System.out.println(c);
public static DeploymentMode valueOf(String name)
name
- the name of the enum constant to be returned.IllegalArgumentException
- if this enum type has no constant with the specified nameNullPointerException
- if the argument is null@Nullable public static @Nullable DeploymentMode fromOrdinal(int ord)
ord
- Ordinal value.
Follow @ApacheIgnite
Ignite Database and Caching Platform : ver. 2.7.2 Release Date : February 6 2019