commit the task by moving the output file out from the temporary directory.
@throws java.io.IOException
161504
@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));
			}
		}
	}
968910
public void commit ()
    {
        // first clear our target
        clearTarget();

        // then post this event onto the queue (but only if we actually
        // accumulated some events)
        int size = _events.size();
        switch (size) {
        case 0: // nothing doing
            break;
        case 1: // no point in being compound
            _omgr.postEvent(_events.get(0));
            break;
        default: // now we're talking
            _transport = _events.get(0).getTransport();
            for (int ii = 1; ii < size; ii++) {
                _transport = _events.get(ii).getTransport().combine(_transport);
            }
            _omgr.postEvent(this);
            break;
        }
    }
1121973
public void close() throws IOException {

        writeStream.close();

        if (!writeFile.delete()) {
            throw new IOException(
                RB.singleton.getString(
                    RB.WORKFILE_DELETE_FAIL, writeFile.getAbsolutePath()));
        }
    }
681
private void finishTask(TaskControllerContext context,
      TaskCommands command) throws IOException{
    if(context.task == null) {
      LOG.info("Context task null not killing the JVM");
      return;
    }
    ShellCommandExecutor shExec = buildTaskControllerExecutor(
        command, context.env.conf.getUser(), 
        buildKillTaskCommandArgs(context), context.env.workDir,
        context.env.env);
    try {
      shExec.execute();
    } catch (Exception e) {
      LOG.warn("Output from task-contoller is : " + shExec.getOutput());
      throw new IOException(e);
    }
  }
1358672
public final static void move(File fromFile, File toFile)
            throws IOException {
        // try the simple way first.
        if (fromFile.renameTo(toFile)) {
            return;
        }

        // copy to the temp file, then rename to the desired name.
        checkThatFileDoesntExist(toFile);
        File tempFile = createTempFile(toFile);
        checkThatFileDoesntExist(tempFile);
        copy(fromFile, tempFile);
        tempFile.renameTo(toFile);
        // delete the old one
        if (!fromFile.delete()) {
            throw new IOException("Failed to delete '" + fromFile.getParent()
                    + "'");
        }
    }
606698
private void commit() {

        m_selectionDone = true;
        if (!m_filesToUpload.isEmpty()) {
            m_okButton.disable(Messages.get().key(Messages.GUI_UPLOAD_BUTTON_OK_DISABLE_UPLOADING_0));
            if (m_uploadButton instanceof UIObject) {
                ((UIObject)m_uploadButton).getElement().getStyle().setDisplay(Display.NONE);
            }
            showProgress();
            submit();
        }
    }
913104
private synchronized void setFile()
        throws IOException
    {
        // Check directory
        File file = new File(_filename);
        _filename=file.getCanonicalPath();
        file=new File(_filename);
        File dir= new File(file.getParent());
        if (!dir.isDirectory() || !dir.canWrite())
            throw new IOException("Cannot write log directory "+dir);
            
        Date now=new Date();
        
        // Is this a rollover file?
        String filename=file.getName();
        int i=filename.toLowerCase().indexOf(YYYY_MM_DD);
        if (i>=0)
        {
            file=new File(dir,
                          filename.substring(0,i)+
                          _fileDateFormat.format(now)+
                          filename.substring(i+YYYY_MM_DD.length()));
        }
            
        if (file.exists()&&!file.canWrite())
            throw new IOException("Cannot write log file "+file);

        // Do we need to change the output stream?
        if (out==null || !file.equals(_file))
        {
            // Yep
            _file=file;
            if (!_append && file.exists())
                file.renameTo(new File(file.toString()+"."+_fileBackupFormat.format(now)));
            OutputStream oldOut=out;
            out=new FileOutputStream(file.toString(),_append);
            if (oldOut!=null)
                oldOut.close();
            if(log.isDebugEnabled())log.debug("Opened "+_file);
        }
    }
806345
def commit(self, cont = False):
        

        self.journal.close()
        self.journal = None
        os.remove(self.j_file)

        for itm in os.listdir(self.tmp_dir): os.remove(cpjoin(self.tmp_dir, itm))

        if cont is True: self.begin()
1308966
void commit()
        throws IOException
    {
        if (_writer!=null && _writer.isWritten())
            _writer.flush();
        else
            _httpResponse.commit();
    }
5163
@Override
    public void commit() throws DataCorruptedException, IOException, IllegalStateException{
        try {
            tranManager.commit(t1);
        } catch (RollbackException e) {
            rollback();
            throw new IOException("Error trying to commit transaction.", e);
        } catch (TransactionException e) {
            rollback();
            throw new IOException("Error trying to commit transaction.", e);
        }
    }
