use of com.amazonaws.services.elasticmapreduce.model.Step 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()));
}
use of com.amazonaws.services.elasticmapreduce.model.Step 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);
}
use of com.amazonaws.services.elasticmapreduce.model.Step in project herd by FINRAOS.
the class EmrServiceImpl method getClusterImpl.
/**
* 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 accountId the optional AWS account that EMR cluster is running in
* @param retrieveInstanceFleets parameter for whether to retrieve instance fleets
*
* @return the EMR Cluster object with details.
* @throws Exception if an error occurred while getting the cluster
*/
protected EmrCluster getClusterImpl(EmrClusterAlternateKeyDto emrClusterAlternateKeyDto, String emrClusterId, String emrStepId, boolean verbose, String accountId, Boolean retrieveInstanceFleets) throws Exception {
AwsParamsDto awsParamsDto = emrHelper.getAwsParamsDtoByAcccountId(accountId);
// Perform the request validation.
validateEmrClusterKey(emrClusterAlternateKeyDto);
// Get the namespace and ensure it exists.
NamespaceEntity namespaceEntity = namespaceDaoHelper.getNamespaceEntity(emrClusterAlternateKeyDto.getNamespace());
// Get the EMR cluster definition and ensure it exists.
EmrClusterDefinitionEntity emrClusterDefinitionEntity = emrClusterDefinitionDaoHelper.getEmrClusterDefinitionEntity(emrClusterAlternateKeyDto.getNamespace(), emrClusterAlternateKeyDto.getEmrClusterDefinitionName());
EmrCluster emrCluster = createEmrClusterFromRequest(null, namespaceEntity.getCode(), emrClusterDefinitionEntity.getName(), emrClusterAlternateKeyDto.getEmrClusterName(), accountId, null, null, null, null);
String clusterName = emrHelper.buildEmrClusterName(namespaceEntity.getCode(), emrClusterDefinitionEntity.getName(), emrClusterAlternateKeyDto.getEmrClusterName());
try {
// Get Cluster status if clusterId is specified
if (StringUtils.isNotBlank(emrClusterId)) {
Cluster cluster = emrDao.getEmrClusterById(emrClusterId.trim(), awsParamsDto);
// 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());
setEmrClusterStatus(emrCluster, cluster.getStatus());
} else {
ClusterSummary clusterSummary = emrDao.getActiveEmrClusterByName(clusterName, awsParamsDto);
// Validate that, Cluster exists with the name
Assert.notNull(clusterSummary, "An EMR cluster must exists with the name \"" + clusterName + "\".");
emrCluster.setId(clusterSummary.getId());
setEmrClusterStatus(emrCluster, clusterSummary.getStatus());
}
// Get active step details
if (emrHelper.isActiveEmrState(emrCluster.getStatus())) {
StepSummary stepSummary = emrDao.getClusterActiveStep(emrCluster.getId(), awsParamsDto);
if (stepSummary != null) {
EmrStep activeStep;
// If verbose get active step details
if (verbose) {
activeStep = buildEmrStepFromAwsStep(stepSummary, true);
} else {
activeStep = buildEmrStepFromAwsStepSummary(stepSummary);
}
emrCluster.setActiveStep(activeStep);
}
}
// Get requested step details
if (StringUtils.isNotBlank(emrStepId)) {
Step step = emrDao.getClusterStep(emrCluster.getId(), emrStepId.trim(), awsParamsDto);
emrCluster.setStep(buildEmrStepFromAwsStep(step, verbose));
}
// Get instance fleet if true
if (BooleanUtils.isTrue(retrieveInstanceFleets)) {
ListInstanceFleetsResult listInstanceFleetsResult = emrDao.getListInstanceFleetsResult(emrCluster.getId(), awsParamsDto);
emrCluster.setInstanceFleets(emrHelper.buildEmrClusterInstanceFleetFromAwsResult(listInstanceFleetsResult));
}
} catch (AmazonServiceException ex) {
handleAmazonException(ex, "An Amazon exception occurred while getting EMR cluster details with name \"" + clusterName + "\".");
}
return emrCluster;
}
Aggregations