Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -32,28 +32,27 @@ public static void main(String[] args) {
}

static void deleteBlob(String bucketName, String blobName) {
// Update the retry settings
// Customize retry behavior
RetrySettings retrySettings =
StorageOptions.getDefaultRetrySettings()
.toBuilder()
// to set the max number of attempts to 10
// Set the max number of attempts to 10 (initial attempt plus 9 retries)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this part can just be "(default=1)" to show that the default number of attempts is 1.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The default number of attempts is 6, so that'd be 5 retries.

.setMaxAttempts(10)
// to set the backoff multiplier to 3.0
// Set the backoff multiplier to 3.0
.setRetryDelayMultiplier(3.0)
// to set the max duration of all attempts to 5 minutes
// Set the max duration of all attempts to 5 minutes
.setTotalTimeout(Duration.ofMinutes(5))
.build();

StorageOptions alwaysRetryStorageOptions =
StorageOptions.newBuilder()
// Configure our options so all requests will be retried even if they are
// non-idempotent.
// Customize retry so all requests are retried even if they are non-idempotent.
.setStorageRetryStrategy(StorageRetryStrategy.getUniformStorageRetryStrategy())
// provide the previously configured retrySettings
.setRetrySettings(retrySettings)
.build();

// Instantiate a client with our options
// Instantiate a client
Storage storage = alwaysRetryStorageOptions.getService();

// Delete the blob
Expand Down