long tryToGetOutputSize ( TaskAttemptID taskId , JobConf conf ) { try { TaskInProgress tip ; synchronized ( this ) { tip = tasks . get ( taskId ) ; } if ( tip == null ) return - 1 ; if ( ! tip . getTask ( ) . isMapTask ( ) || tip . getRunState ( ) != TaskStatus . State . SUCCEEDED ) { return - 1 ; } MapOutputFile mapOutputFile = new MapOutputFile ( ) ; mapOutputFile . setJobId ( taskId . getJobID ( ) ) ; mapOutputFile . setConf ( conf ) ; // In simulation mode, maps/reduces complete instantly and don't produce // any output if ( this . simulatedTaskMode ) { return 0 ; } Path tmp_output = null ; try { tmp_output = mapOutputFile . getOutputFile ( taskId ) ; } catch ( DiskErrorException dex ) { if ( LOG . isDebugEnabled ( ) ) { LOG . debug ( "Error getting map output of a task " + taskId , dex ) ; } } if ( tmp_output == null ) return 0 ; FileSystem localFS = FileSystem . getLocal ( conf ) ; FileStatus stat = localFS . getFileStatus ( tmp_output ) ; if ( stat == null ) return 0 ; else return stat . getLen ( ) ; } catch ( IOException e ) { LOG . info ( e ) ; return - 1 ; } }
Try to get the size of output for this task . Returns - 1 if it can t be found .