use of org.apache.storm.scheduler.resource.normalization.NormalizedResourceRequest in project storm by apache.
the class Nimbus method addBoltAggStats.
/**
* If aggStats are not populated, compute common and component(bolt) agg and create placeholder stat.
* This allow the topology page to show component spec even the topo is not scheduled.
* Otherwise, just fetch data from current topoPageInfo.
*
* @param topoPageInfo topology page info holding bolt AggStats
* @param topology storm topology used to get bolt names
* @param topoConf storm topology config
* @param includeSys whether to show system bolts
*/
private void addBoltAggStats(TopologyPageInfo topoPageInfo, StormTopology topology, Map<String, Object> topoConf, boolean includeSys) {
Map<String, NormalizedResourceRequest> boltResources = ResourceUtils.getBoltsResources(topology, topoConf);
// if agg stats were not populated yet, create placeholder
if (topoPageInfo.get_id_to_bolt_agg_stats().isEmpty()) {
for (Entry<String, Bolt> entry : topology.get_bolts().entrySet()) {
String boltName = entry.getKey();
Bolt bolt = entry.getValue();
if ((!includeSys && Utils.isSystemId(boltName)) || boltName.equals(Constants.SYSTEM_COMPONENT_ID)) {
continue;
}
// component
ComponentAggregateStats placeholderComponentStats = new ComponentAggregateStats();
placeholderComponentStats.set_type(ComponentType.BOLT);
// common aggregate
CommonAggregateStats commonStats = getPlaceholderCommonAggregateStats(bolt);
commonStats.set_resources_map(boltResources.getOrDefault(boltName, new NormalizedResourceRequest()).toNormalizedMap());
placeholderComponentStats.set_common_stats(commonStats);
// bolt aggregate
BoltAggregateStats boltAggStats = new BoltAggregateStats();
boltAggStats.set_execute_latency_ms(0);
boltAggStats.set_process_latency_ms(0);
boltAggStats.set_executed(0);
boltAggStats.set_capacity(0);
SpecificAggregateStats specificStats = new SpecificAggregateStats();
specificStats.set_bolt(boltAggStats);
placeholderComponentStats.set_specific_stats(specificStats);
topoPageInfo.get_id_to_bolt_agg_stats().put(boltName, placeholderComponentStats);
}
} else {
for (Entry<String, ComponentAggregateStats> entry : topoPageInfo.get_id_to_bolt_agg_stats().entrySet()) {
CommonAggregateStats commonStats = entry.getValue().get_common_stats();
setResourcesDefaultIfNotSet(boltResources, entry.getKey(), topoConf);
commonStats.set_resources_map(boltResources.get(entry.getKey()).toNormalizedMap());
}
}
}
Aggregations