blob: 11d54b02dc71704a7bbdaf56009de68f788f20d8 (
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
|
// 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.applications;
import java.util.Objects;
/**
* When there are multiple deployments of an application in different regions,
* instances of the cluster across regions may form a "BCP group".
* By default the clusters in all production regions form such a group, but other arrangements
* may be specified in deployment.xml, see com.yahoo.config.application.api.Bcp.
*
* This contains metrics averaged over the other clusters in the group this belongs to,
* which is used to amend scaling decisions in this cluster when it has little traffic on its own.
*
* @author bratseth
*/
public class BcpGroupInfo {
private static final BcpGroupInfo empty = new BcpGroupInfo(0, 0, 0);
private final double queryRate;
private final double growthRateHeadroom;
private final double cpuCostPerQuery;
public BcpGroupInfo(double queryRate, double growthRateHeadroom, double cpuCostPerQuery) {
this.queryRate = queryRate;
this.growthRateHeadroom = growthRateHeadroom;
this.cpuCostPerQuery = cpuCostPerQuery;
}
/** Returns the max peak query rate (queries/second) of the other clusters in the group this belongs to. */
public double queryRate() { return queryRate; }
/** Returns the average growth rate headroom of the other clusters in the group this belongs to. */
public double growthRateHeadroom() { return growthRateHeadroom; }
/** Returns the average total cluster CPU cost per query of the other clusters in the group this belongs to. */
public double cpuCostPerQuery() { return cpuCostPerQuery; }
public boolean isEmpty() {
return queryRate == 0 && growthRateHeadroom == 0 && cpuCostPerQuery == 0;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if ( ! (o instanceof BcpGroupInfo other)) return false;
if ( other.queryRate != this.queryRate) return false;
if ( other.growthRateHeadroom != this.growthRateHeadroom) return false;
if ( other.cpuCostPerQuery != this.cpuCostPerQuery) return false;
return true;
}
@Override
public int hashCode() {
return Objects.hash(queryRate, growthRateHeadroom, cpuCostPerQuery);
}
@Override
public String toString() {
return "BCP group info: " + queryRate + " q/s, " + growthRateHeadroom + " q/s headroom, " +
cpuCostPerQuery + " CPU cost per q/s";
}
public static BcpGroupInfo empty() { return empty; }
}
|