当前位置: 首页>>代码示例>>Java>>正文


Java AvailabilityZone类代码示例

本文整理汇总了Java中com.amazonaws.services.ec2.model.AvailabilityZone的典型用法代码示例。如果您正苦于以下问题:Java AvailabilityZone类的具体用法?Java AvailabilityZone怎么用?Java AvailabilityZone使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


AvailabilityZone类属于com.amazonaws.services.ec2.model包,在下文中一共展示了AvailabilityZone类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getInstancesMapForZone

import com.amazonaws.services.ec2.model.AvailabilityZone; //导入依赖的package包/类
@Override
public Map<AvailabilityZone, List<Instance>> getInstancesMapForZone(
    AvailabilityZone zone, AmazonEC2Client client) throws Exception {

  OperationStats op = new OperationStats("ec2InstanceStore", "getInstancesMapForZone");

  try {
    Map<AvailabilityZone, List<Instance>> ret = new HashMap<>();
    ret.put(zone, getInstancesForZone(zone, client));

    op.succeed();
    return ret;

  } catch (Exception e) {

    op.failed();
    logger.error(ExceptionUtils.getRootCauseMessage(e));
    throw e;
  }
}
 
开发者ID:pinterest,项目名称:soundwave,代码行数:21,代码来源:Ec2InstanceStore.java

示例2: getReservedInstancesForZone

import com.amazonaws.services.ec2.model.AvailabilityZone; //导入依赖的package包/类
@Override
public Map<AvailabilityZone, List<ReservedInstances>> getReservedInstancesForZone(
    AvailabilityZone zone, AmazonEC2Client client) throws Exception {

  OperationStats op = new OperationStats("ec2InstanceStore", "getReservedInstancesForZone");

  try {
    Map<AvailabilityZone, List<ReservedInstances>> ret = new HashMap<>();
    DescribeReservedInstancesRequest request = new DescribeReservedInstancesRequest()
        .withFilters(new Filter("availability-zone", Arrays.asList(zone.getZoneName())))
        .withSdkClientExecutionTimeout(
            600 * 1000) //10 minutes time out for total execution including retries
        .withSdkRequestTimeout(300 * 1000); //5 minutes time out for a single request

    DescribeReservedInstancesResult result = client.describeReservedInstances(request);
    ret.put(zone, result.getReservedInstances());

    op.succeed();
    return ret;

  } catch (Exception e) {

    op.failed();
    logger.error(ExceptionUtils.getRootCauseMessage(e));
    throw e;
  }
}
 
开发者ID:pinterest,项目名称:soundwave,代码行数:28,代码来源:Ec2InstanceStore.java

示例3: handleSuccess

import com.amazonaws.services.ec2.model.AvailabilityZone; //导入依赖的package包/类
@Override
public void handleSuccess(DescribeAvailabilityZonesRequest request,
        DescribeAvailabilityZonesResult result) {

    List<AvailabilityZone> zones = result.getAvailabilityZones();
    if (zones == null || zones.isEmpty()) {
        this.service
                .logFine(() -> "No AvailabilityZones found. Nothing to be created locally");
        this.context.refreshSubStage = this.next;
        this.service.processRefreshSubStages(this.context);
        return;
    }

    loadLocalResources(this.service, this.context,
            zones.stream()
                    .map(AvailabilityZone::getZoneName)
                    .collect(Collectors.toList()),
            cm -> createMissingLocalInstances(zones, cm),
            cm -> {
                this.service.logFine(() -> "No AvailabilityZones found. Nothing to be"
                        + " created locally");
                this.context.refreshSubStage = this.next;
                this.service.processRefreshSubStages(this.context);
            });
}
 
开发者ID:vmware,项目名称:photon-model,代码行数:26,代码来源:AWSEnumerationAndCreationAdapterService.java

示例4: createComputeDescription

import com.amazonaws.services.ec2.model.AvailabilityZone; //导入依赖的package包/类
private ComputeDescription createComputeDescription(AvailabilityZone z) {
    ComputeDescriptionService.ComputeDescription cd = Utils
            .clone(this.context.parentCompute.description);
    cd.supportedChildren = new ArrayList<>();
    cd.supportedChildren.add(ComputeType.VM_GUEST.toString());
    cd.documentSelfLink = null;
    cd.id = z.getZoneName();
    cd.zoneId = z.getZoneName();
    cd.name = z.getZoneName();
    cd.regionId = z.getRegionName();
    cd.endpointLink = this.context.request.original.endpointLink;
    if (cd.endpointLinks == null) {
        cd.endpointLinks = new HashSet<>();
    }
    cd.computeHostLink = this.context.request.parentCompute.documentSelfLink;
    cd.endpointLinks.add(this.context.request.original.endpointLink);
    // Book keeping information about the creation of the compute description in the system.
    if (cd.customProperties == null) {
        cd.customProperties = new HashMap<>();
    }
    cd.customProperties.put(SOURCE_TASK_LINK,
            ResourceEnumerationTaskService.FACTORY_LINK);

    return cd;
}
 
