Search in sources :

Example 1 with DataPoint

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;
}
Also used : DataPoint(org.apache.storm.metric.api.DataPoint) ArrayList(java.util.ArrayList) SupervisorSummary(org.apache.storm.generated.SupervisorSummary) TopologySummary(org.apache.storm.generated.TopologySummary) DataPoint(org.apache.storm.metric.api.DataPoint)

Example 2 with DataPoint

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());
        }
    }
}
Also used : ClusterInfo(org.apache.storm.metric.api.IClusterMetricsConsumer.ClusterInfo) DataPoint(org.apache.storm.metric.api.DataPoint) ClusterSummary(org.apache.storm.generated.ClusterSummary) ArrayList(java.util.ArrayList) List(java.util.List) ClusterMetricsConsumerExecutor(org.apache.storm.metric.ClusterMetricsConsumerExecutor) SupervisorInfo(org.apache.storm.generated.SupervisorInfo)

Example 3 with DataPoint

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;
}
Also used : HashMap(java.util.HashMap) DataPoint(org.apache.storm.metric.api.DataPoint) IClusterMetricsConsumer(org.apache.storm.metric.api.IClusterMetricsConsumer) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) SupervisorSummary(org.apache.storm.generated.SupervisorSummary) SupervisorInfo(org.apache.storm.generated.SupervisorInfo)

Example 4 with DataPoint

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());
    }
}
Also used : DataPoint(org.apache.storm.metric.api.DataPoint)

Example 5 with DataPoint

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());
    }
}
Also used : DataPoint(org.apache.storm.metric.api.DataPoint)

Aggregations

DataPoint (org.apache.storm.metric.api.DataPoint)5 ArrayList (java.util.ArrayList)3 List (java.util.List)2 SupervisorInfo (org.apache.storm.generated.SupervisorInfo)2 SupervisorSummary (org.apache.storm.generated.SupervisorSummary)2 HashMap (java.util.HashMap)1 ClusterSummary (org.apache.storm.generated.ClusterSummary)1 TopologySummary (org.apache.storm.generated.TopologySummary)1 ClusterMetricsConsumerExecutor (org.apache.storm.metric.ClusterMetricsConsumerExecutor)1 IClusterMetricsConsumer (org.apache.storm.metric.api.IClusterMetricsConsumer)1 ClusterInfo (org.apache.storm.metric.api.IClusterMetricsConsumer.ClusterInfo)1