aboutsummaryrefslogtreecommitdiffstats
path: root/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/autoscale/ClusterMetricSnapshot.java
blob: fd8e91584c42b6ab9a0c9232bc256d92ec30a2e8 (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
// 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;

/**
 * Cluster level metrics.
 * These are aggregated at fetch time over the nodes in the cluster at that point in time.
 *
 * @author bratseth
 */
public class ClusterMetricSnapshot implements Comparable<ClusterMetricSnapshot> {

    private final Instant at;

    private final double queryRate;

    public ClusterMetricSnapshot(Instant at, double queryRate) {
        this.at = at;
        this.queryRate = queryRate;
    }

    public Instant at() { return at; }

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

    public ClusterMetricSnapshot withQueryRate(double queryRate) {
        return new ClusterMetricSnapshot(at, queryRate);
    }

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

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

}