aboutsummaryrefslogtreecommitdiffstats
path: root/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/routing/rotation/Rotation.java
blob: 0cf7101cac03484e6efe88de5c05901538081c1e (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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.hosted.controller.routing.rotation;

import com.yahoo.text.Text;
import java.util.Objects;

/**
 * Represents a global routing rotation.
 *
 * @author mpolden
 */
public class Rotation {

    private final RotationId id;
    private final String name;

    public Rotation(RotationId id, String name) {
        this.id = Objects.requireNonNull(id);
        this.name = Objects.requireNonNull(name);
    }

    /** The ID of the allocated rotation. This value is generated by global routing system */
    public RotationId id() {
        return id;
    }

    /** The global rotation FQDN */
    public String name() {
        return name;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (!(o instanceof Rotation)) return false;
        final Rotation rotation = (Rotation) o;
        return id().equals(rotation.id()) && name().equals(rotation.name());
    }

    @Override
    public int hashCode() {
        return Objects.hash(id(), name());
    }

    @Override
    public String toString() {
        return Text.format("rotation %s -> %s", id().asString(), name());
    }

}