Top Description Constructors Methods
org.apache.avro.file

public Class SyncableFileOutputStream

extends FileOutputStream
implements Syncable
Class Inheritance
All Implemented Interfaces
org.apache.avro.file.Syncable
Imports
java.io.File, .FileDescriptor, .FileNotFoundException, .FileOutputStream, .IOException

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 org.apache.avro.file.DataFileWriter#fSync() method.
See Also
FileOutputStream

Constructor Summary

AccessConstructor and Description
public
SyncableFileOutputStream(String
- the full file name.
name
)

Creates an instance of SyncableFileOutputStream with the given name.

public
SyncableFileOutputStream(File
- The file to use to create the output stream.
file
)

Creates an instance of SyncableFileOutputStream using the given File instance.

public
SyncableFileOutputStream(String
- the full file name.
name
,
boolean
- true if the file is to be appended to
append
)

Creates an instance of SyncableFileOutputStream with the given name and optionally append to the file if it already exists.

public
SyncableFileOutputStream(File
- the file instance to use to create the stream.
file
,
boolean
- true if the file is to be appended to
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.

public
SyncableFileOutputStream(FileDescriptor fdObj)

Creates an instance of SyncableFileOutputStream using the given FileDescriptor instance.

Method Summary

Modifier and TypeMethod and Description
public void
sync()

Implements org.apache.avro.file.Syncable.sync.

Sync the file to disk.
Inherited from java.io.FileOutputStream:
closegetChannelgetFDwritewritewrite

Constructor Detail

SyncableFileOutputStreamback to summary
public SyncableFileOutputStream(String name) throws FileNotFoundException

Creates an instance of SyncableFileOutputStream with the given name.

Parameters
name:String

- the full file name.

Exceptions
FileNotFoundException:
- if the file cannot be created or opened.
SyncableFileOutputStreamback to summary
public SyncableFileOutputStream(File file) throws FileNotFoundException

Creates an instance of SyncableFileOutputStream using the given File instance.

Parameters
file:File

- The file to use to create the output stream.

Exceptions
FileNotFoundException:
- if the file cannot be created or opened.
SyncableFileOutputStreamback to summary
public SyncableFileOutputStream(String name, boolean append) throws FileNotFoundException

Creates an instance of SyncableFileOutputStream with the given name and optionally append to the file if it already exists.

Parameters
name:String

- the full file name.

append:boolean

- true if the file is to be appended to

Exceptions
FileNotFoundException:
- if the file cannot be created or opened.
SyncableFileOutputStreamback to summary
public SyncableFileOutputStream(File file, boolean append) throws FileNotFoundException

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:File

- the file instance to use to create the stream.

append:boolean

- true if the file is to be appended to

Exceptions
FileNotFoundException:
- if the file cannot be created or opened.
SyncableFileOutputStreamback to summary
public SyncableFileOutputStream(FileDescriptor fdObj)

Creates an instance of SyncableFileOutputStream using the given FileDescriptor instance.

Method Detail

syncback to summary
public void sync() throws IOException

Implements org.apache.avro.file.Syncable.sync.

Doc from org.apache.avro.file.Syncable.sync.

Sync the file to disk. On supported platforms, this method behaves like POSIX fsync 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.

Annotations
@Override
Exceptions
IOException:
- if an error occurred while attempting to sync the data to disk.