org.gridgain.grid.spi.topology
Interface GridTopologySpi
- All Superinterfaces:
- GridSpi, GridSpiJsonConfigurable
- All Known Implementing Classes:
- GridAttributesTopologySpi, GridBasicTopologySpi, GridNodeFilterTopologySpi
public interface GridTopologySpi
- extends GridSpi, GridSpiJsonConfigurable
Topology SPI allows developer to have a custom logic deciding what specific set of
grid nodes (topology) is available to GridGain in any given point of time. This SPI is
called every time before grid task gets mapped (GridTask.map(List, Object)).
Implementations can employ various strategies, e.g., some may be time based when certain nodes
are available only at certain time or dates, or topology can be based on average load of
the nodes, or it can be based on specifics of the task obtained from the task session
and ability to match them to grid nodes.
Note that in simple environments the topology is often the same as entire grid (sometimes
minus the local node). More complex topology management is required only when available
topology changes per task or per some other condition.
GridGain comes with following implementations:
-
GridBasicTopologySpi -
based on configuration returns either all,
only local, or only remote nodes. This one is a default implementation.
-
GridAttributesTopologySpi -
based on attributes set.
Those nodes that have attributes with the same values will be included.
-
GridNodeFilterTopologySpi -
based on predicate node filter.
Those nodes that pass predicate filter will be included.
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 GridGain kernal. In rare use cases when
access to a specific implementation of this SPI is required - an instance of this SPI can be obtained
via Grid.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.
-
getTopology
Collection<? extends GridNode> getTopology(GridTaskSession ses,
Collection<? extends GridNode> grid)
throws GridSpiException
- This method is called by GridGain right before calling
GridTask.map(List, Object)
to obtain a topology for the task's split.
- Throws:
GridSpiException - Thrown in case if topology cannot be obtained.- Parameters:
ses - Current task's session. If implementation does not depend on task's
information it may ignore it.grid - Full set of all grid nodes.
- Returns:
- Topology to use for execution of the task represented by the
session passed in.