SOLR-13155: Minor addition to the "stats" section to make it easier to

estimate the distribution of cores across nodes.
This commit is contained in:
Andrzej Bialecki 2019-02-14 11:35:53 +01:00
parent a084cc1e33
commit abcda8282c
1 changed files with 5 additions and 1 deletions

View File

@ -1061,12 +1061,15 @@ public class SolrCLI {
perColl.put("minCoresPerNode", minCoresPerNode); perColl.put("minCoresPerNode", minCoresPerNode);
}); });
Map<String, Map<String, Object>> nodeStats = new TreeMap<>(); Map<String, Map<String, Object>> nodeStats = new TreeMap<>();
Map<Integer, AtomicInteger> coreStats = new TreeMap<>();
for (Row row : session.getSortedNodes()) { for (Row row : session.getSortedNodes()) {
Map<String, Object> nodeStat = nodeStats.computeIfAbsent(row.node, n -> new LinkedHashMap<>()); Map<String, Object> nodeStat = nodeStats.computeIfAbsent(row.node, n -> new LinkedHashMap<>());
nodeStat.put("isLive", row.isLive()); nodeStat.put("isLive", row.isLive());
nodeStat.put("freedisk", row.getVal("freedisk", 0)); nodeStat.put("freedisk", row.getVal("freedisk", 0));
nodeStat.put("totaldisk", row.getVal("totaldisk", 0)); nodeStat.put("totaldisk", row.getVal("totaldisk", 0));
nodeStat.put("cores", row.getVal("cores", 0)); int cores = ((Number)row.getVal("cores", 0)).intValue();
nodeStat.put("cores", cores);
coreStats.computeIfAbsent(cores, num -> new AtomicInteger()).incrementAndGet();
Map<String, Map<String, Map<String, Object>>> collReplicas = new TreeMap<>(); Map<String, Map<String, Map<String, Object>>> collReplicas = new TreeMap<>();
row.forEachReplica(ri -> { row.forEachReplica(ri -> {
Map<String, Object> perReplica = collReplicas.computeIfAbsent(ri.getCollection(), c -> new TreeMap<>()) Map<String, Object> perReplica = collReplicas.computeIfAbsent(ri.getCollection(), c -> new TreeMap<>())
@ -1107,6 +1110,7 @@ public class SolrCLI {
} }
Map<String, Object> stats = new LinkedHashMap<>(); Map<String, Object> stats = new LinkedHashMap<>();
results.put("STATISTICS", stats); results.put("STATISTICS", stats);
stats.put("coresPerNodes", coreStats);
stats.put("nodeStats", nodeStats); stats.put("nodeStats", nodeStats);
stats.put("collectionStats", collStats); stats.put("collectionStats", collStats);
} }