org.apache.ignite.cluster

## Interface ClusterNode

- All Superinterfaces:
    BaselineNode
  All Known Implementing Classes:
    IsolatedNode

      public interface ClusterNode
      extends BaselineNode

  Interface representing a single cluster node. Use `attribute(String)` or `metrics()` to get static and dynamic information about cluster nodes. `ClusterNode` list, which includes all nodes within task topology, is provided to `ComputeTask.map(List, Object)` method.

  # Cluster Node Attributes

  You can use cluster node attributes to provide static information about a node. This information is initialized once within a cluster, during the node startup, and remains the same throughout the lifetime of a node. Use `IgniteConfiguration.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 class="org.apache.ignite.configuration.IgniteConfiguration">
           ...
           <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.ignite.build.ver` - Ignite build version.
  - `org.apache.ignite.jit.name` - Name of JIT compiler used.
  - `org.apache.ignite.net.itf.name` - Name of network interface.
  - `org.apache.ignite.user.name` - Operating system user name.
  - `org.apache.ignite.ignite.name` - Ignite name (see `Ignite.name()`).
  - `spiName.org.apache.ignite.spi.class` - SPI implementation class for every SPI, where `spiName` is the name of the SPI (see `IgniteSpi.getName()`.
  - `spiName.org.apache.ignite.spi.ver` - SPI version for every SPI, where `spiName` is the name of the SPI (see `IgniteSpi.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 (ClusterNode node : ignite.cluster().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"));
       }

  # Cluster Node Metrics

  Cluster 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 controlled by `IgniteConfiguration.getMetricsUpdateFrequency()` parameter. The metrics data will be updated every `2` seconds by default.

  Grid node metrics provide information 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 `ComputeTask.map(List, Object)` operation when jobs are assigned to remote nodes for execution.

  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.

- - ### Method Summary

    All Methods Instance Methods Abstract Methods
    Modifier and Type | Method and Description
    --- | ---
    `Collection<String>` | `addresses()` Gets collection of addresses this node is known by.
    `<T> T` | `attribute(String name)` Gets a node attribute.
    `Map<String,Object>` | `attributes()` Gets all node attributes.
    `Object` | `consistentId()` Gets consistent globally unique node ID.
    `Collection<String>` | `hostNames()` Gets collection of host names this node is known by.
    `UUID` | `id()` Gets globally unique node ID.
    `boolean` | `isClient()` Whether this node is cache client (see `IgniteConfiguration.isClientMode()`).
    `boolean` | `isDaemon()` Tests whether or not this node is a daemon.
    `boolean` | `isLocal()` Tests whether or not this node is a local node.
    `ClusterMetrics` | `metrics()` Gets metrics snapshot for this node.
    `long` | `order()` Node order within grid topology.
    `IgniteProductVersion` | `version()` Gets node version.

- - ### Method Detail

    - #### id

          UUID id()

      Gets globally unique node ID. A new ID is generated every time a node restarts.
      Returns:
        Globally unique node ID.

    - #### consistentId

          Object consistentId()

      Gets consistent globally unique node ID. Unlike `id()` method, this method returns consistent node ID which survives node restarts.
      Specified by:
        `consistentId` in interface `BaselineNode`
      Returns:
        Consistent globally unique node ID.

    - #### attribute

          @Nullable
          <T> T attribute(String name)

      Gets a node attribute. Attributes are assigned to nodes at startup via `IgniteConfiguration.getUserAttributes()` method.

      The system adds the following attributes automatically:

      - `{@link System#getProperties()}` - All system properties.
      - `{@link System#getenv(String)}` - All environment properties.
      - All attributes defined in `IgniteNodeAttributes`

      Note that attributes cannot be changed at runtime.

      Specified by:
        `attribute` in interface `BaselineNode`
      Type Parameters:
        `T` - Attribute Type.
      Parameters:
        `name` - Attribute name. Note that attribute names starting with `org.apache.ignite` are reserved for internal use.
      Returns:
        Attribute value or `null`.

    - #### metrics

          ClusterMetrics 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 `ClusterMetrics.getCurrentCpuLoad()` method and use it during `ComputeTask.map(List, Object)` or during collision resolution.

      Node metrics are updated with some delay which is controlled by `IgniteConfiguration.getMetricsUpdateFrequency()` parameter. By default 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 `IgniteConfiguration.getUserAttributes()` method.

      The system adds the following attributes automatically:

      - `{@link System#getProperties()}` - All system properties.
      - `{@link System#getenv(String)}` - All environment properties.
      - All attributes defined in `IgniteNodeAttributes`

      Note that attributes cannot be changed at runtime.

      Specified by:
        `attributes` in interface `BaselineNode`
      Returns:
        All node attributes.

    - #### addresses

          Collection<String> addresses()

      Gets collection of addresses this node is known by.

      If `IgniteConfiguration.getLocalHost()` value isn't `null` node will try to use that address for all communications and returned collection will contain only that address. If it is `null` then local wildcard address will be used, and Ignite will make the best effort to supply all addresses of that node in returned collection.

      Returns:
        Collection of addresses.

    - #### hostNames

          Collection<String> hostNames()

      Gets collection of host names this node is known by.

      If `IgniteConfiguration.getLocalHost()` value isn't `null` node will try to use the host name of that resolved address for all communications and returned collection will contain only that host name. If that host name can not be resolved then ip address returned by method `addresses()` is used.

      If `IgniteConfiguration.getLocalHost()` value is `null` then local wildcard address will be used, and this method returns host names of all addresses of that node.

      Note: the loopback address will be omitted in results.

      Returns:
        Collection of host names.

    - #### 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 Ignite 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.

    - #### version

          IgniteProductVersion version()

      Gets node version.
      Returns:
        Node version.

    - #### isLocal

          boolean isLocal()

      Tests whether or not this node is a local node.
      Returns:
        `True` if this node is a local node, `false` otherwise.

    - #### isDaemon

          boolean isDaemon()

      Tests whether or not this node is a daemon.

      Daemon nodes are the usual cluster nodes that participate in topology but are not visible on the main APIs, i.e. they are not part of any cluster group. The only way to see daemon nodes is to use `ClusterGroup.forDaemons()` method.

      Daemon nodes are used primarily for management and monitoring functionality that is build on Ignite and needs to participate in the topology, but should be excluded from the "normal" topology, so that they won't participate in the task execution or data grid operations.

      Application code should never use daemon nodes.

      Returns:
        `True` if this node is a daemon, `false` otherwise.

    - #### isClient

          boolean isClient()

      Whether this node is cache client (see `IgniteConfiguration.isClientMode()`).
      Returns:
        `True if client`.
      See Also:
        `IgniteConfiguration.isClientMode()`

2021 Copyright © Apache Software Foundation
| Follow @ApacheIgnite
Ignite Database and Caching Platform | : ver. 2.10.0
Release Date | : March 10 2021