Class GapicSpannerRpc (6.23.4)

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
TypeDescription
String

Static Methods

create(SpannerOptions options)

public static GapicSpannerRpc create(SpannerOptions options)
Parameter
NameDescription
optionsSpannerOptions
Returns
TypeDescription
GapicSpannerRpc

Constructors

GapicSpannerRpc(SpannerOptions options)

public GapicSpannerRpc(SpannerOptions options)
Parameter
NameDescription
optionsSpannerOptions

Methods

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

public ApiFuture<Empty> asyncDeleteSession(String sessionName, Map<SpannerRpc.Option,?> options)
Parameters
NameDescription
sessionNameString
optionsMap<Option,?>
Returns
TypeDescription
ApiFuture<Empty>

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

public List<Session> batchCreateSessions(String databaseName, int sessionCount, Map<String,String> labels, Map<SpannerRpc.Option,?> options)
Parameters
NameDescription
databaseNameString
sessionCountint
labelsMap<String,String>
optionsMap<Option,?>
Returns
TypeDescription
List<Session>
Exceptions
TypeDescription
SpannerException

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

public Transaction beginTransaction(BeginTransactionRequest request, Map<SpannerRpc.Option,?> options)
Parameters
NameDescription
requestBeginTransactionRequest
optionsMap<Option,?>
Returns
TypeDescription
Transaction
Exceptions
TypeDescription
SpannerException

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

public ApiFuture<Transaction> beginTransactionAsync(BeginTransactionRequest request, Map<SpannerRpc.Option,?> options)
Parameters
NameDescription
requestBeginTransactionRequest
optionsMap<Option,?>
Returns
TypeDescription
ApiFuture<Transaction>

cancelOperation(String name)

public void cancelOperation(String name)

Cancels the specified long-running operation.

Parameter
NameDescription
nameString
Exceptions
TypeDescription
SpannerException

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

public CommitResponse commit(CommitRequest commitRequest, Map<SpannerRpc.Option,?> options)
Parameters
NameDescription
commitRequestCommitRequest
optionsMap<Option,?>
Returns
TypeDescription
CommitResponse
Exceptions
TypeDescription
SpannerException

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

public ApiFuture<CommitResponse> commitAsync(CommitRequest request, Map<SpannerRpc.Option,?> options)
Parameters
NameDescription
requestCommitRequest
optionsMap<Option,?>
Returns
TypeDescription
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
NameDescription
sourceBackupIdBackupId
destinationBackupBackup
Returns
TypeDescription
OperationFuture<Backup,CopyBackupMetadata>
Exceptions
TypeDescription
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
NameDescription
backupInfoBackup
Returns
TypeDescription
OperationFuture<Backup,CreateBackupMetadata>
Exceptions
TypeDescription
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
NameDescription
instanceNameString
createDatabaseStatementString
additionalStatementsIterable<String>
databaseInfoDatabase
Returns
TypeDescription
OperationFuture<Database,CreateDatabaseMetadata>
Exceptions
TypeDescription
SpannerException

createInstance(String parent, String instanceId, Instance instance)

public OperationFuture<Instance,CreateInstanceMetadata> createInstance(String parent, String instanceId, Instance instance)
Parameters
NameDescription
parentString
instanceIdString
instanceInstance
Returns
TypeDescription
OperationFuture<Instance,CreateInstanceMetadata>
Exceptions
TypeDescription
SpannerException

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

public Session createSession(String databaseName, Map<String,String> labels, Map<SpannerRpc.Option,?> options)
Parameters
NameDescription
databaseNameString
labelsMap<String,String>
optionsMap<Option,?>
Returns
TypeDescription
Session
Exceptions
TypeDescription
SpannerException

deleteBackup(String backupName)

public void deleteBackup(String backupName)

Deletes a pending or completed backup.

Parameter
NameDescription
backupNameString

deleteInstance(String instanceName)

public void deleteInstance(String instanceName)
Parameter
NameDescription
instanceNameString
Exceptions
TypeDescription
SpannerException

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

public void deleteSession(String sessionName, Map<SpannerRpc.Option,?> options)
Parameters
NameDescription
sessionNameString
optionsMap<Option,?>
Exceptions
TypeDescription
SpannerException

dropDatabase(String databaseName)

public void dropDatabase(String databaseName)
Parameter
NameDescription
databaseNameString
Exceptions
TypeDescription
SpannerException

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