开发者ID:vmware,项目名称:photon-model,代码行数:26,代码来源:AWSEnumerationAndCreationAdapterService.java

示例5: testGetAvailabilityZones

import com.amazonaws.services.ec2.model.AvailabilityZone; //导入依赖的package包/类
@Test
public void testGetAvailabilityZones() {

    String zoneName = "zone-name";

    when(ec2Client.describeAvailabilityZones()).thenReturn(
            new DescribeAvailabilityZonesResult()
                    .withAvailabilityZones(
                            new AvailabilityZone()
                                    .withZoneName(zoneName)
                                    .withState(AvailabilityZoneState.Available),
                            new AvailabilityZone()
                                    .withZoneName("not-available-zone")
                                    .withState(AvailabilityZoneState.Unavailable)
                    )
    );

    // invoke method under test
    List<String> results = ec2Service.getAvailabilityZones();

    assertEquals(1, results.size());
    assertEquals(zoneName, results.get(0));
}
 
开发者ID:Nike-Inc,项目名称:cerberus-lifecycle-cli,代码行数:24,代码来源:Ec2ServiceTest.java

示例6: getInstanceTypeOnDemandPrices

import com.amazonaws.services.ec2.model.AvailabilityZone; //导入依赖的package包/类
/**
 * Returns a mapping of instance types to on-demand prices for the given AZ and instance types. The on-demand prices are retrieved from database
 * configurations. The on-demand prices are looked up by the AZ's region name. This method also validates that the given instance types are real instance
 * types supported by AWS.
 *
 * @param availabilityZone the availability zone of the on-demand instances
 * @param instanceTypes the sizes of the on-demand instances
 *
 * @return the map of instance type to on-demand price
 * @throws ObjectNotFoundException when any of the instance type was not found in the given region
 */
private Map<String, BigDecimal> getInstanceTypeOnDemandPrices(AvailabilityZone availabilityZone, Set<String> instanceTypes)
{
    Map<String, BigDecimal> instanceTypeOnDemandPrices = new HashMap<>();
    for (String instanceType : instanceTypes)
    {
        Ec2OnDemandPricingEntity onDemandPrice = ec2OnDemandPricingDao.getEc2OnDemandPricing(availabilityZone.getRegionName(), instanceType);

        if (onDemandPrice == null)
        {
            throw new ObjectNotFoundException(
                "On-demand price for region '" + availabilityZone.getRegionName() + "' and instance type '" + instanceType + "' not found.");
        }

        instanceTypeOnDemandPrices.put(instanceType, onDemandPrice.getHourlyPrice());
    }

    return instanceTypeOnDemandPrices;
}
 
开发者ID:FINRAOS,项目名称:herd,代码行数:30,代码来源:EmrPricingHelper.java

示例7: getAvailabilityZonesForSubnetIds

import com.amazonaws.services.ec2.model.AvailabilityZone; //导入依赖的package包/类
/**
 * This implementation uses the DescribeAvailabilityZones API to get the list of AZs.
 */
@Override
public List<AvailabilityZone> getAvailabilityZonesForSubnetIds(Collection<Subnet> subnets, AwsParamsDto awsParamsDto)
{
    Set<String> zoneNames = new HashSet<>();
    for (Subnet subnet : subnets)
    {
        zoneNames.add(subnet.getAvailabilityZone());
    }

    AmazonEC2Client ec2Client = getEc2Client(awsParamsDto);
    DescribeAvailabilityZonesRequest describeAvailabilityZonesRequest = new DescribeAvailabilityZonesRequest();
    describeAvailabilityZonesRequest.setZoneNames(zoneNames);
    DescribeAvailabilityZonesResult describeAvailabilityZonesResult = ec2Operations.describeAvailabilityZones(ec2Client, describeAvailabilityZonesRequest);
    return describeAvailabilityZonesResult.getAvailabilityZones();
}
 
开发者ID:FINRAOS,项目名称:herd,代码行数:19,代码来源:Ec2DaoImpl.java

示例8: getAllAvailabilityZones

