Example usage for com.amazonaws.services.elasticmapreduce.model Instance getEc2InstanceId

List of usage examples for com.amazonaws.services.elasticmapreduce.model Instance getEc2InstanceId

Introduction

In this page you can find the example usage for com.amazonaws.services.elasticmapreduce.model Instance getEc2InstanceId.

Prototype


public String getEc2InstanceId() 

Source Link

Document

The unique identifier of the instance in Amazon EC2.

Usage

From source file:org.finra.dm.dao.impl.EmrDaoImpl.java

License:Apache License

/**
 * Add Security groups to the master node of EMR cluster.
 *
 * @param clusterName EMR cluster name.//from  w  w w .ja v a2 s  .  c o m
 * @param securityGroups the security groups list.
 * @param awsParams the proxy details.
 *
 * @return the security groups that were added.
 */
@Override
public List<String> addEmrMasterSecurityGroups(String clusterName, List<String> securityGroups,
        AwsParamsDto awsParams) throws Exception {
    // Look up cluster
    String clusterId = getValidEmrClusterIdByName(clusterName, awsParams);

    // Get the master EC2 instance
    ListInstancesRequest listInstancesRequest = new ListInstancesRequest().withClusterId(clusterId)
            .withInstanceGroupTypes(InstanceGroupType.MASTER);

    List<Instance> instances = emrOperations
            .listClusterInstancesRequest(getEmrClient(awsParams), listInstancesRequest).getInstances();

    // Throw error in case there are no master instances found yet
    if (instances.size() == 0) {
        throw new IllegalArgumentException(
                "No master instances found for the cluster \"" + clusterName + "\".");
    }

    for (Instance instance : instances) {
        ec2Dao.addSecurityGroupsToEc2Instance(instance.getEc2InstanceId(), securityGroups, awsParams);
    }

    return securityGroups;
}

From source file:org.finra.herd.dao.impl.EmrDaoImpl.java

License:Apache License

@Override
public List<String> addEmrMasterSecurityGroups(String clusterId, List<String> securityGroups,
        AwsParamsDto awsParams) throws Exception {
    // Get the master EC2 instance
    ListInstancesRequest listInstancesRequest = new ListInstancesRequest().withClusterId(clusterId)
            .withInstanceGroupTypes(InstanceGroupType.MASTER);

    List<Instance> instances = emrOperations
            .listClusterInstancesRequest(getEmrClient(awsParams), listInstancesRequest).getInstances();

    // Throw error in case there are no master instances found yet
    if (instances.size() == 0) {
        throw new IllegalArgumentException("No master instances found for the cluster \"" + clusterId + "\".");
    }/*from  ww  w .j a v a2  s .  com*/

    for (Instance instance : instances) {
        ec2Dao.addSecurityGroupsToEc2Instance(instance.getEc2InstanceId(), securityGroups, awsParams);
    }

    return securityGroups;
}