Dashboard > GridGain User Guide > Table Of Contents > Developers Guide > Failover SPI > Information > Page Comparison
Failover SPI
Version 19 by morpheus
on Dec 23, 2008 01:54.


compared with
Current by morpheus
on Dec 23, 2008 02:46.

(show comment)
 
Key
These lines were removed. This word was removed.
These lines were added. This word was added.

View page history


There are 1 changes. View first change.

 * [#Package]
 * [#Built-in Implementations]
 * [#Description]
 * [#Configuration]
 ** [#Default Implementation]
  
 {javadocnote}
  
 h2. Package
 {image:spi_failover.png} *org.gridgain.grid.spi.failover* {javadoc:spi/failover/package-summary.html}
  
 h2. Built-in Implementations
 GridGain comes with following implementations for failover SPI:
 {children:excerpt=true}
  
 h2. Description
  (i) 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:GridTaskSpis.html} annotation attached to your {{GridTask}} implementaiton. For more information and examples refer to [Specifying Different SPIs Per GridTask|Grid Configuration#Specifying Different SPIs Per GridTask] documentation.
  
 {{GridFailoverSpi}} {javadoc:spi/failover/GridFailoverSpi.html} 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:GridTask.html#result(org.gridgain.grid.GridJobResult, java.util.List)} returns {{GridJobResultPolicy.FAILOVER}} {javadoc:GridJobResultPolicy.html#FAILOVER} 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:GridTaskAdapter.html}).
 * Job was rejected before it got a chance to execute, while still on waiting list (failover is handled by default in {{GridTaskAdapter}} {javadoc:GridTaskAdapter.html}).
  
 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:GridJobResult.html#getNode()} method.
  
 (i) 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).
  
 h2. Configuration
 {{GridFailoverSpi}} {javadoc:spi/failover/GridFailoverSpi.html} is provided in [Grid Configuration] passed into {{GridFactory}} {javadoc:GridFactory.html} at startup. You can configure a different failover SPI implementation as follows
  
 {code}
 GridConfigurationAdapter cfg = new GridConfigurationAdapter();
  
 GridNeverFailoverSpi failSpi = new GridNeverFailoverSpi();
  
 // Configure your own failover SPI.
 cfg.setFailoverSpi(failSpi);
  
 GridFactory.start(cfg);
 {code}
  
 Note that {{GridConfiguration}} {javadoc:GridConfiguration.html} interface is just a bean and can also be configured using spring XML configuration.
  
 {spring}
 h3. Default Implementation
 If no failover SPI is provided in configuration by default [GridAlwaysFailoverSpi] is used.
  
 !http://www.gridgain.com/javadoc/org/gridgain/grid/spi/failover/GridFailoverSpiW0H0.gif!!http://www.gridgain.com/javadoc/org/gridgain/grid/spi/failover/GridFailoverSpiW1H0.gif!
Powered by Atlassian Confluence, the Enterprise Wiki. (Version: 2.2.10 Build:#528 Nov 29, 2006) - Bug/feature request - Contact Administrators