@Override
	public void close() throws IOException {

		// enforce sequential close() calls
		synchronized (CLOSE_MUTEX) {
			try {
				this.recordWriter.close(this.context);
			} catch (InterruptedException e) {
				throw new IOException("Could not close RecordReader.", e);
			}

			if (this.outputCommitter.needsTaskCommit(this.context)) {
				this.outputCommitter.commitTask(this.context);
			}

			Path outputPath = new Path(this.configuration.get("mapred.output.dir"));

			// rename tmp-file to final name
			FileSystem fs = FileSystem.get(outputPath.toUri(), this.configuration);

			String taskNumberStr = Integer.toString(this.taskNumber);
			String tmpFileTemplate = "tmp-r-00000";
			String tmpFile = tmpFileTemplate.substring(0, 11 - taskNumberStr.length()) + taskNumberStr;

			if (fs.exists(new Path(outputPath.toString() + "/" + tmpFile))) {
				fs.rename(new Path(outputPath.toString() + "/" + tmpFile), new Path(outputPath.toString() + "/" + taskNumberStr));
			}
		}
	}
@ Override public void close ( ) throws IOException { synchronized ( CLOSE_MUTEX ) { try { this . recordWriter . close ( this . context ) ; } catch ( InterruptedException e ) { throw new IOException ( "Could not close RecordReader." , e ) ; } if ( this . outputCommitter . needsTaskCommit ( this . context ) ) { this . outputCommitter . commitTask ( this . context ) ; } Path outputPath = new Path ( this . configuration . get ( "mapred.output.dir" ) ) ; FileSystem fs = FileSystem . get ( outputPath . toUri ( ) , this . configuration ) ; String taskNumberStr = Integer . toString ( this . taskNumber ) ; String tmpFileTemplate = "tmp-r-00000" ; String tmpFile = tmpFileTemplate . substring ( 0 , 11 - taskNumberStr . length ( ) ) + taskNumberStr ; if ( fs . exists ( new Path ( outputPath . toString ( ) + "/" + tmpFile ) ) ) { fs . rename ( new Path ( outputPath . toString ( ) + "/" + tmpFile ) , new Path ( outputPath . toString ( ) + "/" + taskNumberStr ) ) ; } } }
commit the task by moving the output file out from the temporary directory.
@throws java.io.IOException