Search in sources :

Example 6 with RunJobFlowRequest

use of com.amazonaws.services.elasticmapreduce.model.RunJobFlowRequest in project herd by FINRAOS.

the class EmrDaoImpl method createEmrCluster.

@Override
public String createEmrCluster(String clusterName, EmrClusterDefinition emrClusterDefinition, AwsParamsDto awsParams) {
    RunJobFlowRequest runJobFlowRequest = getRunJobFlowRequest(clusterName, emrClusterDefinition);
    LOGGER.info("runJobFlowRequest={}", jsonHelper.objectToJson(runJobFlowRequest));
    String clusterId = emrOperations.runEmrJobFlow(getEmrClient(awsParams), runJobFlowRequest);
    LOGGER.info("EMR cluster started. emrClusterId=\"{}\"", clusterId);
    return clusterId;
}
Also used : RunJobFlowRequest(com.amazonaws.services.elasticmapreduce.model.RunJobFlowRequest)

Example 7 with RunJobFlowRequest

use of com.amazonaws.services.elasticmapreduce.model.RunJobFlowRequest in project herd by FINRAOS.

the class EmrDaoImpl method getRunJobFlowRequest.

/**
 * Create the run job flow request object.
 *
 * @param emrClusterDefinition the EMR definition name value
 * @param clusterName the EMR cluster name
 *
 * @return the run job flow request for the given configuration
 */
private RunJobFlowRequest getRunJobFlowRequest(String clusterName, EmrClusterDefinition emrClusterDefinition) {
    // Create the object
    RunJobFlowRequest runJobFlowRequest = new RunJobFlowRequest(clusterName, getJobFlowInstancesConfig(emrClusterDefinition));
    // Set release label
    if (StringUtils.isNotBlank(emrClusterDefinition.getReleaseLabel())) {
        runJobFlowRequest.setReleaseLabel(emrClusterDefinition.getReleaseLabel());
    }
    // Set list of Applications
    List<EmrClusterDefinitionApplication> emrClusterDefinitionApplications = emrClusterDefinition.getApplications();
    if (!CollectionUtils.isEmpty(emrClusterDefinitionApplications)) {
        runJobFlowRequest.setApplications(getApplications(emrClusterDefinitionApplications));
    }
    // Set list of Configurations
    List<EmrClusterDefinitionConfiguration> emrClusterDefinitionConfigurations = emrClusterDefinition.getConfigurations();
    if (!CollectionUtils.isEmpty(emrClusterDefinitionConfigurations)) {
        runJobFlowRequest.setConfigurations(getConfigurations(emrClusterDefinitionConfigurations));
    }
    // Set the log bucket if specified
    if (StringUtils.isNotBlank(emrClusterDefinition.getLogBucket())) {
        runJobFlowRequest.setLogUri(emrClusterDefinition.getLogBucket());
    }
    // Set the visible to all flag
    if (emrClusterDefinition.isVisibleToAll() != null) {
        runJobFlowRequest.setVisibleToAllUsers(emrClusterDefinition.isVisibleToAll());
    }
    // Set the IAM profile for the nodes
    if (StringUtils.isNotBlank(emrClusterDefinition.getEc2NodeIamProfileName())) {
        runJobFlowRequest.setJobFlowRole(emrClusterDefinition.getEc2NodeIamProfileName());
    } else {
        runJobFlowRequest.setJobFlowRole(herdStringHelper.getRequiredConfigurationValue(ConfigurationValue.EMR_DEFAULT_EC2_NODE_IAM_PROFILE_NAME));
    }
    // Set the IAM profile for the service
    if (StringUtils.isNotBlank(emrClusterDefinition.getServiceIamRole())) {
        runJobFlowRequest.setServiceRole(emrClusterDefinition.getServiceIamRole());
    } else {
        runJobFlowRequest.setServiceRole(herdStringHelper.getRequiredConfigurationValue(ConfigurationValue.EMR_DEFAULT_SERVICE_IAM_ROLE_NAME));
    }
    // Set the AMI version if specified
    if (StringUtils.isNotBlank(emrClusterDefinition.getAmiVersion())) {
        runJobFlowRequest.setAmiVersion(emrClusterDefinition.getAmiVersion());
    }
    // Set the additionalInfo if specified
    if (StringUtils.isNotBlank(emrClusterDefinition.getAdditionalInfo())) {
        runJobFlowRequest.setAdditionalInfo(emrClusterDefinition.getAdditionalInfo());
    }
    // Set the bootstrap actions
    if (!getBootstrapActionConfigList(emrClusterDefinition).isEmpty()) {
        runJobFlowRequest.setBootstrapActions(getBootstrapActionConfigList(emrClusterDefinition));
    }
    // Set the app installation steps
    runJobFlowRequest.setSteps(getStepConfig(emrClusterDefinition));
    // Set the tags
    runJobFlowRequest.setTags(getEmrTags(emrClusterDefinition));
    // Assign supported products as applicable
    if (StringUtils.isNotBlank(emrClusterDefinition.getSupportedProduct())) {
        List<String> supportedProducts = new ArrayList<>();
        supportedProducts.add(emrClusterDefinition.getSupportedProduct());
        runJobFlowRequest.setSupportedProducts(supportedProducts);
    }
    // Assign security configuration.
    if (StringUtils.isNotBlank(emrClusterDefinition.getSecurityConfiguration())) {
        runJobFlowRequest.setSecurityConfiguration(emrClusterDefinition.getSecurityConfiguration());
    }
    // Assign scale down behavior.
    if (StringUtils.isNotBlank(emrClusterDefinition.getScaleDownBehavior())) {
        runJobFlowRequest.setScaleDownBehavior(emrClusterDefinition.getScaleDownBehavior());
    }
    // Return the object
    return runJobFlowRequest;
}
Also used : RunJobFlowRequest(com.amazonaws.services.elasticmapreduce.model.RunJobFlowRequest) ArrayList(java.util.ArrayList) EmrClusterDefinitionConfiguration(org.finra.herd.model.api.xml.EmrClusterDefinitionConfiguration) EmrClusterDefinitionApplication(org.finra.herd.model.api.xml.EmrClusterDefinitionApplication)

