aboutsummaryrefslogtreecommitdiffstats
path: root/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/noderepository/NodeRepoStatsData.java
blob: 0c516a47e135c79d2bf2c3cf35160e3a41acaabf (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
// Copyright Vespa.ai. 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.vespa.hosted.controller.api.integration.configserver.NodeRepoStats;

import java.util.List;
import java.util.stream.Collectors;

/**
 * @author bratseth
 */
@JsonIgnoreProperties(ignoreUnknown = true)
@JsonInclude(JsonInclude.Include.NON_NULL)
public class NodeRepoStatsData {

    @JsonProperty("totalCost")
    public Double totalCost;

    @JsonProperty("totalAllocatedCost")
    public Double totalAllocatedCost;

    @JsonProperty("load")
    public LoadData load;

    @JsonProperty("activeLoad")
    public LoadData activeLoad;

    @JsonProperty("applications")
    public List<ApplicationStatsData> applications;

    public NodeRepoStats toNodeRepoStats() {
        return new NodeRepoStats(totalCost, totalAllocatedCost,
                                 load.toLoad(), activeLoad.toLoad(),
                                 applications.stream().map(stats -> stats.toApplicationStats()).toList());
    }

}