use of com.google.cloud.redis.v1.Instance in project java-redis by googleapis.
the class ITSystemTest method setUp.
@BeforeClass
public static void setUp() throws Exception {
CloudRedisSettings.Builder cloudRedisSettingsBuilder = CloudRedisSettings.newBuilder();
cloudRedisSettingsBuilder.getInstanceSettings().setRetrySettings(cloudRedisSettingsBuilder.getInstanceSettings().getRetrySettings().toBuilder().setTotalTimeout(Duration.ofSeconds(900)).build());
CloudRedisSettings cloudRedisSettings = cloudRedisSettingsBuilder.build();
client = CloudRedisClient.create(cloudRedisSettings);
/* Creates a Redis instance based on the specified tier and memory size. */
Instance instance = Instance.newBuilder().setTier(TIER).setMemorySizeGb(1).setAuthorizedNetwork(AUTHORIZED_NETWORK).build();
client.createInstanceAsync(PARENT, INSTANCE, instance).get();
LOG.info("redis instance created successfully.");
}
use of com.google.cloud.redis.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.cloud.redis.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;
}
use of com.google.cloud.redis.v1.Instance in project TOSCAna by StuPro-TOSCAna.
the class CloudFormationModule method build.
/**
* Build the template.
* <br>
* Following steps are taken:
* <ol>
* <li>Add CFNInit to corresponding instance resource </li>
* <li>Check if EC2 instances need access to S3. If yes, then
* <ol>
* <li>Add necessary IAM resources to the module</li>
* <li>Add <tt>Authentication<tt> and <tt>IamInstanceProfile<tt> to corresponding instance resource</li>
* </ol>
* </li>
* <li>Add the KeyPair to the template if it is needed</li>
* </ol>
*/
@Override
public void build() {
for (Map.Entry<String, CFNInit> pair : cfnInitMap.entrySet()) {
Resource res = this.getResource(pair.getKey());
if (res instanceof Instance) {
Instance instance = (Instance) res;
if (!pair.getValue().getConfigs().isEmpty()) {
instance.addCFNInit(pair.getValue()).userData(new UserData(getUserDataFn(pair.getKey(), CONFIG_SETS, this)));
}
}
}
if (!fileUploadList.isEmpty()) {
Role instanceRole = getS3InstanceRole(this);
getS3Policy(this).roles(instanceRole);
getS3InstanceProfile(this).roles(instanceRole);
Authentication s3authentication = getS3Authentication(bucketName);
for (String instanceName : authenticationSet) {
Resource res = this.getResource(instanceName);
if (res instanceof Instance) {
Instance instance = (Instance) res;
instance.authentication(s3authentication).iamInstanceProfile(ref(INSTANCE_PROFILE));
}
}
}
if (this.hasKeyPair()) {
strParam(KEYNAME).type(KEYNAME_TYPE).description(KEYNAME_DESCRIPTION).constraintDescription(KEYNAME_CONSTRAINT_DESCRIPTION);
}
}
use of com.google.cloud.redis.v1.Instance in project java-docs-samples by GoogleCloudPlatform.
the class ListInstance method listInstances.
// List all instances in the given zone in the specified project ID.
public static void listInstances(String project, String zone) throws IOException {
// safely clean up any remaining background resources.
try (InstancesClient instancesClient = InstancesClient.create()) {
// Set the project and zone to retrieve instances present in the zone.
System.out.printf("Listing instances from %s in %s:", project, zone);
for (Instance zoneInstance : instancesClient.list(project, zone).iterateAll()) {
System.out.println(zoneInstance.getName());
}
System.out.println("####### Listing instances complete #######");
}
}
Aggregations