Search in sources :

Example 66 with Parameter

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

the class GetBusinessObjectDataStatusTest method testGetBusinessObjectDataStatus.

@Test
public void testGetBusinessObjectDataStatus() throws Exception {
    // Create a business object data key.
    BusinessObjectDataKey businessObjectDataKey = new BusinessObjectDataKey(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, DATA_VERSION);
    // Create a business object data entity.
    businessObjectDataDaoTestHelper.createBusinessObjectDataEntity(businessObjectDataKey, LATEST_VERSION_FLAG_SET, BDATA_STATUS);
    List<FieldExtension> fieldExtensionList = new ArrayList<>();
    fieldExtensionList.add(buildFieldExtension("namespace", "${namespace}"));
    fieldExtensionList.add(buildFieldExtension("businessObjectDefinitionName", "${businessObjectDefinitionName}"));
    fieldExtensionList.add(buildFieldExtension("businessObjectFormatUsage", "${businessObjectFormatUsage}"));
    fieldExtensionList.add(buildFieldExtension("businessObjectFormatFileType", "${businessObjectFormatFileType}"));
    fieldExtensionList.add(buildFieldExtension("businessObjectFormatVersion", "${businessObjectFormatVersion}"));
    fieldExtensionList.add(buildFieldExtension("partitionValue", "${partitionValue}"));
    fieldExtensionList.add(buildFieldExtension("subPartitionValues", "${subPartitionValues}"));
    fieldExtensionList.add(buildFieldExtension("businessObjectDataVersion", "${businessObjectDataVersion}"));
    List<Parameter> parameters = new ArrayList<>();
    parameters.add(buildParameter("namespace", BDEF_NAMESPACE));
    parameters.add(buildParameter("businessObjectDefinitionName", BDEF_NAME));
    parameters.add(buildParameter("businessObjectFormatUsage", FORMAT_USAGE_CODE));
    parameters.add(buildParameter("businessObjectFormatFileType", FORMAT_FILE_TYPE_CODE));
    parameters.add(buildParameter("businessObjectFormatVersion", FORMAT_VERSION.toString()));
    parameters.add(buildParameter("partitionValue", PARTITION_VALUE));
    parameters.add(buildParameter("subPartitionValues", herdStringHelper.buildStringWithDefaultDelimiter(SUBPARTITION_VALUES)));
    parameters.add(buildParameter("businessObjectDataVersion", DATA_VERSION.toString()));
    // Build the expected response object.
    BusinessObjectDataStatusInformation expectedBusinessObjectDataStatusInformation = new BusinessObjectDataStatusInformation(businessObjectDataKey, BDATA_STATUS);
    // Run the activiti task and validate the returned response object.
    Map<String, Object> variableValuesToValidate = new HashMap<>();
    variableValuesToValidate.put(GetBusinessObjectDataStatus.VARIABLE_JSON_RESPONSE, jsonHelper.objectToJson(expectedBusinessObjectDataStatusInformation));
    testActivitiServiceTaskSuccess(GetBusinessObjectDataStatus.class.getCanonicalName(), fieldExtensionList, parameters, variableValuesToValidate);
}
Also used : HashMap(java.util.HashMap) FieldExtension(org.activiti.bpmn.model.FieldExtension) ArrayList(java.util.ArrayList) Parameter(org.finra.herd.model.api.xml.Parameter) BusinessObjectDataKey(org.finra.herd.model.api.xml.BusinessObjectDataKey) BusinessObjectDataStatusInformation(org.finra.herd.model.api.xml.BusinessObjectDataStatusInformation) Test(org.junit.Test)

Example 67 with Parameter

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

the class GetBusinessObjectDataTest method test_NoSubPartitions_NoFormatVersion_NoDataVersion_SubPartitionValuesAsEmptyString.

@Test
public void test_NoSubPartitions_NoFormatVersion_NoDataVersion_SubPartitionValuesAsEmptyString() throws Exception {
    // Create a business object data key without sub-partition values.
    BusinessObjectDataKey businessObjectDataKey = new BusinessObjectDataKey(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, NO_SUBPARTITION_VALUES, DATA_VERSION);
    // Create a business object data entity.
    BusinessObjectDataEntity businessObjectDataEntity = businessObjectDataDaoTestHelper.createBusinessObjectDataEntity(businessObjectDataKey, LATEST_VERSION_FLAG_SET, BusinessObjectDataStatusEntity.VALID);
    List<FieldExtension> fieldExtensionList = new ArrayList<>();
    fieldExtensionList.add(buildFieldExtension("namespace", "${namespace}"));
    fieldExtensionList.add(buildFieldExtension("businessObjectDefinitionName", "${businessObjectDefinitionName}"));
    fieldExtensionList.add(buildFieldExtension("businessObjectFormatUsage", "${businessObjectFormatUsage}"));
    fieldExtensionList.add(buildFieldExtension("businessObjectFormatFileType", "${businessObjectFormatFileType}"));
    fieldExtensionList.add(buildFieldExtension("partitionValue", "${partitionValue}"));
    fieldExtensionList.add(buildFieldExtension("subPartitionValues", "${subPartitionValues}"));
    List<Parameter> parameters = new ArrayList<>();
    parameters.add(buildParameter("namespace", BDEF_NAMESPACE));
    parameters.add(buildParameter("businessObjectDefinitionName", BDEF_NAME));
    parameters.add(buildParameter("businessObjectFormatUsage", FORMAT_USAGE_CODE));
    parameters.add(buildParameter("businessObjectFormatFileType", FORMAT_FILE_TYPE_CODE));
    parameters.add(buildParameter("partitionValue", PARTITION_VALUE));
    parameters.add(buildParameter("subPartitionValues", EMPTY_STRING));
    // Build the expected response object.
    BusinessObjectData expectedBusinessObjectData = new BusinessObjectData(businessObjectDataEntity.getId(), BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_KEY, PARTITION_VALUE, NO_SUBPARTITION_VALUES, DATA_VERSION, LATEST_VERSION_FLAG_SET, BusinessObjectDataStatusEntity.VALID, NO_STORAGE_UNITS, NO_ATTRIBUTES, NO_BUSINESS_OBJECT_DATA_PARENTS, NO_BUSINESS_OBJECT_DATA_CHILDREN, NO_BUSINESS_OBJECT_DATA_STATUS_HISTORY);
    // Run the activiti task and validate the returned response object.
    Map<String, Object> variableValuesToValidate = new HashMap<>();
    variableValuesToValidate.put(GetBusinessObjectDataStatus.VARIABLE_JSON_RESPONSE, jsonHelper.objectToJson(expectedBusinessObjectData));
    testActivitiServiceTaskSuccess(GetBusinessObjectData.class.getCanonicalName(), fieldExtensionList, parameters, variableValuesToValidate);
}
Also used : BusinessObjectData(org.finra.herd.model.api.xml.BusinessObjectData) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) BusinessObjectDataKey(org.finra.herd.model.api.xml.BusinessObjectDataKey) FieldExtension(org.activiti.bpmn.model.FieldExtension) Parameter(org.finra.herd.model.api.xml.Parameter) BusinessObjectDataEntity(org.finra.herd.model.jpa.BusinessObjectDataEntity) Test(org.junit.Test)

