Search in sources :

Example 1 with DescribeStepResult

use of com.amazonaws.services.elasticmapreduce.model.DescribeStepResult in project herd by FINRAOS.

the class EmrDaoTest method getClusterStepAssertCallsDescribeStepAndReturnsStep.

@Test
public void getClusterStepAssertCallsDescribeStepAndReturnsStep() throws Exception {
    String clusterId = "clusterId";
    String stepId = "stepId";
    Step expectedStep = new Step();
    when(mockEmrOperations.describeStepRequest(any(), any())).then(new Answer<DescribeStepResult>() {

        @Override
        public DescribeStepResult answer(InvocationOnMock invocation) throws Throwable {
            DescribeStepRequest describeStepRequest = invocation.getArgument(1);
            assertEquals(clusterId, describeStepRequest.getClusterId());
            assertEquals(stepId, describeStepRequest.getStepId());
            DescribeStepResult describeStepResult = new DescribeStepResult();
            describeStepResult.setStep(expectedStep);
            return describeStepResult;
        }
    });
    assertEquals(expectedStep, emrDao.getClusterStep(clusterId, stepId, new AwsParamsDto()));
}
Also used : AwsParamsDto(org.finra.herd.model.dto.AwsParamsDto) DescribeStepResult(com.amazonaws.services.elasticmapreduce.model.DescribeStepResult) DescribeStepRequest(com.amazonaws.services.elasticmapreduce.model.DescribeStepRequest) InvocationOnMock(org.mockito.invocation.InvocationOnMock) Step(com.amazonaws.services.elasticmapreduce.model.Step) HadoopJarStep(org.finra.herd.model.api.xml.HadoopJarStep) Test(org.junit.Test)

Example 2 with DescribeStepResult

use of com.amazonaws.services.elasticmapreduce.model.DescribeStepResult in project herd by FINRAOS.

the class MockEmrOperationsImpl method describeStepRequest.

@Override
public DescribeStepResult describeStepRequest(AmazonElasticMapReduceClient emrClient, DescribeStepRequest describeStepRequest) {
    MockEmrJobFlow cluster = getClusterById(describeStepRequest.getClusterId());
    if (cluster == null) {
        throw new AmazonServiceException("No cluster found with jobFlowId: " + describeStepRequest.getClusterId());
    }
    Step stepResult = null;
    // Add steps that are in these states
    for (MockEmrJobFlow step : cluster.getSteps()) {
        if (describeStepRequest.getStepId().equalsIgnoreCase(step.getJobFlowId())) {
            HadoopStepConfig hadoopStepConfig = new HadoopStepConfig().withJar(step.getJarLocation());
            stepResult = new Step().withId(step.getJobFlowId()).withName(step.getJobFlowName()).withStatus(new StepStatus().withState(step.getStatus())).withConfig(hadoopStepConfig);
            if (stepResult.getName().equalsIgnoreCase(MOCK_STEP_WITHOUT_ID_NAME)) {
                stepResult.setId(null);
            }
            break;
        }
    }
    return new DescribeStepResult().withStep(stepResult);
}
Also used : DescribeStepResult(com.amazonaws.services.elasticmapreduce.model.DescribeStepResult) AmazonServiceException(com.amazonaws.AmazonServiceException) Step(com.amazonaws.services.elasticmapreduce.model.Step) HadoopStepConfig(com.amazonaws.services.elasticmapreduce.model.HadoopStepConfig) StepStatus(com.amazonaws.services.elasticmapreduce.model.StepStatus)

Aggregations

DescribeStepResult (com.amazonaws.services.elasticmapreduce.model.DescribeStepResult)2 Step (com.amazonaws.services.elasticmapreduce.model.Step)2 AmazonServiceException (com.amazonaws.AmazonServiceException)1 DescribeStepRequest (com.amazonaws.services.elasticmapreduce.model.DescribeStepRequest)1 HadoopStepConfig (com.amazonaws.services.elasticmapreduce.model.HadoopStepConfig)1 StepStatus (com.amazonaws.services.elasticmapreduce.model.StepStatus)1 HadoopJarStep (org.finra.herd.model.api.xml.HadoopJarStep)1 AwsParamsDto (org.finra.herd.model.dto.AwsParamsDto)1 Test (org.junit.Test)1 InvocationOnMock (org.mockito.invocation.InvocationOnMock)1