aboutsummaryrefslogtreecommitdiffstats
path: root/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/autoscale/NodeMetricSnapshot.java
blob: 706692d58d5cbc5a0fe62760becee344dd43b0c6 (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
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.hosted.provision.autoscale;

import java.time.Instant;

/**
 * A single measurement of all values we measure for one node.
 *
 * @author bratseth
 */
public class NodeMetricSnapshot implements Comparable<NodeMetricSnapshot> {

    private final Instant at;

    private final Load load;
    private final long generation;
    private final boolean inService;
    private final boolean stable;
    private final double queryRate;

    public NodeMetricSnapshot(Instant at, Load load,
                              long generation, boolean inService, boolean stable,
                              double queryRate) {
        this.at = at;
        this.load = load;
        this.generation = generation;
        this.inService = inService;
        this.stable = stable;
        this.queryRate = queryRate;
    }

    public Instant at() { return at; }
    public Load load() { return load; }

    /** Queries per second */
    public double queryRate() { return queryRate; }

    /** The configuration generation at the time of this measurement, or -1 if not known */
    public long generation() { return generation; }

    public boolean inService() { return inService; }
    public boolean stable() { return stable; }

    @Override
    public int compareTo(NodeMetricSnapshot other) {
        return at.compareTo(other.at);
    }

    @Override
    public String toString() { return "metrics at " + at + ": " +
                                      load +
                                      " generation: " + generation +
                                      " inService: " + inService +
                                      " stable: " + stable +
                                      " queryRate: " + queryRate;
    }

}