Skip to content

Commit 9760fa3

Browse files
committed
docs: update BlobAppendableUpload.AppendableUploadWriteableByteChannel to indicate it is non-blocking
1 parent c15e110 commit 9760fa3

File tree

1 file changed

+34
-4
lines changed

1 file changed

+34
-4
lines changed

google-cloud-storage/src/main/java/com/google/cloud/storage/BlobAppendableUpload.java

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import com.google.cloud.storage.Storage.BlobWriteOption;
2424
import java.io.IOException;
2525
import java.nio.ByteBuffer;
26+
import java.nio.channels.ClosedChannelException;
2627
import java.nio.channels.WritableByteChannel;
2728
import java.util.concurrent.TimeUnit;
2829

@@ -90,14 +91,38 @@ public interface BlobAppendableUpload extends BlobWriteSession {
9091
* <p>This interface allows writing bytes to an Appendable Upload, and provides methods to close
9192
* this channel -- optionally finalizing the upload.
9293
*
94+
* <p>The {@link #write(ByteBuffer)} method of this channel is non-blocking.
95+
*
9396
* @since 2.51.0 This new api is in preview and is subject to breaking changes.
9497
*/
9598
@BetaApi
9699
@InternalExtensionOnly
97100
interface AppendableUploadWriteableByteChannel extends WritableByteChannel {
98101

99102
/**
100-
* Finalize the upload and close this instance to further {@link #write(ByteBuffer)}ing. This
103+
* <b>This method is non-blocking</b>
104+
*
105+
* <p>Consume as many bytes as can fit in the underlying outbound queue. The size of the
106+
* outbound queue is determined from {@link BlobAppendableUploadConfig#getFlushPolicy()}{@code
107+
* .}{@link FlushPolicy#getMaxPendingBytes() getMaxPendingBytes()}. If the outbound queue is
108+
* full, and can not fit more bytes, this method will return 0.
109+
*
110+
* <p>This method may be invoked at any time. If another thread has already initiated a write
111+
* operation upon this channel, however, then an invocation of this method will block until the
112+
* first operation is complete.
113+
*
114+
* @param src The buffer from which bytes are to be retrieved
115+
* @return The number of bytes written, possibly zero
116+
* @throws ClosedChannelException If this channel is closed
117+
* @throws IOException If some other I/O error occurs
118+
*/
119+
@Override
120+
int write(ByteBuffer src) throws IOException;
121+
122+
/**
123+
* <b>This method is blocking</b>
124+
*
125+
* <p>Finalize the upload and close this instance to further {@link #write(ByteBuffer)}ing. This
101126
* will close any underlying stream and release any releasable resources once out of scope.
102127
*
103128
* <p>Once this method is called, and returns no more writes to the object will be allowed by
@@ -116,8 +141,11 @@ interface AppendableUploadWriteableByteChannel extends WritableByteChannel {
116141
void finalizeAndClose() throws IOException;
117142

118143
/**
119-
* Close this instance to further {@link #write(ByteBuffer)}ing without finalizing the upload.
120-
* This will close any underlying stream and release any releasable resources once out of scope.
144+
* <b>This method is blocking</b>
145+
*
146+
* <p>Close this instance to further {@link #write(ByteBuffer)}ing without finalizing the
147+
* upload. This will close any underlying stream and release any releasable resources once out
148+
* of scope.
121149
*
122150
* <p>This method, {@link AppendableUploadWriteableByteChannel#finalizeAndClose()} and {@link
123151
* AppendableUploadWriteableByteChannel#close()} are mutually exclusive. If one of the other
@@ -133,7 +161,9 @@ interface AppendableUploadWriteableByteChannel extends WritableByteChannel {
133161
void closeWithoutFinalizing() throws IOException;
134162

135163
/**
136-
* Close this instance to further {@link #write(ByteBuffer)}ing.
164+
* <b>This method is blocking</b>
165+
*
166+
* <p>Close this instance to further {@link #write(ByteBuffer)}ing.
137167
*
138168
* <p>Whether the upload is finalized during this depends on the {@link
139169
* BlobAppendableUploadConfig#getCloseAction()} provided to create the {@link

0 commit comments

Comments
 (0)