Example usage for com.amazonaws.services.elasticmapreduce.model AddJobFlowStepsRequest getJobFlowId

List of usage examples for com.amazonaws.services.elasticmapreduce.model AddJobFlowStepsRequest getJobFlowId

Introduction

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

Prototype


public String getJobFlowId() 

Source Link

Document

A string that uniquely identifies the job flow.

Usage

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

License:Apache License

/**
 * Add Job Flow Step to AmazonElasticMapReduceClient
 *//*from ww  w  . j av a  2 s . c  o m*/
@Override
public List<String> addJobFlowStepsRequest(AmazonElasticMapReduceClient emrClient,
        AddJobFlowStepsRequest addJobFlowStepsRequest) {
    if (addJobFlowStepsRequest.getSteps() != null && addJobFlowStepsRequest.getSteps().get(0) != null) {
        StepConfig firstStep = addJobFlowStepsRequest.getSteps().get(0);

        if (firstStep.getName().equals(MockAwsOperationsHelper.AMAZON_BAD_REQUEST)) {
            AmazonServiceException badRequestException = new AmazonServiceException(
                    MockAwsOperationsHelper.AMAZON_BAD_REQUEST);
            badRequestException.setStatusCode(HttpStatus.SC_BAD_REQUEST);
            throw badRequestException;
        } else if (firstStep.getName().equals(MockAwsOperationsHelper.AMAZON_NOT_FOUND)) {
            AmazonServiceException notFoundException = new AmazonServiceException(
                    MockAwsOperationsHelper.AMAZON_NOT_FOUND);
            notFoundException.setStatusCode(HttpStatus.SC_NOT_FOUND);
            throw notFoundException;
        } else if (firstStep.getName().equals(MockAwsOperationsHelper.AMAZON_SERVICE_EXCEPTION)) {
            throw new AmazonServiceException(MockAwsOperationsHelper.AMAZON_SERVICE_EXCEPTION);
        }
    }

    MockEmrJobFlow cluster = getClusterById(addJobFlowStepsRequest.getJobFlowId());
    if (cluster == null) {
        throw new AmazonServiceException(
                "No Cluster exists with jobFlowId: " + addJobFlowStepsRequest.getJobFlowId());
    }
    List<String> jobIds = new ArrayList<>();
    for (StepConfig step : addJobFlowStepsRequest.getSteps()) {
        jobIds.add(addClusterStep(cluster.getJobFlowId(), step).getJobFlowId());
    }
    return jobIds;
}