Search in sources :

Example 1 with EmrStep

use of org.finra.herd.model.api.xml.EmrStep in project herd by FINRAOS.

the class EmrServiceImpl method buildEmrStepFromAwsStepSummary.

/**
 * Builds EmrStep object from the EMR StepSummary. Fills in details if verbose=true.
 */
private EmrStep buildEmrStepFromAwsStepSummary(StepSummary stepSummary) {
    EmrStep emrStep = new EmrStep();
    emrStep.setId(stepSummary.getId());
    emrStep.setStepName(stepSummary.getName());
    emrStep.setStatus(stepSummary.getStatus().getState());
    return emrStep;
}
Also used : EmrStep(org.finra.herd.model.api.xml.EmrStep)

Example 2 with EmrStep

use of org.finra.herd.model.api.xml.EmrStep in project herd by FINRAOS.

the class EmrServiceImpl method buildEmrStepFromAwsStep.

/**
 * Builds EmrStep object from the EMR step. Fills in details if verbose=true.
 *
 * @param stepSummary The step summary
 * @param verbose The verbose flag
 *
 * @return EmrStep
 */
private EmrStep buildEmrStepFromAwsStep(StepSummary stepSummary, boolean verbose) {
    EmrStep emrStep = new EmrStep();
    emrStep.setId(stepSummary.getId());
    emrStep.setStepName(stepSummary.getName());
    emrStep.setStatus(stepSummary.getStatus().getState());
    if (verbose) {
        emrStep.setJarLocation(stepSummary.getConfig().getJar());
        emrStep.setMainClass(stepSummary.getConfig().getMainClass());
        emrStep.setScriptArguments(stepSummary.getConfig().getArgs());
        emrStep.setContinueOnError(stepSummary.getActionOnFailure());
    }
    return emrStep;
}
Also used : EmrStep(org.finra.herd.model.api.xml.EmrStep)

Example 3 with EmrStep

use of org.finra.herd.model.api.xml.EmrStep in project herd by FINRAOS.

the class EmrServiceImpl method buildEmrStepFromAwsStep.

/**
 * Builds EmrStep object from the EMR step. Fills in details if verbose=true.
 *
 * @param step The step
 * @param verbose The verbose flag
 *
 * @return EmrStep
 */
private EmrStep buildEmrStepFromAwsStep(Step step, boolean verbose) {
    EmrStep emrStep = new EmrStep();
    emrStep.setId(step.getId());
    emrStep.setStepName(step.getName());
    emrStep.setStatus(step.getStatus().getState());
    if (verbose) {
        emrStep.setJarLocation(step.getConfig().getJar());
        emrStep.setMainClass(step.getConfig().getMainClass());
        emrStep.setScriptArguments(step.getConfig().getArgs());
        emrStep.setContinueOnError(step.getActionOnFailure());
    }
    return emrStep;
}
Also used : EmrStep(org.finra.herd.model.api.xml.EmrStep)

Example 4 with EmrStep

use of org.finra.herd.model.api.xml.EmrStep in project herd by FINRAOS.

the class EmrServiceImpl method getClusterImpl.

/**
 * Gets details of an existing EMR Cluster.
 *
 * @param emrClusterAlternateKeyDto the EMR cluster alternate key
 * @param emrClusterId the cluster id of the cluster to get details
 * @param emrStepId the step id of the step to get details
 * @param verbose parameter for whether to return detailed information
 * @param accountId the optional AWS account that EMR cluster is running in
 * @param retrieveInstanceFleets parameter for whether to retrieve instance fleets
 *
 * @return the EMR Cluster object with details.
 * @throws Exception if an error occurred while getting the cluster
 */
