public void commit ( ) throws IOException { // assures we perform the close operation only once. if ( open . compareAndSet ( true , false ) ) { // flush & close fout . force ( true ) ; fout . close ( ) ; // if the current file exists, and append is true, then append samples and remove temp file // otherwise write header and move tmp file to target boolean exists = Files . exists ( target ) ; if ( logger . isInfoEnabled ( ) ) { logger . info ( "Finishing recording ...... append: " + append + " exists: " + exists + " target:" + target ) ; } if ( append && exists ) { appendSamples ( target , temp ) ; writeHeader ( target ) ; Files . delete ( temp ) ; } else { writeHeader ( temp ) ; Files . move ( temp , target , StandardCopyOption . REPLACE_EXISTING ) ; } } }
Commit this sink . Causes to prevent any further write operations and commits temporary file to target . When this returns Sink is done and cannot be used again .