public ExecuteBatchDmlResponse executeBatchDml(ExecuteBatchDmlRequest request, Map<SpannerRpc.Option,?> options)
Parameters
NameDescription
requestExecuteBatchDmlRequest
optionsMap<Option,?>
Returns
TypeDescription
ExecuteBatchDmlResponse

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

public ApiFuture<ExecuteBatchDmlResponse> executeBatchDmlAsync(ExecuteBatchDmlRequest request, Map<SpannerRpc.Option,?> options)
Parameters
NameDescription
requestExecuteBatchDmlRequest
optionsMap<Option,?>
Returns
TypeDescription
ApiFuture<ExecuteBatchDmlResponse>

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

public ResultSet executePartitionedDml(ExecuteSqlRequest request, Map<SpannerRpc.Option,?> options)
Parameters
NameDescription
requestExecuteSqlRequest
optionsMap<Option,?>
Returns
TypeDescription
ResultSet

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

public SpannerRpc.StreamingCall executeQuery(ExecuteSqlRequest request, SpannerRpc.ResultStreamConsumer consumer, Map<SpannerRpc.Option,?> options)
Parameters
NameDescription
requestExecuteSqlRequest
consumerSpannerRpc.ResultStreamConsumer
optionsMap<Option,?>
Returns
TypeDescription
SpannerRpc.StreamingCall

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

public ResultSet executeQuery(ExecuteSqlRequest request, Map<SpannerRpc.Option,?> options)
Parameters
NameDescription
requestExecuteSqlRequest
optionsMap<Option,?>
Returns
TypeDescription
ResultSet

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

public ApiFuture<ResultSet> executeQueryAsync(ExecuteSqlRequest request, Map<SpannerRpc.Option,?> options)
Parameters
NameDescription
requestExecuteSqlRequest
optionsMap<Option,?>
Returns
TypeDescription
ApiFuture<ResultSet>

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

public ServerStream<PartialResultSet> executeStreamingPartitionedDml(ExecuteSqlRequest request, Map<SpannerRpc.Option,?> options, Duration timeout)
Parameters
NameDescription
requestExecuteSqlRequest
optionsMap<Option,?>
timeoutorg.threeten.bp.Duration
Returns
TypeDescription
ServerStream<PartialResultSet>

getBackup(String backupName)

public Backup getBackup(String backupName)

Gets the backup with the specified name.

Parameter
NameDescription
backupNameString
Returns
TypeDescription
Backup
Exceptions
TypeDescription
SpannerException

getDatabase(String databaseName)

public Database getDatabase(String databaseName)
Parameter
NameDescription
databaseNameString
Returns
TypeDescription
Database
Exceptions
TypeDescription
SpannerException

getDatabaseAdminIAMPolicy(String resource)

public Policy getDatabaseAdminIAMPolicy(String resource)

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

Parameter
NameDescription
resourceString
Returns
TypeDescription
com.google.iam.v1.Policy

getDatabaseDdl(String databaseName)

public List<String> getDatabaseDdl(String databaseName)
Parameter
NameDescription
databaseNameString
Returns
TypeDescription
List<String>
Exceptions
TypeDescription
SpannerException

getInstance(String instanceName)

public Instance getInstance(String instanceName)
Parameter
NameDescription
instanceNameString
Returns
TypeDescription
Instance
Exceptions
TypeDescription
SpannerException

getInstanceAdminIAMPolicy(String resource)

public Policy getInstanceAdminIAMPolicy(String resource)

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

Parameter
NameDescription
resourceString
Returns
TypeDescription
com.google.iam.v1.Policy

getInstanceConfig(String instanceConfigName)

public InstanceConfig getInstanceConfig(String instanceConfigName)
Parameter
NameDescription
instanceConfigNameString
Returns
TypeDescription
InstanceConfig
Exceptions
TypeDescription
SpannerException

getOperation(String name)

public Operation getOperation(String name)

Retrieves a long running operation.

Parameter
NameDescription
nameString
Returns
TypeDescription
Operation
Exceptions
TypeDescription
SpannerException

getPartitionedDmlRetrySettings()

public RetrySettings getPartitionedDmlRetrySettings()
Returns
TypeDescription
RetrySettings

isClosed()

public boolean isClosed()
Returns
TypeDescription
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
NameDescription
instanceNameString
pageSizeint
filterString
pageTokenString
Returns
TypeDescription
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
NameDescription
instanceNameString
pageSizeint
filterString
pageTokenString
Returns
TypeDescription
Paginated<Backup>
Exceptions
TypeDescription
SpannerException

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

