Interface SpannerRpc (6.66.0)

public interface SpannerRpc extends ServiceRpc

Abstracts remote calls to the Cloud Spanner service. Typically end-consumer code will never use this interface; it's main purpose is to abstract the implementation of the public Cloud Spanner API from the underlying transport mechanism.

Each SpannerRPC instance is bound to a particular project and set of authorization credentials.

The interface is currently defined in terms of the generated HTTP client model classes. This is purely for expedience; a future version of this interface is likely to be independent of transport to allow switching between gRPC and HTTP.

Implements

com.google.cloud.ServiceRpc

Methods

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

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

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

public abstract 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 abstract 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 abstract Transaction beginTransaction(BeginTransactionRequest request, Map<SpannerRpc.Option,?> options, boolean routeToLeader)

Begins a transaction.

Parameters
Name Description
request BeginTransactionRequest
options Map<Option,?>
routeToLeader boolean

Set to true to route the request to the leader region, and false to route the request to any region. When leader aware routing is enabled, RW/PDML requests are preferred to be routed to the leader region, and RO requests (except for PartitionRead/PartitionQuery) are preferred to be routed to any region for optimal latency.

Returns
Type Description
Transaction
Exceptions
Type Description
SpannerException

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

public abstract 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

Set to true to route the request to the leader region, and false to route the request to any region. When leader aware routing is enabled, RW/PDML requests are preferred to be routed to the leader region, and RO requests (except for PartitionRead/PartitionQuery) are preferred to be routed to any region for optimal latency.

Returns
Type Description
ApiFuture<Transaction>

cancelOperation(String name)

public abstract 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 abstract 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 commitRequest, Map<SpannerRpc.Option,?> options)

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

copyBackup(BackupId sourceBackupId, Backup destinationBackup)

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

Creates a copy backup from the source backup specified.

Parameters
Name Description
sourceBackupId BackupId
destinationBackup Backup

the backup to create. The instance, database, and expireTime fields of the backup must be filled. It may also optionally have an encryption config set. If no encryption config has been set, the new backup will use the same encryption config as the source backup.

Returns
Type Description
OperationFuture<Backup,CopyBackupMetadata>

the operation that monitors the backup creation.

createBackup(Backup backupInfo)

public abstract 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

the backup to create. The instance, database and expireTime fields of the backup must be filled.

Returns
Type Description
OperationFuture<Backup,CreateBackupMetadata>

the operation that monitors the backup creation.

Exceptions
Type Description
SpannerException

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

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

createInstance(String parent, String instanceId, Instance instance)

public abstract 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 default 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 abstract 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 default 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 abstract void deleteBackup(String backupName)

Deletes a pending or completed backup.

Parameter
Name Description
backupName String

Required. The fully qualified name of the backup to delete.

deleteInstance(String instanceName)

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

deleteInstanceConfig(String instanceConfigName, String etag, Boolean validateOnly)

public default 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 abstract void deleteSession(String sessionName, Map<SpannerRpc.Option,?> options)
Parameters
Name Description
sessionName String
options Map<Option,?>
Exceptions
Type Description
SpannerException

dropDatabase(String databaseName)

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

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

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

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

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

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

public abstract 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 abstract 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

Set to true to route the request to the leader region, and false to route the request to any region. When leader aware routing is enabled, RW/PDML requests are preferred to be routed to the leader region, and RO requests (except for PartitionRead/PartitionQuery) are preferred to be routed to any region for optimal latency.

Returns
Type Description
SpannerRpc.StreamingCall

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

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

Executes a query.

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

Set to true to route the request to the leader region, and false to route the request to any region. When leader aware routing is enabled, RW/PDML requests are preferred to be routed to the leader region, and RO requests (except for PartitionRead/PartitionQuery) are preferred to be routed to any region for optimal latency.

Returns
Type Description
ResultSet

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

public abstract 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

Set to true to route the request to the leader region, and false to route the request to any region. When leader aware routing is enabled, RW/PDML requests are preferred to be routed to the leader region, and RO requests (except for PartitionRead/PartitionQuery) are preferred to be routed to any region for optimal latency.

Returns
Type Description
ApiFuture<ResultSet>

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

public abstract 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 abstract 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 abstract Database getDatabase(String databaseName)
Parameter
Name Description
databaseName String
Returns
Type Description
Database
Exceptions
Type Description
SpannerException

getDatabaseAdminIAMPolicy(String resource, GetPolicyOptions options)

public abstract 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 default DatabaseAdminStubSettings getDatabaseAdminStubSettings()

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

Returns
Type Description
DatabaseAdminStubSettings

DatabaseAdminStubSettings

getDatabaseDdl(String databaseName)

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

getExecuteQueryRetrySettings()

public default RetrySettings getExecuteQueryRetrySettings()

Returns the retry settings for streaming query operations.

Returns
Type Description
RetrySettings

getExecuteQueryRetryableCodes()

public default Set<StatusCode.Code> getExecuteQueryRetryableCodes()

Returns the retryable codes for streaming query operations.

Returns
Type Description
Set<Code>

getInstance(String instanceName)

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

getInstanceAdminIAMPolicy(String resource)

public abstract 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 default InstanceAdminStubSettings getInstanceAdminStubSettings()

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

Returns
Type Description
InstanceAdminStubSettings

InstanceAdminStubSettings

getInstanceConfig(String instanceConfigName)

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

getOperation(String name)

public abstract Operation getOperation(String name)

Retrieves a long running operation.

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

getPartitionedDmlRetrySettings()

public abstract RetrySettings getPartitionedDmlRetrySettings()
Returns
Type Description
RetrySettings

getReadRetrySettings()

public default RetrySettings getReadRetrySettings()

Returns the retry settings for streaming read operations.

Returns
Type Description
RetrySettings

getReadRetryableCodes()

public default Set<StatusCode.Code> getReadRetryableCodes()

Returns the retryable codes for streaming read operations.

Returns
Type Description
Set<Code>

isClosed()

public abstract boolean isClosed()
Returns
Type Description
boolean

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

public abstract 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