public interface CollisionSpi extends IgniteSpi
Collision SPI provides developer with ability to use the custom logic in determining how grid jobs should be executed on a destination grid node. Ignite comes with the following ready implementations for collision resolution that cover most popular strategies:
NOTE: this SPI (i.e. methods in this interface) should never be used directly. SPIs provide internal view on the subsystem and is used internally by Ignite kernal. In rare use cases when access to a specific implementation of this SPI is required - an instance of this SPI can be obtained viaIgnite.configuration()
method to check its configuration properties or call other non-SPI
methods. Note again that calling methods from this interface on the obtained instance can lead
to undefined behavior and explicitly not supported.Modifier and Type | Method and Description |
---|---|
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 )
When new job arrives it is added to the end of the wait list and this
method is called. |
void |
setExternalCollisionListener(@Nullable CollisionExternalListener lsnr)
Listener to be set for notification of external collision events (e.g. job stealing).
|
getName, getNodeAttributes, onClientDisconnected, onClientReconnected, onContextDestroyed, onContextInitialized, spiStart, spiStop
void onCollision(CollisionContext ctx)
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 CollisionContext
and CollisionJobContext
documentation for
more information.
ctx
- Collision context which contains all collision lists.void setExternalCollisionListener(@Nullable @Nullable 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.
lsnr
- Listener for external collision events.
Follow @ApacheIgnite
Ignite Database and Caching Platform : ver. 2.16.0 Release Date : December 15 2023