Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:Ray project Ray NodeInfo

From Leeroopedia
Knowledge Sources
Domains Distributed_Computing, Java_Runtime
Last Updated 2026-02-13 16:00 GMT

Overview

Immutable data class representing the metadata and state of a single node in a Ray cluster.

Description

NodeInfo is a plain data class with all fields declared public final, exposing node identity, network addresses, liveness status, available resources, and user-defined labels. The constructor accepts nine parameters and directly assigns them. A toString() override provides a human-readable representation for logging and debugging.

Usage

Use NodeInfo to inspect cluster topology information returned by RuntimeContext.getAllNodeInfo(). It gives Java applications visibility into which nodes exist, whether they are alive, what resources (CPU, GPU, memory) they offer, and how they can be reached via sockets, enabling resource-aware scheduling decisions and cluster monitoring from user code.

Code Reference

Source Location

  • Repository: Ray
  • File: java/api/src/main/java/io/ray/api/runtimecontext/NodeInfo.java

Signature

public class NodeInfo {

  public final UniqueId nodeId;
  public final String nodeAddress;
  public final String nodeHostname;
  public final int nodeManagerPort;
  public final String objectStoreSocketName;
  public final String rayletSocketName;
  public final boolean isAlive;
  public final Map<String, Double> resources;
  public final Map<String, String> labels;

  public NodeInfo(
      UniqueId nodeId,
      String nodeAddress,
      String nodeHostname,
      int nodeManagerPort,
      String objectStoreSocketName,
      String rayletSocketName,
      boolean isAlive,
      Map<String, Double> resources,
      Map<String, String> labels) { ... }

  public String toString() { ... }
}

Import

import io.ray.api.runtimecontext.NodeInfo;

I/O Contract

Input (Constructor)

Parameter Type Description
nodeId UniqueId Unique identifier for the node
nodeAddress String IP address of the node
nodeHostname String Hostname of the node
nodeManagerPort int Port for the node manager (raylet)
objectStoreSocketName String RPC socket name for the object store
rayletSocketName String RPC socket name for the raylet
isAlive boolean Whether the node is currently alive
resources Map<String, Double> Available resources (e.g., CPU, GPU, memory)
labels Map<String, String> User-defined labels attached to the node

Output

Method Return Type Description
toString() String Human-readable string representation of all node fields

Usage Examples

// Retrieve all node information from the runtime context
RuntimeContext ctx = Ray.getRuntimeContext();
List<NodeInfo> nodes = ctx.getAllNodeInfo();

for (NodeInfo node : nodes) {
    System.out.println("Node: " + node.nodeId);
    System.out.println("Address: " + node.nodeAddress);
    System.out.println("Alive: " + node.isAlive);
    System.out.println("Resources: " + node.resources);
    System.out.println("Labels: " + node.labels);
}

// Filter for alive nodes with GPU resources
List<NodeInfo> gpuNodes = nodes.stream()
    .filter(n -> n.isAlive && n.resources.containsKey("GPU"))
    .collect(Collectors.toList());

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment