/** * Tests case where validation is run against the definition generated by createValidEmrClusterDefinition() The task instance is not specified. The * definition should be valid because task instance is optional. */ @Test public void testValidateEmrClusterDefinitionConfigurationTaskInstanceDefinitionNotSpecified() { EmrClusterDefinition emrClusterDefinition = createValidEmrClusterDefinition(); emrClusterDefinition.getInstanceDefinitions().setTaskInstances(null); try { emrClusterDefinitionHelper.validateEmrClusterDefinitionConfiguration(emrClusterDefinition); } catch (Exception e) { fail("expected no exception, but " + e.getClass() + " was thrown. " + e); } }
/** * This method tests the scenario where task instances are there */ @Test public void testCreateEmrClusterWithTaskInstances() throws Exception { // Create the namespace entity. NamespaceEntity namespaceEntity = namespaceDaoTestHelper.createNamespaceEntity(NAMESPACE); String configXml = IOUtils.toString(resourceLoader.getResource(EMR_CLUSTER_DEFINITION_XML_FILE_WITH_CLASSPATH).getInputStream()); EmrClusterDefinition emrClusterDefinition = xmlHelper.unmarshallXmlToObject(EmrClusterDefinition.class, configXml); InstanceDefinition taskDef = new InstanceDefinition(); taskDef.setInstanceCount(1); // This could be any EC2 instance type supported in EMR. taskDef.setInstanceType(MockEc2OperationsImpl.INSTANCE_TYPE_1); emrClusterDefinition.getInstanceDefinitions().setTaskInstances(taskDef); configXml = xmlHelper.objectToXml(emrClusterDefinition); emrClusterDefinitionDaoTestHelper.createEmrClusterDefinitionEntity(namespaceEntity, EMR_CLUSTER_DEFINITION_NAME, configXml); // Create a new EMR cluster create request. EmrClusterCreateRequest request = getNewEmrClusterCreateRequest(); EmrCluster emrCluster = emrService.createCluster(request); // Validate the returned object against the input. assertNotNull(emrCluster); assertTrue(emrCluster.getNamespace().equals(request.getNamespace())); assertTrue(emrCluster.getEmrClusterDefinitionName().equals(request.getEmrClusterDefinitionName())); assertTrue(emrCluster.getEmrClusterName().equals(request.getEmrClusterName())); }
sourceTaskInstances = this.getTaskInstances(); InstanceDefinition copyTaskInstances = ((InstanceDefinition) strategy.copy(LocatorUtils.property(locator, "taskInstances", sourceTaskInstances), sourceTaskInstances, (this.taskInstances!= null))); copy.setTaskInstances(copyTaskInstances); } else { if (taskInstancesShouldBeCopiedAndSet == Boolean.FALSE) {
sourceTaskInstances = this.getTaskInstances(); InstanceDefinition copyTaskInstances = ((InstanceDefinition) strategy.copy(LocatorUtils.property(locator, "taskInstances", sourceTaskInstances), sourceTaskInstances, (this.taskInstances!= null))); copy.setTaskInstances(copyTaskInstances); } else { if (taskInstancesShouldBeCopiedAndSet == Boolean.FALSE) {
sourceTaskInstances = this.getTaskInstances(); InstanceDefinition copyTaskInstances = ((InstanceDefinition) strategy.copy(LocatorUtils.property(locator, "taskInstances", sourceTaskInstances), sourceTaskInstances, (this.taskInstances!= null))); copy.setTaskInstances(copyTaskInstances); } else { if (taskInstancesShouldBeCopiedAndSet == Boolean.FALSE) {
/** * Creates a new EMR cluster definition using the specified parameters, updates it with best price algorithm, and returns the definition. * * @param subnetId Subnet ID. Optional. * @param masterInstanceDefinition The master instance definition * @param coreInstanceDefinition The core instance definition * @param taskInstanceDefinition The task instance definition. Optional. * * @return Updated EMR cluster definition. */ private EmrClusterDefinition updateEmrClusterDefinitionWithBestPrice(String subnetId, MasterInstanceDefinition masterInstanceDefinition, InstanceDefinition coreInstanceDefinition, InstanceDefinition taskInstanceDefinition) { EmrClusterDefinition emrClusterDefinition = new EmrClusterDefinition(); emrClusterDefinition.setSubnetId(subnetId); InstanceDefinitions instanceDefinitions = new InstanceDefinitions(); instanceDefinitions.setMasterInstances(masterInstanceDefinition); instanceDefinitions.setCoreInstances(coreInstanceDefinition); instanceDefinitions.setTaskInstances(taskInstanceDefinition); emrClusterDefinition.setInstanceDefinitions(instanceDefinitions); emrPricingHelper.updateEmrClusterDefinitionWithBestPrice(new EmrClusterAlternateKeyDto(), emrClusterDefinition, new AwsParamsDto(NO_AWS_ACCESS_KEY, NO_AWS_SECRET_KEY, NO_SESSION_TOKEN, NO_HTTP_PROXY_HOST, NO_HTTP_PROXY_PORT, AWS_REGION_NAME_US_EAST_1)); return emrClusterDefinition; } }
taskInstanceDefinition.setInstanceCount(1); taskInstanceDefinition.setInstanceType(MockEc2OperationsImpl.INSTANCE_TYPE_1); instanceDefinitions.setTaskInstances(taskInstanceDefinition);
new InstanceDefinition(20, "coreInstanceType", NO_EMR_CLUSTER_DEFINITION_EBS_CONFIGURATION, BigDecimal.ONE, NO_INSTANCE_MAX_SEARCH_PRICE, NO_INSTANCE_ON_DEMAND_THRESHOLD)); instanceDefinitions.setTaskInstances( new InstanceDefinition(30, "taskInstanceType", NO_EMR_CLUSTER_DEFINITION_EBS_CONFIGURATION, NO_INSTANCE_SPOT_PRICE, NO_INSTANCE_MAX_SEARCH_PRICE, NO_INSTANCE_ON_DEMAND_THRESHOLD));