Class BlobWriteSessionConfigs (2.27.1)

public final class BlobWriteSessionConfigs

Factory class to select and construct BlobWriteSessionConfigs.

There are several strategies which can be used to upload a Blob to Google Cloud Storage. This class provides factories which allow you to select the appropriate strategy for your workload.

Comparison of Strategies
Strategy Factory Method(s) Description Retry Support Transports Supported Cloud Storage API used Considerations
Default (Chunk based upload) #getDefault() Buffer up to a configurable amount of bytes in memory, write to Cloud Storage when full or close. Buffer size is configurable via DefaultBlobWriteSessionConfig#withChunkSize(int) Each chunk is retried up to the limitations specified in StorageOptions#getRetrySettings() gRPC Resumable Upload The network will only be used for the following operations:
  1. Creating the Resumable Upload Session
  2. Transmitting zero or more incremental chunks
  3. Transmitting the final chunk and finalizing the Resumable Upload Session
  4. If any of the above are interrupted with a retryable error, the Resumable Upload Session will be queried to reconcile client side state with Cloud Storage
Buffer to disk then upload Buffer bytes to a temporary file on disk. On close() upload the entire files contents to Cloud Storage. Delete the temporary file. Upload the file in the fewest number of RPC possible retrying within the limitations specified in StorageOptions#getRetrySettings() gRPC Resumable Upload
  1. A Resumable Upload Session will be used to upload the file on disk.
  2. If the upload is interrupted with a retryable error, the Resumable Upload Session will be queried to restart the upload from Cloud Storage's last received byte
Journal to disk while uploading journaling(Collection < Path>) Create a Resumable Upload Session, before transmitting bytes to Cloud Storage write to a recovery file on disk. If the stream to Cloud Storage is interrupted with a retryable error query the offset of the Resumable Upload Session, then open the recovery file from the offset and transmit the bytes to Cloud Storage. gRPC Resumable Upload
  1. The stream to Cloud Storage will be held open until a) the write is complete b) the stream is interrupted
  2. Because the bytes are journaled to disk, the upload to Cloud Storage can only be as fast as the disk.
  3. The use of Compute Engine Local NVMe SSD is strongly encouraged compared to Compute Engine Persistent Disk.
See Also: Storage#blobWriteSession(BlobInfo, BlobWriteOption...), BlobWriteSessionConfig, GrpcStorageOptions.Builder#setBlobWriteSessionConfig(BlobWriteSessionConfig)

Inheritance

java.lang.Object > BlobWriteSessionConfigs

Static Methods

bufferToDiskThenUpload(Path path)

public static BufferToDiskThenUpload bufferToDiskThenUpload(Path path)

Create a new BlobWriteSessionConfig which will first buffer the content of the object to a temporary file under the specified path.

Once the file on disk is closed, the entire file will then be uploaded to Cloud Storage. See Also: Storage#blobWriteSession(BlobInfo, BlobWriteOption...), GrpcStorageOptions.Builder#setBlobWriteSessionConfig(BlobWriteSessionConfig)

Parameter
Name Description
path Path
Returns
Type Description
BufferToDiskThenUpload
Exceptions
Type Description
IOException

bufferToDiskThenUpload(Collection<Path> paths)

public static BufferToDiskThenUpload bufferToDiskThenUpload(Collection<Path> paths)

Create a new BlobWriteSessionConfig which will first buffer the content of the object to a temporary file under one of the specified paths.

Once the file on disk is closed, the entire file will then be uploaded to Cloud Storage.

The specifics of how the work is spread across multiple paths is undefined and subject to change. See Also: Storage#blobWriteSession(BlobInfo, BlobWriteOption...), GrpcStorageOptions.Builder#setBlobWriteSessionConfig(BlobWriteSessionConfig)

Parameter
Name Description
paths Collection<Path>
Returns
Type Description
BufferToDiskThenUpload
Exceptions
Type Description
IOException

bufferToTempDirThenUpload()

public static BlobWriteSessionConfig bufferToTempDirThenUpload()

Create a new BlobWriteSessionConfig which will first buffer the content of the object to a temporary file under java.io.tmpdir.

Once the file on disk is closed, the entire file will then be uploaded to Cloud Storage. See Also: Storage#blobWriteSession(BlobInfo, BlobWriteOption...), GrpcStorageOptions.Builder#setBlobWriteSessionConfig(BlobWriteSessionConfig)

Returns
Type Description
BlobWriteSessionConfig
Exceptions
Type Description
IOException

getDefault()

public static DefaultBlobWriteSessionConfig getDefault()

Factory to produce the default configuration for uploading an object to Cloud Storage.

Configuration of the chunk size can be performed via DefaultBlobWriteSessionConfig#withChunkSize(int). See Also: GrpcStorageDefaults#getDefaultStorageWriterConfig()

Returns
Type Description
DefaultBlobWriteSessionConfig

journaling(Collection<Path> paths)

public static JournalingBlobWriteSessionConfig journaling(Collection<Path> paths)

Create a new BlobWriteSessionConfig which will journal writes to a temporary file under one of the specified paths before transmitting the bytes to Cloud Storage.

The specifics of how the work is spread across multiple paths is undefined and subject to change. See Also: Storage#blobWriteSession(BlobInfo, BlobWriteOption...), GrpcStorageOptions.Builder#setBlobWriteSessionConfig(BlobWriteSessionConfig)

Parameter
Name Description
paths Collection<Path>
Returns
Type Description
JournalingBlobWriteSessionConfig