Java Code Examples for com.amazonaws.AmazonServiceException#setErrorCode()

The following examples show how to use com.amazonaws.AmazonServiceException#setErrorCode() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SecurityGroupProviderTest.java    From fullstop with Apache License 2.0 6 votes vote down vote up
@Test
public void testAmazonException(){
    final AmazonServiceException amazonServiceException = new AmazonServiceException("");
    amazonServiceException.setErrorCode("InvalidGroup.NotFound");

    when(clientProviderMock.getClient(any(), anyString(), any(Region.class))).thenReturn(amazonEC2ClientMock);
    when(amazonEC2ClientMock.describeSecurityGroups(any(DescribeSecurityGroupsRequest.class))).thenThrow(amazonServiceException);

    securityGroupProvider = new SecurityGroupProvider(clientProviderMock);
    final String securityGroup = securityGroupProvider.getSecurityGroup(Lists.newArrayList("sg.1234"), REGION, "9876");

    Assertions.assertThat(securityGroup).isEqualTo(null);

    verify(clientProviderMock).getClient(any(), anyString(), any(Region.class));
    verify(amazonEC2ClientMock).describeSecurityGroups(any(DescribeSecurityGroupsRequest.class));
}
 
Example 2
Source File: EC2CredentialsUtils.java    From bazel with Apache License 2.0 6 votes vote down vote up
private void handleErrorResponse(InputStream errorStream, int statusCode, String responseMessage) throws IOException {
    String errorCode = null;

    // Parse the error stream returned from the service.
    if(errorStream != null) {
        try (Reader errorReader = new InputStreamReader(errorStream, Charsets.UTF_8)) {
            String errorResponse = CharStreams.toString(errorReader);
            JsonParser parser = new JsonParser();

            JsonObject node = parser.parse(errorResponse).getAsJsonObject();
            JsonElement code = node.get("code");
            JsonElement message = node.get("message");
            if (code != null && message != null) {
                errorCode = code.getAsString();
                responseMessage = message.getAsString();
            }
        } catch (Exception exception) {
            LOG.debug("Unable to parse error stream");
        }
    }

    AmazonServiceException ase = new AmazonServiceException(responseMessage);
    ase.setStatusCode(statusCode);
    ase.setErrorCode(errorCode);
    throw ase;
}
 
Example 3
Source File: DynamicQueueUrlDestinationResolverTest.java    From spring-cloud-aws with Apache License 2.0 6 votes vote down vote up
@Test
void testPotentiallyNoAccessToPerformGetQueueUrl() throws Exception {
	AmazonSQS amazonSqs = mock(AmazonSQS.class);
	AmazonServiceException exception = new QueueDoesNotExistException(
			"AWS.SimpleQueueService.NonExistentQueue");
	exception.setErrorCode("AWS.SimpleQueueService.NonExistentQueue");
	exception.setErrorMessage(
			"The specified queue does not exist or you do not have access to it.");
	String queueUrl = "noAccessGetQueueUrlName";
	when(amazonSqs.getQueueUrl(new GetQueueUrlRequest(queueUrl)))
			.thenThrow(exception);
	DynamicQueueUrlDestinationResolver dynamicQueueDestinationResolver = new DynamicQueueUrlDestinationResolver(
			amazonSqs);
	try {
		dynamicQueueDestinationResolver.resolveDestination(queueUrl);
	}
	catch (DestinationResolutionException e) {
		assertThat(e.getMessage()).startsWith(
				"The queue does not exist or no access to perform action sqs:GetQueueUrl.");
	}
}
 
Example 4
Source File: MockSqsOperationsImpl.java    From herd with Apache License 2.0 6 votes vote down vote up
@Override
public SendMessageResult sendMessage(String queueName, String messageText, Map<String, MessageAttributeValue> messageAttributes, AmazonSQS amazonSQS)
{
    // Throw a throttling exception for a specific queue name for testing purposes.
    if (queueName.equals(MockAwsOperationsHelper.AMAZON_THROTTLING_EXCEPTION))
    {
        AmazonServiceException throttlingException = new AmazonServiceException("test throttling exception");
        throttlingException.setErrorCode("ThrottlingException");
        throw throttlingException;
    }

    // Throw an illegal state exception for a specific queue name for testing purposes.
    if (queueName.equals(MOCK_SQS_QUEUE_NOT_FOUND_NAME))
    {
        throw new IllegalStateException(String.format("AWS SQS queue with \"%s\" name not found.", queueName));
    }

    // Nothing else to do in the normal case since our unit tests aren't reading messages once they have been published.
    return new SendMessageResult().withMessageId(AbstractDaoTest.MESSAGE_ID);
}
 
