Class FifoQueueCollisionSpi
- java.lang.Object
- 
- org.apache.ignite.spi.IgniteSpiAdapter
- 
- org.apache.ignite.spi.collision.fifoqueue.FifoQueueCollisionSpi
 
 
- 
- All Implemented Interfaces:
- CollisionSpi,- IgniteSpi
 
 @IgniteSpiMultipleInstancesSupport(true) public class FifoQueueCollisionSpi extends IgniteSpiAdapter implements CollisionSpi This class provides implementation for Collision SPI based on FIFO queue. Jobs are ordered as they arrived and onlygetParallelJobsNumber()number of jobs is allowed to execute in parallel. Other jobs will be buffered in the passive queue.ConfigurationMandatoryThis SPI has no mandatory configuration parameters.OptionalThis SPI has following optional configuration parameters:- 
      Number of jobs that can execute in parallel (see setParallelJobsNumber(int)). This number should usually be set to the number of threads in the execution thread pool.
 Java ExampleFifoQueueCollisionSpican be configured as follows:FifoQueueCollisionSpi colSpi = new FifoQueueCollisionSpi(); // Execute all jobs sequentially by setting parallel job number to 1. colSpi.setParallelJobsNumber(1); IgniteConfiguration cfg = new IgniteConfiguration(); // Override default collision SPI. cfg.setCollisionSpi(colSpi); // Starts grid. G.start(cfg); Spring ExampleFifoQueueCollisionSpican be configured from Spring XML configuration file:<bean id="grid.custom.cfg" class="org.apache.ignite.configuration.IgniteConfiguration" singleton="true"> ... <property name="collisionSpi"> <bean class="org.apache.ignite.spi.collision.fifoqueue.FifoQueueCollisionSpi"> <property name="parallelJobsNumber" value="1"/> </bean> </property> ... </bean>
- 
- 
Field SummaryFields Modifier and Type Field Description static intDFLT_PARALLEL_JOBS_NUMDefault number of parallel jobs allowed (set to number of cores times 2).static intDFLT_WAIT_JOBS_NUMDefault waiting jobs number.- 
Fields inherited from class org.apache.ignite.spi.IgniteSpiAdapterignite, igniteInstanceName
 
- 
 - 
