|
GridGain 4.3.1e
Enterprise "Big Data" Edition |
|||||||||
| 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.topology.nodefilter.GridNodeFilterTopologySpi
@GridSpiInfo(author="GridGain Systems",
url="www.gridgain.com",
email="support@gridgain.com",
version="4.3.1e.10112012")
@GridSpiMultipleInstancesSupport(value=true)
public class GridNodeFilterTopologySpi
This class provides implementation for topology SPI based on GridPredicate2.
The implementation returns nodes that are accepted by GridPredicate2 provided
in configuration. If no predicate filter was provided, all nodes, local and remote,
will be included into topology.
This topology allows for fine grained node provisioning for grid task execution. Nodes
can be filtered based on any parameter available on GridNode. For example,
you can filter nodes based on operating system, number of CPU's, available heap memory,
average job execution time, current CPU load, any node attribute and about 50 more metrics
available in GridNodeMetrics. Here some of the methods on GridNode interface
which may be used for filtering:
GridNode.attributes() - attributes attached to a grid node. Node
attributes are specified in grid configuration via GridConfiguration.getUserAttributes()
parameter. Note that all system and environment properties are automatically pre-set as
node attributes for every node.
GridNode.metrics() - about 50 node metrics parameters that are periodically
updated, such as heap, CPU, job counts, average job execution times, etc...
GridJexlPredicate2 implementation which allows you
to conveniently filter nodes based on Apache JEXL expression language. Refer to
Apache JEXL documentation for specifics of
JEXL expression language. GridJexlPredicate2 allows for a fairly simple way to
provide complex SLA-based task topology specifications. For example, the configuration
examples below show how the SPI can be configured with GridJexlPredicate2 to
include all Windows XP nodes with more than one processor or core and that are not loaded
over 50%.
GridNodeFilterTopologySpi.setFilter(GridPredicate2) - Node predicate filter
that should be used for decision to accept node.
GridNodeFilterTopologySpi topSpi = new GridNodeFilterTopologySpi();
GridJexlPredicate2<GridNode, GridTaskSession> filter = new GridJexlPredicate2<GridNode, GridTaskSession>(
"node.metrics().availableProcessors > 1 && " +
"node.metrics().averageCpuLoad < 0.5 && " +
"node.attributes().get('os.name') == 'Windows XP'", "node", "ses");
// Add filter.
topSpi.setFilter(filter);
GridConfigurationAdapter cfg = new GridConfigurationAdapter();
// Override topology SPI.
cfg.setTopologySpi(topSpi);
// Starts grid.
G.start(cfg);
<bean id="grid.custom.cfg" class="org.gridgain.grid.GridConfigurationAdapter" singleton="true">
...
<property name="topologySpi">
<bean class="org.gridgain.grid.spi.topology.nodefilter.GridNodeFilterTopologySpi">
<property name="filter">
<bean class="org.gridgain.grid.lang.GridJexlPredicate2">
<constructor-arg>
<value>
<![CDATA[elem1.metrics().availableProcessors > 1 &&
elem1.metrics().averageCpuLoad < 0.5 &&
elem1.attributes().get('os.name') == 'Windows XP']]>
</value>
</constructor-arg>
</bean>
</property>
</bean>
</property>
...
</bean>
![]() |
![]() |
| Constructor Summary | |
|---|---|
GridNodeFilterTopologySpi()
|
|
| Method Summary | |
|---|---|
GridPredicate2<GridNode,GridTaskSession> |
getFilter()
Gets node predicate filter for nodes to be included into topology. |
Collection<GridNode> |
getTopology(GridTaskSession ses,
Collection<? extends GridNode> grid)
This method is called by GridGain right before calling GridTask.map(List, Object)
to obtain a topology for the task's split. |
void |
setFilter(GridPredicate2<GridNode,GridTaskSession> filter)
Sets filter for nodes to be included into task topology. |
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 java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface org.gridgain.grid.spi.GridSpi |
|---|
getName, getNodeAttributes, onContextDestroyed, onContextInitialized |
| Methods inherited from interface org.gridgain.grid.spi.GridSpiJsonConfigurable |
|---|
setJson |
| Methods inherited from interface org.gridgain.grid.spi.GridSpiManagementMBean |
|---|
getAuthor, getGridGainHome, getLocalNodeId, getName, getStartTimestamp, getStartTimestampFormatted, getUpTime, getUpTimeFormatted, getVendorEmail, getVendorUrl, getVersion |
| Constructor Detail |
|---|
public GridNodeFilterTopologySpi()
| Method Detail |
|---|
public GridPredicate2<GridNode,GridTaskSession> getFilter()
getFilter in interface GridNodeFilterTopologySpiMBean@GridSpiConfiguration(optional=true) public void setFilter(GridPredicate2<GridNode,GridTaskSession> filter)
filter - Filter to use.GridJexlPredicate2
public void spiStart(@Nullable
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
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 GridSpiGridSpiException - Thrown in case of any error during SPI stop.public Collection<GridNode> getTopology(GridTaskSession ses, Collection<? extends GridNode> grid) throws GridSpiException
GridTask.map(List, Object)
to obtain a topology for the task's split.
getTopology in interface GridTopologySpiGridSpiException - Thrown in case if topology cannot be obtained.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.
public String toString()
toString in class Object
|
GridGain 4.3.1e
Enterprise "Big Data" Edition |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
|
GridGain - In-Memory Big Data
|
|
|