use of org.finra.herd.service.helper.EmrStepHelper in project herd by FINRAOS.
the class EmrServiceImpl method addStepToClusterImpl.
/**
* Adds step to an existing EMR Cluster.
*
* @param request the EMR steps add request
*
* @return the EMR step add object with added steps
* @throws Exception if there were any errors while adding a step to the cluster.
*/
protected Object addStepToClusterImpl(Object request) throws Exception {
EmrStepHelper stepHelper = emrStepHelperFactory.getStepHelper(request.getClass().getName());
// Perform the request validation.
validateAddStepToClusterRequest(request, stepHelper);
// Perform the step specific validation
stepHelper.validateAddStepRequest(request);
// get accountId and awsParamDto
String accountId = stepHelper.getRequestAccountId(request);
AwsParamsDto awsParamsDto = emrHelper.getAwsParamsDtoByAcccountId(accountId);
// Get the namespace and ensure it exists.
NamespaceEntity namespaceEntity = namespaceDaoHelper.getNamespaceEntity(stepHelper.getRequestNamespace(request));
// Get the EMR cluster definition and ensure it exists.
EmrClusterDefinitionEntity emrClusterDefinitionEntity = emrClusterDefinitionDaoHelper.getEmrClusterDefinitionEntity(stepHelper.getRequestNamespace(request), stepHelper.getRequestEmrClusterDefinitionName(request));
// Update the namespace and cluster definition name in request from database.
stepHelper.setRequestNamespace(request, namespaceEntity.getCode());
stepHelper.setRequestEmrClusterDefinitionName(request, emrClusterDefinitionEntity.getName());
String clusterName = emrHelper.buildEmrClusterName(namespaceEntity.getCode(), emrClusterDefinitionEntity.getName(), stepHelper.getRequestEmrClusterName(request));
Object emrStep = stepHelper.buildResponseFromRequest(request);
try {
String clusterId = emrHelper.getActiveEmrClusterId(stepHelper.getRequestEmrClusterId(request), clusterName, stepHelper.getRequestAccountId(request));
stepHelper.setRequestEmrClusterId(request, clusterId);
String stepId = emrDao.addEmrStep(clusterId, stepHelper.getEmrStepConfig(emrStep), awsParamsDto);
stepHelper.setStepId(emrStep, stepId);
} catch (AmazonServiceException ex) {
handleAmazonException(ex, "An Amazon exception occurred while adding EMR step \"" + stepHelper.getRequestStepName(request) + "\" to cluster with name \"" + clusterName + "\".");
}
return emrStep;
}
Aggregations