import com.amazonaws.services.ec2.model.AvailabilityZone; //导入依赖的package包/类
public static List<String> getAllAvailabilityZones() {
	connect();
	
	DescribeAvailabilityZonesRequest req = new DescribeAvailabilityZonesRequest();
	
	ArrayList<Filter> filters = new ArrayList<Filter>();
	ArrayList<String> regions = new ArrayList<String>();
	regions.add(Configuration.REGION);
	filters.add(new Filter("region-name", regions));
	req.setFilters(filters);
	
	DescribeAvailabilityZonesResult res = client.describeAvailabilityZones(req);
	
	List<AvailabilityZone> zones = res.getAvailabilityZones();
	ArrayList<String> zonesStr = new ArrayList<String>();
	for (AvailabilityZone zone : zones)
		zonesStr.add(zone.getZoneName());
	
	return zonesStr;
}
 
开发者ID:rickdesantis,项目名称:cloud-runner,代码行数:21,代码来源:AmazonEC2.java

示例9: getZoneByName

import com.amazonaws.services.ec2.model.AvailabilityZone; //导入依赖的package包/类
private Zone getZoneByName(String zoneName)
{
    checkState(!isNullOrEmpty(zoneName));
    
    try
    {
        DescribeAvailabilityZonesResult zones = ec2_
                .describeAvailabilityZones(new DescribeAvailabilityZonesRequest()
                .withZoneNames(zoneName)
                .withFilters(new Filter().withName("region-name").withValues(credentials_.getRegion().getName())));

        if (zones != null && zones.getAvailabilityZones().size() == 1)
        {
            //available | impaired | unavailable
            AvailabilityZone availabilityZone = zones.getAvailabilityZones().get(0);
            return new Zone().setName(availabilityZone.getZoneName()).setRegion(credentials_.getRegion()).setStatus(availabilityZone.getState());
        }

    }
    catch (AmazonClientException exception)
    {
        LOG.debug("Invalid zone [{}]! Error message: [{}]", zoneName, exception.getMessage(), exception);
    }
    
    return null;
}
 
开发者ID:alessandroleite,项目名称:dohko,代码行数:27,代码来源:EC2.java

示例10: fetchAutopopulateParametersFor

import com.amazonaws.services.ec2.model.AvailabilityZone; //导入依赖的package包/类
private List<Parameter> fetchAutopopulateParametersFor(ProjectAndEnv projectAndEnv, List<TemplateParameter> declaredParameters, Map<String, AvailabilityZone> zones) throws IOException, InvalidStackParameterException, CannotFindVpcException {
	logger.info(String.format("Discover and populate parameters for %s and %s", templateFile.getAbsolutePath(), projectAndEnv));
	List<Parameter> matches = new LinkedList<>();
	for(TemplateParameter templateParam : declaredParameters) {
		String name = templateParam.getParameterKey();
		if (isBuiltInParamater(name))
		{
			continue;
		}
		logger.info("Checking if parameter should be auto-populated from an existing resource, param name is " + name);
		String description = templateParam.getDescription();
		if (shouldPopulateFor(description)) {
			populateParameter(projectAndEnv, matches, name, description, declaredParameters, zones);
		}
	}
	return matches;
}
 
开发者ID:cartwrightian,项目名称:cfnassist,代码行数:18,代码来源:AutoDiscoverParams.java

示例11: populateParamForZone

import com.amazonaws.services.ec2.model.AvailabilityZone; //导入依赖的package包/类
private void populateParamForZone(Collection<Parameter> results,
								  List<TemplateParameter> declaredParameters,
								  Map<String, AvailabilityZone> zones, String parameterName,
								  String parameterDescription) {
	logger.info(String.format("Check parameter for zone %s and target %s", parameterName, parameterDescription));
	String target = parameterDescription.replaceFirst(PopulatesParameters.CFN_TAG_ZONE, "").toLowerCase();
	logger.debug("Check for zone " + target);
	if (zones.containsKey(target)) {
		String zoneName = zones.get(target).getZoneName();
		declaredParameters.stream().filter(declaredParameter -> declaredParameter.getParameterKey().equals(parameterName)).
				forEach(declaredParameter -> {
					addParameterTo(results, declaredParameters, parameterName, zoneName);
					logger.info(String.format("Adding zone parameter %s with value %s", parameterName, zoneName));
				});
	} else {
		logger.error("Could not find matching zone for target " + target);
	}
}
 
开发者ID:cartwrightian,项目名称:cfnassist,代码行数:19,代码来源:AutoDiscoverParams.java

示例12: shouldApplySimpleTemplateNoParameters

