Package org.apache.avro.file
Class SyncableFileOutputStream
java.lang.Object
java.io.OutputStream
java.io.FileOutputStream
org.apache.avro.file.SyncableFileOutputStream
- All Implemented Interfaces:
Closeable
,Flushable
,AutoCloseable
,Syncable
An implementation of Syncable which writes to a file. An
instance of this class can be used with DataFileWriter to
guarantee that Avro Container Files are persisted to disk on supported
platforms using the DataFileWriter.fSync()
method.
- See Also:
-
Constructor Summary
ConstructorDescriptionSyncableFileOutputStream
(File file) Creates an instance of SyncableFileOutputStream using the given File instance.Creates an instance of SyncableFileOutputStream using the given FileDescriptor instance.SyncableFileOutputStream
(File file, boolean append) Creates an instance of SyncableFileOutputStream that writes to the file represented by the given File instance and optionally append to the file if it already exists.Creates an instance of SyncableFileOutputStream with the given name.SyncableFileOutputStream
(String name, boolean append) Creates an instance of SyncableFileOutputStream with the given name and optionally append to the file if it already exists. -
Method Summary
Methods inherited from class java.io.FileOutputStream
close, finalize, getChannel, getFD, write, write, write
Methods inherited from class java.io.OutputStream
flush, nullOutputStream
-
Constructor Details
-
SyncableFileOutputStream
Creates an instance of SyncableFileOutputStream with the given name.- Parameters:
name
- - the full file name.- Throws:
FileNotFoundException
- - if the file cannot be created or opened.
-
SyncableFileOutputStream
Creates an instance of SyncableFileOutputStream using the given File instance.- Parameters:
file
- - The file to use to create the output stream.- Throws:
FileNotFoundException
- - if the file cannot be created or opened.
-
SyncableFileOutputStream
Creates an instance of SyncableFileOutputStream with the given name and optionally append to the file if it already exists.- Parameters:
name
- - the full file name.append
- - true if the file is to be appended to- Throws:
FileNotFoundException
- - if the file cannot be created or opened.
-
SyncableFileOutputStream
Creates an instance of SyncableFileOutputStream that writes to the file represented by the given File instance and optionally append to the file if it already exists.- Parameters:
file
- - the file instance to use to create the stream.append
- - true if the file is to be appended to- Throws:
FileNotFoundException
- - if the file cannot be created or opened.
-
SyncableFileOutputStream
Creates an instance of SyncableFileOutputStream using the given FileDescriptor instance.
-
-
Method Details
-
sync
Sync the file to disk. On supported platforms, this method behaves like POSIXfsync
and syncs all underlying OS buffers for this file descriptor to disk. On these platforms, if this method returns, the data written to this instance is guaranteed to be persisted on disk.- Specified by:
sync
in interfaceSyncable
- Throws:
IOException
- - if an error occurred while attempting to sync the data to disk.
-