Search in sources :

Example 1 with EmrClusterDefinitionInstanceTypeConfig

use of org.finra.herd.model.api.xml.EmrClusterDefinitionInstanceTypeConfig in project herd by FINRAOS.

the class EmrDaoImplTest method testGetInstanceTypeConfigs.

@Test
public void testGetInstanceTypeConfigs() {
    // Create objects required for testing.
    final String instanceType = STRING_VALUE;
    final Integer weightedCapacity = INTEGER_VALUE;
    final String bidPrice = STRING_VALUE_2;
    final Double bidPriceAsPercentageOfOnDemandPrice = DOUBLE_VALUE;
    final EmrClusterDefinitionEbsConfiguration emrClusterDefinitionEbsConfiguration = null;
    final List<EmrClusterDefinitionConfiguration> emrClusterDefinitionConfigurations = null;
    final EmrClusterDefinitionInstanceTypeConfig emrClusterDefinitionInstanceTypeConfig = new EmrClusterDefinitionInstanceTypeConfig(instanceType, weightedCapacity, bidPrice, bidPriceAsPercentageOfOnDemandPrice, emrClusterDefinitionEbsConfiguration, emrClusterDefinitionConfigurations);
    // Call the method under test.
    List<InstanceTypeConfig> result = emrDaoImpl.getInstanceTypeConfigs(Arrays.asList(emrClusterDefinitionInstanceTypeConfig));
    // Verify the external calls.
    verifyNoMoreInteractionsHelper();
    // Validate the results.
    final List<Configuration> expectedConfigurations = null;
    assertEquals(Arrays.asList(new InstanceTypeConfig().withInstanceType(instanceType).withWeightedCapacity(weightedCapacity).withBidPrice(bidPrice).withBidPriceAsPercentageOfOnDemandPrice(bidPriceAsPercentageOfOnDemandPrice).withEbsConfiguration(null).withConfigurations(expectedConfigurations)), result);
}
Also used : EmrClusterDefinitionInstanceTypeConfig(org.finra.herd.model.api.xml.EmrClusterDefinitionInstanceTypeConfig) EmrClusterDefinitionConfiguration(org.finra.herd.model.api.xml.EmrClusterDefinitionConfiguration) Configuration(com.amazonaws.services.elasticmapreduce.model.Configuration) EmrClusterDefinitionEbsConfiguration(org.finra.herd.model.api.xml.EmrClusterDefinitionEbsConfiguration) EbsConfiguration(com.amazonaws.services.elasticmapreduce.model.EbsConfiguration) EmrClusterDefinitionConfiguration(org.finra.herd.model.api.xml.EmrClusterDefinitionConfiguration) EmrClusterDefinitionEbsConfiguration(org.finra.herd.model.api.xml.EmrClusterDefinitionEbsConfiguration) InstanceTypeConfig(com.amazonaws.services.elasticmapreduce.model.InstanceTypeConfig) EmrClusterDefinitionInstanceTypeConfig(org.finra.herd.model.api.xml.EmrClusterDefinitionInstanceTypeConfig) Test(org.junit.Test) AbstractDaoTest(org.finra.herd.dao.AbstractDaoTest)

Example 2 with EmrClusterDefinitionInstanceTypeConfig

use of org.finra.herd.model.api.xml.EmrClusterDefinitionInstanceTypeConfig in project herd by FINRAOS.

the class EmrDaoImplTest method testGetInstanceFleets.