import com.amazonaws.services.ec2.model.AvailabilityZone; //导入依赖的package包/类
@Test
public void shouldApplySimpleTemplateNoParameters() throws CfnAssistException, IOException, InterruptedException {
	String filename = FilesForTesting.SIMPLE_STACK;
	String stackName = "CfnAssistTestsimpleStack";
	String contents = EnvironmentSetupForTests.loadFile(filename);
	
	List<TemplateParameter> templateParameters = new LinkedList<>();
	Collection<Parameter> creationParameters = new LinkedList<>();

       Map<String, AvailabilityZone> zones = new HashMap<>();
       StackNameAndId stackNameAndId = SetCreateExpectations(stackName, contents, templateParameters, creationParameters, zones);
	
	replayAll();
	StackNameAndId result = aws.applyTemplate(filename, projectAndEnv);
	assertEquals(result, stackNameAndId);
	verifyAll();
}
 
开发者ID:cartwrightian,项目名称:cfnassist,代码行数:18,代码来源:TestAwsFacadeCreatesStacks.java

示例13: shouldApplySimpleTemplateParametersWithOutDescriptions

import com.amazonaws.services.ec2.model.AvailabilityZone; //导入依赖的package包/类
@Test
public void shouldApplySimpleTemplateParametersWithOutDescriptions() throws CfnAssistException, IOException, InterruptedException {
	String filename = FilesForTesting.SIMPLE_STACK;
	String stackName = "CfnAssistTestsimpleStack";
	String contents = EnvironmentSetupForTests.loadFile(filename);
	
	List<TemplateParameter> templateParameters = new LinkedList<>();
	templateParameters.add(new TemplateParameter().withParameterKey("noDescription").withDefaultValue("defaultValue"));
	Collection<Parameter> creationParameters = new LinkedList<>();

       Map<String, AvailabilityZone> zones = new HashMap<>();
       StackNameAndId stackNameAndId = SetCreateExpectations(stackName, contents, templateParameters, creationParameters, zones);
	
	replayAll();
	StackNameAndId result = aws.applyTemplate(filename, projectAndEnv);
	assertEquals(result, stackNameAndId);
	verifyAll();
}
 
开发者ID:cartwrightian,项目名称:cfnassist,代码行数:19,代码来源:TestAwsFacadeCreatesStacks.java

示例14: shouldApplySimpleTemplateOutputParameters

import com.amazonaws.services.ec2.model.AvailabilityZone; //导入依赖的package包/类
@Test
public void shouldApplySimpleTemplateOutputParameters() throws CfnAssistException, IOException, InterruptedException {
	String filename = FilesForTesting.SIMPLE_STACK;
	String stackName = "CfnAssistTestsimpleStack";
	String contents = EnvironmentSetupForTests.loadFile(filename);
	
	List<TemplateParameter> templateParameters = new LinkedList<>();
	Collection<Parameter> creationParameters = new LinkedList<>();
	Collection<Output> outputs = new LinkedList<>();
	outputs.add(new Output().withDescription("::CFN_TAG").withOutputKey("outputKey").withOutputValue("outputValue"));
	outputs.add(new Output().withDescription("something").withOutputKey("ignored").withOutputValue("noThanks"));

       Map<String, AvailabilityZone> zones = new HashMap<>();
       StackNameAndId stackNameAndId = SetCreateExpectations(stackName, contents, templateParameters, creationParameters, "", outputs, zones);
	vpcRepository.setVpcTag(projectAndEnv, "outputKey", "outputValue");
	EasyMock.expectLastCall();
	
	replayAll();
	StackNameAndId result = aws.applyTemplate(filename, projectAndEnv);
	assertEquals(result, stackNameAndId);
	verifyAll();
}
 
开发者ID:cartwrightian,项目名称:cfnassist,代码行数:23,代码来源:TestAwsFacadeCreatesStacks.java

示例15: shouldApplySimpleTemplateNoParametersWithComment

import com.amazonaws.services.ec2.model.AvailabilityZone; //导入依赖的package包/类
@Test
public void shouldApplySimpleTemplateNoParametersWithComment() throws CfnAssistException, IOException, InterruptedException {
	String filename = FilesForTesting.SIMPLE_STACK;
	String stackName = "CfnAssistTestsimpleStack";
	String contents = EnvironmentSetupForTests.loadFile(filename);
	
	List<TemplateParameter> templateParameters = new LinkedList<>();
	Collection<Parameter> creationParameters = new LinkedList<>();

       Map<String, AvailabilityZone> zones = new HashMap<>();
       StackNameAndId stackNameAndId = SetCreateExpectations(stackName, contents, templateParameters, creationParameters, "aComment", zones);

       projectAndEnv.setComment("aComment");
	replayAll();
	StackNameAndId result = aws.applyTemplate(filename, projectAndEnv);
	assertEquals(result, stackNameAndId);
	verifyAll();
}
 
开发者ID:cartwrightian,项目名称:cfnassist,代码行数:19,代码来源:TestAwsFacadeCreatesStacks.java


注:本文中的com.amazonaws.services.ec2.model.AvailabilityZone类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。