Class JobStealingFailoverSpi

  • All Implemented Interfaces:
    FailoverSpi, IgniteSpi

    @IgniteSpiMultipleInstancesSupport(true)
    @IgniteSpiConsistencyChecked(optional=true)
    public class JobStealingFailoverSpi
    extends IgniteSpiAdapter
    implements FailoverSpi
    Job stealing failover SPI needs to always be used in conjunction with JobStealingCollisionSpi SPI. When JobStealingCollisionSpi receives a steal request and rejects jobs so they can be routed to the appropriate node, it is the responsibility of this JobStealingFailoverSpi SPI to make sure that the job is indeed re-routed to the node that has sent the initial request to steal it.

    JobStealingFailoverSpi knows where to route a job based on the JobStealingCollisionSpi.THIEF_NODE_ATTR job context attribute (see ComputeJobContext). Prior to rejecting a job, JobStealingCollisionSpi will populate this attribute with the ID of the node that wants to steal this job. Then JobStealingFailoverSpi 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 AlwaysFailoverSpi, and tries to find the next balanced node to fail-over a job to.

    Configuration

    Mandatory

    This SPI has no mandatory configuration parameters.

    Optional

    This SPI has following optional configuration parameters: Here is a Java example on how to configure grid with JobStealingFailoverSpi.
     JobStealingFailoverSpi spi = new JobStealingFailoverSpi();
    
     // 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 JobStealingFailoverSpi from Spring XML configuration file.
     <property name="failoverSpi">
         <bean class="org.apache.ignite.spi.failover.jobstealing.JobStealingFailoverSpi">
             <property name="maximumFailoverAttempts" value="5"/>
         </bean>
     </property>
     


    For information about Spring framework visit www.springframework.org

    See Also:
    FailoverSpi
    • Field Detail

      • DFLT_MAX_FAILOVER_ATTEMPTS

        public static final int DFLT_MAX_FAILOVER_ATTEMPTS
        Maximum number of attempts to execute a failed job on another node (default is 5).
        See Also:
        Constant Field Values
    • Constructor Detail

      • JobStealingFailoverSpi

        public JobStealingFailoverSpi()
    • Method Detail

      • getMaximumFailoverAttempts

        public int getMaximumFailoverAttempts()
        Returns:
        Maximum number of attempts to execute a failed job on another node.
      • setMaximumFailoverAttempts

        @IgniteSpiConfiguration(optional=true)
        public JobStealingFailoverSpi setMaximumFailoverAttempts​(int maxFailoverAttempts)
        Sets maximum number of attempts to execute a failed job on another node. If job gets stolen and thief node exists then it is not considered as failed job. If not specified, DFLT_MAX_FAILOVER_ATTEMPTS value will be used.

        Note this value must be identical for all grid nodes in the grid.

        Parameters:
        maxFailoverAttempts - Maximum number of attempts to execute a failed job on another node.
        Returns:
        this for chaining.
      • getTotalFailedOverJobsCount

        public int getTotalFailedOverJobsCount()
        Get total number of jobs that were failed over including stolen ones.
        Returns:
        Total number of failed over jobs.
      • getTotalStolenJobsCount

        public int getTotalStolenJobsCount()
        Get total number of jobs that were stolen.
        Returns:
        Total number of stolen jobs.
      • spiStart

        public 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:
        spiStart in interface IgniteSpi
        Parameters:
        igniteInstanceName - Name of Ignite instance this SPI is being started for (null for default Ignite instance).
        Throws:
        IgniteSpiException - Throws in case of any error during SPI start.
      • spiStop

        public void spiStop()
                     throws IgniteSpiException
        This 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:
        spiStop in interface IgniteSpi
        Throws:
        IgniteSpiException - Thrown in case of any error during SPI stop.
      • getConsistentAttributeNames

        protected 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:
        getConsistentAttributeNames in class IgniteSpiAdapter
        Returns:
        List or attribute names.