Example 68 with Parameter

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

the class EmrHelperTest method testBuildEmrClusterInstanceFleetFromAwsResult.

@Test
public void testBuildEmrClusterInstanceFleetFromAwsResult() {
    ListInstanceFleetsResult listInstanceFleetsResult = null;
    assertNull(emrHelper.buildEmrClusterInstanceFleetFromAwsResult(listInstanceFleetsResult));
    listInstanceFleetsResult = new ListInstanceFleetsResult();
    assertNull(emrHelper.buildEmrClusterInstanceFleetFromAwsResult(listInstanceFleetsResult));
    String instanceId = "instance id";
    String instanceName = "instance name";
    String instanceFleetType = "instance fleet type";
    int targetOnDemandCapacity = 1;
    int targetSpotCapacity = 2;
    int provisionedOnDemandCapacity = 3;
    int provisionedSpotCapacity = 4;
    EmrClusterInstanceFleet expectedEmrInstanceFleet = new EmrClusterInstanceFleet();
    expectedEmrInstanceFleet.setId(instanceId);
    expectedEmrInstanceFleet.setName(instanceName);
    expectedEmrInstanceFleet.setInstanceFleetType(instanceFleetType);
    expectedEmrInstanceFleet.setTargetOnDemandCapacity(targetOnDemandCapacity);
    expectedEmrInstanceFleet.setTargetSpotCapacity(targetSpotCapacity);
    expectedEmrInstanceFleet.setProvisionedOnDemandCapacity(provisionedOnDemandCapacity);
    expectedEmrInstanceFleet.setProvisionedSpotCapacity(provisionedSpotCapacity);
    InstanceFleet instanceFleet = new InstanceFleet();
    instanceFleet.setId(instanceId);
    instanceFleet.setName(instanceName);
    instanceFleet.setInstanceFleetType(instanceFleetType);
    instanceFleet.setTargetOnDemandCapacity(targetOnDemandCapacity);
    instanceFleet.setTargetSpotCapacity(targetSpotCapacity);
    instanceFleet.setProvisionedSpotCapacity(provisionedSpotCapacity);
    instanceFleet.setProvisionedOnDemandCapacity(provisionedOnDemandCapacity);
    List<InstanceFleet> instanceFleets = new ArrayList<>();
    instanceFleets.add(null);
    instanceFleets.add(instanceFleet);
    listInstanceFleetsResult.setInstanceFleets(instanceFleets);
    assertEquals(Arrays.asList(expectedEmrInstanceFleet), emrHelper.buildEmrClusterInstanceFleetFromAwsResult(listInstanceFleetsResult));
    EmrClusterInstanceFleetStatus emrClusterInstanceFleetStatus = new EmrClusterInstanceFleetStatus();
    String emrClusterInstanceFleetStatus_State = "state 1";
    emrClusterInstanceFleetStatus.setState(emrClusterInstanceFleetStatus_State);
    expectedEmrInstanceFleet.setInstanceFleetStatus(emrClusterInstanceFleetStatus);
    InstanceFleetStatus instanceFleetStatus = new InstanceFleetStatus();
    instanceFleetStatus.setState(emrClusterInstanceFleetStatus_State);
    instanceFleet.setStatus(instanceFleetStatus);
    assertEquals(Arrays.asList(expectedEmrInstanceFleet), emrHelper.buildEmrClusterInstanceFleetFromAwsResult(listInstanceFleetsResult));
    String emrClusterInstanceFleetStatus_StateChangeCode = "change code 1";
    String emrClusterInstanceFleetStatus_StateChangeMsg = "change msg 1";
    InstanceFleetStateChangeReason instanceFleetStateChangeReason = new InstanceFleetStateChangeReason();
    instanceFleetStateChangeReason.setCode(emrClusterInstanceFleetStatus_StateChangeCode);
    instanceFleetStateChangeReason.setMessage(emrClusterInstanceFleetStatus_StateChangeMsg);
    instanceFleetStatus.setStateChangeReason(instanceFleetStateChangeReason);
    InstanceFleetTimeline instanceFleetTimeline = new InstanceFleetTimeline();
    java.util.Date now = Calendar.getInstance().getTime();
    instanceFleetTimeline.setCreationDateTime(now);
    instanceFleetTimeline.setReadyDateTime(now);
    instanceFleetTimeline.setEndDateTime(now);
    instanceFleetStatus.setTimeline(instanceFleetTimeline);
    EmrClusterInstanceFleetStateChangeReason emrClusterInstanceFleetStateChangeReason = new EmrClusterInstanceFleetStateChangeReason();
    emrClusterInstanceFleetStateChangeReason.setCode(emrClusterInstanceFleetStatus_StateChangeCode);
    emrClusterInstanceFleetStateChangeReason.setMessage(emrClusterInstanceFleetStatus_StateChangeMsg);
    emrClusterInstanceFleetStatus.setStateChangeReason(emrClusterInstanceFleetStateChangeReason);
    EmrClusterInstanceFleetTimeline emrClusterInstanceFleetTimeline = new EmrClusterInstanceFleetTimeline();
    emrClusterInstanceFleetTimeline.setCreationDateTime(HerdDateUtils.getXMLGregorianCalendarValue(now));
    emrClusterInstanceFleetTimeline.setReadyDateTime(HerdDateUtils.getXMLGregorianCalendarValue(now));
    emrClusterInstanceFleetTimeline.setEndDateTime(HerdDateUtils.getXMLGregorianCalendarValue(now));
    emrClusterInstanceFleetStatus.setTimeline(emrClusterInstanceFleetTimeline);
    assertEquals(Arrays.asList(expectedEmrInstanceFleet), emrHelper.buildEmrClusterInstanceFleetFromAwsResult(listInstanceFleetsResult));
    String instanceType = "instance type 1";
    int weightedCapacity = 1;
    String bidPrice = "1.0";
    double bidPricePercent = 0.8;
    boolean ebsOptimized = true;
    InstanceTypeSpecification instanceTypeSpecification = new InstanceTypeSpecification();
    instanceTypeSpecification.setInstanceType(instanceType);
    instanceTypeSpecification.setWeightedCapacity(weightedCapacity);
    instanceTypeSpecification.setBidPrice(bidPrice);
    instanceTypeSpecification.setBidPriceAsPercentageOfOnDemandPrice(bidPricePercent);
    instanceTypeSpecification.setEbsOptimized(ebsOptimized);
    List<InstanceTypeSpecification> instanceTypeSpecifications = new ArrayList<>();
    instanceTypeSpecifications.add(null);
    instanceTypeSpecifications.add(instanceTypeSpecification);
    instanceFleet.setInstanceTypeSpecifications(instanceTypeSpecifications);
    EmrClusterInstanceTypeSpecification emrClusterInstanceTypeSpecification = new EmrClusterInstanceTypeSpecification();
    emrClusterInstanceTypeSpecification.setInstanceType(instanceType);
    emrClusterInstanceTypeSpecification.setWeightedCapacity(weightedCapacity);
    emrClusterInstanceTypeSpecification.setBidPrice(bidPrice);
    emrClusterInstanceTypeSpecification.setBidPriceAsPercentageOfOnDemandPrice(bidPricePercent);
    emrClusterInstanceTypeSpecification.setEbsOptimized(ebsOptimized);
    expectedEmrInstanceFleet.setInstanceTypeSpecifications(Arrays.asList(emrClusterInstanceTypeSpecification));
    assertEquals(Arrays.asList(expectedEmrInstanceFleet), emrHelper.buildEmrClusterInstanceFleetFromAwsResult(listInstanceFleetsResult));
    EbsBlockDevice ebsBlockDevice = new EbsBlockDevice();
    String device = "device 1";
    ebsBlockDevice.setDevice(device);
    List<EbsBlockDevice> ebsBlockDevices = new ArrayList<>();
    ebsBlockDevices.add(ebsBlockDevice);
    ebsBlockDevices.add(null);
    instanceTypeSpecification.setEbsBlockDevices(ebsBlockDevices);
    EmrClusterEbsBlockDevice emrClusterEbsBlockDevice = new EmrClusterEbsBlockDevice();
    emrClusterEbsBlockDevice.setDevice(device);
    emrClusterInstanceTypeSpecification.setEbsBlockDevices(Arrays.asList(emrClusterEbsBlockDevice));
    assertEquals(Arrays.asList(expectedEmrInstanceFleet), emrHelper.buildEmrClusterInstanceFleetFromAwsResult(listInstanceFleetsResult));
    int iops = 100;
    int sizeInGB = 20;
    String volumeType = "volume type 1";
    VolumeSpecification volumeSpecification = new VolumeSpecification();
    volumeSpecification.setIops(iops);
    volumeSpecification.setSizeInGB(sizeInGB);
    volumeSpecification.setVolumeType(volumeType);
    ebsBlockDevice.setVolumeSpecification(volumeSpecification);
    EmrClusterVolumeSpecification emrClusterVolumeSpecification = new EmrClusterVolumeSpecification();
    emrClusterVolumeSpecification.setIops(iops);
    emrClusterVolumeSpecification.setSizeInGB(sizeInGB);
    emrClusterVolumeSpecification.setVolumeType(volumeType);
    emrClusterEbsBlockDevice.setVolumeSpecification(emrClusterVolumeSpecification);
    assertEquals(Arrays.asList(expectedEmrInstanceFleet), emrHelper.buildEmrClusterInstanceFleetFromAwsResult(listInstanceFleetsResult));
    InstanceFleetProvisioningSpecifications instanceFleetProvisioningSpecifications = new InstanceFleetProvisioningSpecifications();
    instanceFleet.setLaunchSpecifications(instanceFleetProvisioningSpecifications);
    EmrClusterInstanceFleetProvisioningSpecifications emrClusterInstanceFleetProvisioningSpecifications = new EmrClusterInstanceFleetProvisioningSpecifications();
    expectedEmrInstanceFleet.setLaunchSpecifications(emrClusterInstanceFleetProvisioningSpecifications);
    assertEquals(Arrays.asList(expectedEmrInstanceFleet), emrHelper.buildEmrClusterInstanceFleetFromAwsResult(listInstanceFleetsResult));
    List<Configuration> configurations = new ArrayList<>();
    Configuration configuration = new Configuration();
    String classification = "classification 1";
    configuration.setClassification(classification);
    configurations.add(null);
    configurations.add(configuration);
    instanceTypeSpecification.setConfigurations(configurations);
    EmrClusterInstanceTypeConfiguration emrClusterInstanceTypeConfiguration = new EmrClusterInstanceTypeConfiguration();
    emrClusterInstanceTypeConfiguration.setClassification(classification);
    emrClusterInstanceTypeSpecification.setConfigurations(Arrays.asList(emrClusterInstanceTypeConfiguration));
    assertEquals(Arrays.asList(expectedEmrInstanceFleet), emrHelper.buildEmrClusterInstanceFleetFromAwsResult(listInstanceFleetsResult));
    String paramKey = "param 1";
    String paramVal = "param val 1";
    java.util.Map<String, String> map = new HashMap<>();
    map.put(paramKey, paramVal);
    configuration.setProperties(map);
    Parameter parameter = new Parameter(paramKey, paramVal);
    emrClusterInstanceTypeConfiguration.setProperties(Arrays.asList(parameter));
    assertEquals(Arrays.asList(expectedEmrInstanceFleet), emrHelper.buildEmrClusterInstanceFleetFromAwsResult(listInstanceFleetsResult));
    int blockDurationMin = 30;
    String timeoutAction = "action 1";
    int timeoutDurationMin = 60;
    // to do time out action
    SpotProvisioningSpecification spotProvisioningSpecification = new SpotProvisioningSpecification();
    spotProvisioningSpecification.setBlockDurationMinutes(blockDurationMin);
    spotProvisioningSpecification.setTimeoutAction(timeoutAction);
    spotProvisioningSpecification.setTimeoutDurationMinutes(timeoutDurationMin);
    instanceFleetProvisioningSpecifications.setSpotSpecification(spotProvisioningSpecification);
    EmrClusterSpotProvisioningSpecification emrClusterSpotProvisioningSpecification = new EmrClusterSpotProvisioningSpecification();
    emrClusterSpotProvisioningSpecification.setBlockDurationMinutes(blockDurationMin);
    emrClusterSpotProvisioningSpecification.setTimeoutAction(timeoutAction);
    emrClusterSpotProvisioningSpecification.setTimeoutDurationMinutes(timeoutDurationMin);
    emrClusterInstanceFleetProvisioningSpecifications.setSpotSpecification(emrClusterSpotProvisioningSpecification);
    assertEquals(Arrays.asList(expectedEmrInstanceFleet), emrHelper.buildEmrClusterInstanceFleetFromAwsResult(listInstanceFleetsResult));
}
Also used : EmrClusterInstanceFleetStateChangeReason(org.finra.herd.model.api.xml.EmrClusterInstanceFleetStateChangeReason) Configuration(com.amazonaws.services.elasticmapreduce.model.Configuration) EmrClusterInstanceTypeConfiguration(org.finra.herd.model.api.xml.EmrClusterInstanceTypeConfiguration) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) EmrClusterInstanceFleet(org.finra.herd.model.api.xml.EmrClusterInstanceFleet) InstanceFleet(com.amazonaws.services.elasticmapreduce.model.InstanceFleet) EmrClusterInstanceFleet(org.finra.herd.model.api.xml.EmrClusterInstanceFleet) EmrClusterInstanceTypeSpecification(org.finra.herd.model.api.xml.EmrClusterInstanceTypeSpecification) InstanceTypeSpecification(com.amazonaws.services.elasticmapreduce.model.InstanceTypeSpecification) SpotProvisioningSpecification(com.amazonaws.services.elasticmapreduce.model.SpotProvisioningSpecification) EmrClusterSpotProvisioningSpecification(org.finra.herd.model.api.xml.EmrClusterSpotProvisioningSpecification) EmrClusterInstanceFleetTimeline(org.finra.herd.model.api.xml.EmrClusterInstanceFleetTimeline) EmrClusterInstanceTypeConfiguration(org.finra.herd.model.api.xml.EmrClusterInstanceTypeConfiguration) InstanceFleetStateChangeReason(com.amazonaws.services.elasticmapreduce.model.InstanceFleetStateChangeReason) EmrClusterInstanceFleetStateChangeReason(org.finra.herd.model.api.xml.EmrClusterInstanceFleetStateChangeReason) EmrClusterInstanceFleetProvisioningSpecifications(org.finra.herd.model.api.xml.EmrClusterInstanceFleetProvisioningSpecifications) InstanceFleetStatus(com.amazonaws.services.elasticmapreduce.model.InstanceFleetStatus) EmrClusterInstanceFleetStatus(org.finra.herd.model.api.xml.EmrClusterInstanceFleetStatus) EmrClusterVolumeSpecification(org.finra.herd.model.api.xml.EmrClusterVolumeSpecification) InstanceFleetProvisioningSpecifications(com.amazonaws.services.elasticmapreduce.model.InstanceFleetProvisioningSpecifications) EmrClusterInstanceFleetProvisioningSpecifications(org.finra.herd.model.api.xml.EmrClusterInstanceFleetProvisioningSpecifications) EmrClusterInstanceFleetStatus(org.finra.herd.model.api.xml.EmrClusterInstanceFleetStatus) EmrClusterInstanceTypeSpecification(org.finra.herd.model.api.xml.EmrClusterInstanceTypeSpecification) VolumeSpecification(com.amazonaws.services.elasticmapreduce.model.VolumeSpecification) EmrClusterVolumeSpecification(org.finra.herd.model.api.xml.EmrClusterVolumeSpecification) EmrClusterSpotProvisioningSpecification(org.finra.herd.model.api.xml.EmrClusterSpotProvisioningSpecification) ListInstanceFleetsResult(com.amazonaws.services.elasticmapreduce.model.ListInstanceFleetsResult) EmrClusterEbsBlockDevice(org.finra.herd.model.api.xml.EmrClusterEbsBlockDevice) EbsBlockDevice(com.amazonaws.services.elasticmapreduce.model.EbsBlockDevice) Parameter(org.finra.herd.model.api.xml.Parameter) EmrClusterInstanceFleetTimeline(org.finra.herd.model.api.xml.EmrClusterInstanceFleetTimeline) InstanceFleetTimeline(com.amazonaws.services.elasticmapreduce.model.InstanceFleetTimeline) EmrClusterEbsBlockDevice(org.finra.herd.model.api.xml.EmrClusterEbsBlockDevice) Test(org.junit.Test) AbstractDaoTest(org.finra.herd.dao.AbstractDaoTest)

