GridGain™ 3.6.0e
Enterprise Edition

org.gridgain.grid
Interface GridNode

All Superinterfaces:
GridMetadataAware, Serializable
All Known Subinterfaces:
GridRichNode

public interface GridNode
extends GridMetadataAware

Interface representing a single grid node. Use GridNode.attribute(String) or GridNode.metrics() 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) method. You can also get a handle on discovered nodes by calling any of the following methods:

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:
 <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>
 

The system adds the following attributes automatically:

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 : G.grid().nodes()) {
     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"));
 }
 

This interface provide a system view on the node instance. All user-level APIs work with GridRichNode interface that provides much more functionality and extends this interface. Consult GridRichNode for more information.

Grid Node Metrics

Grid node metrics (see GridNode.metrics()) 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 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 GridTask.map(List, Object) operation when jobs are assigned to remote nodes for execution. For example, you can 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 graph.

Wiki & Forum:


Wiki
Forum

See Also:
GridRichNode
 

Method Summary
<T> T
attribute(String name)
          Gets a node attribute.
 Map<String,Object> attributes()
          Gets all node attributes.
 Collection<String> externalAddresses()
          Gets collection of IP addresses this node is known by externally outside of ths LAN.
 UUID id()
          Gets globally unique node ID.
 Collection<String> internalAddresses()
          Gets collection of IP addresses this node is known by internally on the same LAN.
 GridNodeMetrics metrics()
          Gets metrics snapshot for this node.
 long order()
          Node order within grid topology.
 
Methods inherited from interface org.gridgain.grid.GridMetadataAware
addMeta, addMetaIfAbsent, addMetaIfAbsent, allMeta, copyMeta, copyMeta, hasMeta, hasMeta, meta, putMetaIfAbsent, putMetaIfAbsent, removeMeta, removeMeta, replaceMeta
 

Method Detail

id

UUID id()
Gets globally unique node ID.

Returns:
Globally unique node ID.

attribute

<T> T attribute(String name)
Gets a node attribute. Attributes are assigned to nodes at startup via GridConfiguration.getUserAttributes() method.

The system adds the following attributes automatically:

Note that attributes cannot be changed at runtime.

Type Parameters:
T - Attribute Type.
Parameters:
name - Attribute name. Note that attribute names starting with org.gridgain are reserved for internal use.
Returns:
Attribute value or null.

metrics

GridNodeMetrics metrics()
Gets metrics snapshot for this node. Note that node metrics are constantly updated and provide up to date information about nodes. For example, you can get an idea about CPU load on remote node via GridNodeMetrics.getCurrentCpuLoad() method and use it during GridTask.map(List, Object) or during collision resolution.

Node metrics are updated with some delay which is directly related to heartbeat frequency. For example, when used with default GridMulticastDiscoverySpi the update will happen every 2 seconds.

Returns:
Runtime metrics snapshot for this node.

attributes

Map<String,Object> attributes()
Gets all node attributes. Attributes are assigned to nodes at startup via GridConfiguration.getUserAttributes() method.

The system adds the following attributes automatically:

Note that attributes cannot be changed at runtime.

Returns:
All node attributes.

internalAddresses

Collection<String> internalAddresses()
Gets collection of IP addresses this node is known by internally on the same LAN.

In many managed environments like Amazon EC2 a virtual instance and therefore a GridGain node can have multiple internal and external IP addresses. Internal addresses are used to address the node from within this environment, while external addresses used to address this node from the outside of this environment.

Returns:
Collection of internal IP addresses. This collection is never null but can be empty.

externalAddresses

Collection<String> externalAddresses()
Gets collection of IP addresses this node is known by externally outside of ths LAN.

In many managed environments like Amazon EC2 a virtual instance and therefore a GridGain node can have multiple internal and external IP addresses. Internal addresses are used to address the node from within this environment, while external addresses used to address this node from the outside of this environment.

Returns:
Collection of external IP addresses. This collection is never null but can be empty.

order

long order()
Node order within grid topology. Discovery SPIs that support node ordering will assign a proper order to each node and will guarantee that discovery event notifications for new nodes will come in proper order. All other SPIs not supporting ordering may choose to return node startup time here.

NOTE: in cases when discovery SPI doesn't support ordering GridGain cannot guarantee that orders on all nodes will be unique or chronologically correct. If such guarantee is required - make sure use discovery SPI that provides ordering.

Returns:
Node startup order.

GridGain™ 3.6.0e
Enterprise Edition

GridGain - Real Time Big Data
Enterprise Edition, ver. 3.6.0e.13012012
2012 Copyright © GridGain Systems
Follow us:   Follow GridGain on Github Follow GridGain on Facebook Join GridGain User Group Follow GridGain on Twitter Follow GridGain on YouTube