public interface GcsServiceAllows creating and accessing files in Google Cloud Storage. This class uses the
RetryParamsthat were passed to
GcsServiceFactory. This is used for all of the methods provided by this class. So an
RetriesExhaustedExceptionmeans that these have failed. Retry logic is handled internally to this class, because while writing to the
GcsOutputChannela request can span the boundaries of segments written to
RawGcsService. As a result a write call could partly succeed, making error recovery at an application level next to impossible. Reading, deleting, and gettingMetadata are all idempotent operations. However for symmetry and convenience the
RetryParamsare applied to these calls as well.
All Methods Instance Methods Abstract Methods Modifier and Type Method and Description
compose(Iterable<String> source, GcsFilename dest)Concatenates a list of existing files into a new file in the same bucket.
copy(GcsFilename source, GcsFilename dest)Copies a file to a specified location.
createOrReplace(GcsFilename filename, GcsFileOptions options)Creates a new object.
createOrReplace(GcsFilename filename, GcsFileOptions options, ByteBuffer src)Creates, writes, and closes a new object with a given content.
delete(GcsFilename filename)Deletes a file.
list(String bucket, ListOptions options)Retrieves a list of objects.
openPrefetchingReadChannel(GcsFilename filename, long startPosition, int blockSizeBytes)Same as
openReadChannel, but buffers data in memory and prefetches it before it is required to avoid blocking on most read calls.
openReadChannel(GcsFilename filename, long startPosition)Note that the implementation may check if the file exists during the call to
openReadChannel, or only check it when the first byte is requested.
update(GcsFilename source, GcsFileOptions options)Updates a file's metadata with the given options.
GcsOutputChannel createOrReplace(GcsFilename filename, GcsFileOptions options) throws IOExceptionCreates a new object. The content of the file will only be available after the channel was closed.
void createOrReplace(GcsFilename filename, GcsFileOptions options, ByteBuffer src) throws IOExceptionCreates, writes, and closes a new object with a given content. This is equivalent to calling
createOrReplace(GcsFilename, GcsFileOptions), then
GcsOutputChannel.write(ByteBuffer), and finally
GcsOutputChannel.close(), but will try to minimize the underlying RPC calls.