Search in sources :

Example 16 with EmrClusterDefinitionEntity

use of org.finra.herd.model.jpa.EmrClusterDefinitionEntity in project herd by FINRAOS.

the class EmrClusterDefinitionDaoTest method testGetEmrClusterDefinitionByAltKeyDefinitionNameNoExists.

/**
 * Tests the scenario by providing a EMR Cluster name that doesn't exist.
 */
@Test
public void testGetEmrClusterDefinitionByAltKeyDefinitionNameNoExists() throws IOException {
    // Create and persist an EMR Cluster definition entity.
    emrClusterDefinitionDaoTestHelper.createEmrClusterDefinitionEntity(namespaceDaoTestHelper.createNamespaceEntity(NAMESPACE), EMR_CLUSTER_DEFINITION_NAME, IOUtils.toString(resourceLoader.getResource(EMR_CLUSTER_DEFINITION_XML_FILE_WITH_CLASSPATH).getInputStream()));
    // Call the API to query the newly added entity by providing the app and a definition name that doesn't exist.
    EmrClusterDefinitionEntity emrClusterDefinitionEntityResult = emrClusterDefinitionDao.getEmrClusterDefinitionByAltKey(NAMESPACE, EMR_CLUSTER_DEFINITION_NAME_2);
    // Validate the results.
    assertNull(emrClusterDefinitionEntityResult);
}
Also used : EmrClusterDefinitionEntity(org.finra.herd.model.jpa.EmrClusterDefinitionEntity) Test(org.junit.Test)

Example 17 with EmrClusterDefinitionEntity

use of org.finra.herd.model.jpa.EmrClusterDefinitionEntity in project herd by FINRAOS.

the class EmrClusterDefinitionDaoTestHelper method createEmrClusterDefinitionEntity.

/**
 * Creates and persists a new EMR cluster definition entity.
 *
 * @param namespaceEntity the namespace entity
 * @param definitionName the cluster definition name
 * @param configurationXml the cluster configuration XML
 *
 * @return the newly created job definition entity
 */
public EmrClusterDefinitionEntity createEmrClusterDefinitionEntity(NamespaceEntity namespaceEntity, String definitionName, String configurationXml) {
    EmrClusterDefinitionEntity emrClusterDefinitionEntity = new EmrClusterDefinitionEntity();
    emrClusterDefinitionEntity.setNamespace(namespaceEntity);
    emrClusterDefinitionEntity.setName(definitionName);
    emrClusterDefinitionEntity.setConfiguration(configurationXml);
    return emrClusterDefinitionDao.saveAndRefresh(emrClusterDefinitionEntity);
}
Also used : EmrClusterDefinitionEntity(org.finra.herd.model.jpa.EmrClusterDefinitionEntity)

Example 18 with EmrClusterDefinitionEntity

use of org.finra.herd.model.jpa.EmrClusterDefinitionEntity in project herd by FINRAOS.

the class JobServiceTestHelper method createJobForCreateCluster.

/**
 * Creates a job based on the specified Activiti XML classpath resource location and defines a EMR cluster definition.
 *
 * @param activitiXmlClasspathResourceName the Activiti XML classpath resource location.
 * @param parameters the job parameters.
 *
 * @return the job.
 * @throws Exception if any errors were encountered.
 */
public Job createJobForCreateCluster(String activitiXmlClasspathResourceName, List<Parameter> parameters, String amiVersion) throws Exception {
    jobDefinitionServiceTestHelper.createJobDefinition(activitiXmlClasspathResourceName);
    NamespaceEntity namespaceEntity = namespaceDao.getNamespaceByCd(AbstractServiceTest.TEST_ACTIVITI_NAMESPACE_CD);
    String configXml = IOUtils.toString(resourceLoader.getResource(AbstractServiceTest.EMR_CLUSTER_DEFINITION_XML_FILE_WITH_CLASSPATH).getInputStream());
    EmrClusterDefinition emrClusterDefinition = xmlHelper.unmarshallXmlToObject(EmrClusterDefinition.class, configXml);
    emrClusterDefinition.setAmiVersion(amiVersion);
    configXml = xmlHelper.objectToXml(emrClusterDefinition);
    EmrClusterDefinitionEntity emrClusterDefinitionEntity = emrClusterDefinitionDaoTestHelper.createEmrClusterDefinitionEntity(namespaceEntity, AbstractServiceTest.EMR_CLUSTER_DEFINITION_NAME, configXml);
    Parameter parameter = new Parameter("emrClusterDefinitionName", emrClusterDefinitionEntity.getName());
    parameters.add(parameter);
    parameter = new Parameter("namespace", AbstractServiceTest.TEST_ACTIVITI_NAMESPACE_CD);
    parameters.add(parameter);
    // Start the job synchronously.
    return jobService.createAndStartJob(createJobCreateRequest(AbstractServiceTest.TEST_ACTIVITI_NAMESPACE_CD, AbstractServiceTest.TEST_ACTIVITI_JOB_NAME, parameters));
}
Also used : NamespaceEntity(org.finra.herd.model.jpa.NamespaceEntity) EmrClusterDefinition(org.finra.herd.model.api.xml.EmrClusterDefinition) Parameter(org.finra.herd.model.api.xml.Parameter) EmrClusterDefinitionEntity(org.finra.herd.model.jpa.EmrClusterDefinitionEntity)

Example 19 with EmrClusterDefinitionEntity

use of org.finra.herd.model.jpa.EmrClusterDefinitionEntity in project herd by FINRAOS.

the class JobServiceTestHelper method createJobForCreateClusterForActivitiXml.

/**
 * Creates a job based on the specified Activiti XML and defines a EMR cluster definition.
 *
 * @param activitiXml the Activiti XML.
 * @param parameters the job parameters.
 *
 * @return the job.
 * @throws Exception if any errors were encountered.
 */
