Click on Javadoc link to open Javadoc documentation.
Package
org.gridgain.grid.spi.topology.nodefilter Javadoc![]()
Description
GridNodeFilterTopologySpi ![]()
This topology allows for fine grained node provisioning for grid task execution. Nodes can be filtered based on any parameter available on GridNode ![]()
![]()
![]()
- GridNode.getPhysicalAddress()
Javadoc - in mose cases this parameter represents the IP address the node.
- GridNode.getAttributes()
Javadoc - attributes attached to a grid node. Node attributes are specified in grid configuration via GridConfiguration.getUserAttributes()
Javadoc parameter. Note that all system and environment properties are automatically pre-set as node attributes for every node.
- GridNode.getMetrics()
Javadoc - about 50 node metrics parameters that are periodically updated, such as heap, CPU, job counts, average job execution times, etc...
Apache JEXL Node Filter
GridGain also comes with GridJexlNodeFilter ![]()
expression language. Refer to Apache JEXL
documentation for specifics of JEXL expression language. GridJexlNodeFilter ![]()
| Expression variables Variable named node, which is a GridNode |
Configuration
The following configuration parameters can be used to configure GridAttributesTopologySpi ![]()
| Setter Method | Description | Optional | Default |
|---|---|---|---|
| setFilter(GridNodeFilter) |
Sets filter for nodes to be included into task topology. | Yes | — |
Examples
As any GridGain SPI, GridNodeFilterTopologySpi ![]()
![]()
GridNodeFilterTopologySpi topSpi = new GridNodeFilterTopologySpi(); GridNodeFilter filter = new GridJexlNodeFilter( "node.metrics.availableProcessors > 1 && " + "node.metrics.averageCpuLoad < 0.5 && " + "node.attributes['os.name'] == 'Windows XP'"); // Add filter. topSpi.setFilter(filter); GridConfigurationAdapter cfg = new GridConfigurationAdapter(); // Override topology SPI. cfg.setTopologySpi(topSpi); // Start grid. GridFactory.start(cfg);
or from Spring configuration file:
<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.GridJexlNodeFilter"> <property name="expression"> <value> <![CDATA[ node.metrics.availableProcessors > 1 && node.metrics.averageCpuLoad < 0.5 && node.attributes['os.name'] == 'Windows XP' ]]> </value> </property> </bean> </property> </bean> </property> ... </bean>

For more information about using Spring framework for configuration click here.
