summaryrefslogtreecommitdiffstats
path: root/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/nodeagent/NodeAttributes.java
blob: 8ad4a8aa465449a6503030bdcf47cc76a8aafd34 (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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.hosted.node.admin.nodeagent;

import com.yahoo.vespa.hosted.dockerapi.DockerImage;

import java.util.Objects;


// It somewhat sucks that this class almost duplicates a binding class used by NodeRepositoryImpl,
// but using the binding class here would be a layer violation, and would also tie this logic to
// serialization-related dependencies it needs not have.
public class NodeAttributes {
    private Long restartGeneration = null;
    private Long rebootGeneration = null;
    private DockerImage dockerImage = null;
    private String vespaVersion = null;

    public NodeAttributes() { }

    public NodeAttributes withRestartGeneration(Long restartGeneration) {
        this.restartGeneration = restartGeneration;
        return this;
    }

    public NodeAttributes withRebootGeneration(Long rebootGeneration) {
        this.rebootGeneration = rebootGeneration;
        return this;
    }

    public NodeAttributes withDockerImage(DockerImage dockerImage) {
        this.dockerImage = dockerImage;
        return this;
    }

    public NodeAttributes withVespaVersion(String vespaVersion) {
        this.vespaVersion = vespaVersion;
        return this;
    }

    public Long getRestartGeneration() {
        return restartGeneration;
    }

    public Long getRebootGeneration() {
        return rebootGeneration;
    }

    public DockerImage getDockerImage() {
        return dockerImage;
    }

    public String getVespaVersion() {
        return vespaVersion;
    }

    @Override
    public int hashCode() {
        return Objects.hash(restartGeneration, rebootGeneration, dockerImage, vespaVersion);
    }

    @Override
    public boolean equals(final Object o) {
        if (!(o instanceof NodeAttributes)) {
            return false;
        }
        final NodeAttributes other = (NodeAttributes) o;

        return Objects.equals(restartGeneration, other.restartGeneration)
                && Objects.equals(rebootGeneration, other.rebootGeneration)
                && Objects.equals(dockerImage, other.dockerImage)
                && Objects.equals(vespaVersion, other.vespaVersion);
    }

    @Override
    public String toString() {
        return "NodeAttributes{" +
                "restartGeneration=" + restartGeneration +
                ", rebootGeneration=" + rebootGeneration +
                ", dockerImage=" + dockerImage.asString() +
                ", vespaVersion='" + vespaVersion + '\'' +
                '}';
    }
}