aboutsummaryrefslogtreecommitdiffstats
path: root/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/autoscale/MetricSnapshot.java
blob: 82812592809343390f04e6ff340d7fcf8277232d (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
// Copyright Verizon Media. 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 MetricSnapshot implements Comparable<MetricSnapshot> {

    private final Instant at;

    private final double cpu;
    private final double memory;
    private final double disk;
    private final long generation;
    private final boolean inService;
    private final boolean stable;
    private final double queryRate;

    public MetricSnapshot(Instant at, double cpu, double memory, double disk,
                          long generation, boolean inService, boolean stable,
                          double queryRate) {
        this.at = at;
        this.cpu = cpu;
        this.memory = memory;
        this.disk = disk;
        this.generation = generation;
        this.inService = inService;
        this.stable = stable;
        this.queryRate = queryRate;
    }

    public Instant at() { return at; }
    public double cpu() { return cpu; }
    public double memory() { return memory; }
    public double disk() { return disk; }

    /** 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(MetricSnapshot other) {
        return at.compareTo(other.at);
    }

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

}