Dashboard > GridGain User Guide > Table Of Contents > GridGain Book > Failover SPI > GridJobStealingFailoverSpi
GridJobStealingFailoverSpi
Added by morpheus, last edited by morpheus on May 28, 2008  (view change)
Labels: 
(None)


Click on Javadoc link to open Javadoc documentation.

Package

org.gridgain.grid.spi.failover.jobstealing Javadoc

Available starting with GridGain

Description

GridJobStealingFailoverSpi Javadoc needs to always be used in conjunction with GridJobStealingCollisionSpi Javadoc SPI. When GridJobStealingCollisionSpi receives a steal request and rejects jobs so they can be routed to the appropriate node, it is the responsibility of this GridJobStealingFailoverSpi SPI to make sure that the job is indeed re-routed to the node that has sent the initial request to steal it.

GridJobStealingFailoverSpi knows where to route a job based on the GridJobStealingCollisionSpi.THIEF_NODE_ATTR Javadoc job context attribute (see GridJobContext Javadoc ). Prior to rejecting a job, GridJobStealingCollisionSpi will populate this attribute with the ID of the node that wants to steal this job. Then GridJobStealingFailoverSpi will read the value of this attribute and route the job to the node specified.

If failure is caused by a node crash, and not by steal request, then this SPI behaves identically to GridAlwaysFailoverSpi Javadoc , and tries to find the next balanced node to fail-over a job to.

Usage

GridJobStealingFailoverSpi Javadoc must always be used in conjunction with GridJobStealingCollisionSpi Javadoc . Please refer to GridJobStealingCollisionSpi documentation for more information.

Keep in mind that collision resolution happens on job executing nodes (workers), and failover happens on task-initiating node (master). So, if you have a case where a group of nodes is responsible only for sending tasks (masters) and another group is responsible for executing jobs (workers), it should be sufficient to configure GridJobStealingFailoverSpi on worker nodes only and GridJobStealingCollisionSpi on master nodes only.

Configuration

The following configuration parameters can be used to configure GridJobStealingFailoverSpi Javadoc

Setter Method Description Optional Default
setMaximumFailoverAttempts(int) Javadoc Sets maximum number of attempts to execute a failed job on another node. Yes 5 specified in GridJobStealingFailoverSpi.DFLT_MAX_FAILOVER_ATTEMPTS Javadoc

Examples

As any GridGain SPI, GridAlwaysFailoverSpi Javadoc can be configured either directly from code or from Spring configuration file. Here is an example of GridAlwaysFailoverSpi Javadoc configuration from code:

GridJobStealingFailoverSpi failSpi = new GridJobStealingFailoverSpi();

GridConfigurationAdapter cfg = new GridConfigurationAdapter();

// Override maximum failover attempts.
failSpi.setMaximumFailoverAttempts(5);

// Override default failover SPI.
cfg.setFailoverSpi(failSpi);

// Start grid.
GridFactory.start(cfg);

or from Spring configuration file

<bean id="grid.custom.cfg" class="org.gridgain.grid.GridConfigurationAdapter" singleton="true">
    ...
    <bean class="org.gridgain.grid.spi.failover.jobstealing.GridJobStealingFailoverSpi">
         <property name="maximumFailoverAttempts" value="5"/>
    </bean>
    ...
</bean>


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

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