summaryrefslogtreecommitdiffstats
path: root/clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/hostinfo/StorageNode.java
blob: bf7c1fad6cac5cf6dbf4ca2a2edb6e6483d59dd2 (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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.clustercontroller.core.hostinfo;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;

import java.util.ArrayList;
import java.util.List;

/**
 * Keeping information about a storage node seen from the distributor.
 *
 * @author Haakon Dybdahl
 */
public class StorageNode {

    static public class Put {
        private final Long latencyMsSum;
        private final Long count;

        @JsonCreator
        public Put(@JsonProperty("latency-ms-sum") Long latencyMsSum, @JsonProperty("count") Long count) {
            this.latencyMsSum = latencyMsSum;
            this.count = count;
        }

        public Long getLatencyMsSum() { return latencyMsSum; }
        public Long getCount() { return count; }
    }

    static public class OpsLatency {
        private final Put put;

        @JsonCreator
        public OpsLatency(@JsonProperty("put") Put put) {
            this.put = put;
        }

        public Put getPut() { return put; }
    }

    static public class BucketStats {
        private final long total;
        private final long pending;

        @JsonCreator
        public BucketStats(@JsonProperty("total") Long total, @JsonProperty("pending") Long pending) {
            this.total = total;
            this.pending = pending;
        }

        public long getTotal() {
            return total;
        }
        public long getPending() {
            return pending;
        }
    }

    static public class BucketSpaceStats {
        private final String name;
        @JsonProperty("buckets")
        private BucketStats bucketStats = null;

        @JsonCreator
        public BucketSpaceStats(@JsonProperty("name") String name) {
            this.name = name;
        }

        public String getName() {
            return name;
        }
        public boolean valid() {
            return bucketStats != null;
        }
        public BucketStats getBucketStats() {
            return bucketStats;
        }
    }

    private final Integer index;

    @JsonProperty("ops-latency")
    private OpsLatency opsLatencies;

    // If a Distributor does not manage any bucket copies for a particular storage node,
    // then the distributor will not return any min-current-replication-factor for that
    // storage node.
    @JsonProperty("min-current-replication-factor")
    private Integer minCurrentReplicationFactor;

    @JsonProperty("bucket-spaces")
    private List<BucketSpaceStats> bucketSpacesStats = new ArrayList<>();

    @JsonCreator
    public StorageNode(@JsonProperty("node-index") Integer index) {
        this.index = index;
    }

    public Integer getIndex() {
        return index;
    }

    public OpsLatency getOpsLatenciesOrNull() {
        return opsLatencies;
    }

    // See documentation on minCurrentReplicationFactor.
    public Integer getMinCurrentReplicationFactorOrNull() {
        return minCurrentReplicationFactor;
    }

    public List<BucketSpaceStats> getBucketSpacesStats() {
        return bucketSpacesStats;
    }
}