blob: 7bc019caabbd612d4fa78b6ac52564b4c9d61bff (
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
|
// 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 com.yahoo.config.provision.NodeResources;
import com.yahoo.vespa.hosted.provision.applications.Application;
import java.time.Clock;
import java.time.Duration;
import java.util.OptionalDouble;
/**
* A resource target to hit for the allocation optimizer.
* The target is measured in cpu, memory and disk per node in the current allocation.
*
* @author bratseth
*/
public class ResourceTarget {
/** The target real resources per node, assuming the node assignment where this was decided */
private final NodeResources resources;
private ResourceTarget(NodeResources resources) {
this.resources = resources;
}
/** Returns the target resources per node in terms of the current allocation */
public NodeResources resources() { return resources; }
@Override
public String toString() {
return "target " + resources;
}
/** Create a target of achieving ideal load given a current load */
public static ResourceTarget idealLoad(ClusterModel clusterModel,
AllocatableClusterResources current) {
return new ResourceTarget(clusterModel.loadAdjustment().scaled(current.realResources().nodeResources()));
}
/** Crete a target of preserving a current allocation */
public static ResourceTarget preserve(ClusterModel clusterModel,
AllocatableClusterResources current) {
return new ResourceTarget(current.realResources().nodeResources());
}
}
|