Overview
GridNode ![]()
![]()
![]()
- Grid.getLocalNode()
- Grid.getRemoteNodes()
- Grid.getAllNodes()|
Grid Node Attributes
You can use grid node attributes to provide static information about a node. This information is initialized once within grid, during node startup, and remains the same throughout the lifetime of a node. Use GridConfiguration.getUserAttributes() method to initialize your custom node attributes at startup. For example, to provide benchmark data about every node from Spring XML configuration file, you would do the following:
view plaincopy to clipboardprint?
<bean id="grid.cfg" class="org.gridgain.grid.GridConfigurationAdapter" scope="singleton"> ... <property name="userAttributes"> <map> <entry key="grid.node.benchmark"> <bean class="org.gridgain.grid.benchmarks.GridLocalNodeBenchmark" init-method="start"/> </entry> </map> </property> ... </bean>
Note that all System and Environment properties for all nodes are automatically included into node attributes. This gives you an ability to get any information specified in System.getProperties() about any node. So for example, in order to print out information about Operating System for all nodes you would do the following:
for (GridNode node : GridFactory.getGrid().getAllNodes()) { System.out.println("Operating system name: " + node.getAttribute("os.name")); System.out.println("Operating system architecture: " + node.getAttribute("os.arch")); System.out.println("Operating system version: " + node.getAttribute("os.version")); }
Grid Node Metrics
Grid node metrics (see GridNode.getMetrics() ![]()
![]()
Grid node metrics provide information about other nodes that can frequently change, such as Heap and Non-Heap memory utilization, CPU load, number of active and waiting grid jobs, etc... This information can become useful during job collision resolution or task map operation (see GridTask.map(List, Object) ![]()
Local node metrics are registered as MBean and can be accessed from any JMX management console. The simplest way is to use standard JConsole that comes with JDK as it also provides ability to view any node parameter as a frequently updated graph.
Grid Node Segmentation
Often in deployments you need to segment your grid nodes into several groups, having each group perform one or more subsets of jobs only. For example, let's say you have a scenario where you have some nodes only submitting jobs to grid (masters), and other groups of nodes only executing these jobs (workers). Then you would segment your grid into 2 groups, masters and workers, and have each group do only what it is supposed to do.
For more information see Segmenting Grid Nodes.
Multiple Sub-Grids
Node segmentation allows you to create multiple sub-grids within your grid. Every sub-grid may have it's own static physical characteristics and logical responsibilities. All node characteristics, physical or logical, if they are static, can be specified in Spring Configuration and used in your Topology SPI or GridTask.map(..) ![]()
Note, that based on its attributes, every node can participate in one or multiple segments.
Dynamic Sub-Grids
You may also wish to segment your grid based on dynamic characteristics, not static. For example, what if you only want to include nodes that have less than 50% CPU utilization. In GridGain you can achieve this by using dynamic GridNodeMetrics ![]()
![]()
![]()
For more information, see Segmenting Grid Nodes documentation.
