Grid Node Filters
Starting with GridGain 2.1 you are able to filter nodes by providing your implementation of GridNodeFilter ![]()
![]()
GridGain also comes with GridJexlNodeFilter ![]()
documentation.
Together with GridNodeFilterTopologySpi, GridJexlNodeFilter ![]()
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>
