public class RemoteStorageHelper extends Object
getOptions()
()} method. Returned options have custom ServiceOptions.getRetrySettings()
: RetrySettings.getMaxAttempts()
is 10
, RetrySettings.getMaxRetryDelay()
is 30000
, RetrySettings.getTotalTimeout()
is
120000
and RetrySettings.getInitialRetryDelay()
is 250
. HttpTransportOptions.getConnectTimeout()
and HttpTransportOptions.getReadTimeout()
are
both set to 60000
.Modifier and Type | Class and Description |
---|---|
static class |
RemoteStorageHelper.StorageHelperException |
Modifier and Type | Method and Description |
---|---|
static void |
cleanBuckets(Storage storage,
long olderThan,
long timeoutMs) |
static RemoteStorageHelper |
create()
Creates a
RemoteStorageHelper object using default project id and authentication
credentials. |
static RemoteStorageHelper |
create(String projectId,
InputStream keyStream)
Creates a
RemoteStorageHelper object for the given project id and JSON key input
stream. |
static void |
forceDelete(Storage storage,
String bucket)
Deletes a bucket, even if non-empty.
|
static Boolean |
forceDelete(Storage storage,
String bucket,
long timeout,
TimeUnit unit)
Deletes a bucket, even if non-empty.
|
static Boolean |
forceDelete(Storage storage,
String bucket,
long timeout,
TimeUnit unit,
String userProject)
Deletes a bucket, even if non-empty.
|
static String |
generateBucketName()
Returns a bucket name generated using a random UUID.
|
StorageOptions |
getOptions()
Returns a
StorageOptions object to be used for testing. |
public StorageOptions getOptions()
StorageOptions
object to be used for testing.public static void cleanBuckets(Storage storage, long olderThan, long timeoutMs)
public static Boolean forceDelete(Storage storage, String bucket, long timeout, TimeUnit unit) throws InterruptedException, ExecutionException
timeout
expires. To allow for the timeout, this method uses a
separate thread to send the delete requests. Use forceDelete(Storage storage, String
bucket)
if spawning an additional thread is undesirable, such as in the App Engine production
runtime.storage
- the storage service to be used to issue requestsbucket
- the bucket to be deletedtimeout
- the maximum time to waitunit
- the time unit of the timeout argumentInterruptedException
- if the thread deleting the bucket is interrupted while waitingExecutionException
- if an exception was thrown while deleting bucket or bucket objectspublic static Boolean forceDelete(Storage storage, String bucket, long timeout, TimeUnit unit, String userProject) throws InterruptedException, ExecutionException
timeout
expires. To allow for the timeout, this method uses a
separate thread to send the delete requests. Use forceDelete(Storage storage, String
bucket)
if spawning an additional thread is undesirable, such as in the App Engine production
runtime.storage
- the storage service to be used to issue requestsbucket
- the bucket to be deletedtimeout
- the maximum time to waitunit
- the time unit of the timeout argumentuserProject
- the project to bill for requester-pays buckets (or "")InterruptedException
- if the thread deleting the bucket is interrupted while waitingExecutionException
- if an exception was thrown while deleting bucket or bucket objectspublic static void forceDelete(Storage storage, String bucket)
storage
- the storage service to be used to issue requestsbucket
- the bucket to be deletedStorageException
- if an exception is encountered during bucket deletionpublic static String generateBucketName()
public static RemoteStorageHelper create(String projectId, InputStream keyStream) throws RemoteStorageHelper.StorageHelperException
RemoteStorageHelper
object for the given project id and JSON key input
stream.projectId
- id of the project to be used for running the testskeyStream
- input stream for a JSON keyRemoteStorageHelper
object for the provided optionsRemoteStorageHelper.StorageHelperException
- if keyStream
is not a valid JSON key streampublic static RemoteStorageHelper create() throws RemoteStorageHelper.StorageHelperException
RemoteStorageHelper
object using default project id and authentication
credentials.Copyright © 2019 Google LLC. All rights reserved.