Class GapicSpannerRpc (6.66.0)

public class GapicSpannerRpc implements SpannerRpc

Implementation of Cloud Spanner remote calls using Gapic libraries.

Inheritance

java.lang.Object > GapicSpannerRpc

Implements

SpannerRpc

Static Fields

DEFAULT_USER_AGENT

public static final String DEFAULT_USER_AGENT
Field Value
Type Description
String

Static Methods

create(SpannerOptions options)

public static GapicSpannerRpc create(SpannerOptions options)
Parameter
Name Description
options SpannerOptions
Returns
Type Description
GapicSpannerRpc

Constructors

GapicSpannerRpc(SpannerOptions options)

public GapicSpannerRpc(SpannerOptions options)
Parameter
Name Description
options SpannerOptions

Methods

asyncDeleteSession(String sessionName, Map<SpannerRpc.Option,?> options)

public ApiFuture<Empty> asyncDeleteSession(String sessionName, Map<SpannerRpc.Option,?> options)
Parameters
Name Description
sessionName String
options Map<Option,?>
Returns
Type Description
ApiFuture<Empty>

batchCreateSessions(String databaseName, int sessionCount, String databaseRole, Map<String,String> labels, Map<SpannerRpc.Option,?> options)

public List<Session> batchCreateSessions(String databaseName, int sessionCount, String databaseRole, Map<String,String> labels, Map<SpannerRpc.Option,?> options)
Parameters
Name Description
databaseName String
sessionCount int
databaseRole String
labels Map<String,String>
options Map<Option,?>
Returns
Type Description
List<Session>
Exceptions
Type Description
SpannerException

batchWriteAtLeastOnce(BatchWriteRequest request, Map<SpannerRpc.Option,?> options)

public ServerStream<BatchWriteResponse> batchWriteAtLeastOnce(BatchWriteRequest request, Map<SpannerRpc.Option,?> options)
Parameters
Name Description
request BatchWriteRequest
options Map<Option,?>
Returns
Type Description
ServerStream<BatchWriteResponse>

beginTransaction(BeginTransactionRequest request, Map<SpannerRpc.Option,?> options, boolean routeToLeader)

public Transaction beginTransaction(BeginTransactionRequest request, Map<SpannerRpc.Option,?> options, boolean routeToLeader)

Begins a transaction.

Parameters
Name Description
request BeginTransactionRequest
options Map<Option,?>
routeToLeader boolean
Returns
Type Description
Transaction
Exceptions
Type Description
SpannerException

beginTransactionAsync(BeginTransactionRequest request, Map<SpannerRpc.Option,?> options, boolean routeToLeader)

public ApiFuture<Transaction> beginTransactionAsync(BeginTransactionRequest request, Map<SpannerRpc.Option,?> options, boolean routeToLeader)

Begins a transaction asynchronously.

Parameters
Name Description
request BeginTransactionRequest
options Map<Option,?>
routeToLeader boolean
Returns
Type Description
ApiFuture<Transaction>

cancelOperation(String name)

public void cancelOperation(String name)

Cancels the specified long-running operation.

Parameter
Name Description
name String
Exceptions
Type Description
SpannerException

commit(CommitRequest commitRequest, Map<SpannerRpc.Option,?> options)

public CommitResponse commit(CommitRequest commitRequest, Map<SpannerRpc.Option,?> options)
Parameters
Name Description
commitRequest CommitRequest
options Map<Option,?>
Returns
Type Description
CommitResponse
Exceptions
Type Description
SpannerException

commitAsync(CommitRequest request, Map<SpannerRpc.Option,?> options)

public ApiFuture<CommitResponse> commitAsync(CommitRequest request, Map<SpannerRpc.Option,?> options)
Parameters
Name Description
request CommitRequest
options Map<Option,?>
Returns
Type Description
ApiFuture<CommitResponse>

copyBackup(BackupId sourceBackupId, Backup destinationBackup)

public OperationFuture<Backup,CopyBackupMetadata> copyBackup(BackupId sourceBackupId, Backup destinationBackup)

Creates a copy backup from the source backup specified.

