Dashboard > GridGain User Guide > Table Of Contents > GridGain Book > Failover SPI
Failover SPI
Added by morpheus, last edited by Dmitriy Setrakyan on Dec 23, 2008  (view change)
Labels: 
(None)


Click on Javadoc link to open Javadoc documentation.

Package

org.gridgain.grid.spi.failover Javadoc

Built-in Implementations

GridGain comes with following implementations for failover SPI:

Description

Starting with GridGain 2.1 you can provide multiple instances of Failover SPIs and then specify which one to use on per-task level via @GridTaskSpis Javadoc annotation attached to your GridTask implementaiton. For more information and examples refer to Specifying Different SPIs Per GridTask documentation.

GridFailoverSpi Javadoc SPI provides developer with ability to supply custom logic for handling failed execution of a grid job. Failover is triggered when method GridTask.result(GridJobResult, List) Javadoc returns GridJobResultPolicy.FAILOVER Javadoc policy indicating that the result of job execution must be failed over. Job execution can fail for a number of reasons:

  • Job execution threw an exception (this condition has to be handled by user explicitly).
  • Job returned bad result (this condition has to be handled by user explicitly).
  • Node on which job was executing left topology, crashed, or stopped (failover is handled by default in GridTaskAdapter Javadoc ).
  • Job was rejected before it got a chance to execute, while still on waiting list (failover is handled by default in GridTaskAdapter Javadoc ).

In all cases Failover SPI takes failed job (as failover context) and list of all grid nodes and produces another node on which the job execution will be retried. It is up to failover SPI to make sure that job is not mapped to the node it failed on. The failed node can be retrieved from GridFailoverContext.getJobResult().getNode() Javadoc method.

Note that for any job spawned by a task, Failover SPI will be invoked only on the node that initiated the task (obviously, it cannot be invoked on failed node).

Configuration

GridFailoverSpi Javadoc is provided in Grid Configuration passed into GridFactory Javadoc at startup. You can configure a different failover SPI implementation as follows

GridConfigurationAdapter cfg = new GridConfigurationAdapter();

GridNeverFailoverSpi failSpi = new GridNeverFailoverSpi();

// Configure your own failover SPI.
cfg.setFailoverSpi(failSpi);

GridFactory.start(cfg);

Note that GridConfiguration Javadoc interface is just a bean and can also be configured using spring XML configuration.


For more information about using Spring framework for configuration click here.

Default Implementation

If no failover SPI is provided in configuration by default GridAlwaysFailoverSpi is used.

GridAlwaysFailoverSpi (GridGain User Guide)
GridJobStealingFailoverSpi (GridGain User Guide)
GridNeverFailoverSpi (GridGain User Guide)

Powered by Atlassian Confluence, the Enterprise Wiki. (Version: 2.2.10 Build:#528 Nov 29, 2006) - Bug/feature request - Contact Administrators