blob: c20ab0684684e796fc16c9d11e118179b7a04039 (
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
|
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.hosted.provision.node;
/**
* An immutable generation, with wanted and current generation fields. Wanted generation
* is increased when an action (restart services or reboot are the available
* actions) is wanted, current is updated when the action has been done on the node.
*
* @author hmusum
*/
public class Generation {
private final long wanted;
private final long current;
public Generation(long wanted, long current) {
this.wanted = wanted;
this.current = current;
}
public long wanted() {
return wanted;
}
public long current() {
return current;
}
public boolean pending() {
return current < wanted;
}
public Generation withIncreasedWanted() {
return new Generation(wanted + 1, current);
}
public Generation withCurrent(long newValue) {
return new Generation(wanted, newValue);
}
@Override
public String toString() {
return "current generation: " + current + ", wanted: " + wanted;
}
/** Returns the initial generation (0, 0) */
public static Generation initial() { return new Generation(0, 0); }
}
|