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 Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.hosted.controller.api.integration.noderepository;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.yahoo.config.provision.ClusterSpec;
import com.yahoo.vespa.hosted.controller.api.integration.configserver.Cluster;
import java.time.Duration;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;
/**
* @author bratseth
*/
@JsonIgnoreProperties(ignoreUnknown = true)
@JsonInclude(JsonInclude.Include.NON_NULL)
public class ClusterData {
@JsonProperty("type")
public String type;
@JsonProperty("min")
public ClusterResourcesData min;
@JsonProperty("max")
public ClusterResourcesData max;
@JsonProperty("current")
public ClusterResourcesData current;
@JsonProperty("suggested")
public ClusterResourcesData suggested;
@JsonProperty("target")
public ClusterResourcesData target;
@JsonProperty("utilization")
public ClusterUtilizationData utilization;
@JsonProperty("scalingEvents")
public List<ScalingEventData> scalingEvents;
@JsonProperty("autoscalingStatusCode")
public String autoscalingStatusCode;
@JsonProperty("autoscalingStatus")
public String autoscalingStatus;
@JsonProperty("scalingDuration")
public Long scalingDuration;
@JsonProperty("maxQueryGrowthRate")
public Double maxQueryGrowthRate;
@JsonProperty("currentQueryFractionOfMax")
public Double currentQueryFractionOfMax;
public Cluster toCluster(String id) {
return new Cluster(ClusterSpec.Id.from(id),
ClusterSpec.Type.from(type),
min.toClusterResources(),
max.toClusterResources(),
current.toClusterResources(),
target == null ? Optional.empty() : Optional.of(target.toClusterResources()),
suggested == null ? Optional.empty() : Optional.of(suggested.toClusterResources()),
utilization == null ? Cluster.Utilization.empty() : utilization.toClusterUtilization(),
scalingEvents == null ? List.of()
: scalingEvents.stream().map(data -> data.toScalingEvent()).collect(Collectors.toList()),
autoscalingStatusCode,
autoscalingStatus,
scalingDuration == null ? Duration.ofMillis(0) : Duration.ofMillis(scalingDuration),
maxQueryGrowthRate == null ? -1 : maxQueryGrowthRate,
currentQueryFractionOfMax == null ? -1 : currentQueryFractionOfMax);
}
}
|