public SpannerRpc.Paginated<Operation> listDatabaseOperations(String instanceName, int pageSize, String filter, String pageToken)
Parameters
NameDescription
instanceNameString
pageSizeint
filterString
pageTokenString
Returns
TypeDescription
Paginated<Operation>

listDatabases(String instanceName, int pageSize, String pageToken)

public SpannerRpc.Paginated<Database> listDatabases(String instanceName, int pageSize, String pageToken)
Parameters
NameDescription
instanceNameString
pageSizeint
pageTokenString
Returns
TypeDescription
Paginated<Database>
Exceptions
TypeDescription
SpannerException

listInstanceConfigs(int pageSize, String pageToken)

public SpannerRpc.Paginated<InstanceConfig> listInstanceConfigs(int pageSize, String pageToken)
Parameters
NameDescription
pageSizeint
pageTokenString
Returns
TypeDescription
Paginated<InstanceConfig>
Exceptions
TypeDescription
SpannerException

listInstances(int pageSize, String pageToken, String filter)

public SpannerRpc.Paginated<Instance> listInstances(int pageSize, String pageToken, String filter)
Parameters
NameDescription
pageSizeint
pageTokenString
filterString
Returns
TypeDescription
Paginated<Instance>
Exceptions
TypeDescription
SpannerException

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

public PartitionResponse partitionQuery(PartitionQueryRequest request, Map<SpannerRpc.Option,?> options)
Parameters
NameDescription
requestPartitionQueryRequest
optionsMap<Option,?>
Returns
TypeDescription
PartitionResponse
Exceptions
TypeDescription
SpannerException

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

public PartitionResponse partitionRead(PartitionReadRequest request, Map<SpannerRpc.Option,?> options)
Parameters
NameDescription
requestPartitionReadRequest
optionsMap<Option,?>
Returns
TypeDescription
PartitionResponse
Exceptions
TypeDescription
SpannerException

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

public SpannerRpc.StreamingCall read(ReadRequest request, SpannerRpc.ResultStreamConsumer consumer, Map<SpannerRpc.Option,?> options)
Parameters
NameDescription
requestReadRequest
consumerSpannerRpc.ResultStreamConsumer
optionsMap<Option,?>
Returns
TypeDescription
SpannerRpc.StreamingCall

restoreDatabase(Restore restore)

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

Restore a backup into the given database.

Parameter
NameDescription
restoreRestore
Returns
TypeDescription
OperationFuture<Database,RestoreDatabaseMetadata>

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

public void rollback(RollbackRequest request, Map<SpannerRpc.Option,?> options)
Parameters
NameDescription
requestRollbackRequest
optionsMap<Option,?>
Exceptions
TypeDescription
SpannerException

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

public ApiFuture<Empty> rollbackAsync(RollbackRequest request, Map<SpannerRpc.Option,?> options)
Parameters
NameDescription
requestRollbackRequest
optionsMap<Option,?>
Returns
TypeDescription
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
NameDescription
resourceString
policycom.google.iam.v1.Policy
Returns
TypeDescription
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
NameDescription
resourceString
policycom.google.iam.v1.Policy
Returns
TypeDescription
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
NameDescription
resourceString
permissionsIterable<String>
Returns
TypeDescription
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
NameDescription
resourceString
permissionsIterable<String>
Returns
TypeDescription
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
NameDescription
backupBackup
updateMaskFieldMask
Returns
TypeDescription
Backup

updateDatabaseDdl(String databaseName, Iterable<String> updateDatabaseStatements, String updateId)

public OperationFuture<Empty,UpdateDatabaseDdlMetadata> updateDatabaseDdl(String databaseName, 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
NameDescription
databaseNameString
updateDatabaseStatementsIterable<String>
updateIdString
Returns
TypeDescription
OperationFuture<Empty,UpdateDatabaseDdlMetadata>
Exceptions
TypeDescription
SpannerException

updateInstance(Instance instance, FieldMask fieldMask)

public OperationFuture<Instance,UpdateInstanceMetadata> updateInstance(Instance instance, FieldMask fieldMask)
Parameters
NameDescription
instanceInstance
fieldMaskFieldMask
Returns
TypeDescription
OperationFuture<Instance,UpdateInstanceMetadata>
Exceptions
TypeDescription
SpannerException