Class S3OutputFile
java.lang.Object
dev.hardwood.AbstractOutputFile
dev.hardwood.s3.S3OutputFile
- All Implemented Interfaces:
OutputFile, Closeable, AutoCloseable
An OutputFile that writes one S3 object, created by S3Source.outputFile(String, String).
The object is sent as a multipart upload, or in a single PUT when it is smaller than one
part, and appears at its key only once AbstractOutputFile.close() succeeds. AbstractOutputFile.discard() aborts the upload.
See S3Source.outputFile(String, String) for buffering, size limits and failure handling.
-
Method Summary
Modifier and TypeMethodDescriptionprotected voiddoClose()Publishes the object: onePUT, or the remaining parts and the completion of the multipart upload.protected voiddoCreate()Acquires the destination's resources, such as opening a file channel.protected voidWaits for the part uploads in flight to end and aborts the multipart upload, if one was started.protected voiddoWrite(ByteBuffer data) Appends the remaining bytes ofdata, consuming the buffer.Methods inherited from class AbstractOutputFile
close, create, discard, position, requireClosed, write
-
Method Details
-
doCreate
protected void doCreate()Description copied from class:AbstractOutputFileAcquires the destination's resources, such as opening a file channel. Does nothing by default.- Overrides:
doCreatein classAbstractOutputFile
-
doWrite
Description copied from class:AbstractOutputFileAppends the remaining bytes ofdata, consuming the buffer. Returning with bytes left indatamakeswritethrowIllegalStateException, sinceposition()would no longer match the file.- Specified by:
doWritein classAbstractOutputFile- Parameters:
data- the bytes to append- Throws:
IOException- if the write fails
-
doClose
Publishes the object: onePUT, or the remaining parts and the completion of the multipart upload. When it fails,doDiscard()aborts the upload.- Overrides:
doClosein classAbstractOutputFile- Throws:
IOException- if the file cannot be published; the file then ends discarded
-
doDiscard
Waits for the part uploads in flight to end and aborts the multipart upload, if one was started.
The wait and the abort run with the thread's interrupt status cleared, and the status restored afterwards, so that an interrupted writer still releases its parts.
- Overrides:
doDiscardin classAbstractOutputFile- Throws:
IOException- if the resources cannot be released
-