Example usage for com.amazonaws.services.ec2.model PlacementStrategy Cluster

List of usage examples for com.amazonaws.services.ec2.model PlacementStrategy Cluster

Introduction

In this page you can find the example usage for com.amazonaws.services.ec2.model PlacementStrategy Cluster.

Prototype

PlacementStrategy Cluster

To view the source code for com.amazonaws.services.ec2.model PlacementStrategy Cluster.

Click Source Link

Usage

From source file:de.unibi.cebitec.bibigrid.meta.aws.CreateClusterEnvironmentAWS.java

@Override
public CreateClusterAWS createPlacementGroup() {

    // if both instance-types fulfill the cluster specifications, create a 
    // placementGroup.
    if (cluster.getConfig().getMasterInstanceType().getSpec().clusterInstance
            && cluster.getConfig().getSlaveInstanceType().getSpec().clusterInstance) {

        placementGroup = (PLACEMENT_GROUP_PREFIX + cluster.getClusterId());
        log.info("Creating placement group...");
        cluster.getEc2().createPlacementGroup(
                new CreatePlacementGroupRequest(placementGroup, PlacementStrategy.Cluster));

    } else {/*from w  w w  .j a v  a2  s .  c o  m*/

        log.info(V, "Placement Group not available for selected Instances-types ...");
        return cluster;

    }

    return cluster;
}

From source file:org.excalibur.service.aws.ec2.EC2.java

License:Open Source License

public void createPlacementGroupsIfDoNotExist(org.excalibur.core.cloud.api.Placement... groups) {
    if (groups != null) {
        ListeningExecutorService executor = newListeningDynamicScalingThreadPool(
                String.format("create-groups-%s", credentials_.getRegion().getName()));

        List<Callable<Void>> tasks = newArrayList();

        for (final org.excalibur.core.cloud.api.Placement placement : groups) {
            tasks.add(new Callable<Void>() {
                @Override//from  www. j a v  a 2s  . c o  m
                public Void call() throws Exception {
                    if (placement != null && !isNullOrEmpty(placement.getGroupName())) {
                        try {
                            new AmazonEC2Client(awsCredentials_)
                                    .describePlacementGroups(new DescribePlacementGroupsRequest()
                                            .withGroupNames(placement.getGroupName()));
                        } catch (AmazonClientException exception) {
                            LOG.debug("The group {} is unknown! Provider message: {}", placement.getGroupName(),
                                    exception.getMessage());
                            ec2_.createPlacementGroup(
                                    new CreatePlacementGroupRequest().withGroupName(placement.getGroupName())
                                            .withStrategy(PlacementStrategy.Cluster));
                        }
                    }
                    return null;
                }
            });
        }

        invokeAllAndShutdownWhenFinish(tasks, executor);
    }
}