/** * aggregate spout stats. * * @param statsSeq a seq of ExecutorStats * @param includeSys whether to include system streams * @return aggregated spout stats: {metric -> win -> global stream id -> value} */ public static Map<String, Map> aggregateSpoutStats(List<ExecutorSummary> statsSeq, boolean includeSys) { // actually Map<String, Map<String, Map<String, Long/Double>>> Map<String, Map> ret = new HashMap<>(); Map<String, Map<String, Map<String, Long>>> commonStats = aggregateCommonStats(statsSeq); // filter sys streams if necessary commonStats = preProcessStreamSummary(commonStats, includeSys); List<Map<String, Map<String, Long>>> acked = new ArrayList<>(); List<Map<String, Map<String, Long>>> failed = new ArrayList<>(); List<Map<String, Map<String, Double>>> completeLatencies = new ArrayList<>(); for (ExecutorSummary summary : statsSeq) { ExecutorStats stats = summary.get_stats(); acked.add(stats.get_specific().get_spout().get_acked()); failed.add(stats.get_specific().get_spout().get_failed()); completeLatencies.add(stats.get_specific().get_spout().get_complete_ms_avg()); } ret.putAll(commonStats); ((Map) ret).put(ACKED, aggregateCounts(acked)); ((Map) ret).put(FAILED, aggregateCounts(failed)); ((Map) ret).put(COMP_LATENCIES, aggregateAverages(completeLatencies, acked)); return ret; }
/** * convert thrift ExecutorStats structure into a java HashMap. */ public static Map<String, Object> convertExecutorStats(ExecutorStats stats) { Map<String, Object> ret = new HashMap<>(); ret.put(EMITTED, stats.get_emitted()); ret.put(TRANSFERRED, stats.get_transferred()); ret.put(RATE, stats.get_rate()); if (stats.get_specific().is_set_bolt()) { ret.putAll(convertSpecificStats(stats.get_specific().get_bolt())); ret.put(TYPE, ClientStatsUtil.BOLT); } else { ret.putAll(convertSpecificStats(stats.get_specific().get_spout())); ret.put(TYPE, ClientStatsUtil.SPOUT); } return ret; }
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");
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");
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");
SpoutStats spoutStats = executorSpecificStats.get_spout(); Map<String, Long> acked = spoutStats.get_acked().get(":all-time"); if (acked != null) {
if (exec.get_stats() != null && exec.get_stats().get_specific() != null && exec.get_stats().get_specific().is_set_spout()) { 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");
if (stats != null) { if (stats.get_specific().is_set_spout()) { SpoutStats ss = stats.get_specific().get_spout(); Map<String, Long> failedMap = ss.get_failed().get(":all-time"); if (failedMap != null) {