public Job createJobForCreateClusterForActivitiXml(String activitiXml, List<Parameter> parameters) throws Exception {
    jobDefinitionServiceTestHelper.createJobDefinitionForActivitiXml(activitiXml);
    NamespaceEntity namespaceEntity = namespaceDao.getNamespaceByCd(AbstractServiceTest.TEST_ACTIVITI_NAMESPACE_CD);
    EmrClusterDefinitionEntity emrClusterDefinitionEntity = emrClusterDefinitionDaoTestHelper.createEmrClusterDefinitionEntity(namespaceEntity, AbstractServiceTest.EMR_CLUSTER_DEFINITION_NAME, IOUtils.toString(resourceLoader.getResource(AbstractServiceTest.EMR_CLUSTER_DEFINITION_XML_FILE_WITH_CLASSPATH).getInputStream()));
    Parameter parameter = new Parameter("namespace", namespaceEntity.getCode());
    parameters.add(parameter);
    parameter = new Parameter("emrClusterDefinitionName", emrClusterDefinitionEntity.getName());
    parameters.add(parameter);
    parameter = new Parameter("dryRun", null);
    parameters.add(parameter);
    parameter = new Parameter("contentType", null);
    parameters.add(parameter);
    parameter = new Parameter("emrClusterDefinitionOverride", null);
    parameters.add(parameter);
    // Start the job synchronously.
    return jobService.createAndStartJob(createJobCreateRequest(AbstractServiceTest.TEST_ACTIVITI_NAMESPACE_CD, AbstractServiceTest.TEST_ACTIVITI_JOB_NAME, parameters));
}
Also used : NamespaceEntity(org.finra.herd.model.jpa.NamespaceEntity) Parameter(org.finra.herd.model.api.xml.Parameter) EmrClusterDefinitionEntity(org.finra.herd.model.jpa.EmrClusterDefinitionEntity)

Example 20 with EmrClusterDefinitionEntity

use of org.finra.herd.model.jpa.EmrClusterDefinitionEntity in project herd by FINRAOS.

the class EmrClusterDefinitionServiceTest method testGetEmrClusterDefinitionTrimParameters.

@Test
public void testGetEmrClusterDefinitionTrimParameters() throws Exception {
    // Create and persist the namespace entity.
    NamespaceEntity namespaceEntity = namespaceDaoTestHelper.createNamespaceEntity(NAMESPACE);
    // Create and persist the EMR cluster definition entity.
    EmrClusterDefinitionEntity emrClusterDefinitionEntity = emrClusterDefinitionDaoTestHelper.createEmrClusterDefinitionEntity(namespaceEntity, EMR_CLUSTER_DEFINITION_NAME, getTestEmrClusterDefinitionConfigurationXml(EMR_CLUSTER_DEFINITION_XML_FILE_WITH_CLASSPATH));
    // Get an EMR cluster definition by passing namespace and EMR cluster definition name with leading and trailing whitespace characters.
    EmrClusterDefinitionInformation resultEmrClusterDefinition = emrClusterDefinitionService.getEmrClusterDefinition(new EmrClusterDefinitionKey(addWhitespace(NAMESPACE), addWhitespace(EMR_CLUSTER_DEFINITION_NAME)));
    // Validate the returned object.
    validateEmrClusterDefinition(emrClusterDefinitionEntity.getId(), NAMESPACE, EMR_CLUSTER_DEFINITION_NAME, getTestEmrClusterDefinitionConfiguration(EMR_CLUSTER_DEFINITION_XML_FILE_WITH_CLASSPATH), resultEmrClusterDefinition);
}
Also used : NamespaceEntity(org.finra.herd.model.jpa.NamespaceEntity) EmrClusterDefinitionKey(org.finra.herd.model.api.xml.EmrClusterDefinitionKey) EmrClusterDefinitionInformation(org.finra.herd.model.api.xml.EmrClusterDefinitionInformation) EmrClusterDefinitionEntity(org.finra.herd.model.jpa.EmrClusterDefinitionEntity) Test(org.junit.Test)

Aggregations

EmrClusterDefinitionEntity (org.finra.herd.model.jpa.EmrClusterDefinitionEntity)31 NamespaceEntity (org.finra.herd.model.jpa.NamespaceEntity)24 Test (org.junit.Test)16 EmrClusterDefinitionKey (org.finra.herd.model.api.xml.EmrClusterDefinitionKey)14 EmrClusterDefinitionInformation (org.finra.herd.model.api.xml.EmrClusterDefinitionInformation)12 AwsParamsDto (org.finra.herd.model.dto.AwsParamsDto)6 AmazonServiceException (com.amazonaws.AmazonServiceException)5 NamespacePermission (org.finra.herd.model.annotation.NamespacePermission)4 ClusterSummary (com.amazonaws.services.elasticmapreduce.model.ClusterSummary)2 CriteriaBuilder (javax.persistence.criteria.CriteriaBuilder)2 Predicate (javax.persistence.criteria.Predicate)2 EmrClusterDefinition (org.finra.herd.model.api.xml.EmrClusterDefinition)2 Parameter (org.finra.herd.model.api.xml.Parameter)2 EmrClusterAlternateKeyDto (org.finra.herd.model.dto.EmrClusterAlternateKeyDto)2 Cluster (com.amazonaws.services.elasticmapreduce.model.Cluster)1 ListInstanceFleetsResult (com.amazonaws.services.elasticmapreduce.model.ListInstanceFleetsResult)1 Step (com.amazonaws.services.elasticmapreduce.model.Step)1 StepSummary (com.amazonaws.services.elasticmapreduce.model.StepSummary)1 ArrayList (java.util.ArrayList)1 Tuple (javax.persistence.Tuple)1