Search in sources :

Example 6 with ClusterSummary

use of org.apache.storm.generated.ClusterSummary in project storm by apache.

the class HdfsSpoutTopology method printMetrics.

static void printMetrics(Nimbus.Client client, String name) throws Exception {
    ClusterSummary summary = client.getClusterInfo();
    String id = null;
    for (TopologySummary ts : summary.get_topologies()) {
        if (name.equals(ts.get_name())) {
            id = ts.get_id();
        }
    }
    if (id == null) {
        throw new Exception("Could not find a topology named " + name);
    }
    TopologyInfo info = client.getTopologyInfo(id);
    int uptime = info.get_uptime_secs();
    long acked = 0;
    long failed = 0;
    double weightedAvgTotal = 0.0;
    for (ExecutorSummary exec : info.get_executors()) {
        if ("spout".equals(exec.get_component_id())) {
            SpoutStats stats = exec.get_stats().get_specific().get_spout();
            Map<String, Long> failedMap = stats.get_failed().get(":all-time");
            Map<String, Long> ackedMap = stats.get_acked().get(":all-time");
            Map<String, Double> avgLatMap = stats.get_complete_ms_avg().get(":all-time");
            for (String key : ackedMap.keySet()) {
                if (failedMap != null) {
                    Long tmp = failedMap.get(key);
                    if (tmp != null) {
                        failed += tmp;
                    }
                }
                long ackVal = ackedMap.get(key);
                double latVal = avgLatMap.get(key) * ackVal;
                acked += ackVal;
                weightedAvgTotal += latVal;
            }
        }
    }
    double avgLatency = weightedAvgTotal / acked;
    System.out.println("uptime: " + uptime + " acked: " + acked + " avgLatency: " + avgLatency + " acked/sec: " + (((double) acked) / uptime + " failed: " + failed));
}
Also used : ClusterSummary(org.apache.storm.generated.ClusterSummary) ExecutorSummary(org.apache.storm.generated.ExecutorSummary) TopologySummary(org.apache.storm.generated.TopologySummary) SpoutStats(org.apache.storm.generated.SpoutStats) TopologyInfo(org.apache.storm.generated.TopologyInfo)

Example 7 with ClusterSummary

use of org.apache.storm.generated.ClusterSummary 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)

Aggregations

ClusterSummary (org.apache.storm.generated.ClusterSummary)7 TopologySummary (org.apache.storm.generated.TopologySummary)5 ArrayList (java.util.ArrayList)3 List (java.util.List)2 NimbusSummary (org.apache.storm.generated.NimbusSummary)2 SupervisorSummary (org.apache.storm.generated.SupervisorSummary)2 TopologyInfo (org.apache.storm.generated.TopologyInfo)2 Joiner (com.google.common.base.Joiner)1 ImmutableMap (com.google.common.collect.ImmutableMap)1 Lists (com.google.common.collect.Lists)1 PrintWriter (java.io.PrintWriter)1 StringWriter (java.io.StringWriter)1 Collections (java.util.Collections)1 Comparator (java.util.Comparator)1 EnumSet (java.util.EnumSet)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 LinkedList (java.util.LinkedList)1 Map (java.util.Map)1 NavigableMap (java.util.NavigableMap)1