aboutsummaryrefslogtreecommitdiffstats
path: root/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/application/AssignedRotation.java
blob: c2949e395e97b270658ab8b8f595ec1bb8f29296 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.hosted.controller.application;

import com.yahoo.config.provision.ClusterSpec;
import com.yahoo.config.provision.RegionName;
import com.yahoo.vespa.hosted.controller.routing.rotation.RotationId;

import java.util.Objects;
import java.util.Set;

/**
 * Contains the tuple of [clusterId, endpointId, rotationId, regions[]], to keep track
 * of which services have assigned which rotations under which name.
 *
 * @author ogronnesby
 */
public record AssignedRotation(ClusterSpec.Id clusterId, EndpointId endpointId, RotationId rotationId, Set<RegionName> regions) {

    public AssignedRotation(ClusterSpec.Id clusterId, EndpointId endpointId, RotationId rotationId, Set<RegionName> regions) {
        this.clusterId = requireNonEmpty(clusterId, clusterId.value(), "clusterId");
        this.endpointId = Objects.requireNonNull(endpointId);
        this.rotationId = Objects.requireNonNull(rotationId);
        this.regions = Set.copyOf(Objects.requireNonNull(regions));
    }

    private static <T> T requireNonEmpty(T object, String value, String field) {
        Objects.requireNonNull(object);
        Objects.requireNonNull(value);
        if (value.isEmpty()) {
            throw new IllegalArgumentException("Field '" + field + "' was empty");
        }
        return object;
    }

}