Class AlwaysFailoverSpi
- java.lang.Object
- 
- org.apache.ignite.spi.IgniteSpiAdapter
- 
- org.apache.ignite.spi.failover.always.AlwaysFailoverSpi
 
 
- 
- All Implemented Interfaces:
- FailoverSpi,- IgniteSpi
 
 @IgniteSpiMultipleInstancesSupport(true) @IgniteSpiConsistencyChecked(optional=true) public class AlwaysFailoverSpi extends IgniteSpiAdapter implements FailoverSpi Failover SPI that always reroutes a failed job to another node. Note, that at first an attempt will be made to reroute the failed job to a node that was not part of initial split for a better chance of success. If no such nodes are available, then an attempt will be made to reroute the failed job to the nodes in the initial split minus the node the job is failed on. If none of the above attempts succeeded, then the job will not be failed over andnullwill be returned.ConfigurationThis SPI is default failover SPI and does not have to be explicitly configured unless configuration parameters need to be changed.MandatoryThis SPI has no mandatory configuration parameters.OptionalThis SPI has following optional configuration parameters:- 
          Maximum failover attempts for a single job (see setMaximumFailoverAttempts(int)). If maximum failover attempts is reached, then job will not be failed-over and, hence, will fail.
 AlwaysFailoverSpifailover 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 configureAlwaysFailoverSpifrom 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- See Also:
- FailoverSpi
 
- 
- 
Field SummaryFields Modifier and Type Field Description static StringAFFINITY_CALL_ATTEMPTName of job context attribute containing number of affinity call attempts.static intDFLT_MAX_FAILOVER_ATTEMPTSMaximum number of attempts to execute a failed job on another node (default is5).static StringFAILED_NODE_LIST_ATTRName of job context attribute containing all nodes a job failed on.static StringMAX_FAILOVER_ATTEMPT_ATTRMaximum attempts attribute key should be the same on all nodes.- 
Fields inherited from class org.apache.ignite.spi.IgniteSpiAdapterignite, igniteInstanceName
 
- 
 - 
Constructor SummaryConstructors Constructor Description AlwaysFailoverSpi()
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description ClusterNodefailover(FailoverContext ctx, List<ClusterNode> top)This method is called when methodComputeTask.result(org.apache.ignite.compute.ComputeJobResult, List)returns valueComputeJobResultPolicy.FAILOVERpolicy 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.intgetMaximumFailoverAttempts()Map<String,Object>getNodeAttributes()This method is called before SPI starts (before methodIgniteSpi.spiStart(String)is called).intgetTotalFailoverJobsCount()Get total number of jobs that were failed over.AlwaysFailoverSpisetMaximumFailoverAttempts(int maxFailoverAttempts)Sets maximum number of attempts to execute a failed job on another node.AlwaysFailoverSpisetName(String name)Sets SPI name.voidspiStart(String igniteInstanceName)This method is called to start SPI.voidspiStop()This method is called to stop SPI.StringtoString()- 
Methods inherited from class org.apache.ignite.spi.IgniteSpiAdapteraddTimeoutObject, 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
 - 
Methods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 - 
Methods inherited from interface org.apache.ignite.spi.IgniteSpigetName, onClientDisconnected, onClientReconnected, onContextDestroyed, onContextInitialized
 
- 
 
- 
- 
- 
Field Detail- 
DFLT_MAX_FAILOVER_ATTEMPTSpublic static final int DFLT_MAX_FAILOVER_ATTEMPTS Maximum number of attempts to execute a failed job on another node (default is5).- See Also:
- Constant Field Values
 
 - 
FAILED_NODE_LIST_ATTRpublic static final String FAILED_NODE_LIST_ATTR Name of job context attribute containing all nodes a job failed on.- See Also:
- ComputeJobContext, Constant Field Values
 
 - 
AFFINITY_CALL_ATTEMPTpublic static final String AFFINITY_CALL_ATTEMPT Name of job context attribute containing number of affinity call attempts.- See Also:
- Constant Field Values
 
 - 
MAX_FAILOVER_ATTEMPT_ATTRpublic static final String MAX_FAILOVER_ATTEMPT_ATTR Maximum attempts attribute key should be the same on all nodes.- See Also:
- Constant Field Values
 
 
- 
 - 
Method Detail- 
getMaximumFailoverAttemptspublic int getMaximumFailoverAttempts() - Returns:
- Maximum number of attempts to execute a failed job on another node.
 
 - 
setMaximumFailoverAttempts@IgniteSpiConfiguration(optional=true) public AlwaysFailoverSpi setMaximumFailoverAttempts(int maxFailoverAttempts) Sets maximum number of attempts to execute a failed job on another node. If not specified,DFLT_MAX_FAILOVER_ATTEMPTSvalue will be used.- Parameters:
- maxFailoverAttempts- Maximum number of attempts to execute a failed job on another node.
- Returns:
- thisfor chaining.
 
 - 
getTotalFailoverJobsCountpublic int getTotalFailoverJobsCount() Get total number of jobs that were failed over.- Returns:
- Total number of failed over jobs.
 
 - 
getNodeAttributespublic Map<String,Object> getNodeAttributes() throws IgniteSpiException This method is called before SPI starts (before methodIgniteSpi.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.- Specified by:
- getNodeAttributesin interface- IgniteSpi
- Overrides:
- getNodeAttributesin class- IgniteSpiAdapter
- Returns:
- Map of local node attributes this SPI wants to add.
- Throws:
- IgniteSpiException- Throws in case of any error.
 
 - 
spiStartpublic void spiStart(String igniteInstanceName) throws IgniteSpiException This method is called to start SPI. After this method returns successfully kernel assumes that SPI is fully operational.- Specified by:
- spiStartin interface- IgniteSpi
- Parameters:
- igniteInstanceName- Name of Ignite instance this SPI is being started for (- nullfor default Ignite instance).
- Throws:
- IgniteSpiException- Throws in case of any error during SPI start.
 
 - 
spiStoppublic void spiStop() throws IgniteSpiExceptionThis 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:
- spiStopin interface- IgniteSpi
- Throws:
- IgniteSpiException- Thrown in case of any error during SPI stop.
 
 - 
failoverpublic ClusterNode failover(FailoverContext ctx, List<ClusterNode> top) This method is called when methodComputeTask.result(org.apache.ignite.compute.ComputeJobResult, List)returns valueComputeJobResultPolicy.FAILOVERpolicy 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 suppliedtopologyto retry job execution on it. For best performance it is advised thatFailoverContext.getBalancedNode(List)method is used to select node for execution of failed job.- Specified by:
- failoverin interface- FailoverSpi
- Parameters:
- ctx- Failover context.
- top- Collection of all grid nodes within task topology (may include failed node).
- Returns:
- New node to route this job to or nullif new node cannot be picked. If job failover fails (returnsnull) the whole task will be failed.
 
 - 
getConsistentAttributeNamesprotected List<String> getConsistentAttributeNames() Returns back a list of attributes that should be consistent for this SPI. Consistency means that remote node has to have the same attribute with the same value.- Overrides:
- getConsistentAttributeNamesin class- IgniteSpiAdapter
- Returns:
- List or attribute names.
 
 - 
setNamepublic AlwaysFailoverSpi setName(String name) Sets SPI name.- Overrides:
- setNamein class- IgniteSpiAdapter
- Parameters:
- name- SPI name.
- Returns:
- thisfor chaining.
 
 
- 
 
-