@IgniteSpiMultipleInstancesSupport(value=true) @IgniteSpiConsistencyChecked(optional=true) public class AlwaysFailoverSpi extends IgniteSpiAdapter implements FailoverSpi
null
will be returned.
setMaximumFailoverAttempts(int)
).
If maximum failover attempts is reached, then job will not be failed-over and,
hence, will fail.
AlwaysFailoverSpi
failover SPI.
AlwaysFailoverSpi spi = new AlwaysFailoverSpi(); // Override maximum failover attempts. spi.setMaximumFailoverAttempts(5); IgniteConfiguration cfg = new IgniteConfiguration(); // Override default failover SPI. cfg.setFailoverSpiSpi(spi); // Starts grid. G.start(cfg);Here is an example of how to configure
AlwaysFailoverSpi
from Spring XML configuration file.
<property name="failoverSpi"> <bean class="org.apache.ignite.spi.failover.always.AlwaysFailoverSpi"> <property name="maximumFailoverAttempts" value="5"/> </bean> </property>
For information about Spring framework visit www.springframework.org
FailoverSpi
Modifier and Type | Field and Description |
---|---|
static String |
AFFINITY_CALL_ATTEMPT
Name of job context attribute containing number of affinity call attempts.
|
static int |
DFLT_MAX_FAILOVER_ATTEMPTS
Maximum number of attempts to execute a failed job on another node (default is
5 ). |
static String |
FAILED_NODE_LIST_ATTR
Name of job context attribute containing all nodes a job failed on.
|
static String |
MAX_FAILOVER_ATTEMPT_ATTR
Maximum attempts attribute key should be the same on all nodes.
|
ignite, igniteInstanceName
Constructor and Description |
---|
AlwaysFailoverSpi() |
Modifier and Type | Method and Description |
---|---|
ClusterNode |
failover(FailoverContext ctx,
List<ClusterNode> top)
This method is called when method
ComputeTask.result(org.apache.ignite.compute.ComputeJobResult, List) returns
value ComputeJobResultPolicy.FAILOVER policy indicating that the result of
job execution must be failed over. |
protected List<String> |
getConsistentAttributeNames()
Returns back a list of attributes that should be consistent
for this SPI.
|
int |
getMaximumFailoverAttempts()
|
Map<String,Object> |
getNodeAttributes()
This method is called before SPI starts (before method
IgniteSpi.spiStart(String)
is called). |
int |
getTotalFailoverJobsCount()
Get total number of jobs that were failed over.
|
AlwaysFailoverSpi |
setMaximumFailoverAttempts(int maxFailoverAttempts)
Sets maximum number of attempts to execute a failed job on another node.
|
AlwaysFailoverSpi |
setName(String name)
Sets SPI name.
|
void |
spiStart(String igniteInstanceName)
This method is called to start SPI.
|
void |
spiStop()
This method is called to stop SPI.
|
String |
toString() |
addTimeoutObject, assertParameter, checkConfigurationConsistency0, clientFailureDetectionTimeout, configInfo, createSpiAttributeName, failureDetectionTimeout, failureDetectionTimeoutEnabled, failureDetectionTimeoutEnabled, getExceptionRegistry, getLocalNode, getName, getSpiContext, ignite, initFailureDetectionTimeout, injectables, injectResources, isNodeStopping, onBeforeStart, onClientDisconnected, onClientReconnected, onContextDestroyed, onContextDestroyed0, onContextInitialized, onContextInitialized0, registerMBean, removeTimeoutObject, started, startInfo, startStopwatch, stopInfo, unregisterMBean
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
getName, onClientDisconnected, onClientReconnected, onContextDestroyed, onContextInitialized
public static final int DFLT_MAX_FAILOVER_ATTEMPTS
5
).public static final String FAILED_NODE_LIST_ATTR
ComputeJobContext
,
Constant Field Valuespublic static final String AFFINITY_CALL_ATTEMPT
public static final String MAX_FAILOVER_ATTEMPT_ATTR
public int getMaximumFailoverAttempts()
@IgniteSpiConfiguration(optional=true) public AlwaysFailoverSpi setMaximumFailoverAttempts(int maxFailoverAttempts)
DFLT_MAX_FAILOVER_ATTEMPTS
value will be used.maxFailoverAttempts
- Maximum number of attempts to execute a failed job on another node.this
for chaining.public int getTotalFailoverJobsCount()
public Map<String,Object> getNodeAttributes() throws IgniteSpiException
IgniteSpi.spiStart(String)
is called). It allows SPI implementation to add attributes to a local
node. Kernal collects these attributes from all SPI implementations
loaded up and then passes it to discovery SPI so that they can be
exchanged with other nodes.getNodeAttributes
in interface IgniteSpi
getNodeAttributes
in class IgniteSpiAdapter
IgniteSpiException
- Throws in case of any error.public void spiStart(String igniteInstanceName) throws IgniteSpiException
spiStart
in interface IgniteSpi
igniteInstanceName
- Name of Ignite instance this SPI is being started for
(null
for default Ignite instance).IgniteSpiException
- Throws in case of any error during SPI start.public void spiStop() throws IgniteSpiException
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.
spiStop
in interface IgniteSpi
IgniteSpiException
- Thrown in case of any error during SPI stop.public ClusterNode failover(FailoverContext ctx, List<ClusterNode> top)
ComputeTask.result(org.apache.ignite.compute.ComputeJobResult, List)
returns
value ComputeJobResultPolicy.FAILOVER
policy indicating that the result of
job execution must be failed over. Implementation of this method should examine failover
context and choose one of the grid nodes from supplied topology
to retry job execution
on it. For best performance it is advised that FailoverContext.getBalancedNode(List)
method is used to select node for execution of failed job.failover
in interface FailoverSpi
ctx
- Failover context.top
- Collection of all grid nodes within task topology (may include failed node).null
if new node cannot be picked.
If job failover fails (returns null
) the whole task will be failed.protected List<String> getConsistentAttributeNames()
getConsistentAttributeNames
in class IgniteSpiAdapter
public AlwaysFailoverSpi setName(String name)
setName
in class IgniteSpiAdapter
name
- SPI name.this
for chaining.
Follow @ApacheIgnite
Ignite Database and Caching Platform : ver. 2.7.2 Release Date : February 6 2019