private void computeStatistics ( TaskInProgress tip , String host , long inputBytes ) { int level = this . maxLevel ; String [ ] splitLocations = tip . getSplitLocations ( ) ; if ( splitLocations . length > 0 ) { Node tracker = topologyCache . getNode ( host ) ; // find the right level across split locations for ( String local : splitLocations ) { Node datanode = topologyCache . getNode ( local ) ; int newLevel = this . maxLevel ; if ( tracker != null && datanode != null ) { newLevel = getMatchingLevelForNodes ( tracker , datanode , maxLevel ) ; } if ( newLevel < level ) { level = newLevel ; if ( level == 0 ) { break ; } } } } boolean updateTaskCountOnly = inputBytes < 0 ; switch ( level ) { case 0 : if ( updateTaskCountOnly ) { LOG . info ( "Chose data-local task " + tip . getTIPId ( ) ) ; jobCounters . incrCounter ( Counter . DATA_LOCAL_MAPS , 1 ) ; jobStats . incNumDataLocalMaps ( ) ; } else { jobCounters . incrCounter ( Counter . LOCAL_MAP_INPUT_BYTES , inputBytes ) ; jobStats . incLocalMapInputBytes ( inputBytes ) ; } break ; case 1 : if ( updateTaskCountOnly ) { LOG . info ( "Chose rack-local task " + tip . getTIPId ( ) ) ; jobCounters . incrCounter ( Counter . RACK_LOCAL_MAPS , 1 ) ; jobStats . incNumRackLocalMaps ( ) ; } else { jobCounters . incrCounter ( Counter . RACK_MAP_INPUT_BYTES , inputBytes ) ; jobStats . incRackMapInputBytes ( inputBytes ) ; } break ; default : LOG . info ( "Chose non-local task " + tip . getTIPId ( ) + " at level " + level ) ; // check if there is any locality if ( updateTaskCountOnly && level != this . maxLevel ) { jobCounters . incrCounter ( Counter . OTHER_LOCAL_MAPS , 1 ) ; } break ; } }
Peform the computation statistics .