Example 5
Source File: MockEc2OperationsImpl.java    From herd with Apache License 2.0 6 votes vote down vote up
@Override
public void modifyInstanceAttribute(AmazonEC2Client ec2Client, ModifyInstanceAttributeRequest modifyInstanceAttributeRequest)
{
    if (modifyInstanceAttributeRequest.getGroups() != null &&
        modifyInstanceAttributeRequest.getGroups().get(0).equals(MockAwsOperationsHelper.AMAZON_SERVICE_EXCEPTION))
    {
        throw new AmazonServiceException(MockAwsOperationsHelper.AMAZON_SERVICE_EXCEPTION);
    }

    if (modifyInstanceAttributeRequest.getGroups() != null &&
        modifyInstanceAttributeRequest.getGroups().get(0).equals(MockAwsOperationsHelper.AMAZON_THROTTLING_EXCEPTION))
    {
        AmazonServiceException throttlingException = new AmazonServiceException("test throttling exception");
        throttlingException.setErrorCode("ThrottlingException");

        throw throttlingException;
    }

}
 
Example 6
Source File: AWSControllerIT.java    From development with Apache License 2.0 6 votes vote down vote up
@Ignore
@Test(expected = AbortException.class)
public void modifyInstance_AmazonServiceException() throws Exception {

    parameters.put(PropertyHandler.FLOW_STATE,
            new Setting(PropertyHandler.FLOW_STATE,
                    FlowState.MODIFICATION_REQUESTED.name()));
    parameters.put(PropertyHandler.OPERATION, new Setting(
            PropertyHandler.OPERATION, Operation.EC2_MODIFICATION.name()));

    AmazonServiceException ase = new AmazonServiceException("Test message");
    ase.setErrorCode("Unknown1234");
    ec2mock.createDescribeImagesException(ase);

    runUntilReady();
}
 
Example 7
Source File: AWSControllerIT.java    From development with Apache License 2.0 5 votes vote down vote up
@Test(expected = AbortException.class)
public void executeServiceOperation_AmazonServiceException()
        throws Exception {

    parameters.put(PropertyHandler.FLOW_STATE, new Setting(
            PropertyHandler.FLOW_STATE, FlowState.START_REQUESTED.name()));
    parameters.put(PropertyHandler.OPERATION, new Setting(
            PropertyHandler.OPERATION, Operation.EC2_OPERATION.name()));

    AmazonServiceException ase = new AmazonServiceException("Test message");
    ase.setErrorCode("Unknown1234");
    ec2mock.createStartInstanceException(ase);

    runUntilReady();
}
 
Example 8
Source File: VmManagerTest.java    From SeleniumGridScaler with GNU General Public License v2.0 5 votes vote down vote up
@Test
// Tests that if no fallback subnets are specified, the correct exception is thrown
public void testSubnetNoFallBack() throws NodesCouldNotBeStartedException {
    MockAmazonEc2Client client = new MockAmazonEc2Client(null);
    AmazonServiceException exception = new AmazonServiceException("message");
    exception.setErrorCode("InsufficientInstanceCapacity");
    client.setThrowDescribeInstancesError(exception);
    RunInstancesResult runInstancesResult = new RunInstancesResult();
    Reservation reservation = new Reservation();
    reservation.setInstances(Arrays.asList(new Instance()));
    runInstancesResult.setReservation(reservation);
    client.setRunInstances(runInstancesResult);
    Properties properties = new Properties();
    String region = "east", uuid="uuid",browser="chrome",os="linux";
    Integer threadCount = 5,maxSessions=5;
    MockManageVm manageEC2 = new MockManageVm(client,properties,region);
    String userData = "userData";
    String securityGroup="securityGroup",subnetId="subnetId",keyName="keyName",windowsImage="windowsImage";
    properties.setProperty(region + "_security_group",securityGroup);
    properties.setProperty(region + "_subnet_id", subnetId);
    properties.setProperty(region + "_key_name", keyName);
    properties.setProperty(region + "_windows_node_ami", windowsImage);
    manageEC2.setUserData(userData);
    try{
        manageEC2.launchNodes(uuid,os,browser,null,threadCount,maxSessions);
    } catch(NodesCouldNotBeStartedException e) {
        Assert.assertTrue("Failure message should be correct",e.getMessage().contains("Sufficient resources were not available in any of the availability zones"));
        return;
    }
    Assert.fail("Call should fail due to insufficient resources");
}
 
