use of org.apache.storm.metric.api.DataPoint in project storm by apache.
the class Nimbus method extractClusterMetrics.
private static List<DataPoint> extractClusterMetrics(ClusterSummary summ) {
List<DataPoint> ret = new ArrayList<>();
ret.add(new DataPoint("supervisors", summ.get_supervisors_size()));
ret.add(new DataPoint("topologies", summ.get_topologies_size()));
int totalSlots = 0;
int usedSlots = 0;
for (SupervisorSummary sup : summ.get_supervisors()) {
usedSlots += sup.get_num_used_workers();
totalSlots += sup.get_num_workers();
}
ret.add(new DataPoint("slotsTotal", totalSlots));
ret.add(new DataPoint("slotsUsed", usedSlots));
ret.add(new DataPoint("slotsFree", totalSlots - usedSlots));
int totalExecutors = 0;
int totalTasks = 0;
for (TopologySummary topo : summ.get_topologies()) {
totalExecutors += topo.get_num_executors();
totalTasks += topo.get_num_tasks();
}
ret.add(new DataPoint("executorsTotal", totalExecutors));
ret.add(new DataPoint("tasksTotal", totalTasks));
return ret;
}
use of org.apache.storm.metric.api.DataPoint in project storm by apache.
the class Nimbus method sendClusterMetricsToExecutors.
private void sendClusterMetricsToExecutors() throws Exception {
ClusterInfo clusterInfo = mkClusterInfo();
ClusterSummary clusterSummary = getClusterInfoImpl();
List<DataPoint> clusterMetrics = extractClusterMetrics(clusterSummary);
Map<IClusterMetricsConsumer.SupervisorInfo, List<DataPoint>> supervisorMetrics = extractSupervisorMetrics(clusterSummary);
for (ClusterMetricsConsumerExecutor consumerExecutor : clusterConsumerExceutors) {
consumerExecutor.handleDataPoints(clusterInfo, clusterMetrics);
for (Entry<IClusterMetricsConsumer.SupervisorInfo, List<DataPoint>> entry : supervisorMetrics.entrySet()) {
consumerExecutor.handleDataPoints(entry.getKey(), entry.getValue());
}
}
}
use of org.apache.storm.metric.api.DataPoint in project storm by apache.
the class Nimbus method extractSupervisorMetrics.
private static Map<IClusterMetricsConsumer.SupervisorInfo, List<DataPoint>> extractSupervisorMetrics(ClusterSummary summ) {
Map<IClusterMetricsConsumer.SupervisorInfo, List<DataPoint>> ret = new HashMap<>();
for (SupervisorSummary sup : summ.get_supervisors()) {
IClusterMetricsConsumer.SupervisorInfo info = new IClusterMetricsConsumer.SupervisorInfo(sup.get_host(), sup.get_supervisor_id(), Time.currentTimeSecs());
List<DataPoint> metrics = new ArrayList<>();
metrics.add(new DataPoint("slotsTotal", sup.get_num_workers()));
metrics.add(new DataPoint("slotsUsed", sup.get_num_used_workers()));
metrics.add(new DataPoint("totalMem", sup.get_total_resources().get(Config.SUPERVISOR_MEMORY_CAPACITY_MB)));
metrics.add(new DataPoint("totalCpu", sup.get_total_resources().get(Config.SUPERVISOR_CPU_CAPACITY)));
metrics.add(new DataPoint("usedMem", sup.get_used_mem()));
metrics.add(new DataPoint("usedCpu", sup.get_used_cpu()));
ret.put(info, metrics);
}
return ret;
}
use of org.apache.storm.metric.api.DataPoint in project storm by apache.
the class LoggingClusterMetricsConsumer method logDataPoints.
private void logDataPoints(Collection<DataPoint> dataPoints, StringBuilder sb, String header) {
for (DataPoint p : dataPoints) {
sb.delete(header.length(), sb.length());
sb.append(p.getName()).append(padding).delete(header.length() + 23, sb.length()).append("\t").append(p.getValue());
LOG.info(sb.toString());
}
}
use of org.apache.storm.metric.api.DataPoint in project storm by apache.
the class LoggingClusterMetricsConsumer method handleDataPoints.
@Override
public void handleDataPoints(SupervisorInfo supervisorInfo, Collection<DataPoint> dataPoints) {
StringBuilder sb = new StringBuilder();
String header = String.format("%d\t%15s\t%40s\t", supervisorInfo.getTimestamp(), supervisorInfo.getSrcSupervisorHost(), supervisorInfo.getSrcSupervisorId());
sb.append(header);
for (DataPoint p : dataPoints) {
sb.delete(header.length(), sb.length());
sb.append(p.getName()).append(padding).delete(header.length() + 23, sb.length()).append("\t").append(p.getValue());
LOG.info(sb.toString());
}
}
Aggregations