Example usage for com.amazonaws.services.elasticmapreduce.model RunJobFlowRequest getAmiVersion

List of usage examples for com.amazonaws.services.elasticmapreduce.model RunJobFlowRequest getAmiVersion

Introduction

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

Prototype


public String getAmiVersion() 

Source Link

Document

Applies only to Amazon EMR AMI versions 3.x and 2.x.

Usage

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

License:Apache License

@Override
public String runEmrJobFlow(AmazonElasticMapReduceClient emrClient, RunJobFlowRequest jobFlowRequest) {
    String clusterStatus = ClusterState.BOOTSTRAPPING.toString();

    if (StringUtils.isNotBlank(jobFlowRequest.getAmiVersion())) {
        if (jobFlowRequest.getAmiVersion().equals(MockAwsOperationsHelper.AMAZON_THROTTLING_EXCEPTION)) {
            AmazonServiceException throttlingException = new AmazonServiceException(
                    "test throttling exception");
            throttlingException.setErrorCode("ThrottlingException");

            throw throttlingException;
        } else if (jobFlowRequest.getAmiVersion().equals(MockAwsOperationsHelper.AMAZON_BAD_REQUEST)) {
            AmazonServiceException badRequestException = new AmazonServiceException(
                    MockAwsOperationsHelper.AMAZON_BAD_REQUEST);
            badRequestException.setStatusCode(HttpStatus.SC_BAD_REQUEST);
            throw badRequestException;
        } else if (jobFlowRequest.getAmiVersion().equals(MockAwsOperationsHelper.AMAZON_NOT_FOUND)) {
            AmazonServiceException notFoundException = new AmazonServiceException(
                    MockAwsOperationsHelper.AMAZON_NOT_FOUND);
            notFoundException.setStatusCode(HttpStatus.SC_NOT_FOUND);
            throw notFoundException;
        } else if (jobFlowRequest.getAmiVersion().equals(MockAwsOperationsHelper.AMAZON_SERVICE_EXCEPTION)) {
            throw new AmazonServiceException(MockAwsOperationsHelper.AMAZON_SERVICE_EXCEPTION);
        } else if (jobFlowRequest.getAmiVersion()
                .equals(MockAwsOperationsHelper.AMAZON_CLUSTER_STATUS_WAITING)) {
            clusterStatus = ClusterState.WAITING.toString();
        } else if (jobFlowRequest.getAmiVersion()
                .equals(MockAwsOperationsHelper.AMAZON_CLUSTER_STATUS_RUNNING)) {
            clusterStatus = ClusterState.RUNNING.toString();
        }/*from  www . j a va  2  s .  c  o  m*/
    }

    return createNewCluster(jobFlowRequest, clusterStatus).getJobFlowId();
}

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

License:Apache License

@Override
public String runEmrJobFlow(AmazonElasticMapReduceClient emrClient, RunJobFlowRequest jobFlowRequest) {
    String clusterStatus = ClusterState.BOOTSTRAPPING.toString();

    StatusChangeReason reason = new StatusChangeReason(ClusterStateChangeReasonCode.USER_REQUEST.toString(),
            "Started " + clusterStatus);
    StatusTimeline timeline = new StatusTimeline();
    timeline.setCreationTime(HerdDateUtils.getXMLGregorianCalendarValue(new Date()));

    if (StringUtils.isNotBlank(jobFlowRequest.getAmiVersion())) {
        if (jobFlowRequest.getAmiVersion().equals(MockAwsOperationsHelper.AMAZON_THROTTLING_EXCEPTION)) {
            AmazonServiceException throttlingException = new AmazonServiceException(
                    "test throttling exception");
            throttlingException.setErrorCode("ThrottlingException");

            throw throttlingException;
        } else if (jobFlowRequest.getAmiVersion().equals(MockAwsOperationsHelper.AMAZON_BAD_REQUEST)) {
            AmazonServiceException badRequestException = new AmazonServiceException(
                    MockAwsOperationsHelper.AMAZON_BAD_REQUEST);
            badRequestException.setStatusCode(HttpStatus.SC_BAD_REQUEST);
            throw badRequestException;
        } else if (jobFlowRequest.getAmiVersion().equals(MockAwsOperationsHelper.AMAZON_NOT_FOUND)) {
            AmazonServiceException notFoundException = new AmazonServiceException(
                    MockAwsOperationsHelper.AMAZON_NOT_FOUND);
            notFoundException.setStatusCode(HttpStatus.SC_NOT_FOUND);
            throw notFoundException;
        } else if (jobFlowRequest.getAmiVersion().equals(MockAwsOperationsHelper.AMAZON_SERVICE_EXCEPTION)) {
            throw new AmazonServiceException(MockAwsOperationsHelper.AMAZON_SERVICE_EXCEPTION);
        } else if (jobFlowRequest.getAmiVersion()
                .equals(MockAwsOperationsHelper.AMAZON_CLUSTER_STATUS_WAITING)) {
            clusterStatus = ClusterState.WAITING.toString();
        } else if (jobFlowRequest.getAmiVersion()
                .equals(MockAwsOperationsHelper.AMAZON_CLUSTER_STATUS_RUNNING)) {
            clusterStatus = ClusterState.RUNNING.toString();
        }//  w  w  w  . j  av  a 2 s  . c om
    }

    return createNewCluster(jobFlowRequest, clusterStatus, reason, timeline).getJobFlowId();
}