Example 69 with Parameter

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

the class EmrDaoTest method createEmrClusterAssertCallRunEmrJobFlowOptionalParams.

@Test
public void createEmrClusterAssertCallRunEmrJobFlowOptionalParams() throws Exception {
    String clusterName = "clusterName";
    EmrClusterDefinition emrClusterDefinition = new EmrClusterDefinition();
    InstanceDefinitions instanceDefinitions = new InstanceDefinitions();
    instanceDefinitions.setMasterInstances(new MasterInstanceDefinition(10, "masterInstanceType", NO_EMR_CLUSTER_DEFINITION_EBS_CONFIGURATION, NO_INSTANCE_SPOT_PRICE, NO_INSTANCE_MAX_SEARCH_PRICE, NO_INSTANCE_ON_DEMAND_THRESHOLD));
    instanceDefinitions.setCoreInstances(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));
    emrClusterDefinition.setInstanceDefinitions(instanceDefinitions);
    emrClusterDefinition.setNodeTags(Arrays.asList(new NodeTag("tagName", "tagValue"), new NodeTag("", "tagValue"), new NodeTag("tagName", "")));
    emrClusterDefinition.setSshKeyPairName("sshKeyPairName");
    emrClusterDefinition.setSubnetId("subnetId");
    emrClusterDefinition.setKeepAlive(true);
    emrClusterDefinition.setTerminationProtection(true);
    emrClusterDefinition.setHadoopVersion("hadoopVersion");
    emrClusterDefinition.setReleaseLabel("releaseLabel");
    emrClusterDefinition.setApplications(new ArrayList<>());
    {
        EmrClusterDefinitionApplication emrClusterDefinitionApplication = new EmrClusterDefinitionApplication();
        emrClusterDefinitionApplication.setName("applicationName1");
        emrClusterDefinitionApplication.setVersion("applicationVersion1");
        emrClusterDefinitionApplication.setArgs(Arrays.asList("applicationArg1"));
        emrClusterDefinition.getApplications().add(emrClusterDefinitionApplication);
    }
    {
        EmrClusterDefinitionApplication emrClusterDefinitionApplication = new EmrClusterDefinitionApplication();
        emrClusterDefinitionApplication.setName("applicationName2");
        emrClusterDefinitionApplication.setVersion("applicationVersion2");
        emrClusterDefinitionApplication.setArgs(Arrays.asList("applicationArg2"));
        emrClusterDefinitionApplication.setAdditionalInfoList(Arrays.asList(new Parameter("applicationAdditionalInfoName2", "applicationAdditionalInfoValue2")));
        emrClusterDefinition.getApplications().add(emrClusterDefinitionApplication);
    }
    emrClusterDefinition.setConfigurations(new ArrayList<>());
    {
        EmrClusterDefinitionConfiguration emrClusterDefinitionConfiguration = new EmrClusterDefinitionConfiguration();
        emrClusterDefinitionConfiguration.setClassification("classification");
        EmrClusterDefinitionConfiguration emrClusterDefinitionConfigurationInner = new EmrClusterDefinitionConfiguration();
        emrClusterDefinitionConfigurationInner.setClassification("classificationInner");
        emrClusterDefinitionConfiguration.setConfigurations(Arrays.asList(emrClusterDefinitionConfigurationInner));
        emrClusterDefinitionConfiguration.setProperties(Arrays.asList(new Parameter("propertyKey", "propertyValue")));
        emrClusterDefinition.getConfigurations().add(emrClusterDefinitionConfiguration);
    }
    emrClusterDefinition.setLogBucket("logBucket");
    emrClusterDefinition.setVisibleToAll(true);
    emrClusterDefinition.setEc2NodeIamProfileName("ec2NodeIamProfileName");
    emrClusterDefinition.setServiceIamRole("serviceIamRole");
    emrClusterDefinition.setAmiVersion("amiVersion");
    emrClusterDefinition.setAdditionalInfo("additionalInfo");
    emrClusterDefinition.setEncryptionEnabled(true);
    emrClusterDefinition.setDaemonConfigurations(Arrays.asList(new Parameter("daemonConfigurationsKey", "daemonConfigurationsValue")));
    ConfigurationFiles configurationFiles = new ConfigurationFiles();
    configurationFiles.getConfigurationFiles().add(new ConfigurationFile("fileNameShortcut", "configFileLocation"));
    KeyValuePairConfigurations keyValuePairConfigurations = new KeyValuePairConfigurations();
    keyValuePairConfigurations.getKeyValuePairConfigurations().add(new KeyValuePairConfiguration("keyValueShortcut", "attribKey", "attribVal"));
    emrClusterDefinition.setHadoopConfigurations(Arrays.asList(configurationFiles, keyValuePairConfigurations));
    emrClusterDefinition.setCustomBootstrapActionAll(new ArrayList<>());
    {
        ScriptDefinition scriptDefinitionAll = new ScriptDefinition();
        scriptDefinitionAll.setScriptName("scriptDefinitionAllName1");
        scriptDefinitionAll.setScriptLocation("scriptDefinitionAllLocation1");
        scriptDefinitionAll.setScriptArguments(Arrays.asList("scriptDefinitionAllArg1"));
        emrClusterDefinition.getCustomBootstrapActionAll().add(scriptDefinitionAll);
    }
    {
        ScriptDefinition scriptDefinitionAll = new ScriptDefinition();
        scriptDefinitionAll.setScriptName("scriptDefinitionAllName2");
        scriptDefinitionAll.setScriptLocation("scriptDefinitionAllLocation2");
        emrClusterDefinition.getCustomBootstrapActionAll().add(scriptDefinitionAll);
    }
    emrClusterDefinition.setCustomBootstrapActionMaster(new ArrayList<>());
    {
        ScriptDefinition scriptDefinitionMaster = new ScriptDefinition();
        scriptDefinitionMaster.setScriptName("scriptDefinitionMasterName1");
        scriptDefinitionMaster.setScriptLocation("scriptDefinitionMasterLocation1");
        scriptDefinitionMaster.setScriptArguments(Arrays.asList("scriptDefinitionMasterArg1"));
        emrClusterDefinition.getCustomBootstrapActionMaster().add(scriptDefinitionMaster);
    }
    {
        ScriptDefinition scriptDefinitionMaster = new ScriptDefinition();
        scriptDefinitionMaster.setScriptName("scriptDefinitionMasterName2");
        scriptDefinitionMaster.setScriptLocation("scriptDefinitionMasterLocation2");
        emrClusterDefinition.getCustomBootstrapActionMaster().add(scriptDefinitionMaster);
    }
    emrClusterDefinition.setHiveVersion("hiveVersion");
    emrClusterDefinition.setPigVersion("pigVersion");
    emrClusterDefinition.setInstallOozie(true);
    emrClusterDefinition.setHadoopJarSteps(Arrays.asList(new HadoopJarStep("stepName", "jarLocation", "mainClass", null, true)));
    emrClusterDefinition.setSupportedProduct("supportedProduct");
    emrClusterDefinition.setSecurityConfiguration("securityConfiguration");
    emrClusterDefinition.setScaleDownBehavior("scaleDownBehavior");
    emrClusterDefinition.setMasterSecurityGroup(EMR_MASTER_SECURITY_GROUP);
    emrClusterDefinition.setSlaveSecurityGroup(EMR_SLAVE_SECURITY_GROUP);
    String clusterId = "clusterId";
    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);
            assertEquals(3, runJobFlowRequest.getInstances().getInstanceGroups().size());
            {
                InstanceGroupConfig instanceGroupConfig = runJobFlowRequest.getInstances().getInstanceGroups().get(1);
                assertEquals("1", instanceGroupConfig.getBidPrice());
            }
            {
                InstanceGroupConfig instanceGroupConfig = runJobFlowRequest.getInstances().getInstanceGroups().get(2);
                assertEquals("taskInstanceType", instanceGroupConfig.getInstanceType());
                assertEquals(30, instanceGroupConfig.getInstanceCount().intValue());
            }
            assertEquals("sshKeyPairName", runJobFlowRequest.getInstances().getEc2KeyName());
            assertEquals("subnetId", runJobFlowRequest.getInstances().getEc2SubnetId());
            assertEquals(true, runJobFlowRequest.getInstances().getKeepJobFlowAliveWhenNoSteps());
            assertEquals(true, runJobFlowRequest.getInstances().getTerminationProtected());
            assertEquals("hadoopVersion", runJobFlowRequest.getInstances().getHadoopVersion());
            assertEquals("releaseLabel", runJobFlowRequest.getReleaseLabel());
            assertEquals(2, runJobFlowRequest.getApplications().size());
            {
                Application application = runJobFlowRequest.getApplications().get(0);
                assertEquals("applicationName1", application.getName());
                assertEquals("applicationVersion1", application.getVersion());
                assertEquals(Arrays.asList("applicationArg1"), application.getArgs());
            }
            {
                Application application = runJobFlowRequest.getApplications().get(1);
                Map<String, String> additionalInfo = application.getAdditionalInfo();
                assertEquals(1, additionalInfo.size());
                assertEquals("applicationAdditionalInfoValue2", additionalInfo.get("applicationAdditionalInfoName2"));
            }
            assertEquals(1, runJobFlowRequest.getConfigurations().size());
            {
                Configuration configuration = runJobFlowRequest.getConfigurations().get(0);
                assertEquals("classification", configuration.getClassification());
                assertEquals(1, configuration.getConfigurations().size());
                {
                    Configuration configurationInner = configuration.getConfigurations().get(0);
                    assertEquals("classificationInner", configurationInner.getClassification());
                }
                assertEquals(1, configuration.getProperties().size());
                assertEquals("propertyValue", configuration.getProperties().get("propertyKey"));
            }
            assertEquals("logBucket", runJobFlowRequest.getLogUri());
            assertEquals(true, runJobFlowRequest.getVisibleToAllUsers());
            assertEquals("ec2NodeIamProfileName", runJobFlowRequest.getJobFlowRole());
            assertEquals("serviceIamRole", runJobFlowRequest.getServiceRole());
            assertEquals("amiVersion", runJobFlowRequest.getAmiVersion());
            assertEquals("additionalInfo", runJobFlowRequest.getAdditionalInfo());
            assertEquals(7, runJobFlowRequest.getBootstrapActions().size());
            {
                BootstrapActionConfig bootstrapActionConfig = runJobFlowRequest.getBootstrapActions().get(0);
                assertEquals("emr.encryption.script", bootstrapActionConfig.getName());
                ScriptBootstrapActionConfig scriptBootstrapAction = bootstrapActionConfig.getScriptBootstrapAction();
                assertEquals("s3:////herd_SCRIPTS/encrypt_disks.sh", scriptBootstrapAction.getPath());
                assertEquals(0, scriptBootstrapAction.getArgs().size());
            }
            {
                BootstrapActionConfig bootstrapActionConfig = runJobFlowRequest.getBootstrapActions().get(1);
                assertEquals("emr.aws.configure.daemon", bootstrapActionConfig.getName());
                ScriptBootstrapActionConfig scriptBootstrapAction = bootstrapActionConfig.getScriptBootstrapAction();
                assertEquals("s3://elasticmapreduce/bootstrap-actions/configure-daemons", scriptBootstrapAction.getPath());
                assertEquals(Arrays.asList("daemonConfigurationsKey=daemonConfigurationsValue"), scriptBootstrapAction.getArgs());
            }
            {
                BootstrapActionConfig bootstrapActionConfig = runJobFlowRequest.getBootstrapActions().get(2);
                assertEquals("emr.aws.configure.hadoop", bootstrapActionConfig.getName());
                ScriptBootstrapActionConfig scriptBootstrapAction = bootstrapActionConfig.getScriptBootstrapAction();
                assertEquals("s3://us-east-1.elasticmapreduce/bootstrap-actions/configure-hadoop", scriptBootstrapAction.getPath());
                assertEquals(Arrays.asList("fileNameShortcut", "configFileLocation", "keyValueShortcut", "attribKey=attribVal"), scriptBootstrapAction.getArgs());
            }
            {
                BootstrapActionConfig bootstrapActionConfig = runJobFlowRequest.getBootstrapActions().get(3);
                assertEquals("scriptDefinitionAllName1", bootstrapActionConfig.getName());
                ScriptBootstrapActionConfig scriptBootstrapAction = bootstrapActionConfig.getScriptBootstrapAction();
                assertEquals("scriptDefinitionAllLocation1", scriptBootstrapAction.getPath());
                assertEquals(Arrays.asList("scriptDefinitionAllArg1"), scriptBootstrapAction.getArgs());
            }
            {
                BootstrapActionConfig bootstrapActionConfig = runJobFlowRequest.getBootstrapActions().get(4);
                ScriptBootstrapActionConfig scriptBootstrapAction = bootstrapActionConfig.getScriptBootstrapAction();
                assertEquals(0, scriptBootstrapAction.getArgs().size());
            }
            {
                BootstrapActionConfig bootstrapActionConfig = runJobFlowRequest.getBootstrapActions().get(5);
                assertEquals("scriptDefinitionMasterName1", bootstrapActionConfig.getName());
                ScriptBootstrapActionConfig scriptBootstrapAction = bootstrapActionConfig.getScriptBootstrapAction();
                assertEquals("s3://elasticmapreduce/bootstrap-actions/run-if", scriptBootstrapAction.getPath());
                assertEquals(Arrays.asList("instance.isMaster=true", "scriptDefinitionMasterLocation1", "scriptDefinitionMasterArg1"), scriptBootstrapAction.getArgs());
            }
            {
                BootstrapActionConfig bootstrapActionConfig = runJobFlowRequest.getBootstrapActions().get(6);
                ScriptBootstrapActionConfig scriptBootstrapAction = bootstrapActionConfig.getScriptBootstrapAction();
                assertEquals(Arrays.asList("instance.isMaster=true", "scriptDefinitionMasterLocation2"), scriptBootstrapAction.getArgs());
            }
            assertEquals(Arrays.asList("supportedProduct"), runJobFlowRequest.getSupportedProducts());
            assertEquals("securityConfiguration", runJobFlowRequest.getSecurityConfiguration());
            assertEquals("scaleDownBehavior", runJobFlowRequest.getScaleDownBehavior());
            assertEquals(EMR_MASTER_SECURITY_GROUP, runJobFlowRequest.getInstances().getEmrManagedMasterSecurityGroup());
            assertEquals(EMR_SLAVE_SECURITY_GROUP, runJobFlowRequest.getInstances().getEmrManagedSlaveSecurityGroup());
            return clusterId;
        }
    });
    assertEquals(clusterId, emrDao.createEmrCluster(clusterName, emrClusterDefinition, new AwsParamsDto()));
}
Also used : MasterInstanceDefinition(org.finra.herd.model.api.xml.MasterInstanceDefinition) InstanceDefinition(org.finra.herd.model.api.xml.InstanceDefinition) AwsParamsDto(org.finra.herd.model.dto.AwsParamsDto) ScriptDefinition(org.finra.herd.model.api.xml.ScriptDefinition) EmrClusterDefinitionConfiguration(org.finra.herd.model.api.xml.EmrClusterDefinitionConfiguration) Configuration(com.amazonaws.services.elasticmapreduce.model.Configuration) KeyValuePairConfiguration(org.finra.herd.model.api.xml.KeyValuePairConfiguration) ClientConfiguration(com.amazonaws.ClientConfiguration) KeyValuePairConfigurations(org.finra.herd.model.api.xml.KeyValuePairConfigurations) HadoopJarStep(org.finra.herd.model.api.xml.HadoopJarStep) EmrClusterDefinition(org.finra.herd.model.api.xml.EmrClusterDefinition) KeyValuePairConfiguration(org.finra.herd.model.api.xml.KeyValuePairConfiguration) ScriptBootstrapActionConfig(com.amazonaws.services.elasticmapreduce.model.ScriptBootstrapActionConfig) NodeTag(org.finra.herd.model.api.xml.NodeTag) EmrClusterDefinitionConfiguration(org.finra.herd.model.api.xml.EmrClusterDefinitionConfiguration) EmrClusterDefinitionApplication(org.finra.herd.model.api.xml.EmrClusterDefinitionApplication) InstanceGroupConfig(com.amazonaws.services.elasticmapreduce.model.InstanceGroupConfig) RunJobFlowRequest(com.amazonaws.services.elasticmapreduce.model.RunJobFlowRequest) MasterInstanceDefinition(org.finra.herd.model.api.xml.MasterInstanceDefinition) ConfigurationFiles(org.finra.herd.model.api.xml.ConfigurationFiles) InstanceDefinitions(org.finra.herd.model.api.xml.InstanceDefinitions) BootstrapActionConfig(com.amazonaws.services.elasticmapreduce.model.BootstrapActionConfig) ScriptBootstrapActionConfig(com.amazonaws.services.elasticmapreduce.model.ScriptBootstrapActionConfig) InvocationOnMock(org.mockito.invocation.InvocationOnMock) Parameter(org.finra.herd.model.api.xml.Parameter) ConfigurationFile(org.finra.herd.model.api.xml.ConfigurationFile) Application(com.amazonaws.services.elasticmapreduce.model.Application) EmrClusterDefinitionApplication(org.finra.herd.model.api.xml.EmrClusterDefinitionApplication) Test(org.junit.Test)

