Implementation:Vespa engine Vespa Cluster
| Knowledge Sources | |
|---|---|
| Domains | Cloud_API, Cluster_Management |
| Last Updated | 2026-02-09 00:00 GMT |
Overview
Immutable value object describing the properties of a cluster of nodes in a Vespa Cloud deployment.
Description
WARNING: PARTIAL DEPRECATION — The constructor Cluster(int size, List<Integer> indices) is annotated @Deprecated(forRemoval = true) and will be removed in Vespa 9. Use Cluster(String id, int size, List<Integer> indices) instead. See Heuristic:Vespa_engine_Vespa_Warning_Deprecated_Cloud_API_Constructors.
The Cluster class is part of the Vespa Cloud public API (ai.vespa.cloud package). It represents the properties of a deployed cluster, including its identifier (from services.xml), the number of nodes, and the list of node indices. This information is useful for application code that needs to distribute work across cluster nodes or behave differently based on cluster topology.
The class provides:
- Construction from cluster id, size, and node index list
- A deprecated constructor (Vespa 9 removal) for backward compatibility
- Accessor methods for id, size, and indices
- Proper equals/hashCode for use in collections
Usage
Use this class when you need information about the cluster topology your code is running in. It is typically obtained via SystemInfo injection in a Vespa Cloud environment. Useful for partitioning work across cluster nodes.
Code Reference
Source Location
- Repository: Vespa
- File: hosted-zone-api/src/main/java/ai/vespa/cloud/Cluster.java
- Lines: 1-56
Signature
public class Cluster {
@Deprecated(forRemoval = true)
public Cluster(int size, List<Integer> indices)
public Cluster(String id, int size, List<Integer> indices)
/** Returns the id of this cluster set in services.xml */
public String id()
/** Returns the number of nodes in this cluster. */
public int size()
/** Returns a list of node indices in this cluster. */
public List<Integer> indices()
@Override public boolean equals(Object o)
@Override public int hashCode()
}
Import
import ai.vespa.cloud.Cluster;
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| id | String | Yes | Cluster identifier from services.xml |
| size | int | Yes | Total number of nodes in the cluster |
| indices | List<Integer> | Yes | List of node indices |
Outputs
| Name | Type | Description |
|---|---|---|
| id() | String | The cluster identifier |
| size() | int | Node count in the cluster |
| indices() | List<Integer> | Immutable copy of node indices |
Usage Examples
Accessing Cluster Information
import ai.vespa.cloud.Cluster;
import ai.vespa.cloud.SystemInfo;
import com.yahoo.component.annotation.Inject;
public class DistributedProcessor {
private final String clusterId;
private final int clusterSize;
@Inject
public DistributedProcessor(SystemInfo systemInfo) {
this.clusterId = systemInfo.clusterName();
// Cluster size can be used to partition work
}
}