aboutsummaryrefslogtreecommitdiffstats
path: root/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/ConvergenceSummary.java
blob: 2b1d00ada957d6a6074af4d279c1d3e52a882078 (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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
// 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.deployment;

import java.util.Objects;

/**
 * Summary of node and service status during a deployment job.
 *
 * @author jonmv
 */
public class ConvergenceSummary {

    private final long nodes;
    private final long down;
    private final long upgradingOs;
    private final long upgradingFirmware;
    private final long needPlatformUpgrade;
    private final long upgradingPlatform;
    private final long needReboot;
    private final long rebooting;
    private final long needRestart;
    private final long restarting;
    private final long services;
    private final long needNewConfig;
    private final long retiring;

    public ConvergenceSummary(long nodes, long down, long upgradingOs, long upgradingFirmware, long needPlatformUpgrade, long upgradingPlatform,
                              long needReboot, long rebooting, long needRestart, long restarting, long services, long needNewConfig, long retiring) {
        this.nodes = nodes;
        this.down = down;
        this.upgradingOs = upgradingOs;
        this.upgradingFirmware = upgradingFirmware;
        this.needPlatformUpgrade = needPlatformUpgrade;
        this.upgradingPlatform = upgradingPlatform;
        this.needReboot = needReboot;
        this.rebooting = rebooting;
        this.needRestart = needRestart;
        this.restarting = restarting;
        this.services = services;
        this.needNewConfig = needNewConfig;
        this.retiring = retiring;
    }

    /** Number of nodes in the application. */
    public long nodes() {
        return nodes;
    }

    /** Number of nodes allowed to be down. */
    public long down() {
        return down;
    }

    /** Number of nodes down for OS upgrade. */
    public long upgradingOs() {
        return upgradingOs;
    }

    /** Number of nodes down for firmware upgrade. */
    public long upgradingFirmware() {
        return upgradingFirmware;
    }

    /** Number of nodes in need of a platform upgrade. */
    public long needPlatformUpgrade() {
        return needPlatformUpgrade;
    }

    /** Number of nodes down for platform upgrade. */
    public long upgradingPlatform() {
        return upgradingPlatform;
    }

    /** Number of nodes in need of a reboot. */
    public long needReboot() {
        return needReboot;
    }

    /** Number of nodes down for reboot. */
    public long rebooting() {
        return rebooting;
    }

    /** Number of nodes in need of a restart. */
    public long needRestart() {
        return needRestart;
    }

    /** Number of nodes down for restart. */
    public long restarting() {
        return restarting;
    }

    /** Number of services in the application. */
    public long services() {
        return services;
    }

    /** Number of services with outdated config generation. */
    public long needNewConfig() {
        return needNewConfig;
    }

    /** Number of nodes that are retiring. */
    public long retiring() {
        return retiring;
    }

    /** Whether the convergence is done. */
    public boolean converged() {
        return     nodes > 0
                && needPlatformUpgrade == 0
                && needReboot == 0
                && needRestart == 0
                && services > 0
                && needNewConfig == 0;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        ConvergenceSummary that = (ConvergenceSummary) o;
        return nodes == that.nodes &&
               down == that.down &&
               upgradingOs == that.upgradingOs &&
               upgradingFirmware == that.upgradingFirmware &&
               needPlatformUpgrade == that.needPlatformUpgrade &&
               upgradingPlatform == that.upgradingPlatform &&
               needReboot == that.needReboot &&
               rebooting == that.rebooting &&
               needRestart == that.needRestart &&
               restarting == that.restarting &&
               services == that.services &&
               needNewConfig == that.needNewConfig &&
               retiring == that.retiring;
    }

    @Override
    public int hashCode() {
        return Objects.hash(nodes, down, upgradingOs, upgradingFirmware, needPlatformUpgrade, upgradingPlatform, needReboot, rebooting, needRestart, restarting, services, needNewConfig, retiring);
    }

}