Parameters
Name Description
sourceBackupId BackupId
destinationBackup Backup
Returns
Type Description
OperationFuture<Backup,CopyBackupMetadata>
Exceptions
Type Description
SpannerException

createBackup(Backup backupInfo)

public OperationFuture<Backup,CreateBackupMetadata> createBackup(Backup backupInfo)

Creates a new backup from the source database specified in the com.google.cloud.spanner.Backup instance.

Parameter
Name Description
backupInfo Backup
Returns
Type Description
OperationFuture<Backup,CreateBackupMetadata>
Exceptions
Type Description
SpannerException

createDatabase(String instanceName, String createDatabaseStatement, Iterable<String> additionalStatements, Database databaseInfo)

public OperationFuture<Database,CreateDatabaseMetadata> createDatabase(String instanceName, String createDatabaseStatement, Iterable<String> additionalStatements, Database databaseInfo)
Parameters
Name Description
instanceName String
createDatabaseStatement String
additionalStatements Iterable<String>
databaseInfo Database
Returns
Type Description
OperationFuture<Database,CreateDatabaseMetadata>
Exceptions
Type Description
SpannerException

createInstance(String parent, String instanceId, Instance instance)

public OperationFuture<Instance,CreateInstanceMetadata> createInstance(String parent, String instanceId, Instance instance)
Parameters
Name Description
parent String
instanceId String
instance Instance
Returns
Type Description
OperationFuture<Instance,CreateInstanceMetadata>
Exceptions
Type Description
SpannerException

createInstanceConfig(String parent, String instanceConfigId, InstanceConfig instanceConfig, Boolean validateOnly)

public OperationFuture<InstanceConfig,CreateInstanceConfigMetadata> createInstanceConfig(String parent, String instanceConfigId, InstanceConfig instanceConfig, Boolean validateOnly)
Parameters
Name Description
parent String
instanceConfigId String
instanceConfig InstanceConfig
validateOnly Boolean
Returns
Type Description
OperationFuture<InstanceConfig,CreateInstanceConfigMetadata>
Exceptions
Type Description
SpannerException

createSession(String databaseName, String databaseRole, Map<String,String> labels, Map<SpannerRpc.Option,?> options)

public Session createSession(String databaseName, String databaseRole, Map<String,String> labels, Map<SpannerRpc.Option,?> options)
Parameters
Name Description
databaseName String
databaseRole String
labels Map<String,String>
options Map<Option,?>
Returns
Type Description
Session
Exceptions
Type Description
SpannerException

createSession(String databaseName, String databaseRole, Map<String,String> labels, Map<SpannerRpc.Option,?> options, boolean isMultiplexed)

public Session createSession(String databaseName, String databaseRole, Map<String,String> labels, Map<SpannerRpc.Option,?> options, boolean isMultiplexed)
Parameters
Name Description
databaseName String
databaseRole String
labels Map<String,String>
options Map<Option,?>
isMultiplexed boolean
Returns
Type Description
Session
Exceptions
Type Description
SpannerException

deleteBackup(String backupName)

public void deleteBackup(String backupName)

Deletes a pending or completed backup.

Parameter
Name Description
backupName String

deleteInstance(String instanceName)

public void deleteInstance(String instanceName)
Parameter
Name Description
instanceName String
Exceptions
Type Description
SpannerException

deleteInstanceConfig(String instanceConfigName, String etag, Boolean validateOnly)

public void deleteInstanceConfig(String instanceConfigName, String etag, Boolean validateOnly)
Parameters
Name Description
instanceConfigName String
etag String
validateOnly Boolean
Exceptions
Type Description
SpannerException

deleteSession(String sessionName, Map<SpannerRpc.Option,?> options)

public void deleteSession(String sessionName, Map<SpannerRpc.Option,?> options)
Parameters
Name Description
sessionName String
options Map<Option,?>
Exceptions
Type Description
SpannerException

dropDatabase(String databaseName)

public void dropDatabase(String databaseName)
Parameter
Name Description
databaseName String
Exceptions
Type Description
SpannerException

