public interface RawGcsService
GcsService
should be used.
Methods throw IOException for connection errors etc. that are retryable, and other exceptions for bad requests and similar errors that should not be retried.
Implementing classes handle authentication through mechanisms not exposed in this interface.
Modifier and Type | Interface and Description |
---|---|
static interface |
RawGcsService.RawGcsCreationToken
Immutable token that wraps the information a specific implementation of
RawGcsService needs to write to an object. |
Modifier and Type | Method and Description |
---|---|
RawGcsService.RawGcsCreationToken |
beginObjectCreation(GcsFilename filename,
GcsFileOptions options,
long timeoutMillis) |
Future<RawGcsService.RawGcsCreationToken> |
continueObjectCreationAsync(RawGcsService.RawGcsCreationToken token,
ByteBuffer chunk,
long timeoutMillis)
Reads all remaining bytes from
chunk and writes them to the object and offset specified
by token asynchronously. |
boolean |
deleteObject(GcsFilename filename,
long timeoutMillis)
Returns true if deleted, false if not found.
|
void |
finishObjectCreation(RawGcsService.RawGcsCreationToken token,
ByteBuffer chunk,
long timeoutMillis)
Reads all remaining bytes from
chunk and writes them to the object
and offset specified by token , as the final bytes of the object. |
int |
getChunkSizeBytes()
Calls to
continueObjectCreationAsync(RawGcsCreationToken, ByteBuffer, long)
need to pass fixed size chunks. |
GcsFileMetadata |
getObjectMetadata(GcsFilename filename,
long timeoutMillis)
Returns the meta-data for
filename . |
void |
putObject(GcsFilename filename,
GcsFileOptions options,
ByteBuffer content,
long timeoutMillis)
Create or replace
filename with the given content . |
Future<GcsFileMetadata> |
readObjectAsync(ByteBuffer dst,
GcsFilename filename,
long offset,
long timeoutMillis)
Issues a request to the server to retrieve data to fill the provided buffer.
|
int getChunkSizeBytes()
continueObjectCreationAsync(RawGcsCreationToken, ByteBuffer, long)
need to pass fixed size chunks.
This returns the size expected by the implementation.RawGcsService.RawGcsCreationToken beginObjectCreation(GcsFilename filename, GcsFileOptions options, long timeoutMillis) throws IOException
options
- null means let Google Cloud Storage use its defaultIOException
Future<RawGcsService.RawGcsCreationToken> continueObjectCreationAsync(RawGcsService.RawGcsCreationToken token, ByteBuffer chunk, long timeoutMillis)
chunk
and writes them to the object and offset specified
by token
asynchronously.
Returns a future for a new token to be used to continue writing to the object. Does not mutate
token
.
The number of bytes remaining in chunk
must be a nonzero multiple of
getChunkSizeBytes()
and may be subject to an upper limit that is
implementation-dependent.
On error, does not consume any bytes from chunk
. The write may be retried by making
another call with the same token
. A whole sequence of writes may be retried by using a
previous token (this is useful if the calling code crashes and rolls back to an earlier state).
In both cases, the calling code is responsible for guaranteeing that the byte sequence written
to the object remains identical across retries. (This is because the write may have succeeded
on the backend even though an exception was thrown by this method, and writing different data
on a retry leaves the object in a bad state.)
void finishObjectCreation(RawGcsService.RawGcsCreationToken token, ByteBuffer chunk, long timeoutMillis) throws IOException
chunk
and writes them to the object
and offset specified by token
, as the final bytes of the object.
The object will become readable, and further writes will be rejected.
The number of bytes remaining in chunk
may be subject to an
upper limit that is implementation-dependent.
On error, does not consume any bytes from chunk
. The write may
be retried by making another call with the same token
. A whole
sequence of writes may be retried by using a previous token (this is useful
if the calling code crashes and rolls back to an earlier state). In both
cases, the calling code is responsible for guaranteeing that the byte
sequence written to the object remains identical across retries. (This is
because the write may have succeeded on the backend even though an
exception was thrown by this method, and writing different data on a retry
leaves the object in a bad state.)
IOException
void putObject(GcsFilename filename, GcsFileOptions options, ByteBuffer content, long timeoutMillis) throws IOException
filename
with the given content
.IOException
Future<GcsFileMetadata> readObjectAsync(ByteBuffer dst, GcsFilename filename, long offset, long timeoutMillis)
offset
may not be negative.GcsFileMetadata getObjectMetadata(GcsFilename filename, long timeoutMillis) throws IOException
filename
.IOException
boolean deleteObject(GcsFilename filename, long timeoutMillis) throws IOException
IOException
Copyright © 2014 Google. All Rights Reserved.