use of com.google.spanner.admin.instance.v1.Instance in project java-notebooks by googleapis.
the class ITNotebookServiceClientTest method startInstance.
private String startInstance() throws ExecutionException, InterruptedException {
StartInstanceRequest request = StartInstanceRequest.newBuilder().setName(INSTANCE_NAME).build();
Instance response = client.startInstanceAsync(request).get();
return response.getState().name();
}
use of com.google.spanner.admin.instance.v1.Instance in project google-cloud-java by GoogleCloudPlatform.
the class InstanceAdminClientSnippets method updateInstance.
/**
* Example to update an instance.
*/
public void updateInstance(Instance my_instance, final String my_client_project, final String my_instance_id, final String my_display_name) {
// [START instance_admin_client_update_instance]
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
OperationFuture<Instance, UpdateInstanceMetadata> op = instanceAdminClient.updateInstance(toUpdate, InstanceInfo.InstanceField.DISPLAY_NAME);
try {
op.get();
} catch (ExecutionException e) {
throw (SpannerException) e.getCause();
} catch (InterruptedException e) {
throw SpannerExceptionFactory.propagateInterrupt(e);
}
// [END instance_admin_client_update_instance]
}
use of com.google.spanner.admin.instance.v1.Instance in project spanner-jdbc by olavloite.
the class CloudSpannerIT method createInstance.
private void createInstance() {
InstanceAdminClient instanceAdminClient = spanner.getInstanceAdminClient();
InstanceConfig config = instanceAdminClient.getInstanceConfig("regional-europe-west1");
Instance instance = instanceAdminClient.newInstanceBuilder(InstanceId.of(getProject(), instanceId)).setDisplayName("Test Instance").setInstanceConfigId(config.getId()).setNodeCount(1).build();
Operation<Instance, CreateInstanceMetadata> createInstance = instanceAdminClient.createInstance(instance);
createInstance = createInstance.waitFor();
}
use of com.google.spanner.admin.instance.v1.Instance in project omegat by omegat-org.
the class FilterMaster method getDefaultSettingsFromFilter.
/**
* Create default filter's config.
*
* @param filterClassname
* filter's classname
* @return default filter's config
*/
public static Filter getDefaultSettingsFromFilter(final String filterClassname) {
IFilter f = getFilterInstance(filterClassname);
if (f == null) {
return null;
}
Filter fc = new Filter();
fc.setClassName(f.getClass().getName());
fc.setEnabled(true);
for (Instance ins : f.getDefaultInstances()) {
Files ff = new Files();
ff.setSourceEncoding(ins.getSourceEncoding());
ff.setSourceFilenameMask(ins.getSourceFilenameMask());
ff.setTargetEncoding(ins.getTargetEncoding());
ff.setTargetFilenamePattern(ins.getTargetFilenamePattern());
fc.getFiles().add(ff);
}
return fc;
}
use of com.google.spanner.admin.instance.v1.Instance in project TOSCAna by StuPro-TOSCAna.
the class CloudFormationVisitor method createSqlEc2.
/**
* Creates a EC2 for a {@link MysqlDatabase} that runs an initial sql query.
*
* @param mysqlDatabase the {@link MysqlDatabase} this sql query should be run on
* @param sqlQuery the sql query to run
* @return the instance name of the created EC2 Instance
*/
protected String createSqlEc2(MysqlDatabase mysqlDatabase, String sqlQuery) {
String ec2Name = toAlphanumerical(mysqlDatabase.getEntityName()) + "TmpSqlServer";
SecurityGroup webServerSecurityGroup = cfnModule.resource(SecurityGroup.class, ec2Name + SECURITY_GROUP).groupDescription("Temporary group for accessing mysqlDatabase" + toAlphanumerical(mysqlDatabase.getEntityName()) + " with SQLRequest");
cfnModule.resource(Instance.class, ec2Name).securityGroupIds(webServerSecurityGroup).imageId("ami-79873901").instanceType("t2.micro").instanceInitiatedShutdownBehavior("terminate").userData(new UserData(StackUtils.getUserDataDBConnFn(mysqlDatabase, sqlQuery)));
return ec2Name;
}
Aggregations