Example 9
Source File: VmManagerTest.java    From SeleniumGridScaler with GNU General Public License v2.0 5 votes vote down vote up
@Test
// Test that if a fallback subnet is specified, that the request for new nodes will fallback successfully and nodes will be spun up
public void testSubnetFallsBackSuccessfully() throws NodesCouldNotBeStartedException {
    MockAmazonEc2Client client = new MockAmazonEc2Client(null);
    AmazonServiceException exception = new AmazonServiceException("message");
    exception.setErrorCode("InsufficientInstanceCapacity");
    client.setThrowDescribeInstancesError(exception);
    RunInstancesResult runInstancesResult = new RunInstancesResult();
    Reservation reservation = new Reservation();
    reservation.setInstances(Arrays.asList(new Instance()));
    runInstancesResult.setReservation(reservation);
    client.setRunInstances(runInstancesResult);
    Properties properties = new Properties();
    String region = "east", uuid="uuid",browser="chrome",os="linux";
    Integer threadCount = 5,maxSessions=5;
    MockManageVm manageEC2 = new MockManageVm(client,properties,region);
    String userData = "userData";
    String securityGroup="securityGroup",subnetId="subnetId",keyName="keyName",windowsImage="windowsImage",fallBackSubnet="fallback";
    properties.setProperty(region + "_security_group",securityGroup);
    properties.setProperty(region + "_subnet_id", subnetId);
    properties.setProperty(region + "_subnet_fallback_id_1", fallBackSubnet);
    properties.setProperty(region + "_key_name", keyName);
    properties.setProperty(region + "_windows_node_ami", windowsImage);
    manageEC2.setUserData(userData);
    List<Instance> instances = manageEC2.launchNodes(uuid,os,browser,null,threadCount,maxSessions);
    System.out.print("");
}
 
Example 10
Source File: AWSControllerIT.java    From development with Apache License 2.0 5 votes vote down vote up
@Test(expected = AbortException.class)
public void createInstance_AmazonServiceException() throws Exception {

    parameters.put(PropertyHandler.FLOW_STATE,
            new Setting(PropertyHandler.FLOW_STATE,
                    FlowState.CREATION_REQUESTED.name()));
    parameters.put(PropertyHandler.OPERATION, new Setting(
            PropertyHandler.OPERATION, Operation.EC2_CREATION.name()));

    AmazonServiceException ase = new AmazonServiceException("Test message");
    ase.setErrorCode("Unknown1234");
    ec2mock.createDescribeImagesException(ase);

    runUntilReady();
}
 
Example 11
Source File: AWSControllerIT.java    From development with Apache License 2.0 5 votes vote down vote up
@Test(expected = SuspendException.class)
public void createInstance_AuthorizationFailed() throws Exception {

    parameters.put(PropertyHandler.FLOW_STATE,
            new Setting(PropertyHandler.FLOW_STATE,
                    FlowState.CREATION_REQUESTED.name()));
    parameters.put(PropertyHandler.OPERATION, new Setting(
            PropertyHandler.OPERATION, Operation.EC2_CREATION.name()));

    AmazonServiceException ase = new AmazonServiceException("Test message");
    ase.setErrorCode("UnauthorizedOperation");
    ec2mock.createDescribeImagesException(ase);

    runUntilReady();
}
 
