Class LocalDataOutputStream
- java.lang.Object
-
- java.io.OutputStream
-
- org.apache.flink.core.fs.FSDataOutputStream
-
- org.apache.flink.core.fs.local.LocalDataOutputStream
-
- All Implemented Interfaces:
Closeable,Flushable,AutoCloseable
@Internal public class LocalDataOutputStream extends FSDataOutputStream
TheLocalDataOutputStreamclass is a wrapper class for a data output stream to the local file system.
-
-
Constructor Summary
Constructors Constructor Description LocalDataOutputStream(File file)Constructs a newLocalDataOutputStreamobject from a givenFileobject.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Closes the output stream.voidflush()Flushes the stream, writing any data currently buffered in stream implementation to the proper output stream.longgetPos()Gets the position of the stream (non-negative), defined as the number of bytes from the beginning of the file to the current writing position.voidsync()Flushes the data all the way to the persistent non-volatile storage (for example disks).voidwrite(byte[] b)voidwrite(byte[] b, int off, int len)voidwrite(int b)-
Methods inherited from class java.io.OutputStream
nullOutputStream
-
-
-
-
Constructor Detail
-
LocalDataOutputStream
public LocalDataOutputStream(File file) throws IOException
Constructs a newLocalDataOutputStreamobject from a givenFileobject.- Parameters:
file- theFileobject the data stream is read from- Throws:
IOException- thrown if the data output stream cannot be created
-
-
Method Detail
-
write
public void write(int b) throws IOException- Specified by:
writein classOutputStream- Throws:
IOException
-
write
public void write(@Nonnull byte[] b) throws IOException
- Overrides:
writein classOutputStream- Throws:
IOException
-
write
public void write(byte[] b, int off, int len) throws IOException- Overrides:
writein classOutputStream- Throws:
IOException
-
close
public void close() throws IOExceptionDescription copied from class:FSDataOutputStreamCloses the output stream. After this method returns, the implementation must guarantee that all data written to the stream is persistent/visible, as defined in theclass-level docs.The above implies that the method must block until persistence can be guaranteed. For example for distributed replicated file systems, the method must block until the replication quorum has been reached. If the calling thread is interrupted in the process, it must fail with an
IOExceptionto indicate that persistence cannot be guaranteed.If this method throws an exception, the data in the stream cannot be assumed to be persistent.
Implementation note: This overrides the method defined in
OutputStreamas abstract to force implementations of theFSDataOutputStreamto implement this method directly.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Specified by:
closein classFSDataOutputStream- Throws:
IOException- Thrown, if an error occurred while closing the stream or guaranteeing that the data is persistent.
-
flush
public void flush() throws IOExceptionDescription copied from class:FSDataOutputStreamFlushes the stream, writing any data currently buffered in stream implementation to the proper output stream. After this method has been called, the stream implementation must not hold onto any buffered data any more.A completed flush does not mean that the data is necessarily persistent. Data persistence can is only assumed after calls to
FSDataOutputStream.close()orFSDataOutputStream.sync().Implementation note: This overrides the method defined in
OutputStreamas abstract to force implementations of theFSDataOutputStreamto implement this method directly.- Specified by:
flushin interfaceFlushable- Specified by:
flushin classFSDataOutputStream- Throws:
IOException- Thrown if an I/O error occurs while flushing the stream.
-
sync
public void sync() throws IOExceptionDescription copied from class:FSDataOutputStreamFlushes the data all the way to the persistent non-volatile storage (for example disks). The method behaves similar to the fsync function, forcing all data to be persistent on the devices.- Specified by:
syncin classFSDataOutputStream- Throws:
IOException- Thrown if an I/O error occurs
-
getPos
public long getPos() throws IOExceptionDescription copied from class:FSDataOutputStreamGets the position of the stream (non-negative), defined as the number of bytes from the beginning of the file to the current writing position. The position corresponds to the zero-based index of the next byte that will be written.This method must report accurately report the current position of the stream. Various components of the high-availability and recovery logic rely on the accurate
- Specified by:
getPosin classFSDataOutputStream- Returns:
- The current position in the stream, defined as the number of bytes from the beginning of the file to the current writing position.
- Throws:
IOException- Thrown if an I/O error occurs while obtaining the position from the stream implementation.
-
-