869903
public void writeTo(OutputStream out) throws IOException {
        out.write(this.content);
        out.flush();
        out.close();
    }
59466
@Override
  public void commit()
      throws IOException {
    this.closer.close();

    setStagingFileGroup();

    if (!this.fs.exists(this.stagingFile)) {
      throw new IOException(String.format("File %s does not exist", this.stagingFile));
    }

    FileStatus stagingFileStatus = this.fs.getFileStatus(this.stagingFile);

    // Double check permission of staging file
    if (!stagingFileStatus.getPermission().equals(this.filePermission)) {
      this.fs.setPermission(this.stagingFile, this.filePermission);
    }

    this.bytesWritten = Optional.of(Long.valueOf(stagingFileStatus.getLen()));

    LOG.info(String.format("Moving data from %s to %s", this.stagingFile, this.outputFile));
    // For the same reason as deleting the staging file if it already exists, overwrite
    // the output file if it already exists to prevent task retry from being blocked.
    HadoopUtils.renamePath(this.fileContext, this.stagingFile, this.outputFile, true);

    // The staging file is moved to the output path in commit, so rename to add record count after that
    if (this.shouldIncludeRecordCountInFileName) {
      String filePathWithRecordCount = addRecordCountToFileName();
      this.properties.appendToSetProp(this.allOutputFilesPropName, filePathWithRecordCount);
    } else {
      this.properties.appendToSetProp(this.allOutputFilesPropName, getOutputFilePath());
    }

    FsWriterMetrics metrics = new FsWriterMetrics(
        this.id,
        new PartitionIdentifier(this.partitionKey, this.branchId),
        ImmutableSet.of(new FsWriterMetrics.FileInfo(this.outputFile.getName(), recordsWritten()))
    );
    this.properties.setProp(FS_WRITER_METRICS_KEY, metrics.toJson());
 }
675186
public void writeTo (@Nonnull @WillNotClose final OutputStream aOS) throws IOException
  {
    // we may only need to check if this is closed if we are working with a file
    // but we should force the habit of closing whether we are working with
    // a file or memory.
    if (!m_bClosed)
      throw new IOException ("This stream is not closed");

    if (isInMemory ())
    {
      m_aMemoryOS.writeTo (aOS);
    }
    else
    {
      final InputStream aIS = FileHelper.getInputStream (m_aOutputFile);
      StreamHelper.copyInputStreamToOutputStream (aIS, aOS);
    }
  }
733211
@Override
	public void close() throws IOException {
		this.recordWriter.close(new DummyHadoopReporter());
		if (this.fileOutputCommitterWrapper.needsTaskCommit(this.jobConf, TaskAttemptID.forName(this.jobConf.get("mapred.task.id")))) {
			this.fileOutputCommitterWrapper.commitTask(this.jobConf, TaskAttemptID.forName(this.jobConf.get("mapred.task.id")));
		}
	//TODO: commitjob when all the tasks are finished
	}
293295
@Override
    public void commit()
        throws HeuristicMixedException,
               HeuristicRollbackException,
               RollbackException,
               SystemException
    {
        try {
            if (!Context.isTMNoTransaction()) {
                if (Context.isTMActive()) {
                    Context.commit();
                } else {
                    Context.rollback();
                }
            }
        } catch (final EFapsException e) {
            throw new SystemException(e.getMessage());
        }
    }
767274
public void commit ()
        throws PersistenceException
    {
        // only write ourselves out if we've changed
        if (_storedTileSetID == _nextTileSetID) {
            return;
        }

        try {
            BufferedWriter bout = new BufferedWriter(new FileWriter(_mapfile));
            // write out our metadata
            String tline = "" + _nextTileSetID;
            bout.write(tline, 0, tline.length());
            bout.newLine();
            // write out our mappings
            writeMapFile(bout, _map);
            bout.close();

        } catch (IOException ioe) {
            String errmsg = "Failure writing map file.";
            throw new PersistenceException(errmsg, ioe);
        }
    }
369561
@SuppressWarnings("unchecked")
  void commit() {
    // Execute any tasks that were queue during execution of the command.
    if (!tasks.isEmpty()) {
      for (ServerTask task : tasks) {
        context.update(context.index(), context.clock().instant(), ServerStateMachineContext.Type.COMMAND);
        try {
          task.future.complete(task.callback.get());
        } catch (Exception e) {
          task.future.completeExceptionally(e);
        }
      }
      tasks.clear();
    }
    context.commit();
  }