Aggregations

RunJobFlowRequest (com.amazonaws.services.elasticmapreduce.model.RunJobFlowRequest)7 EmrClusterDefinition (org.finra.herd.model.api.xml.EmrClusterDefinition)5 NodeTag (org.finra.herd.model.api.xml.NodeTag)5 AwsParamsDto (org.finra.herd.model.dto.AwsParamsDto)5 Test (org.junit.Test)5 InvocationOnMock (org.mockito.invocation.InvocationOnMock)5 InstanceDefinition (org.finra.herd.model.api.xml.InstanceDefinition)4 InstanceDefinitions (org.finra.herd.model.api.xml.InstanceDefinitions)4 MasterInstanceDefinition (org.finra.herd.model.api.xml.MasterInstanceDefinition)4 ArrayList (java.util.ArrayList)3 InstanceGroupConfig (com.amazonaws.services.elasticmapreduce.model.InstanceGroupConfig)2 JobFlowInstancesConfig (com.amazonaws.services.elasticmapreduce.model.JobFlowInstancesConfig)2 Tag (com.amazonaws.services.elasticmapreduce.model.Tag)2 List (java.util.List)2 EmrClusterDefinitionApplication (org.finra.herd.model.api.xml.EmrClusterDefinitionApplication)2 EmrClusterDefinitionConfiguration (org.finra.herd.model.api.xml.EmrClusterDefinitionConfiguration)2 ClientConfiguration (com.amazonaws.ClientConfiguration)1 Application (com.amazonaws.services.elasticmapreduce.model.Application)1 BootstrapActionConfig (com.amazonaws.services.elasticmapreduce.model.BootstrapActionConfig)1 Configuration (com.amazonaws.services.elasticmapreduce.model.Configuration)1