protected EmrCluster getClusterImpl(EmrClusterAlternateKeyDto emrClusterAlternateKeyDto, String emrClusterId, String emrStepId, boolean verbose, String accountId, Boolean retrieveInstanceFleets) throws Exception {
    AwsParamsDto awsParamsDto = emrHelper.getAwsParamsDtoByAcccountId(accountId);
    // Perform the request validation.
    validateEmrClusterKey(emrClusterAlternateKeyDto);
    // Get the namespace and ensure it exists.
    NamespaceEntity namespaceEntity = namespaceDaoHelper.getNamespaceEntity(emrClusterAlternateKeyDto.getNamespace());
    // Get the EMR cluster definition and ensure it exists.
    EmrClusterDefinitionEntity emrClusterDefinitionEntity = emrClusterDefinitionDaoHelper.getEmrClusterDefinitionEntity(emrClusterAlternateKeyDto.getNamespace(), emrClusterAlternateKeyDto.getEmrClusterDefinitionName());
    EmrCluster emrCluster = createEmrClusterFromRequest(null, namespaceEntity.getCode(), emrClusterDefinitionEntity.getName(), emrClusterAlternateKeyDto.getEmrClusterName(), accountId, null, null, null, null);
    String clusterName = emrHelper.buildEmrClusterName(namespaceEntity.getCode(), emrClusterDefinitionEntity.getName(), emrClusterAlternateKeyDto.getEmrClusterName());
    try {
        // Get Cluster status if clusterId is specified
        if (StringUtils.isNotBlank(emrClusterId)) {
            Cluster cluster = emrDao.getEmrClusterById(emrClusterId.trim(), awsParamsDto);
            // Validate that, Cluster exists
            Assert.notNull(cluster, "An EMR cluster must exists with the cluster ID \"" + emrClusterId + "\".");
            // Validate that, Cluster name match as specified
            Assert.isTrue(clusterName.equalsIgnoreCase(cluster.getName()), "Cluster name of specified cluster id \"" + emrClusterId + "\" must match the name specified.");
            emrCluster.setId(cluster.getId());
            setEmrClusterStatus(emrCluster, cluster.getStatus());
        } else {
            ClusterSummary clusterSummary = emrDao.getActiveEmrClusterByName(clusterName, awsParamsDto);
            // Validate that, Cluster exists with the name
            Assert.notNull(clusterSummary, "An EMR cluster must exists with the name \"" + clusterName + "\".");
            emrCluster.setId(clusterSummary.getId());
            setEmrClusterStatus(emrCluster, clusterSummary.getStatus());
        }
        // Get active step details
        if (emrHelper.isActiveEmrState(emrCluster.getStatus())) {
            StepSummary stepSummary = emrDao.getClusterActiveStep(emrCluster.getId(), awsParamsDto);
            if (stepSummary != null) {
                EmrStep activeStep;
                // If verbose get active step details
                if (verbose) {
                    activeStep = buildEmrStepFromAwsStep(stepSummary, true);
                } else {
                    activeStep = buildEmrStepFromAwsStepSummary(stepSummary);
                }
                emrCluster.setActiveStep(activeStep);
            }
        }
        // Get requested step details
        if (StringUtils.isNotBlank(emrStepId)) {
            Step step = emrDao.getClusterStep(emrCluster.getId(), emrStepId.trim(), awsParamsDto);
            emrCluster.setStep(buildEmrStepFromAwsStep(step, verbose));
        }
        // Get instance fleet if true
        if (BooleanUtils.isTrue(retrieveInstanceFleets)) {
            ListInstanceFleetsResult listInstanceFleetsResult = emrDao.getListInstanceFleetsResult(emrCluster.getId(), awsParamsDto);
            emrCluster.setInstanceFleets(emrHelper.buildEmrClusterInstanceFleetFromAwsResult(listInstanceFleetsResult));
        }
    } catch (AmazonServiceException ex) {
        handleAmazonException(ex, "An Amazon exception occurred while getting EMR cluster details with name \"" + clusterName + "\".");
    }
    return emrCluster;
}
Also used : AwsParamsDto(org.finra.herd.model.dto.AwsParamsDto) NamespaceEntity(org.finra.herd.model.jpa.NamespaceEntity) StepSummary(com.amazonaws.services.elasticmapreduce.model.StepSummary) ListInstanceFleetsResult(com.amazonaws.services.elasticmapreduce.model.ListInstanceFleetsResult) ClusterSummary(com.amazonaws.services.elasticmapreduce.model.ClusterSummary) EmrCluster(org.finra.herd.model.api.xml.EmrCluster) AmazonServiceException(com.amazonaws.AmazonServiceException) EmrCluster(org.finra.herd.model.api.xml.EmrCluster) Cluster(com.amazonaws.services.elasticmapreduce.model.Cluster) EmrStep(org.finra.herd.model.api.xml.EmrStep) Step(com.amazonaws.services.elasticmapreduce.model.Step) EmrStep(org.finra.herd.model.api.xml.EmrStep) EmrClusterDefinitionEntity(org.finra.herd.model.jpa.EmrClusterDefinitionEntity)

Aggregations

EmrStep (org.finra.herd.model.api.xml.EmrStep)4 AmazonServiceException (com.amazonaws.AmazonServiceException)1 Cluster (com.amazonaws.services.elasticmapreduce.model.Cluster)1 ClusterSummary (com.amazonaws.services.elasticmapreduce.model.ClusterSummary)1 ListInstanceFleetsResult (com.amazonaws.services.elasticmapreduce.model.ListInstanceFleetsResult)1 Step (com.amazonaws.services.elasticmapreduce.model.Step)1 StepSummary (com.amazonaws.services.elasticmapreduce.model.StepSummary)1 EmrCluster (org.finra.herd.model.api.xml.EmrCluster)1 AwsParamsDto (org.finra.herd.model.dto.AwsParamsDto)1 EmrClusterDefinitionEntity (org.finra.herd.model.jpa.EmrClusterDefinitionEntity)1 NamespaceEntity (org.finra.herd.model.jpa.NamespaceEntity)1