Example 70 with Parameter

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

the class EmrDaoImpl method getApplications.

/**
 * Converts the given list of {@link EmrClusterDefinitionApplication} into a list of {@link Application}
 *
 * @param emrClusterDefinitionApplications list of {@link EmrClusterDefinitionApplication}
 *
 * @return list {@link Application}
 */
public List<Application> getApplications(List<EmrClusterDefinitionApplication> emrClusterDefinitionApplications) {
    List<Application> applications = new ArrayList<>();
    for (EmrClusterDefinitionApplication emrClusterDefinitionApplication : emrClusterDefinitionApplications) {
        Application application = new Application();
        application.setName(emrClusterDefinitionApplication.getName());
        application.setVersion(emrClusterDefinitionApplication.getVersion());
        application.setArgs(emrClusterDefinitionApplication.getArgs());
        List<Parameter> additionalInfoList = emrClusterDefinitionApplication.getAdditionalInfoList();
        if (!CollectionUtils.isEmpty(additionalInfoList)) {
            application.setAdditionalInfo(getMap(additionalInfoList));
        }
        applications.add(application);
    }
    return applications;
}
Also used : ArrayList(java.util.ArrayList) Parameter(org.finra.herd.model.api.xml.Parameter) Application(com.amazonaws.services.elasticmapreduce.model.Application) EmrClusterDefinitionApplication(org.finra.herd.model.api.xml.EmrClusterDefinitionApplication) EmrClusterDefinitionApplication(org.finra.herd.model.api.xml.EmrClusterDefinitionApplication)