executeBatchDml(ExecuteBatchDmlRequest request, Map<SpannerRpc.Option,?> options)

public ExecuteBatchDmlResponse executeBatchDml(ExecuteBatchDmlRequest request, Map<SpannerRpc.Option,?> options)
Parameters
Name Description
request ExecuteBatchDmlRequest
options Map<Option,?>
Returns
Type Description
ExecuteBatchDmlResponse

executeBatchDmlAsync(ExecuteBatchDmlRequest request, Map<SpannerRpc.Option,?> options)

public ApiFuture<ExecuteBatchDmlResponse> executeBatchDmlAsync(ExecuteBatchDmlRequest request, Map<SpannerRpc.Option,?> options)
Parameters
Name Description
request ExecuteBatchDmlRequest
options Map<Option,?>
Returns
Type Description
ApiFuture<ExecuteBatchDmlResponse>

executePartitionedDml(ExecuteSqlRequest request, Map<SpannerRpc.Option,?> options)

public ResultSet executePartitionedDml(ExecuteSqlRequest request, Map<SpannerRpc.Option,?> options)
Parameters
Name Description
request ExecuteSqlRequest
options Map<Option,?>
Returns
Type Description
ResultSet

executeQuery(ExecuteSqlRequest request, SpannerRpc.ResultStreamConsumer consumer, Map<SpannerRpc.Option,?> options, boolean routeToLeader)

public SpannerRpc.StreamingCall executeQuery(ExecuteSqlRequest request, SpannerRpc.ResultStreamConsumer consumer, Map<SpannerRpc.Option,?> options, boolean routeToLeader)

Executes a query with streaming result.

Parameters
Name Description
request ExecuteSqlRequest
consumer SpannerRpc.ResultStreamConsumer
options Map<Option,?>
routeToLeader boolean
Returns
Type Description
SpannerRpc.StreamingCall

executeQuery(ExecuteSqlRequest request, Map<SpannerRpc.Option,?> options, boolean routeToLeader)

public ResultSet executeQuery(ExecuteSqlRequest request, Map<SpannerRpc.Option,?> options, boolean routeToLeader)

Executes a query.

Parameters
Name Description
request ExecuteSqlRequest
options Map<Option,?>
routeToLeader boolean
Returns
Type Description
ResultSet

executeQueryAsync(ExecuteSqlRequest request, Map<SpannerRpc.Option,?> options, boolean routeToLeader)

public ApiFuture<ResultSet> executeQueryAsync(ExecuteSqlRequest request, Map<SpannerRpc.Option,?> options, boolean routeToLeader)

Executes a query asynchronously.

Parameters
Name Description
request ExecuteSqlRequest
options Map<Option,?>
routeToLeader boolean
Returns
Type Description
ApiFuture<ResultSet>

executeStreamingPartitionedDml(ExecuteSqlRequest request, Map<SpannerRpc.Option,?> options, Duration timeout)

public ServerStream<PartialResultSet> executeStreamingPartitionedDml(ExecuteSqlRequest request, Map<SpannerRpc.Option,?> options, Duration timeout)
Parameters
Name Description
request ExecuteSqlRequest
options Map<Option,?>
timeout org.threeten.bp.Duration
Returns
Type Description
ServerStream<PartialResultSet>

getBackup(String backupName)

public Backup getBackup(String backupName)

Gets the backup with the specified name.

Parameter
Name Description
backupName String
Returns
Type Description
Backup
Exceptions
Type Description
SpannerException

getDatabase(String databaseName)

public Database getDatabase(String databaseName)
Parameter
Name Description
databaseName String
Returns
Type Description
Database
Exceptions
Type Description
SpannerException

getDatabaseAdminIAMPolicy(String resource, GetPolicyOptions options)

public Policy getDatabaseAdminIAMPolicy(String resource, GetPolicyOptions options)

Gets the IAM policy for the given resource using the DatabaseAdminStub.

Parameters
Name Description
resource String
options com.google.iam.v1.GetPolicyOptions
Returns
Type Description
com.google.iam.v1.Policy

