本文整理汇总了Java中com.amazonaws.services.ec2.AmazonEC2Client.setEndpoint方法的典型用法代码示例。如果您正苦于以下问题:Java AmazonEC2Client.setEndpoint方法的具体用法?Java AmazonEC2Client.setEndpoint怎么用?Java AmazonEC2Client.setEndpoint使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.amazonaws.services.ec2.AmazonEC2Client
的用法示例。
在下文中一共展示了AmazonEC2Client.setEndpoint方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: AmazonEC2HostProvider
import com.amazonaws.services.ec2.AmazonEC2Client; //导入方法依赖的package包/类
public AmazonEC2HostProvider(final AWSCredentials credentials, final ClientConfiguration configuration, String endpoint, Function<Instance, Host> instance_converter) {
this.instance_converter = instance_converter;
ec2_client = new AmazonEC2Client(credentials, configuration);
ec2_client.setEndpoint(endpoint);
next_host_index = new AtomicInteger();
}
示例2: connect
import com.amazonaws.services.ec2.AmazonEC2Client; //导入方法依赖的package包/类
private static AmazonEC2 connect(final String credentialsId, final String region) {
final AmazonWebServicesCredentials credentials = AWSCredentialsHelper.getCredentials(credentialsId, Jenkins.getInstance());
final AmazonEC2Client client =
credentials != null ?
new AmazonEC2Client(credentials) :
new AmazonEC2Client();
if (region != null)
client.setEndpoint("https://ec2." + region + ".amazonaws.com/");
return client;
}
示例3: AwsGatlingRunner
import com.amazonaws.services.ec2.AmazonEC2Client; //导入方法依赖的package包/类
public AwsGatlingRunner(final String endpoint) {
final AWSCredentialsProviderChain credentials = new AWSCredentialsProviderChain(
new PropertiesFileCredentialsProvider("aws.properties"),
new EnvironmentVariableCredentialsProvider(),
new SystemPropertiesCredentialsProvider(),
new ProfileCredentialsProvider(),
new InstanceProfileCredentialsProvider());
ec2client = new AmazonEC2Client(credentials);
ec2client.setEndpoint(endpoint);
transferManager = new TransferManager(credentials);
}
示例4: aggregateInstances
import com.amazonaws.services.ec2.AmazonEC2Client; //导入方法依赖的package包/类
@Override
public Instances aggregateInstances()
{
final Instances instances = new Instances();
for (final Region region : this.listRegions())
{
AmazonEC2Client client = new AmazonEC2Client(awsCredentials_);
client.setEndpoint(region.getEndpoint());
DescribeInstancesRequest request = new DescribeInstancesRequest().withFilters(CONSIDERED_INSTANCE_STATES_FILTER);
instances.addInstances(toExcaliburInstances(toEc2Instances(client.describeInstances(request).getReservations()), null));
}
return instances;
}
示例5: listAvailableZonesOfRegion
import com.amazonaws.services.ec2.AmazonEC2Client; //导入方法依赖的package包/类
private List<Zone> listAvailableZonesOfRegion(Region region)
{
checkNotNull(region);
checkState(!isNullOrEmpty(region.getName()));
checkState(!isNullOrEmpty(region.getEndpoint()));
List<Zone> zones = newArrayList();
AmazonEC2Client client = new AmazonEC2Client(awsCredentials_);
client.setEndpoint(region.getEndpoint());
try
{
DescribeAvailabilityZonesResult availabilityZonesResult = client.describeAvailabilityZones(new DescribeAvailabilityZonesRequest()
.withFilters(new com.amazonaws.services.ec2.model.Filter().withName("region-name").withValues(region.getName()),
new com.amazonaws.services.ec2.model.Filter().withName("state").withValues("available"))
);
for (AvailabilityZone zone : availabilityZonesResult.getAvailabilityZones())
{
zones.add(new Zone().setName(zone.getZoneName()).setRegion(region));
}
Collections.sort(zones);
}
catch (AmazonClientException exception)
{
LOG.warn("Error on listing the available zones of region [name:{}, endpoint:{}]. Error message: [{}]",
region.getName(), region.getEndpoint(), exception.getMessage(), exception);
}
return zones;
}
示例6: amazonEC2
import com.amazonaws.services.ec2.AmazonEC2Client; //导入方法依赖的package包/类
@Bean
@ConditionalOnProperty("aws.accessKeyId")
AmazonEC2Client amazonEC2(@Value("${aws.accessKeyId}") String accessKeyId,
@Value("${aws.secretAccessKey}") String secretAccessKey,
@Value("${aws.region:us-east-1}") String regionName) {
AmazonEC2Client amazonEC2Client = new AmazonEC2Client(new BasicAWSCredentials(accessKeyId, secretAccessKey));
Region region = Region.getRegion(Regions.fromName(regionName));
amazonEC2Client.setEndpoint(region.getServiceEndpoint("ec2"));
return amazonEC2Client;
}
示例7: GetASGName
import com.amazonaws.services.ec2.AmazonEC2Client; //导入方法依赖的package包/类
public GetASGName(String region, String instanceId) {
super(NUMBER_OF_RETRIES, WAIT_TIME);
this.region = region;
this.instanceId = instanceId;
client = new AmazonEC2Client(provider.getAwsCredentialProvider());
client.setEndpoint("ec2." + region + ".amazonaws.com");
}
示例8: EC2Wrapper
import com.amazonaws.services.ec2.AmazonEC2Client; //导入方法依赖的package包/类
EC2Wrapper(EC2CloudPlatformConfiguration config) throws IOException
{
this.config = config;
this.log = JCloudScaleConfiguration.getLogger(this);
// connect to EC2
InputStream credentialsAsStream = new FileInputStream(config.getAwsConfigFile());
creds = new PropertiesCredentials(credentialsAsStream);
ec2Client = new AmazonEC2Client(creds);
ec2Client.setEndpoint(config.getAwsEndpoint());
}
示例9: setup
import com.amazonaws.services.ec2.AmazonEC2Client; //导入方法依赖的package包/类
@Override
public void setup() {
try {
InputStream is = null;
is = new FileInputStream(SystemConstants.FILE_CREDENTIALS_AMAZON);
PropertiesCredentials credentials = new PropertiesCredentials(is);
EC2 = new AmazonEC2Client(credentials);
EC2.setEndpoint("ec2.sa-east-1.amazonaws.com");
} catch (IOException ioe) {
throw new RuntimeException(ioe);
}//, IllegalArgumentException
}
示例10: init
import com.amazonaws.services.ec2.AmazonEC2Client; //导入方法依赖的package包/类
private static void init() throws Exception
{
//vamos buscar um historico de metricas guardados na memoria persistente do Load Balancer e guardamos na memoria interna para acesso mais rapido
internalStorage = Request.getRanksFromPersistentMemory();
if(internalStorage == null)
internalStorage = new HashMap<String,BigInteger>();
Connection.setupServer();
try {
credentials = new ProfileCredentialsProvider().getCredentials();
} catch (Exception e) {
throw new AmazonClientException(
"Cannot load the credentials from the credential profiles file. " +
"Please make sure that your credentials file is at the correct " +
"location (~/.aws/credentials), and is in valid format.",
e);
}
ec2 = new AmazonEC2Client(credentials);
cloudWatch= new AmazonCloudWatchClient(credentials);
try {
/* Using AWS Ireland. Pick the zone where you have AMI, key and secgroup */
ec2.setEndpoint("ec2.eu-west-1.amazonaws.com");
cloudWatch.setEndpoint("monitoring.eu-west-1.amazonaws.com");
describeInstancesResult = ec2.describeInstances();
reservations = describeInstancesResult.getReservations();
listOfActiveInstances = new ArrayList<InstanceObject>();
//funcionamento:vamos buscar todas as instancias e guardamos numa lista auxiliar, depois metemos na lista definitiva
//apenas as instancias que estao a correr
ArrayList<Instance> auxListOfInstances = new ArrayList<Instance>();
for (Reservation reservation : reservations) {
auxListOfInstances.addAll(reservation.getInstances());
}
lockListOfActiveInstances.lock();
for (Instance instance : auxListOfInstances) {
if(AutoScaling.checkInstanceState(instance)) //se a instancia estiver running, adicionamo-la
{
if(!instance.getInstanceId().equals(Connection.checkInstanceId())) //id do load balancer, nao adicionamos este as instancias
{
InstanceObject instanceObject = new InstanceObject(instance);
listOfActiveInstances.add(instanceObject);
}
}
}
lockListOfActiveInstances.unlock();
instanceDimension = new Dimension();
instanceDimension.setName("InstanceId");
List<Dimension> dims = new ArrayList<Dimension>();
dims.add(instanceDimension);
} catch (AmazonServiceException ase) {
lockListOfActiveInstances.unlock();
System.out.println("Caught Exception: " + ase.getMessage());
System.out.println("Reponse Status Code: " + ase.getStatusCode());
System.out.println("Error Code: " + ase.getErrorCode());
System.out.println("Request ID: " + ase.getRequestId());
}
Thread thread = new ThreadScaling();
thread.start(); //thread responsavel pela monitorizacao das instancias (Fara o papel de Auto Scaling)
//vamos ter outra thread que e responsavel por fazer os health checks das instancias iniciais
Thread threadHealth = new ThreadHealthChecks();
threadHealth.start();
}
示例11: setup
import com.amazonaws.services.ec2.AmazonEC2Client; //导入方法依赖的package包/类
public static void setup() throws IOException, IllegalArgumentException {
PropertiesCredentials credentials = new PropertiesCredentials(Ec2Commands.class.getResourceAsStream("/AwsCredentials.properties"));
EC2 = new AmazonEC2Client(credentials);
EC2.setEndpoint("ec2.us-west-2.amazonaws.com");
}