@IgniteSpiMultipleInstancesSupport(value=true) public class FifoQueueCollisionSpi extends IgniteSpiAdapter implements CollisionSpi, FifoQueueCollisionSpiMBean
getParallelJobsNumber() number of jobs is allowed to
execute in parallel. Other jobs will be buffered in the passive queue.
setParallelJobsNumber(int)).
This number should usually be set to the number of threads in the execution thread pool.
FifoQueueCollisionSpi can 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);
FifoQueueCollisionSpi can 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>
| Modifier and Type | Field and Description |
|---|---|
static int |
DFLT_PARALLEL_JOBS_NUM
Default number of parallel jobs allowed (set to number of cores times 2).
|
static int |
DFLT_WAIT_JOBS_NUM
Default waiting jobs number.
|
gridName, ignite| Constructor and Description |
|---|
FifoQueueCollisionSpi() |
| Modifier and Type | Method and Description |
|---|---|
int |
getCurrentActiveJobsNumber()
Gets current number of jobs that are active, i.e.
|
int |
getCurrentHeldJobsNumber()
Gets number of currently
'held' jobs. |
int |
getCurrentRunningJobsNumber() |
int |
getCurrentWaitJobsNumber()
Gets current number of jobs that wait for the execution.
|
int |
getParallelJobsNumber()
Gets number of jobs that can be executed in parallel.
|
int |
getWaitingJobsNumber()
Maximum number of jobs that are allowed to wait in waiting queue.
|
void |
onCollision(CollisionContext ctx)
This is a callback called when either new grid job arrived or executing job finished its
execution.
|
void |
setExternalCollisionListener(CollisionExternalListener lsnr)
Listener to be set for notification of external collision events (e.g. job stealing).
|
void |
setParallelJobsNumber(int parallelJobsNum)
Sets number of jobs that can be executed in parallel.
|
void |
setWaitingJobsNumber(int waitJobsNum)
Sets maximum number of jobs that are allowed to wait in waiting queue.
|
void |
spiStart(String gridName)
This method is called to start SPI.
|
void |
spiStop()
This method is called to stop SPI.
|
String |
toString() |
addTimeoutObject, assertParameter, checkConfigurationConsistency0, configInfo, createSpiAttributeName, failureDetectionTimeout, failureDetectionTimeoutEnabled, failureDetectionTimeoutEnabled, getConsistentAttributeNames, getExceptionRegistry, getIgniteHome, getLocalNode, getLocalNodeId, getName, getNodeAttributes, getSpiContext, getStartTimestamp, getStartTimestampFormatted, getUpTime, getUpTimeFormatted, initFailureDetectionTimeout, injectables, injectResources, isNodeStopping, onClientDisconnected, onClientReconnected, onContextDestroyed, onContextDestroyed0, onContextInitialized, onContextInitialized0, registerMBean, removeTimeoutObject, setName, startInfo, startStopwatch, stopInfo, unregisterMBeanclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitgetName, getNodeAttributes, onClientDisconnected, onClientReconnected, onContextDestroyed, onContextInitializedgetIgniteHome, getLocalNodeId, getName, getStartTimestamp, getStartTimestampFormatted, getUpTime, getUpTimeFormattedpublic static final int DFLT_PARALLEL_JOBS_NUM
public static final int DFLT_WAIT_JOBS_NUM
Integer.MAX_VALUE.public int getParallelJobsNumber()
getParallelJobsNumber in interface FifoQueueCollisionSpiMBean@IgniteSpiConfiguration(optional=true) public void setParallelJobsNumber(int parallelJobsNum)
setParallelJobsNumber in interface FifoQueueCollisionSpiMBeanparallelJobsNum - Parallel jobs number.public int getWaitingJobsNumber()
getWaitingJobsNumber in interface FifoQueueCollisionSpiMBean@IgniteSpiConfiguration(optional=true) public void setWaitingJobsNumber(int waitJobsNum)
setWaitingJobsNumber in interface FifoQueueCollisionSpiMBeanwaitJobsNum - Waiting jobs number.public int getCurrentWaitJobsNumber()
getCurrentWaitJobsNumber in interface FifoQueueCollisionSpiMBeanpublic int getCurrentActiveJobsNumber()
'running + held' jobs.getCurrentActiveJobsNumber in interface FifoQueueCollisionSpiMBeanpublic int getCurrentRunningJobsNumber()
getCurrentRunningJobsNumber in interface FifoQueueCollisionSpiMBeanpublic int getCurrentHeldJobsNumber()
'held' jobs.getCurrentHeldJobsNumber in interface FifoQueueCollisionSpiMBean'held' jobs.public void spiStart(String gridName) throws IgniteSpiException
spiStart in interface IgniteSpigridName - Name of grid instance this SPI is being started for
(null for default grid).IgniteSpiException - Throws in case of any error during SPI start.public void spiStop()
throws IgniteSpiException
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.
spiStop in interface IgniteSpiIgniteSpiException - Thrown in case of any error during SPI stop.public void setExternalCollisionListener(CollisionExternalListener lsnr)
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.
setExternalCollisionListener in interface CollisionSpilsnr - Listener for external collision events.public void onCollision(CollisionContext ctx)
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 CollisionContext and CollisionJobContext documentation for
more information.
onCollision in interface CollisionSpictx - Collision context which contains all collision lists.
Follow @ApacheIgnite
Ignite Fabric : ver. 1.5.11 Release Date : April 8 2016