GridGain™ 2.1.0
Java API Specification

org.gridgain.grid.spi.collision
Interface GridCollisionSpi

All Superinterfaces:
GridSpi
All Known Implementing Classes:
GridFifoQueueCollisionSpi, GridJobStealingCollisionSpi, GridPriorityQueueCollisionSpi

@Apache20LicenseCompatible
public interface GridCollisionSpi
extends GridSpi

Collision SPI allows to regulate how grid jobs get executed when they arrive on a destination node for execution. In general a grid node will have multiple jobs arriving to it for execution and potentially multiple jobs that are already executing or waiting for execution on it. There are multiple possible strategies dealing with this situation: all jobs can proceed in parallel, or jobs can be serialized i.e., only one job can execute in any given point of time, or only certain number or types of grid jobs can proceed in parallel, etc.

Collision SPI provides developer with ability to use the custom logic in determining how grid jobs should be executed on a destination grid node. GridGain comes with the following ready implementations for collision resolution that cover most popular strategies:





See Also:

  Documentation
  Email Support
  Online Forums
  Issue Tracking

Author:   2005-2008 Copyright © GridGain Systems. All Rights Reserved. ver. 2.1.0

 

Method Summary
 void onCollision(Collection<GridCollisionJobContext> waitJobs, Collection<GridCollisionJobContext> activeJobs)
          This is a callback called when either new grid job arrived or executing job finished its execution.
 void setExternalCollisionListener(GridCollisionExternalListener listener)
          Listener to be set for notification of external collision events (e.g. job stealing).
 
Methods inherited from interface org.gridgain.grid.spi.GridSpi
getName, getNodeAttributes, onContextDestroyed, onContextInitialized, spiStart, spiStop
 

Method Detail

onCollision

void onCollision(Collection<GridCollisionJobContext> waitJobs,
                 Collection<GridCollisionJobContext> activeJobs)
This is a callback called when either new grid job arrived or executing job finished its execution. When new job arrives it is added to the end of the wait list and this method is called. When job finished its execution, it is removed from the active list and this method is called (i.e., when grid job is finished it will not appear in any list in collision resolution).

Implementation of this method should act on two lists, each of which contains collision job contexts that define a set of operations available during collision resolution. Refer to GridCollisionJobContext documentation for more information.

Parameters:
waitJobs - Ordered collection of collision contexts for jobs that are currently waiting for execution. It can be empty but never null. Note that a new newly arrived job, if any, will always be represented by the last item in this list.
activeJobs - Ordered collection of collision contexts for jobs that are currently executing. It can be empty but never null.

setExternalCollisionListener

void setExternalCollisionListener(GridCollisionExternalListener listener)
Listener to be set for notification of external collision events (e.g. job stealing). Once grid receives such notification, it will immediately invoke collision SPI.

GridGain uses this listener to enable job stealing from overloaded to underloaded nodes. However, you can also utilize it, for instance, to provide time based collision resolution. To achieve this, you most likely would mark some job by setting a certain attribute in job context (see GridJobContext) for a job that requires time-based scheduling and set some timer in your SPI implementation that would wake up after a certain period of time. Once this period is reached, you would notify this listener that a collision resolution should take place. Then inside of your collision resolution logic, you would find the marked waiting job and activate it.

Note that most collision SPI's may not have external collisions. In that case, they should simply ignore this method and do nothing when listener is set.

Parameters:
listener - Listener for external collision events.

GridGain™ 2.1.0
Java API Specification

GridGain™ - Grid Computing Made Simple, ver. 2.1.0.19122008
2005-2008 Copyright © GridGain Systems. All Rights Reserved.