Implementation:Vespa engine Vespa Zone
| Knowledge Sources | |
|---|---|
| Domains | Cloud_API, Deployment_Zones |
| Last Updated | 2026-02-09 00:00 GMT |
Overview
Immutable value object representing a deployment zone as a combination of an Environment (dev, staging, prod, etc.) and a region string.
Description
The Zone class is part of the Vespa Cloud public API (ai.vespa.cloud package). It represents the deployment zone where a Vespa application is running, combining an Environment enum value with a region string. The class supports both programmatic construction and parsing from the "environment.region" string format via the from() factory method.
The class provides:
- Construction from Environment enum and region string
- Static from(String) factory that parses "environment.region" format
- Accessor methods for environment and region
- Proper equals/hashCode/toString implementations
Usage
Use this class when you need to determine the deployment environment and region. It is typically obtained via SystemInfo.zone() in a Vespa Cloud environment. Common use cases include environment-conditional logic (e.g., relaxed validation in dev) and region-aware routing.
Code Reference
Source Location
- Repository: Vespa
- File: hosted-zone-api/src/main/java/ai/vespa/cloud/Zone.java
- Lines: 1-63
Signature
public class Zone {
public Zone(Environment environment, String region)
public Environment environment()
public String region()
/** Returns the string environment.region */
@Override public String toString()
@Override public int hashCode()
@Override public boolean equals(Object o)
/**
* Creates a zone from a string on the form environment.region
* @throws IllegalArgumentException if the given string is not a valid zone
*/
public static Zone from(String zoneString)
}
Import
import ai.vespa.cloud.Zone;
import ai.vespa.cloud.Environment;
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| environment | Environment | Yes | The deployment environment (dev, staging, perf, prod) |
| region | String | Yes | The deployment region identifier |
Outputs
| Name | Type | Description |
|---|---|---|
| environment() | Environment | The environment enum value |
| region() | String | The region string |
| toString() | String | Format: "environment.region" |
| from(String) | Zone (static) | Parses "environment.region" into a Zone |
Usage Examples
Parsing Zone Strings
import ai.vespa.cloud.Zone;
import ai.vespa.cloud.Environment;
// Parse from string
Zone zone = Zone.from("prod.us-east-1");
assert zone.environment() == Environment.prod;
assert zone.region().equals("us-east-1");
// Construct directly
Zone devZone = new Zone(Environment.dev, "us-west-2");
System.out.println(devZone); // "dev.us-west-2"
Environment-Conditional Logic
import ai.vespa.cloud.SystemInfo;
import ai.vespa.cloud.Environment;
import com.yahoo.component.annotation.Inject;
public class ConfigurableComponent {
private final int maxRetries;
@Inject
public ConfigurableComponent(SystemInfo systemInfo) {
// Use more retries in production
this.maxRetries = systemInfo.zone().environment() == Environment.prod ? 5 : 1;
}
}