public static List < UITaskMetric > getTaskMetrics ( MetricInfo info , String component , int window ) { TreeMap < Integer , UITaskMetric > taskData = new TreeMap <> ( ) ; if ( info != null ) { for ( Map . Entry < String , Map < Integer , MetricSnapshot > > metric : info . get_metrics ( ) . entrySet ( ) ) { String name = metric . getKey ( ) ; String [ ] split_name = name . split ( "@" ) ; int taskId = JStormUtils . parseInt ( UIMetricUtils . extractTaskId ( split_name ) ) ; String componentName = UIMetricUtils . extractComponentName ( split_name ) ; if ( componentName != null && ! componentName . equals ( component ) ) continue ; //only handle the tasks belongs to the specific component String metricName = UIMetricUtils . extractMetricName ( split_name ) ; String parentComp = null ; if ( metricName != null && metricName . contains ( "." ) ) { parentComp = metricName . split ( "\\." ) [ 0 ] ; metricName = metricName . split ( "\\." ) [ 1 ] ; } if ( ! metric . getValue ( ) . containsKey ( window ) ) { LOG . info ( "task snapshot {} missing window:{}" , metric . getKey ( ) , window ) ; continue ; } MetricSnapshot snapshot = metric . getValue ( ) . get ( window ) ; UITaskMetric taskMetric ; if ( taskData . containsKey ( taskId ) ) { taskMetric = taskData . get ( taskId ) ; } else { taskMetric = new UITaskMetric ( component , taskId ) ; taskData . put ( taskId , taskMetric ) ; } taskMetric . setMetricValue ( snapshot , parentComp , metricName ) ; } } for ( UITaskMetric t : taskData . values ( ) ) { t . mergeValue ( ) ; } return new ArrayList <> ( taskData . values ( ) ) ; }
get all task metrics in the specific component