@Test
public void testGetInstanceFleets() {
    // Create objects required for testing.
    final String name = STRING_VALUE;
    final String instanceFleetType = STRING_VALUE_2;
    final Integer targetOnDemandCapacity = INTEGER_VALUE;
    final Integer targetSpotCapacity = INTEGER_VALUE_2;
    final List<EmrClusterDefinitionInstanceTypeConfig> emrClusterDefinitionInstanceTypeConfigs = null;
    final EmrClusterDefinitionLaunchSpecifications emrClusterDefinitionLaunchSpecifications = null;
    final EmrClusterDefinitionInstanceFleet emrClusterDefinitionInstanceFleet = new EmrClusterDefinitionInstanceFleet(name, instanceFleetType, targetOnDemandCapacity, targetSpotCapacity, emrClusterDefinitionInstanceTypeConfigs, emrClusterDefinitionLaunchSpecifications);
    // Call the method under test.
    List<InstanceFleetConfig> result = emrDaoImpl.getInstanceFleets(Arrays.asList(emrClusterDefinitionInstanceFleet));
    // Verify the external calls.
    verifyNoMoreInteractionsHelper();
    // Validate the results.
    final List<InstanceTypeConfig> expectedInstanceTypeConfigs = null;
    assertEquals(Arrays.asList(new InstanceFleetConfig().withName(name).withInstanceFleetType(instanceFleetType).withTargetOnDemandCapacity(targetOnDemandCapacity).withTargetSpotCapacity(targetSpotCapacity).withInstanceTypeConfigs(expectedInstanceTypeConfigs).withLaunchSpecifications(null)), result);
}
Also used : EmrClusterDefinitionInstanceTypeConfig(org.finra.herd.model.api.xml.EmrClusterDefinitionInstanceTypeConfig) InstanceFleetConfig(com.amazonaws.services.elasticmapreduce.model.InstanceFleetConfig) EmrClusterDefinitionInstanceFleet(org.finra.herd.model.api.xml.EmrClusterDefinitionInstanceFleet) InstanceTypeConfig(com.amazonaws.services.elasticmapreduce.model.InstanceTypeConfig) EmrClusterDefinitionInstanceTypeConfig(org.finra.herd.model.api.xml.EmrClusterDefinitionInstanceTypeConfig) EmrClusterDefinitionLaunchSpecifications(org.finra.herd.model.api.xml.EmrClusterDefinitionLaunchSpecifications) Test(org.junit.Test) AbstractDaoTest(org.finra.herd.dao.AbstractDaoTest)

Example 3 with EmrClusterDefinitionInstanceTypeConfig

use of org.finra.herd.model.api.xml.EmrClusterDefinitionInstanceTypeConfig in project herd by FINRAOS.

the class EmrDaoTest method createEmrClusterAssertCallRunEmrJobFlowWithInstanceFleetAndMultipleSubnets.