Example 12
Source File: VmManagerTest.java    From SeleniumGridScaler with GNU General Public License v2.0 5 votes vote down vote up
@Test
// Tests that the built in guard against an infinite loop in the fallback recursive logic has a working safeguard
public void testSubnetInfiniteLoop() throws NodesCouldNotBeStartedException {
    MockAmazonEc2Client client = new MockAmazonEc2Client(null);
    client.setThrowExceptionsInRunInstancesIndefinitely();
    AmazonServiceException exception = new AmazonServiceException("message");
    exception.setErrorCode("InsufficientInstanceCapacity");
    client.setThrowDescribeInstancesError(exception);
    RunInstancesResult runInstancesResult = new RunInstancesResult();
    Reservation reservation = new Reservation();
    reservation.setInstances(Arrays.asList(new Instance()));
    runInstancesResult.setReservation(reservation);
    client.setRunInstances(runInstancesResult);
    Properties properties = new Properties();
    String region = "east", uuid="uuid",browser="chrome",os="linux";
    Integer threadCount = 5,maxSessions=5;
    MockManageVm manageEC2 = new MockManageVm(client,properties,region);
    String userData = "userData";
    String securityGroup="securityGroup",subnetId="subnetId",keyName="keyName",windowsImage="windowsImage";
    properties.setProperty(region + "_security_group",securityGroup);
    properties.setProperty(region + "_subnet_id", subnetId);
    properties.setProperty(region + "_subnet_fallback_id_1", "foo");
    properties.setProperty(region + "_subnet_fallback_id_2", "foo");
    properties.setProperty(region + "_subnet_fallback_id_3", "foo");
    properties.setProperty(region + "_subnet_fallback_id_4", "foo");
    properties.setProperty(region + "_subnet_fallback_id_5", "foo");
    properties.setProperty(region + "_subnet_fallback_id_6", "foo");
    properties.setProperty(region + "_key_name", keyName);
    properties.setProperty(region + "_windows_node_ami", windowsImage);
    manageEC2.setUserData(userData);
    try{
        manageEC2.launchNodes(uuid,os,browser,null,threadCount,maxSessions);
    } catch(NodesCouldNotBeStartedException e) {
        Assert.assertTrue("Failure message should be correct",e.getMessage().contains("Sufficient resources were not available in any of the availability zones"));
        return;
    }
    Assert.fail("Call should fail due to insufficient resources");
}
 
Example 13
Source File: DynamoDBFibonacciRetryerTest.java    From emr-dynamodb-connector with Apache License 2.0 5 votes vote down vote up
@Test(expected = RuntimeException.class)
public void testNonRetryableASEException() throws Exception {
  AmazonServiceException ase = new AmazonServiceException("Test");
  ase.setErrorCode("ArbitNonRetryableException");
  ase.setStatusCode(400);
  when(call.call()).thenThrow(ase);
  DynamoDBFibonacciRetryer retryer = new DynamoDBFibonacciRetryer(Duration.standardSeconds(10));

  try {
    retryer.runWithRetry(call, null, null);
  } finally {
    verify(call).call();
  }
}
 
Example 14
Source File: DynamoDBFibonacciRetryerTest.java    From emr-dynamodb-connector with Apache License 2.0 5 votes vote down vote up
@Test(expected = RuntimeException.class)
public void testRetryableASEException2() throws Exception {
  AmazonServiceException ase = new AmazonServiceException("Test");
  ase.setErrorCode("ArbitRetryableException");
  ase.setStatusCode(503);
  when(call.call()).thenThrow(ase);
  DynamoDBFibonacciRetryer retryer = new DynamoDBFibonacciRetryer(Duration.standardSeconds(10));

  try {
    retryer.runWithRetry(call, null, null);
  } finally {
    verify(call, atLeast(2)).call();
    verify(call, atMost(15)).call();
  }
}
 