getDatabaseAdminStubSettings()

public DatabaseAdminStubSettings getDatabaseAdminStubSettings()

Getter method to obtain the auto-generated database admin client stub settings.

Returns
Type Description
DatabaseAdminStubSettings

getDatabaseDdl(String databaseName)

public GetDatabaseDdlResponse getDatabaseDdl(String databaseName)
Parameter
Name Description
databaseName String
Returns
Type Description
GetDatabaseDdlResponse
Exceptions
Type Description
SpannerException

getExecuteQueryRetrySettings()

public RetrySettings getExecuteQueryRetrySettings()

Returns the retry settings for streaming query operations.

Returns
Type Description
RetrySettings

getExecuteQueryRetryableCodes()

public Set<StatusCode.Code> getExecuteQueryRetryableCodes()

Returns the retryable codes for streaming query operations.

Returns
Type Description
Set<Code>

getInstance(String instanceName)

public Instance getInstance(String instanceName)
Parameter
Name Description
instanceName String
Returns
Type Description
Instance
Exceptions
Type Description
SpannerException

getInstanceAdminIAMPolicy(String resource)

public Policy getInstanceAdminIAMPolicy(String resource)

Gets the IAM policy for the given resource using the InstanceAdminStub.

Parameter
Name Description
resource String
Returns
Type Description
com.google.iam.v1.Policy

getInstanceAdminStubSettings()

public InstanceAdminStubSettings getInstanceAdminStubSettings()

Getter method to obtain the auto-generated instance admin client stub settings.

Returns
Type Description
InstanceAdminStubSettings

getInstanceConfig(String instanceConfigName)

public InstanceConfig getInstanceConfig(String instanceConfigName)
Parameter
Name Description
instanceConfigName String
Returns
Type Description
InstanceConfig
Exceptions
Type Description
SpannerException

getOperation(String name)

public Operation getOperation(String name)

Retrieves a long running operation.

Parameter
Name Description
name String
Returns
Type Description
Operation
Exceptions
Type Description
SpannerException

getPartitionedDmlRetrySettings()

public RetrySettings getPartitionedDmlRetrySettings()
Returns
Type Description
RetrySettings

getReadRetrySettings()

public RetrySettings getReadRetrySettings()

Returns the retry settings for streaming read operations.

Returns
Type Description
RetrySettings

getReadRetryableCodes()

public Set<StatusCode.Code> getReadRetryableCodes()

Returns the retryable codes for streaming read operations.

Returns
Type Description
Set<Code>

isClosed()

public boolean isClosed()
Returns
Type Description
boolean

listBackupOperations(String instanceName, int pageSize, String filter, String pageToken)

public SpannerRpc.Paginated<Operation> listBackupOperations(String instanceName, int pageSize, String filter, String pageToken)

List all long-running backup operations on the given instance.

Parameters
Name Description
instanceName String
pageSize int
filter String
pageToken String
Returns
Type Description
Paginated<Operation>

listBackups(String instanceName, int pageSize, String filter, String pageToken)

public SpannerRpc.Paginated<Backup> listBackups(String instanceName, int pageSize, String filter, String pageToken)

Lists the backups in the specified instance.

Parameters
Name Description
instanceName String
pageSize int
filter String
pageToken String
Returns
Type Description
Paginated<Backup>
Exceptions
Type Description
SpannerException

listDatabaseOperations(String instanceName, int pageSize, String filter, String pageToken)

public SpannerRpc.Paginated<Operation> listDatabaseOperations(String instanceName, int pageSize, String filter, String pageToken)
Parameters
Name Description
instanceName String
pageSize int
filter String
pageToken String
Returns
Type Description
Paginated<Operation>

listDatabaseRoles(String databaseName, int pageSize, String pageToken)

public SpannerRpc.Paginated<DatabaseRole> listDatabaseRoles(String databaseName, int pageSize, String pageToken)
Parameters
Name Description
databaseName String
pageSize int
pageToken String
Returns
Type Description
Paginated<DatabaseRole>

listDatabases(String instanceName, int pageSize, String pageToken)