Aggregations

Parameter (org.finra.herd.model.api.xml.Parameter)148 Test (org.junit.Test)121 ArrayList (java.util.ArrayList)98 FieldExtension (org.activiti.bpmn.model.FieldExtension)64 HashMap (java.util.HashMap)61 BusinessObjectDataKey (org.finra.herd.model.api.xml.BusinessObjectDataKey)30 Job (org.finra.herd.model.api.xml.Job)30 SystemJobRunRequest (org.finra.herd.model.api.xml.SystemJobRunRequest)20 SystemJobRunResponse (org.finra.herd.model.api.xml.SystemJobRunResponse)14 S3PropertiesLocation (org.finra.herd.model.api.xml.S3PropertiesLocation)13 AbstractServiceTest (org.finra.herd.service.AbstractServiceTest)13 BusinessObjectDataAttribute (org.finra.herd.model.api.xml.BusinessObjectDataAttribute)12 JobDefinition (org.finra.herd.model.api.xml.JobDefinition)9 BusinessObjectDataAttributeEntity (org.finra.herd.model.jpa.BusinessObjectDataAttributeEntity)9 HistoricProcessInstance (org.activiti.engine.history.HistoricProcessInstance)8 BusinessObjectDataEntity (org.finra.herd.model.jpa.BusinessObjectDataEntity)7 ObjectNotFoundException (org.finra.herd.model.ObjectNotFoundException)6 JobAction (org.finra.herd.model.api.xml.JobAction)6 NotificationRegistrationKey (org.finra.herd.model.api.xml.NotificationRegistrationKey)6 BusinessObjectData (org.finra.herd.model.api.xml.BusinessObjectData)5