Constructor SummaryConstructors Constructor Description FifoQueueCollisionSpi()
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description intgetCurrentActiveJobsNumber()Gets current number of jobs that are active, i.e.intgetCurrentHeldJobsNumber()Gets number of currently'held'jobs.intgetCurrentRunningJobsNumber()Gets number of currently running (not'held) jobs.intgetCurrentWaitJobsNumber()Gets current number of jobs that wait for the execution.intgetParallelJobsNumber()intgetWaitingJobsNumber()voidonCollision(CollisionContext ctx)This is a callback called: new grid job arrived executing job finished its execution topology changed periodically (onEventType.EVT_NODE_METRICS_UPDATED) When new job arrives it is added to the end of the wait list and this method is called.voidsetExternalCollisionListener(CollisionExternalListener lsnr)Listener to be set for notification of external collision events (e.g. job stealing).FifoQueueCollisionSpisetName(String name)Sets SPI name.FifoQueueCollisionSpisetParallelJobsNumber(int parallelJobsNum)Sets number of jobs that can be executed in parallel.FifoQueueCollisionSpisetWaitingJobsNumber(int waitJobsNum)Sets maximum number of jobs that are allowed to wait in waiting queue.voidspiStart(String igniteInstanceName)This method is called to start SPI.voidspiStop()This method is called to stop SPI.StringtoString()- 
Methods inherited from class org.apache.ignite.spi.IgniteSpiAdapteraddTimeoutObject, assertParameter, checkConfigurationConsistency0, clientFailureDetectionTimeout, configInfo, createSpiAttributeName, failureDetectionTimeout, failureDetectionTimeoutEnabled, failureDetectionTimeoutEnabled, getConsistentAttributeNames, getExceptionRegistry, getLocalNode, getName, getNodeAttributes, getSpiContext, ignite, initFailureDetectionTimeout, injectables, injectResources, isNodeStopping, onBeforeStart, onClientDisconnected, onClientReconnected, onContextDestroyed, onContextDestroyed0, onContextInitialized, onContextInitialized0, registerMBean, removeTimeoutObject, started, startInfo, startStopwatch, stopInfo, unregisterMBean
 - 
Methods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 - 
Methods inherited from interface org.apache.ignite.spi.IgniteSpigetName, getNodeAttributes, onClientDisconnected, onClientReconnected, onContextDestroyed, onContextInitialized
 
- 
 
- 
- 
- 
Field Detail- 
DFLT_PARALLEL_JOBS_NUMpublic static final int DFLT_PARALLEL_JOBS_NUM Default number of parallel jobs allowed (set to number of cores times 2).
 - 
DFLT_WAIT_JOBS_NUMpublic static final int DFLT_WAIT_JOBS_NUM Default waiting jobs number. If number of waiting jobs exceeds this number, jobs will be rejected. Default value isInteger.MAX_VALUE.- See Also:
- Constant Field Values
 
 
- 
 - 
Method Detail- 
getParallelJobsNumberpublic int getParallelJobsNumber() - Returns:
- Number of jobs that can be executed in parallel.
 
 - 
setParallelJobsNumber@IgniteSpiConfiguration(optional=true) public FifoQueueCollisionSpi setParallelJobsNumber(int parallelJobsNum) Sets number of jobs that can be executed in parallel.- Parameters:
- parallelJobsNum- Parallel jobs number.
- Returns:
- thisfor chaining.
 
 - 
getWaitingJobsNumberpublic int getWaitingJobsNumber() - Returns:
- Maximum allowed number of waiting jobs.
 
 - 
setWaitingJobsNumber@IgniteSpiConfiguration(optional=true) public FifoQueueCollisionSpi setWaitingJobsNumber(int waitJobsNum) Sets maximum number of jobs that are allowed to wait in waiting queue. If number of waiting jobs ever exceeds this number, excessive jobs will be rejected.- Parameters:
- waitJobsNum- Waiting jobs number.
- Returns:
- thisfor chaining.
 
 - 
getCurrentWaitJobsNumberpublic int getCurrentWaitJobsNumber() Gets current number of jobs that wait for the execution.- Returns:
- Number of jobs that wait for execution.
 
 - 
getCurrentActiveJobsNumberpublic int getCurrentActiveJobsNumber() Gets current number of jobs that are active, i.e.'running + held'jobs.- Returns:
- Number of active jobs.
 
 - 
getCurrentRunningJobsNumberpublic int getCurrentRunningJobsNumber() Gets number of currently running (not'held) jobs.- Returns:
- Number of currently running (not 'held) jobs.
 
 - 
getCurrentHeldJobsNumberpublic int getCurrentHeldJobsNumber() Gets number of currently'held'jobs.- Returns:
- Number of currently 'held'jobs.
 
 - 
spiStartpublic 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:
- spiStartin interface- IgniteSpi
- Parameters:
- igniteInstanceName- Name of Ignite instance this SPI is being started for (- nullfor default Ignite instance).
- Throws:
- IgniteSpiException- Throws in case of any error during SPI start.
 
 - 
spiStoppublic void spiStop() throws IgniteSpiExceptionThis 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:
- spiStopin interface- IgniteSpi
- Throws:
- IgniteSpiException- Thrown in case of any error during SPI stop.
 
 - 
setExternalCollisionListenerpublic void setExternalCollisionListener(CollisionExternalListener lsnr) 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.Ignite 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 ComputeJobContext) 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 might not have external collisions. In that case, they should simply ignore this method and do nothing when listener is set. - Specified by:
- setExternalCollisionListenerin interface- CollisionSpi
- Parameters:
- lsnr- Listener for external collision events.
 
 - 
onCollisionpublic void onCollision(CollisionContext ctx) This is a callback called:- new grid job arrived
- executing job finished its execution
- topology changed
- periodically (on EventType.EVT_NODE_METRICS_UPDATED)
 Implementation of this method should act on all lists, each of which contains collision job contexts that define a set of operations available during collision resolution. Refer to CollisionContextandCollisionJobContextdocumentation for more information.- Specified by:
- onCollisionin interface- CollisionSpi
- Parameters:
- ctx- Collision context which contains all collision lists.
 
 - 
setNamepublic FifoQueueCollisionSpi setName(String name) Sets SPI name.- Overrides:
- setNamein class- IgniteSpiAdapter
- Parameters:
- name- SPI name.
- Returns:
- thisfor chaining.
 
 
- 
 
-