|
GridGain 2.0.3
Java API Specification |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.gridgain.grid.spi.GridSpiAdapter
org.gridgain.grid.spi.collision.fifoqueue.GridFifoQueueCollisionSpi
@GridSpiInfo(author="GridGain Systems",
url="www.gridgain.org",
email="support@gridgain.com",
version="x.x")
@GridSpiMultipleInstancesSupport(value=true)
public class GridFifoQueueCollisionSpi
This class provides implementation for Collision SPI based on FIFO queue. Jobs are ordered
as they arrived and only GridFifoQueueCollisionSpi.getParallelJobsNumber() number of jobs is allowed to
execute in parallel. Other jobs will be buffered in the passive queue.
GridFifoQueueCollisionSpi.setParallelJobsNumber(int)).
This number should usually be set to the number of threads in the execution thread pool.
GridFifoQueueCollisionSpi colSpi = new GridFifoQueueCollisionSpi(); // Execute all jobs sequentially by setting parallel job number to 1. colSpi.setParallelJobsNumber(1); GridConfigurationAdapter cfg = new GridConfigurationAdapter(); // Override default collision SPI. cfg.setCollisionSpi(colSpi); // Start grid. GridFactory.start(cfg);
<bean id="grid.custom.cfg" class="org.gridgain.grid.GridConfigurationAdapter" singleton="true">
...
<property name="collisionSpi">
<bean class="org.gridgain.grid.spi.collision.fifoqueue.GridFifoQueueCollisionSpi">
<property name="parallelJobsNumber" value="1"/>
</bean>
</property>
...
</bean>
Documentation
Email Support
Online Forums
Issue Tracking
Author: 2005-2008 Copyright © GridGain Systems. All Rights Reserved. ver. 2.0.3
![]() |
![]() |
| Field Summary | |
|---|---|
static int |
DFLT_PARALLEL_JOBS_NUM
Default number of parallel jobs allowed (value is 95 which is slightly less same as default value of threads in the execution thread pool to allow some extra threads for system processing). |
| Constructor Summary | |
|---|---|
GridFifoQueueCollisionSpi()
|
|
| Method Summary | |
|---|---|
int |
getCurrentActiveJobsNumber()
Gets current number of jobs that are being executed. |
int |
getCurrentWaitJobsNumber()
Gets current number of jobs that wait for the execution. |
int |
getParallelJobsNumber()
Gets number of jobs that can be executed in parallel. |
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). |
void |
setParallelJobsNumber(int parallelJobsNum)
Sets number of jobs that are allowed to be executed in parallel on this node. |
void |
spiStart(String gridName)
This method is called to start SPI. |
void |
spiStop()
This method is called to stop SPI. |
String |
toString()
|
| Methods inherited from class org.gridgain.grid.spi.GridSpiAdapter |
|---|
assertParameter, checkConfigurationConsistency, configInfo, getAuthor, getGridGainHome, getLocalNodeId, getNodeAttributes, getSpiContext, getStartTimestamp, getStartTimestampFormatted, getUpTime, getUpTimeFormatted, getVendorEmail, getVendorUrl, getVersion, onContextDestroyed, onContextInitialized, registerMBean, setSpiContext, startInfo, startStopwatch, stopInfo, unregisterMBean, warnSpi, warnSpiParameter |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface org.gridgain.grid.spi.GridSpi |
|---|
getNodeAttributes, onContextDestroyed, onContextInitialized |
| Methods inherited from interface org.gridgain.grid.spi.GridSpiManagementMBean |
|---|
getAuthor, getGridGainHome, getLocalNodeId, getStartTimestamp, getStartTimestampFormatted, getUpTime, getUpTimeFormatted, getVendorEmail, getVendorUrl, getVersion |
| Field Detail |
|---|
public static final int DFLT_PARALLEL_JOBS_NUM
| Constructor Detail |
|---|
public GridFifoQueueCollisionSpi()
| Method Detail |
|---|
@GridSpiConfiguration(optional=true) public void setParallelJobsNumber(int parallelJobsNum)
GridFifoQueueCollisionSpi.DFLT_PARALLEL_JOBS_NUM.
parallelJobsNum - Maximum number of jobs to be executed in parallel.public int getParallelJobsNumber()
getParallelJobsNumber in interface GridFifoQueueCollisionSpiMBeanpublic int getCurrentWaitJobsNumber()
getCurrentWaitJobsNumber in interface GridFifoQueueCollisionSpiMBeanpublic int getCurrentActiveJobsNumber()
getCurrentActiveJobsNumber in interface GridFifoQueueCollisionSpiMBean
public void spiStart(String gridName)
throws GridSpiException
spiStart in interface GridSpiGridSpiException - Throws in case of any error during SPI start.gridName - Name of grid instance this SPI is being started for
(null for default grid).
public void spiStop()
throws GridSpiException
spiStop in interface GridSpiGridSpiException - Thrown in case of any error during SPI stop.public void setExternalCollisionListener(GridCollisionExternalListener listener)
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.
setExternalCollisionListener in interface GridCollisionSpilistener - Listener for external collision events.
public void onCollision(Collection<GridCollisionJobContext> waitJobs,
Collection<GridCollisionJobContext> activeJobs)
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.
onCollision in interface GridCollisionSpiwaitJobs - 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.public String toString()
toString in class Object
|
GridGain 2.0.3
Java API Specification |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
|
GridGain - Grid Computing Made Simple, ver. 2.0.3.20052008
2005-2008 Copyright © GridGain Systems. All Rights Reserved. |
|