Package org.apache.hadoop.hdfs.util
Class AtomicFileOutputStream
java.lang.Object
java.io.OutputStream
java.io.FilterOutputStream
org.apache.hadoop.hdfs.util.AtomicFileOutputStream
- All Implemented Interfaces:
Closeable,Flushable,AutoCloseable
A FileOutputStream that has the property that it will only show
up at its destination once it has been entirely written and flushed
to disk. While being written, it will use a .tmp suffix.
When the output stream is closed, it is flushed, fsynced, and
will be moved into place, overwriting any file that already
exists at that location.
NOTE: on Windows platforms, it will not atomically
replace the target file - instead the target file is deleted
before this one is moved into place.
-
Field Summary
Fields inherited from class java.io.FilterOutputStream
out -
Constructor Summary
Constructors -
Method Summary
Methods inherited from class java.io.FilterOutputStream
flush, write, write, writeMethods inherited from class java.io.OutputStream
nullOutputStream
-
Constructor Details
-
AtomicFileOutputStream
- Throws:
FileNotFoundException
-
-
Method Details
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classFilterOutputStream- Throws:
IOException
-
abort
public void abort()Close the atomic file, but do not "commit" the temporary file on top of the destination. This should be used if there is a failure in writing.
-