Example usage for com.amazonaws.services.elasticmapreduce.model StepSummary getId

List of usage examples for com.amazonaws.services.elasticmapreduce.model StepSummary getId

Introduction

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

Prototype


public String getId() 

Source Link

Document

The identifier of the cluster step.

Usage

From source file:org.finra.dm.service.impl.EmrServiceImpl.java

License:Apache License

/**
 * 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 retrieveOozieJobs parameter for whether to retrieve oozie job information
 *
 * @return the EMR Cluster object with details.
 * @throws Exception if an error occurred while getting the cluster.
 *//* w w w.  j a va2 s  .  c o  m*/
protected EmrCluster getClusterImpl(EmrClusterAlternateKeyDto emrClusterAlternateKeyDto, String emrClusterId,
        String emrStepId, boolean verbose, boolean retrieveOozieJobs) throws Exception {
    // Perform the request validation.
    emrHelper.validateEmrClusterKey(emrClusterAlternateKeyDto);

    // Get the namespace and ensure it exists.
    NamespaceEntity namespaceEntity = dmDaoHelper.getNamespaceEntity(emrClusterAlternateKeyDto.getNamespace());

    // Get the EMR cluster definition and ensure it exists.
    EmrClusterDefinitionEntity emrClusterDefinitionEntity = dmDaoHelper.getEmrClusterDefinitionEntity(
            emrClusterAlternateKeyDto.getNamespace(), emrClusterAlternateKeyDto.getEmrClusterDefinitionName());

    EmrCluster emrCluster = createEmrClusterFromRequest(null, namespaceEntity.getCode(),
            emrClusterDefinitionEntity.getName(), emrClusterAlternateKeyDto.getEmrClusterName(), null, null,
            null, null);
    String clusterName = emrHelper.buildEmrClusterName(namespaceEntity.getCode(),
            emrClusterDefinitionEntity.getName(), emrClusterAlternateKeyDto.getEmrClusterName());
    try {
        // Get Cluster status if clusterId is specified
        if (StringUtils.hasText(emrClusterId)) {
            Cluster cluster = emrDao.getEmrClusterById(emrClusterId.trim(), emrHelper.getAwsParamsDto());

            // 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());
            emrCluster.setStatus(cluster.getStatus().getState());
        } else {
            ClusterSummary clusterSummary = emrDao.getActiveEmrClusterByName(clusterName,
                    emrHelper.getAwsParamsDto());

            // Validate that, Cluster exists with the name
            Assert.notNull(clusterSummary, "An EMR cluster must exists with the name \"" + clusterName + "\".");

            emrCluster.setId(clusterSummary.getId());
            emrCluster.setStatus(clusterSummary.getStatus().getState());
        }

        // Get active step details
        if (emrHelper.isActiveEmrState(emrCluster.getStatus())) {
            StepSummary stepSummary = emrDao.getClusterActiveStep(emrCluster.getId(),
                    emrHelper.getAwsParamsDto());
            if (stepSummary != null) {
                EmrStep activeStep;

                // If verbose get active step details
                if (verbose) {
                    activeStep = buildEmrStepFromAwsStep(emrDao.getClusterStep(emrCluster.getId(),
                            stepSummary.getId(), emrHelper.getAwsParamsDto()), true);
                } else {
                    activeStep = buildEmrStepFromAwsStepSummary(stepSummary);
                }
                emrCluster.setActiveStep(activeStep);
            }
        }

        // Get requested step details
        if (StringUtils.hasText(emrStepId)) {
            Step step = emrDao.getClusterStep(emrCluster.getId(), emrStepId.trim(),
                    emrHelper.getAwsParamsDto());

            emrCluster.setStep(buildEmrStepFromAwsStep(step, verbose));
        }

        // Get oozie job details if requested.
        if (retrieveOozieJobs && (emrCluster.getStatus().equalsIgnoreCase("RUNNING")
                || emrCluster.getStatus().equalsIgnoreCase("WAITING"))) {
            emrCluster.setOozieWorkflowJobs(retrieveOozieJobs(emrCluster.getId()));
        }
    } catch (AmazonServiceException ex) {
        handleAmazonException(ex, "An Amazon exception occurred while getting EMR cluster details with name \""
                + clusterName + "\".");
    }

    return emrCluster;
}

From source file:org.finra.dm.service.impl.EmrServiceImpl.java

License:Apache License

/**
 * Builds EmrStep object from the EMR StepSummary. Fills in details if verbose=true.
 *//*w w w  .j a  v  a2 s  . c o  m*/
private EmrStep buildEmrStepFromAwsStepSummary(StepSummary stepSummary) {
    EmrStep emrStep = new EmrStep();
    emrStep.setId(stepSummary.getId());
    emrStep.setStepName(stepSummary.getName());
    emrStep.setStatus(stepSummary.getStatus().getState());

    return emrStep;
}

From source file:org.finra.herd.service.impl.EmrServiceImpl.java

License:Apache License

/**
 * Builds EmrStep object from the EMR step. Fills in details if verbose=true.
 *
 * @param stepSummary The step summary/*from   ww w .  j  a v a 2  s.co  m*/
 * @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;
}