Example 15
Source File: DynamoDBFibonacciRetryerTest.java    From emr-dynamodb-connector with Apache License 2.0 5 votes vote down vote up
@Test(expected = RuntimeException.class)
public void testRetryThrottleException() throws Exception {
  AmazonServiceException ase = new AmazonServiceException("Test");
  ase.setErrorCode("ProvisionedThroughputExceededException");
  ase.setStatusCode(400);
  when(call.call()).thenThrow(ase);
  DynamoDBFibonacciRetryer retryer = new DynamoDBFibonacciRetryer(Duration.standardSeconds(10));

  try {
    retryer.runWithRetry(call, null, null);
  } finally {
    verify(call, atLeast(2)).call();
    verify(call, atMost(15)).call();
  }
}
 
Example 16
Source File: AmazonServiceExceptionMappingServiceTest.java    From cyberduck with GNU General Public License v3.0 5 votes vote down vote up
@Test
public void testAccessFailure() {
    final AmazonServiceException f = new AmazonServiceException("message", null);
    f.setStatusCode(403);
    f.setErrorCode("AccessDenied");
    assertTrue(new AmazonServiceExceptionMappingService().map(f) instanceof AccessDeniedException);
    f.setErrorCode("SignatureDoesNotMatch");
    assertTrue(new AmazonServiceExceptionMappingService().map(f) instanceof LoginFailureException);
}
 
Example 17
Source File: MockS3OperationsImpl.java    From herd with Apache License 2.0 4 votes vote down vote up
/**
 * {@inheritDoc} <p/> <p> This implementation simulates a copyFile operation. </p> <p> This method copies files in-memory. </p> <p> The result {@link Copy}
 * has the following properties: <dl> <p/> <dt>description</dt> <dd>"MockTransfer"</dd> <p/> <dt>state</dt> <dd>{@link TransferState#Completed}</dd> <p/>
 * <dt>transferProgress.totalBytesToTransfer</dt> <dd>1024</dd> <p/> <dt>transferProgress.updateProgress</dt> <dd>1024</dd> <p/> </dl> <p/> All other
 * properties are set as default. </p> <p> This operation takes the following hints when suffixed in copyObjectRequest.sourceKey: <dl> <p/>
 * <dt>MOCK_S3_FILE_NAME_SERVICE_EXCEPTION</dt> <dd>Throws a AmazonServiceException</dd> <p/> </dl> </p>
 */
