Dashboard > GridGain User Guide > Table Of Contents > Developers Guide > GridNode Interface
GridNode Interface
Added by morpheus, last edited by morpheus on Apr 03, 2008  (view change)
Labels: 
(None)


Overview

GridNode Javadoc interface represents a single grid node. Use GridNode.getAttribute(String) or GridNode.getMetrics() to get static and dynamic information about remote nodes. GridNode list, which includes all nodes within task topology, is provided to GridTask.map(List, Object) Javadoc method. You can also get a handle on discovered nodes by calling any of the following methods on Grid Javadoc interface:

  • 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() Javadoc ) are updated frequently for all nodes and can be used to get dynamic information about a node. The frequency of update is often directly related to the heartbeat exchange between nodes. So if, for example, default GridMulticastDiscoverySpi Javadoc is used, the metrics data will be updated every 3 seconds by default.

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) Javadoc ), when jobs are assigned to remote nodes for execution. For example, you can choose to only pick nodes that don't have any jobs waiting to be executed.

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(..) Javadoc logic to implement the segmentation (this is shown in example below).

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 Javadoc provided by GridNodes Javadoc . All you would have to do is grab current CPU utilization from node metrics and in your GridTask.map(..) Javadoc method only pick the nodes with CPU's loaded under 50%.

For more information, see Segmenting Grid Nodes documentation.

Powered by Atlassian Confluence, the Enterprise Wiki. (Version: 2.2.10 Build:#528 Nov 29, 2006) - Bug/feature request - Contact Administrators