Interface representing a single grid node. Use
#attribute(String) or
#metrics() to get static and dynamic information about remote nodes.
GridNode list, which includes all nodes within task topology, is provided
to
GridComputeTask#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. Here is an example of how to assign an attribute to a node at startup:
<bean id="grid.cfg" class="org.gridgain.grid.GridConfiguration">
...
<property name="userAttributes">
<map>
<entry key="worker" value="true"/>
</map>
</property>
...
</bean>
The system adds the following attributes automatically:
-
{@link System#getProperties()}} - All system properties.
-
{@link System#getenv(String)}} - All environment properties.
-
org.gridgain.build.ver - GridGain build version.
-
org.gridgain.jit.name - Name of JIT compiler used.
-
org.gridgain.net.itf.name - Name of network interface.
-
org.gridgain.user.name - Operating system user name.
-
org.gridgain.grid.name - Grid name (see
Grid#name()).
-
spiName.org.gridgain.spi.class - SPI implementation class for every SPI,
where
spiName is the name of the SPI (see
GridSpi#getName().
-
spiName.org.gridgain.spi.ver - SPI version for every SPI,
where
spiName is the name of the SPI (see
GridSpi#getName().
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
GridNode interface that provides much more functionality and extends this
interface. Consult
GridNode for more information.
Grid Node Metrics
Grid node metrics (see
#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
GridTcpDiscoverySpi is used,
the metrics data will be updated every
2 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
GridComputeTask#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
jconsolethat comes with JDK as it also provides ability to view any node parameter
as a graph.