public SpannerRpc.Paginated<Database> listDatabases(String instanceName, int pageSize, String pageToken)
Parameters
Name Description
instanceName String
pageSize int
pageToken String
Returns
Type Description
Paginated<Database>
Exceptions
Type Description
SpannerException

listInstanceConfigOperations(int pageSize, String filter, String pageToken)

public SpannerRpc.Paginated<Operation> listInstanceConfigOperations(int pageSize, String filter, String pageToken)

List all long-running instance config operations on the given project.

Parameters
Name Description
pageSize int
filter String
pageToken String
Returns
Type Description
Paginated<Operation>

listInstanceConfigs(int pageSize, String pageToken)

public SpannerRpc.Paginated<InstanceConfig> listInstanceConfigs(int pageSize, String pageToken)
Parameters
Name Description
pageSize int
pageToken String
Returns
Type Description
Paginated<InstanceConfig>
Exceptions
Type Description
SpannerException

listInstances(int pageSize, String pageToken, String filter)

public SpannerRpc.Paginated<Instance> listInstances(int pageSize, String pageToken, String filter)
Parameters
Name Description
pageSize int
pageToken String
filter String
Returns
Type Description
Paginated<Instance>
Exceptions
Type Description
SpannerException

partitionQuery(PartitionQueryRequest request, Map<SpannerRpc.Option,?> options)

public PartitionResponse partitionQuery(PartitionQueryRequest request, Map<SpannerRpc.Option,?> options)
Parameters
Name Description
request PartitionQueryRequest
options Map<Option,?>
Returns
Type Description
PartitionResponse
Exceptions
Type Description
SpannerException

partitionRead(PartitionReadRequest request, Map<SpannerRpc.Option,?> options)

public PartitionResponse partitionRead(PartitionReadRequest request, Map<SpannerRpc.Option,?> options)
Parameters
Name Description
request PartitionReadRequest
options Map<Option,?>
Returns
Type Description
PartitionResponse
Exceptions
Type Description
SpannerException

read(ReadRequest request, SpannerRpc.ResultStreamConsumer consumer, Map<SpannerRpc.Option,?> options, boolean routeToLeader)

public SpannerRpc.StreamingCall read(ReadRequest request, SpannerRpc.ResultStreamConsumer consumer, Map<SpannerRpc.Option,?> options, boolean routeToLeader)

Performs a streaming read.

Parameters
Name Description
request ReadRequest
consumer SpannerRpc.ResultStreamConsumer
options Map<Option,?>
routeToLeader boolean
Returns
Type Description
SpannerRpc.StreamingCall

restoreDatabase(Restore restore)

public OperationFuture<Database,RestoreDatabaseMetadata> restoreDatabase(Restore restore)

Restore a backup into the given database.

Parameter
Name Description
restore Restore
Returns
Type Description
OperationFuture<Database,RestoreDatabaseMetadata>

rollback(RollbackRequest request, Map<SpannerRpc.Option,?> options)

public void rollback(RollbackRequest request, Map<SpannerRpc.Option,?> options)
Parameters
Name Description
request RollbackRequest
options Map<Option,?>
Exceptions
Type Description
SpannerException

rollbackAsync(RollbackRequest request, Map<SpannerRpc.Option,?> options)

public ApiFuture<Empty> rollbackAsync(RollbackRequest request, Map<SpannerRpc.Option,?> options)
Parameters
Name Description
request RollbackRequest
options Map<Option,?>
Returns
Type Description
ApiFuture<Empty>

setDatabaseAdminIAMPolicy(String resource, Policy policy)

public Policy setDatabaseAdminIAMPolicy(String resource, Policy policy)

Updates the IAM policy for the given resource using the DatabaseAdminStub. It is highly recommended to first get the current policy and base the updated policy on the returned policy. See Policy.Builder#setEtag(com.google.protobuf.ByteString) for information on the recommended read-modify-write cycle.

Parameters
Name Description
resource String
policy com.google.iam.v1.Policy
Returns
Type Description
com.google.iam.v1.Policy

