use of com.amazonaws.services.elasticmapreduce.model.StepSummary 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