Package alluxio.underfs.cos
Class COSOutputStream
- java.lang.Object
-
- java.io.OutputStream
-
- alluxio.underfs.cos.COSOutputStream
-
- All Implemented Interfaces:
java.io.Closeable,java.io.Flushable,java.lang.AutoCloseable
@NotThreadSafe public final class COSOutputStream extends java.io.OutputStreamA stream for writing a file into COS. 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 COSOutputStream(java.lang.String bucketName, java.lang.String key, com.qcloud.cos.COSClient client, java.util.List<java.lang.String> tmpDirs)Creates a name instance ofCOSOutputStream.
-
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
-
COSOutputStream
public COSOutputStream(java.lang.String bucketName, java.lang.String key, com.qcloud.cos.COSClient client, java.util.List<java.lang.String> tmpDirs) throws java.io.IOExceptionCreates a name instance ofCOSOutputStream.- Parameters:
bucketName- the name of the bucketkey- the key of the fileclient- the client for COStmpDirs- a list of possible 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 COS 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
-
-