private void extractMetrics(Map<String, ComponentMetric> metricMap, List<Map<String, ?>> components, String topologyJsonID) { for (Map<String, ?> component : components) { String name = (String) component.get(topologyJsonID); String componentId = StormTopologyUtil.extractStreamlineComponentId(name); ComponentMetric metric = extractMetric(name, component); metricMap.put(componentId, metric); } }
private ComponentMetric extractMetric(String componentName, Map<String, ?> componentMap) { Long inputRecords = getLongValueOrDefault(componentMap, STATS_JSON_EXECUTED_TUPLES, 0L); Long outputRecords = getLongValueOrDefault(componentMap, STATS_JSON_EMITTED_TUPLES, 0L); Long failedRecords = getLongValueOrDefault(componentMap, STATS_JSON_FAILED_TUPLES, 0L); Double processedTime = getDoubleValueFromStringOrDefault(componentMap, STATS_JSON_PROCESS_LATENCY, 0.0d); return new ComponentMetric(StormTopologyUtil.extractStreamlineComponentName(componentName), inputRecords, outputRecords, failedRecords, processedTime); }
Map<String, ?> responseMap = getTopologyInfo(topologyId, asUser); for (Map<String, ?> topoStats : topologyStatsList) { String windowStr = (String) topoStats.get(TOPOLOGY_JSON_WINDOW); Long window = convertWindowString(windowStr, uptimeSeconds); if (smallestWindow > window) { smallestWindow = window; Long acked = getLongValueOrDefault(topologyStatsMap, STATS_JSON_ACKED_TUPLES, 0L); Long failedRecords = getLongValueOrDefault(topologyStatsMap, STATS_JSON_FAILED_TUPLES, 0L); Double completeLatency = getDoubleValueFromStringOrDefault(topologyStatsMap, STATS_JSON_COMPLETE_LATENCY, 0.0d); Long emittedTotal = getLongValueOrDefault(topologyStatsMap, STATS_JSON_EMITTED_TUPLES, 0L); Long transferred = getLongValueOrDefault(topologyStatsMap, STATS_JSON_TRANSFERRED_TUPLES, 0L); Long errorsTotal = getErrorCountFromAllComponents(topologyId, spouts, bolts, asUser);
/** * {@inheritDoc} */ @Override public Map<String, ComponentMetric> getMetricsForTopology(TopologyLayout topology, String asUser) { String topologyId = StormTopologyUtil.findStormTopologyId(client, topology.getId(), asUser); if (StringUtils.isEmpty(topologyId)) { throw new TopologyNotAliveException("Topology not found in Storm Cluster - topology id: " + topology.getId()); } Map<String, ?> responseMap = getTopologyInfo(topologyId, asUser); Map<String, ComponentMetric> metricMap = new HashMap<>(); List<Map<String, ?>> spouts = (List<Map<String, ?>>) responseMap.get(TOPOLOGY_JSON_SPOUTS); extractMetrics(metricMap, spouts, TOPOLOGY_JSON_SPOUT_ID); List<Map<String, ?>> bolts = (List<Map<String, ?>>) responseMap.get(TOPOLOGY_JSON_BOLTS); extractMetrics(metricMap, bolts, TOPOLOGY_JSON_BOLT_ID); return metricMap; }
Map componentStats = getComponentInfo(topologyId, componentId, asUser); List<?> componentErrors = (List<?>) componentStats.get(TOPOLOGY_JSON_COMPONENT_ERRORS); if (componentErrors != null && !componentErrors.isEmpty()) {