public interface InstanceAdminClient
Modifier and Type | Method and Description |
---|---|
OperationFuture<Instance,com.google.spanner.admin.instance.v1.CreateInstanceMetadata> |
createInstance(InstanceInfo instance)
Creates an instance and begins preparing it to begin serving.
|
void |
deleteInstance(String instanceId)
Deletes an instance.
|
Instance |
getInstance(String instanceId)
Gets an instance.
|
InstanceConfig |
getInstanceConfig(String configId)
Gets an instance config.
|
Page<InstanceConfig> |
listInstanceConfigs(Options.ListOption... options)
Lists the supported instance configs for current project.
|
Page<Instance> |
listInstances(Options.ListOption... options)
Lists the instances.
|
Instance.Builder |
newInstanceBuilder(InstanceId id)
Returns a builder for
Instance object with the given id. |
OperationFuture<Instance,com.google.spanner.admin.instance.v1.UpdateInstanceMetadata> |
updateInstance(InstanceInfo instance,
InstanceInfo.InstanceField... fieldsToUpdate)
Updates an instance, and begins allocating or releasing resources as requested.
|
InstanceConfig getInstanceConfig(String configId) throws SpannerException
SpannerException
Page<InstanceConfig> listInstanceConfigs(Options.ListOption... options) throws SpannerException
SpannerException
OperationFuture<Instance,com.google.spanner.admin.instance.v1.CreateInstanceMetadata> createInstance(InstanceInfo instance) throws SpannerException
Operation
can be used to track the progress of preparing the new instance. The instance name is assigned
by the caller. If the named instance already exists, a SpannerException is thrown. Immediately
upon completion of this request:
CREATING
.
final String instanceId = my_instance_id;
final String configId = my_config_id;
final String clientProject = my_client_project;
Operation<Instance, CreateInstanceMetadata> op =
instanceAdminClient.createInstance(InstanceInfo
.newBuilder(InstanceId.of(clientProject, instanceId))
.setInstanceConfigId(InstanceConfigId.of(clientProject, configId))
.setDisplayName(instanceId)
.setNodeCount(1)
.build());
op.waitFor();
SpannerException
Instance getInstance(String instanceId) throws SpannerException
SpannerException
Page<Instance> listInstances(Options.ListOption... options) throws SpannerException
options
- Options to control the instances returned. It also supports Options.filter(String)
option. The fields eligible for filtering are:
List<Instance> instances =
Lists.newArrayList(
instanceAdminClient.listInstances(Options.pageSize(1)).iterateAll());
SpannerException
void deleteInstance(String instanceId) throws SpannerException
SpannerException
OperationFuture<Instance,com.google.spanner.admin.instance.v1.UpdateInstanceMetadata> updateInstance(InstanceInfo instance, InstanceInfo.InstanceField... fieldsToUpdate)
Operation
can be used to track the progress of updating the instance. If the named
instance does not exist, throws SpannerException.
Immediately upon completion of this request:
Instance instance = my_instance;
final String clientProject = my_client_project;
final String instanceId = my_instance_id;
final String newDisplayName = my_display_name;
InstanceInfo toUpdate =
InstanceInfo.newBuilder(InstanceId.of(clientProject, instanceId))
.setDisplayName(newDisplayName)
.setNodeCount(instance.getNodeCount() + 1)
.build();
// Only update display name
Operation<Instance, UpdateInstanceMetadata> op =
instanceAdminClient.updateInstance(toUpdate, InstanceInfo.InstanceField.DISPLAY_NAME);
op.waitFor().getResult();
Instance.Builder newInstanceBuilder(InstanceId id)
Instance
object with the given id.Copyright © 2019 Google LLC. All rights reserved.