@Test
public void createEmrClusterAssertCallRunEmrJobFlowWithInstanceFleetAndMultipleSubnets() throws Exception {
    // Create objects required for testing.
    final String clusterName = "clusterName";
    final String clusterId = "clusterId";
    final String name = STRING_VALUE;
    final String instanceFleetType = STRING_VALUE_2;
    final Integer targetOnDemandCapacity = INTEGER_VALUE;
    final Integer targetSpotCapacity = INTEGER_VALUE_2;
    final List<EmrClusterDefinitionInstanceTypeConfig> emrClusterDefinitionInstanceTypeConfigs = null;
    final EmrClusterDefinitionLaunchSpecifications emrClusterDefinitionLaunchSpecifications = null;
    final EmrClusterDefinitionInstanceFleet emrClusterDefinitionInstanceFleet = new EmrClusterDefinitionInstanceFleet(name, instanceFleetType, targetOnDemandCapacity, targetSpotCapacity, emrClusterDefinitionInstanceTypeConfigs, emrClusterDefinitionLaunchSpecifications);
    // Create an EMR cluster definition with instance fleet configuration and multiple EC2 subnet IDs.
    EmrClusterDefinition emrClusterDefinition = new EmrClusterDefinition();
    emrClusterDefinition.setInstanceFleets(Arrays.asList(emrClusterDefinitionInstanceFleet));
    emrClusterDefinition.setSubnetId(String.format("%s , %s  ", EC2_SUBNET, EC2_SUBNET_2));
    emrClusterDefinition.setNodeTags(Arrays.asList(new NodeTag("tagName", "tagValue")));
    when(mockEmrOperations.runEmrJobFlow(any(), any())).then(new Answer<String>() {

        @Override
        public String answer(InvocationOnMock invocation) throws Throwable {
            // Assert that the given EMR cluster definition produced the correct RunJobFlowRequest.
            RunJobFlowRequest runJobFlowRequest = invocation.getArgument(1);
            JobFlowInstancesConfig jobFlowInstancesConfig = runJobFlowRequest.getInstances();
            assertEquals(0, CollectionUtils.size(jobFlowInstancesConfig.getInstanceGroups()));
            final List<InstanceTypeConfig> expectedInstanceTypeConfigs = null;
            assertEquals(Arrays.asList(new InstanceFleetConfig().withName(name).withInstanceFleetType(instanceFleetType).withTargetOnDemandCapacity(targetOnDemandCapacity).withTargetSpotCapacity(targetSpotCapacity).withInstanceTypeConfigs(expectedInstanceTypeConfigs).withLaunchSpecifications(null)), jobFlowInstancesConfig.getInstanceFleets());
            assertNull(jobFlowInstancesConfig.getEc2SubnetId());
            assertEquals(2, CollectionUtils.size(jobFlowInstancesConfig.getEc2SubnetIds()));
            assertTrue(jobFlowInstancesConfig.getEc2SubnetIds().contains(EC2_SUBNET));
            assertTrue(jobFlowInstancesConfig.getEc2SubnetIds().contains(EC2_SUBNET_2));
            assertEquals(herdStringHelper.getRequiredConfigurationValue(ConfigurationValue.EMR_DEFAULT_EC2_NODE_IAM_PROFILE_NAME), runJobFlowRequest.getJobFlowRole());
            assertEquals(herdStringHelper.getRequiredConfigurationValue(ConfigurationValue.EMR_DEFAULT_SERVICE_IAM_ROLE_NAME), runJobFlowRequest.getServiceRole());
            List<StepConfig> stepConfigs = runJobFlowRequest.getSteps();
            assertEquals(0, stepConfigs.size());
            List<Tag> tags = runJobFlowRequest.getTags();
            assertEquals(1, tags.size());
            {
                Tag tag = tags.get(0);
                assertEquals("tagName", tag.getKey());
                assertEquals("tagValue", tag.getValue());
            }
            return clusterId;
        }
    });
    assertEquals(clusterId, emrDao.createEmrCluster(clusterName, emrClusterDefinition, new AwsParamsDto()));
}
Also used : EmrClusterDefinitionInstanceTypeConfig(org.finra.herd.model.api.xml.EmrClusterDefinitionInstanceTypeConfig) AwsParamsDto(org.finra.herd.model.dto.AwsParamsDto) RunJobFlowRequest(com.amazonaws.services.elasticmapreduce.model.RunJobFlowRequest) JobFlowInstancesConfig(com.amazonaws.services.elasticmapreduce.model.JobFlowInstancesConfig) InstanceFleetConfig(com.amazonaws.services.elasticmapreduce.model.InstanceFleetConfig) EmrClusterDefinition(org.finra.herd.model.api.xml.EmrClusterDefinition) InvocationOnMock(org.mockito.invocation.InvocationOnMock) NodeTag(org.finra.herd.model.api.xml.NodeTag) List(java.util.List) ArrayList(java.util.ArrayList) Tag(com.amazonaws.services.elasticmapreduce.model.Tag) NodeTag(org.finra.herd.model.api.xml.NodeTag) EmrClusterDefinitionInstanceFleet(org.finra.herd.model.api.xml.EmrClusterDefinitionInstanceFleet) EmrClusterDefinitionLaunchSpecifications(org.finra.herd.model.api.xml.EmrClusterDefinitionLaunchSpecifications) Test(org.junit.Test)

Example 4 with EmrClusterDefinitionInstanceTypeConfig

use of org.finra.herd.model.api.xml.EmrClusterDefinitionInstanceTypeConfig in project herd by FINRAOS.

the class EmrDaoImpl method getInstanceTypeConfigs.

/**
 * Creates a list of {@link InstanceTypeConfig} from a given list of {@link EmrClusterDefinitionInstanceTypeConfig}.
 *
 * @param emrClusterDefinitionInstanceTypeConfigs the list of {@link EmrClusterDefinitionInstanceTypeConfig}
 *
 * @return the list of {@link InstanceTypeConfig}
 */