@Override
public Copy copyFile(final CopyObjectRequest copyObjectRequest, TransferManager transferManager)
{
    LOGGER.debug(
        "copyFile(): copyObjectRequest.getSourceBucketName() = " + copyObjectRequest.getSourceBucketName() + ", copyObjectRequest.getSourceKey() = " +
            copyObjectRequest.getSourceKey() + ", copyObjectRequest.getDestinationBucketName() = " + copyObjectRequest.getDestinationBucketName() +
            ", copyObjectRequest.getDestinationKey() = " + copyObjectRequest.getDestinationKey());

    if (copyObjectRequest.getSourceKey().endsWith(MOCK_S3_FILE_NAME_SERVICE_EXCEPTION))
    {
        throw new AmazonServiceException(null);
    }

    String sourceBucketName = copyObjectRequest.getSourceBucketName();
    String sourceKey = copyObjectRequest.getSourceKey();

    MockS3Bucket mockSourceS3Bucket = getOrCreateBucket(sourceBucketName);
    MockS3Object mockSourceS3Object = mockSourceS3Bucket.getObjects().get(sourceKey);

    if (mockSourceS3Object == null)
    {
        AmazonServiceException amazonServiceException = new AmazonServiceException(S3Operations.ERROR_CODE_NO_SUCH_KEY);
        amazonServiceException.setErrorCode(S3Operations.ERROR_CODE_NO_SUCH_KEY);
        throw amazonServiceException;
    }

    // Set the result CopyImpl and TransferProgress.
    TransferProgress transferProgress = new TransferProgress();
    transferProgress.setTotalBytesToTransfer(mockSourceS3Object.getObjectMetadata().getContentLength());
    transferProgress.updateProgress(mockSourceS3Object.getObjectMetadata().getContentLength());
    CopyImpl copy = new CopyImpl(MOCK_TRANSFER_DESCRIPTION, transferProgress, null, null);
    copy.setState(TransferState.Completed);

    // If an invalid KMS Id was passed in, mark the transfer as failed and return an exception via the transfer monitor.
    if (copyObjectRequest.getSSEAwsKeyManagementParams() != null)
    {
        final String kmsId = copyObjectRequest.getSSEAwsKeyManagementParams().getAwsKmsKeyId();
        if (kmsId.startsWith(MOCK_KMS_ID_FAILED_TRANSFER))
        {
            copy.setState(TransferState.Failed);
            copy.setMonitor(new TransferMonitor()
            {
                @Override
                public Future<?> getFuture()
                {
                    if (!kmsId.equals(MOCK_KMS_ID_FAILED_TRANSFER_NO_EXCEPTION))
                    {
                        throw new AmazonServiceException("Key '" + copyObjectRequest.getSSEAwsKeyManagementParams().getAwsKmsKeyId() +
                            "' does not exist (Service: Amazon S3; Status Code: 400; Error Code: KMS.NotFoundException; Request ID: 1234567890123456)");
                    }

                    // We don't want an exception to be thrown so return a basic future that won't throw an exception.
                    BasicFuture<?> future = new BasicFuture<Void>(null);
                    future.completed(null);
                    return future;
                }

                @Override
                public boolean isDone()
                {
                    return true;
                }
            });
        }
        else if (kmsId.startsWith(MOCK_KMS_ID_CANCELED_TRANSFER))
        {
            // If the KMS indicates a cancelled transfer, just update the state to canceled.
            copy.setState(TransferState.Canceled);
        }
    }

    // If copy operation is marked as completed, perform the actual file copy in memory.
    if (copy.getState().equals(TransferState.Completed))
    {
        String destinationBucketName = copyObjectRequest.getDestinationBucketName();
        String destinationObjectKey = copyObjectRequest.getDestinationKey();
        String destinationObjectVersion = MOCK_S3_BUCKET_NAME_VERSIONING_ENABLED.equals(destinationBucketName) ? UUID.randomUUID().toString() : null;
        String destinationObjectKeyVersion = destinationObjectKey + (destinationObjectVersion != null ? destinationObjectVersion : "");

        ObjectMetadata objectMetadata = copyObjectRequest.getNewObjectMetadata();
        MockS3Object mockDestinationS3Object = new MockS3Object();
        mockDestinationS3Object.setKey(destinationObjectKey);
        mockDestinationS3Object.setVersion(destinationObjectVersion);
        mockDestinationS3Object.setData(Arrays.copyOf(mockSourceS3Object.getData(), mockSourceS3Object.getData().length));
        mockDestinationS3Object.setObjectMetadata(objectMetadata);

        MockS3Bucket mockDestinationS3Bucket = getOrCreateBucket(destinationBucketName);
        mockDestinationS3Bucket.getObjects().put(destinationObjectKey, mockDestinationS3Object);
        mockDestinationS3Bucket.getVersions().put(destinationObjectKeyVersion, mockDestinationS3Object);
    }

    return copy;
}
 
Example 18
Source File: MockEmrOperationsImpl.java    From herd with Apache License 2.0 4 votes vote down vote up
@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();
        }
    }


    return createNewCluster(jobFlowRequest, clusterStatus, reason, timeline).getJobFlowId();
}
 
Example 19
Source File: JobExceptionHandlerImplTest.java    From fullstop with Apache License 2.0 4 votes vote down vote up
@Test
public void onRequestLimitExceededException() throws Exception {
    final AmazonServiceException exception = new AmazonServiceException("Oops");
    exception.setErrorCode("RequestLimitExceeded");
    jobExceptionHandler.onException(exception, ImmutableMap.of("aws_account", "111222333444"));
}
 
Example 20
Source File: JobExceptionHandlerImplTest.java    From fullstop with Apache License 2.0 4 votes vote down vote up
@Test
public void onAmazonException() throws Exception {
    final AmazonServiceException  exception = new AmazonServiceException("bla");
    exception.setErrorCode("SomethingElse");
    jobExceptionHandler.onException(exception, ImmutableMap.of("aws_account", "111222333444"));
}