use of com.linkedin.kafka.cruisecontrol.common.Statistic in project cruise-control by linkedin.
the class AnalyzerUtils method getJsonStructure.
/*
* Return an object that can be further used
* to encode into JSON
*
* @param clusterModelStats Cluster model stats.
*/
public static Map<String, Object> getJsonStructure(ClusterModelStats clusterModelStats) {
Map<String, Object> clusterStatsMap = new HashMap<>();
clusterStatsMap.put("brokers", clusterModelStats.numBrokers());
clusterStatsMap.put("replicas", clusterModelStats.numReplicasInCluster());
clusterStatsMap.put("topics", clusterModelStats.numTopics());
Map<Statistic, Map<Resource, Double>> resourceUtilizationStats = clusterModelStats.resourceUtilizationStats();
Map<Statistic, Double> nwOutUtilizationStats = clusterModelStats.potentialNwOutUtilizationStats();
Map<Statistic, Number> replicaStats = clusterModelStats.replicaStats();
Map<Statistic, Number> topicReplicaStats = clusterModelStats.topicReplicaStats();
Map<String, Object> statisticMap = new HashMap<>();
for (Statistic stat : Statistic.values()) {
Map<String, Double> resourceMap = new HashMap<>();
for (Resource resource : Resource.values()) {
resourceMap.put(resource.resource(), resourceUtilizationStats.get(stat).get(resource));
}
resourceMap.put("potentialNwOut", nwOutUtilizationStats.get(stat));
resourceMap.put("replicas", replicaStats.get(stat).doubleValue());
resourceMap.put("topicReplicas", topicReplicaStats.get(stat).doubleValue());
statisticMap.put(stat.stat(), resourceMap);
}
clusterStatsMap.put("statistics", statisticMap);
return clusterStatsMap;
}
use of com.linkedin.kafka.cruisecontrol.common.Statistic in project cruise-control by linkedin.
the class ClusterModelStats method getJsonStructure.
/*
* Return an object that can be further used
* to encode into JSON
*/
public Map<String, Object> getJsonStructure() {
Map<String, Object> statMap = new HashMap<>();
Map<String, Integer> basicMap = new HashMap<>();
basicMap.put("brokers", numBrokers());
basicMap.put("replicas", numReplicasInCluster());
basicMap.put("topics", numTopics());
// List of all statistics AVG, MAX, MIN, STD
Map<String, Object> allStatMap = new HashMap();
for (Statistic stat : Statistic.values()) {
Map<String, Object> resourceMap = new HashMap<>();
for (Resource resource : Resource.values()) {
resourceMap.put(resource.resource(), resourceUtilizationStats().get(stat).get(resource));
}
resourceMap.put("potentialNwOut", potentialNwOutUtilizationStats().get(stat));
resourceMap.put("replicas", replicaStats().get(stat));
resourceMap.put("topicReplicas", topicReplicaStats().get(stat));
allStatMap.put(stat.stat(), resourceMap);
}
statMap.put("metadata", basicMap);
statMap.put("statistics", allStatMap);
return statMap;
}
use of com.linkedin.kafka.cruisecontrol.common.Statistic in project cruise-control by linkedin.
the class ClusterModelStats method toString.
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append(String.format("brokers:%d replicas:%d topics:%d%n", numBrokers(), numReplicasInCluster(), numTopics()));
for (Statistic stat : Statistic.values()) {
sb.append(String.format("%s:{", stat));
for (Resource resource : Resource.values()) {
sb.append(String.format("%s:%12.3f ", resource, resourceUtilizationStats().get(stat).get(resource)));
}
sb.append(String.format("potentialNwOut:%12.3f replicas:%s topicReplicas:%s}%n", potentialNwOutUtilizationStats().get(stat), replicaStats().get(stat), topicReplicaStats().get(stat)));
}
return sb.substring(0, sb.length() - 2);
}
Aggregations