setInstanceAdminIAMPolicy(String resource, Policy policy)

public Policy setInstanceAdminIAMPolicy(String resource, Policy policy)

Updates the IAM policy for the given resource using the InstanceAdminStub. It is highly recommended to first get the current policy and base the updated policy on the returned policy. See Policy.Builder#setEtag(com.google.protobuf.ByteString) for information on the recommended read-modify-write cycle.

Parameters
Name Description
resource String
policy com.google.iam.v1.Policy
Returns
Type Description
com.google.iam.v1.Policy

shutdown()

public void shutdown()

shutdownNow()

public void shutdownNow()

testDatabaseAdminIAMPermissions(String resource, Iterable<String> permissions)

public TestIamPermissionsResponse testDatabaseAdminIAMPermissions(String resource, Iterable<String> permissions)

Tests the IAM permissions for the given resource using the DatabaseAdminStub.

Parameters
Name Description
resource String
permissions Iterable<String>
Returns
Type Description
com.google.iam.v1.TestIamPermissionsResponse

testInstanceAdminIAMPermissions(String resource, Iterable<String> permissions)

public TestIamPermissionsResponse testInstanceAdminIAMPermissions(String resource, Iterable<String> permissions)

Tests the IAM permissions for the given resource using the InstanceAdminStub.

Parameters
Name Description
resource String
permissions Iterable<String>
Returns
Type Description
com.google.iam.v1.TestIamPermissionsResponse

updateBackup(Backup backup, FieldMask updateMask)

public Backup updateBackup(Backup backup, FieldMask updateMask)

Updates the specified backup. The only supported field for updates is expireTime.

Parameters
Name Description
backup Backup
updateMask FieldMask
Returns
Type Description
Backup

updateDatabase(Database database, FieldMask updateMask)

public OperationFuture<Database,UpdateDatabaseMetadata> updateDatabase(Database database, FieldMask updateMask)

Updates the specified fields of a Cloud Spanner database.

Parameters
Name Description
database Database
updateMask FieldMask
Returns
Type Description
OperationFuture<Database,UpdateDatabaseMetadata>
Exceptions
Type Description
SpannerException

updateDatabaseDdl(Database databaseInfo, Iterable<String> updateDatabaseStatements, String updateId)

public OperationFuture<Empty,UpdateDatabaseDdlMetadata> updateDatabaseDdl(Database databaseInfo, Iterable<String> updateDatabaseStatements, String updateId)

If the update database ddl operation returns an ALREADY_EXISTS error, meaning the operation id used is already in flight, this method will simply resume the original operation. The returned future will be completed when the original operation finishes.

This mechanism is necessary, because the update database ddl can be retried. If a retryable failure occurs, the backend has already started processing the update database ddl operation with the given id and the library issues a retry, an ALREADY_EXISTS error will be returned. If we were to bubble this error up, it would be confusing for the caller, who used originally called the method with a new operation id.

Parameters
Name Description
databaseInfo Database
updateDatabaseStatements Iterable<String>
updateId String
Returns
Type Description
OperationFuture<Empty,UpdateDatabaseDdlMetadata>
Exceptions
Type Description
SpannerException

updateInstance(Instance instance, FieldMask fieldMask)

public OperationFuture<Instance,UpdateInstanceMetadata> updateInstance(Instance instance, FieldMask fieldMask)
Parameters
Name Description
instance Instance
fieldMask FieldMask
Returns
Type Description
OperationFuture<Instance,UpdateInstanceMetadata>
Exceptions
Type Description
SpannerException

updateInstanceConfig(InstanceConfig instanceConfig, Boolean validateOnly, FieldMask fieldMask)

public OperationFuture<InstanceConfig,UpdateInstanceConfigMetadata> updateInstanceConfig(InstanceConfig instanceConfig, Boolean validateOnly, FieldMask fieldMask)
Parameters
Name Description
instanceConfig InstanceConfig
validateOnly Boolean
fieldMask FieldMask
Returns
Type Description
OperationFuture<InstanceConfig,UpdateInstanceConfigMetadata>
Exceptions
Type Description
SpannerException