blob: 02516ce79accafa31088089dbebd360374ad58fb (
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
|
// 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.yahoo.vespa.clustercontroller.core.LatencyStats;
import com.yahoo.vespa.clustercontroller.core.NodeMergeStats;
import com.yahoo.vespa.clustercontroller.core.StorageMergeStats;
import com.yahoo.vespa.clustercontroller.core.StorageNodeStats;
import com.yahoo.vespa.clustercontroller.core.StorageNodeStatsContainer;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* Class used to create a StorageNodeStatsContainer from HostInfo.
* @author hakonhall
*/
public class StorageNodeStatsBridge {
private StorageNodeStatsBridge() { }
public static StorageNodeStatsContainer traverseHostInfo(HostInfo hostInfo) {
StorageNodeStatsContainer container = new StorageNodeStatsContainer();
List<StorageNode> storageNodes = hostInfo.getDistributor().getStorageNodes();
for (StorageNode storageNode : storageNodes) {
Integer storageNodeIndex = storageNode.getIndex();
if (storageNodeIndex == null) {
continue;
}
StorageNode.OpsLatency opsLatency = storageNode.getOpsLatenciesOrNull();
if (opsLatency == null) {
continue;
}
StorageNode.Put putLatency = opsLatency.getPut();
Long putLatencyMsSum = putLatency.getLatencyMsSum();
Long putLatencyCount = putLatency.getCount();
if (putLatencyMsSum == null || putLatencyCount == null) {
continue;
}
LatencyStats putLatencyStats = new LatencyStats(putLatencyMsSum, putLatencyCount);
StorageNodeStats nodeStats = new StorageNodeStats(putLatencyStats);
container.put(storageNodeIndex, nodeStats);
}
return container;
}
public static StorageMergeStats generate(Distributor distributor) {
Map<Integer, NodeMergeStats> mapToNodeStats = new HashMap<>();
for (StorageNode storageNode : distributor.getStorageNodes()) {
mapToNodeStats.put(storageNode.getIndex(), new NodeMergeStats(storageNode));
}
return new StorageMergeStats(mapToNodeStats);
}
}
|