Search in sources :

Example 46 with Instance

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();
}
Also used : Instance(com.google.cloud.notebooks.v1beta1.Instance) StartInstanceRequest(com.google.cloud.notebooks.v1beta1.StartInstanceRequest)

Example 47 with Instance

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]
}
Also used : Instance(com.google.cloud.spanner.Instance) UpdateInstanceMetadata(com.google.spanner.admin.instance.v1.UpdateInstanceMetadata) ExecutionException(java.util.concurrent.ExecutionException) InstanceInfo(com.google.cloud.spanner.InstanceInfo)

Example 48 with 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();
}
Also used : InstanceConfig(com.google.cloud.spanner.InstanceConfig) Instance(com.google.cloud.spanner.Instance) InstanceAdminClient(com.google.cloud.spanner.InstanceAdminClient) CreateInstanceMetadata(com.google.spanner.admin.instance.v1.CreateInstanceMetadata)

Example 49 with Instance

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;
}
Also used : IFilter(org.omegat.filters2.IFilter) IFilter(org.omegat.filters2.IFilter) Filter(gen.core.filters.Filter) AbstractFilter(org.omegat.filters2.AbstractFilter) Instance(org.omegat.filters2.Instance) Files(gen.core.filters.Files)

Example 50 with Instance

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;
}
Also used : Instance(com.scaleset.cfbuilder.ec2.Instance) UserData(com.scaleset.cfbuilder.ec2.UserData) SecurityGroup(com.scaleset.cfbuilder.ec2.SecurityGroup)

Aggregations

Test (org.junit.Test)50 AbstractMessage (com.google.protobuf.AbstractMessage)19 ByteString (com.google.protobuf.ByteString)17 ExecutionException (java.util.concurrent.ExecutionException)16 Instance (com.google.cloud.spanner.Instance)15 StatusRuntimeException (io.grpc.StatusRuntimeException)14 Instance (com.google.cloud.compute.v1.Instance)11 InstancesClient (com.google.cloud.compute.v1.InstancesClient)11 CreateInstanceMetadata (com.google.spanner.admin.instance.v1.CreateInstanceMetadata)11 Instance (com.google.spanner.admin.instance.v1.Instance)11 Instance (com.google.bigtable.admin.v2.Instance)10 InstanceAdminClient (com.google.cloud.spanner.InstanceAdminClient)10 InstanceInfo (com.google.cloud.spanner.InstanceInfo)10 InvalidArgumentException (com.google.api.gax.rpc.InvalidArgumentException)9 Instance (com.google.cloud.notebooks.v1beta1.Instance)9 Spanner (com.google.cloud.spanner.Spanner)8 ArrayList (java.util.ArrayList)8 Operation (com.google.cloud.compute.v1.Operation)7 FieldMask (com.google.protobuf.FieldMask)7 InstanceName (com.google.spanner.admin.instance.v1.InstanceName)7