protected List<InstanceTypeConfig> getInstanceTypeConfigs(List<EmrClusterDefinitionInstanceTypeConfig> emrClusterDefinitionInstanceTypeConfigs) {
    List<InstanceTypeConfig> instanceTypeConfigs = null;
    if (!CollectionUtils.isEmpty(emrClusterDefinitionInstanceTypeConfigs)) {
        instanceTypeConfigs = new ArrayList<>();
        for (EmrClusterDefinitionInstanceTypeConfig emrClusterDefinitionInstanceTypeConfig : emrClusterDefinitionInstanceTypeConfigs) {
            if (emrClusterDefinitionInstanceTypeConfig != null) {
                InstanceTypeConfig instanceTypeConfig = new InstanceTypeConfig();
                instanceTypeConfig.setInstanceType(emrClusterDefinitionInstanceTypeConfig.getInstanceType());
                instanceTypeConfig.setWeightedCapacity(emrClusterDefinitionInstanceTypeConfig.getWeightedCapacity());
                instanceTypeConfig.setBidPrice(emrClusterDefinitionInstanceTypeConfig.getBidPrice());
                instanceTypeConfig.setBidPriceAsPercentageOfOnDemandPrice(emrClusterDefinitionInstanceTypeConfig.getBidPriceAsPercentageOfOnDemandPrice());
                instanceTypeConfig.setEbsConfiguration(getEbsConfiguration(emrClusterDefinitionInstanceTypeConfig.getEbsConfiguration()));
                instanceTypeConfig.setConfigurations(getConfigurations(emrClusterDefinitionInstanceTypeConfig.getConfigurations()));
                instanceTypeConfigs.add(instanceTypeConfig);
            }
        }
    }
    return instanceTypeConfigs;
}
Also used : EmrClusterDefinitionInstanceTypeConfig(org.finra.herd.model.api.xml.EmrClusterDefinitionInstanceTypeConfig) InstanceTypeConfig(com.amazonaws.services.elasticmapreduce.model.InstanceTypeConfig) EmrClusterDefinitionInstanceTypeConfig(org.finra.herd.model.api.xml.EmrClusterDefinitionInstanceTypeConfig)

Aggregations

EmrClusterDefinitionInstanceTypeConfig (org.finra.herd.model.api.xml.EmrClusterDefinitionInstanceTypeConfig)4 InstanceTypeConfig (com.amazonaws.services.elasticmapreduce.model.InstanceTypeConfig)3 Test (org.junit.Test)3 InstanceFleetConfig (com.amazonaws.services.elasticmapreduce.model.InstanceFleetConfig)2 AbstractDaoTest (org.finra.herd.dao.AbstractDaoTest)2 EmrClusterDefinitionInstanceFleet (org.finra.herd.model.api.xml.EmrClusterDefinitionInstanceFleet)2 EmrClusterDefinitionLaunchSpecifications (org.finra.herd.model.api.xml.EmrClusterDefinitionLaunchSpecifications)2 Configuration (com.amazonaws.services.elasticmapreduce.model.Configuration)1 EbsConfiguration (com.amazonaws.services.elasticmapreduce.model.EbsConfiguration)1 JobFlowInstancesConfig (com.amazonaws.services.elasticmapreduce.model.JobFlowInstancesConfig)1 RunJobFlowRequest (com.amazonaws.services.elasticmapreduce.model.RunJobFlowRequest)1 Tag (com.amazonaws.services.elasticmapreduce.model.Tag)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 EmrClusterDefinition (org.finra.herd.model.api.xml.EmrClusterDefinition)1 EmrClusterDefinitionConfiguration (org.finra.herd.model.api.xml.EmrClusterDefinitionConfiguration)1 EmrClusterDefinitionEbsConfiguration (org.finra.herd.model.api.xml.EmrClusterDefinitionEbsConfiguration)1 NodeTag (org.finra.herd.model.api.xml.NodeTag)1 AwsParamsDto (org.finra.herd.model.dto.AwsParamsDto)1 InvocationOnMock (org.mockito.invocation.InvocationOnMock)1