Example usage for com.amazonaws.services.ec2 AmazonEC2Client describePlacementGroups

List of usage examples for com.amazonaws.services.ec2 AmazonEC2Client describePlacementGroups

Introduction

In this page you can find the example usage for com.amazonaws.services.ec2 AmazonEC2Client describePlacementGroups.

Prototype

@Override
public DescribePlacementGroupsResult describePlacementGroups(DescribePlacementGroupsRequest request) 

Source Link

Document

Describes the specified placement groups or all of your placement groups.

Usage

From source file:com.cloudera.director.aws.ec2.EC2InstanceTemplateConfigurationValidator.java

License:Apache License

/**
 * Validates the configured placement group.
 *
 * @param client              the EC2 client
 * @param configuration       the configuration to be validated
 * @param accumulator         the exception condition accumulator
 * @param localizationContext the localization context
 *///from w w w .  ja va2 s . c  o m
@VisibleForTesting
void checkPlacementGroup(AmazonEC2Client client, Configured configuration,
        PluginExceptionConditionAccumulator accumulator, LocalizationContext localizationContext) {

    String placementGroup = configuration.getConfigurationValue(PLACEMENT_GROUP, localizationContext);

    if (placementGroup != null) {
        LOG.info(">> Describing placement group '{}'", placementGroup);

        try {
            DescribePlacementGroupsResult result = client.describePlacementGroups(
                    new DescribePlacementGroupsRequest().withGroupNames(placementGroup));

            checkCount(accumulator, PLACEMENT_GROUP, localizationContext, "Placement group",
                    result.getPlacementGroups());
        } catch (AmazonServiceException e) {
            if (e.getErrorCode().startsWith(INVALID_PLACEMENT_GROUP_ID)) {
                addError(accumulator, PLACEMENT_GROUP, localizationContext, null, INVALID_PLACEMENT_GROUP_MSG,
                        placementGroup);
            } else {
                throw Throwables.propagate(e);
            }
        }
    }
}