Package alluxio.underfs.oss
Class OSSOutputStream
- java.lang.Object
-
- java.io.OutputStream
-
- alluxio.underfs.oss.OSSOutputStream
-
- All Implemented Interfaces:
java.io.Closeable,java.io.Flushable,java.lang.AutoCloseable
@NotThreadSafe public final class OSSOutputStream extends java.io.OutputStreamA stream for writing a file into OSS. The data will be persisted to a temporary directory on the local disk and copied as a complete file when theclose()method is called.
-
-
Constructor Summary
Constructors Constructor Description OSSOutputStream(java.lang.String bucketName, java.lang.String key, com.aliyun.oss.OSS client, java.util.List<java.lang.String> tmpDirs)Creates a name instance ofOSSOutputStream.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Closes this output stream.voidflush()Flushes this output stream and forces any buffered output bytes to be written out.voidwrite(byte[] b)Writes the given byte array to this output stream.voidwrite(byte[] b, int off, int len)Writes the given number of bytes from the given byte array starting at the given offset to this output stream.voidwrite(int b)Writes the given bytes to this output stream.
-
-
-
Constructor Detail
-
OSSOutputStream
public OSSOutputStream(java.lang.String bucketName, java.lang.String key, com.aliyun.oss.OSS client, java.util.List<java.lang.String> tmpDirs) throws java.io.IOExceptionCreates a name instance ofOSSOutputStream.- Parameters:
bucketName- the name of the bucketkey- the key of the fileclient- the client for OSStmpDirs- a list of temporary directories- Throws:
java.io.IOException
-
-
Method Detail
-
write
public void write(int b) throws java.io.IOExceptionWrites the given bytes to this output stream. Before close, the bytes are all written to local file.- Specified by:
writein classjava.io.OutputStream- Parameters:
b- the bytes to write- Throws:
java.io.IOException
-
write
public void write(byte[] b) throws java.io.IOExceptionWrites the given byte array to this output stream. Before close, the bytes are all written to local file.- Overrides:
writein classjava.io.OutputStream- Parameters:
b- the byte array- Throws:
java.io.IOException
-
write
public void write(byte[] b, int off, int len) throws java.io.IOExceptionWrites the given number of bytes from the given byte array starting at the given offset to this output stream. Before close, the bytes are all written to local file.- Overrides:
writein classjava.io.OutputStream- Parameters:
b- the byte arrayoff- the start offset in the datalen- the number of bytes to write- Throws:
java.io.IOException
-
flush
public void flush() throws java.io.IOExceptionFlushes this output stream and forces any buffered output bytes to be written out. Before close, the data are flushed to local file.- Specified by:
flushin interfacejava.io.Flushable- Overrides:
flushin classjava.io.OutputStream- Throws:
java.io.IOException
-
close
public void close() throws java.io.IOExceptionCloses this output stream. When an output stream is closed, the local temporary file is uploaded to OSS Service. Once the file is uploaded, the temporary file is deleted.- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable- Overrides:
closein classjava.io.OutputStream- Throws:
java.io.IOException
-
-