Search in sources :

Example 1 with EmrClusterInstanceFleetProvisioningSpecifications

use of org.finra.herd.model.api.xml.EmrClusterInstanceFleetProvisioningSpecifications 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 2 with EmrClusterInstanceFleetProvisioningSpecifications

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

the class EmrHelper method getLaunchSpecifications.

/**
 * Returns  EmrClusterInstanceFleetProvisioningSpecifications
 *
 * @param instanceFleetProvisioningSpecifications AWS object
 *
 * @return EmrClusterInstanceFleetProvisioningSpecifications
 */
protected EmrClusterInstanceFleetProvisioningSpecifications getLaunchSpecifications(InstanceFleetProvisioningSpecifications instanceFleetProvisioningSpecifications) {
    EmrClusterInstanceFleetProvisioningSpecifications emrClusterDefinitionLaunchSpecifications = null;
    if (instanceFleetProvisioningSpecifications != null) {
        emrClusterDefinitionLaunchSpecifications = new EmrClusterInstanceFleetProvisioningSpecifications();
        emrClusterDefinitionLaunchSpecifications.setSpotSpecification(getSpotSpecification(instanceFleetProvisioningSpecifications.getSpotSpecification()));
    }
    return emrClusterDefinitionLaunchSpecifications;
}
Also used : EmrClusterInstanceFleetProvisioningSpecifications(org.finra.herd.model.api.xml.EmrClusterInstanceFleetProvisioningSpecifications)

Aggregations

EmrClusterInstanceFleetProvisioningSpecifications (org.finra.herd.model.api.xml.EmrClusterInstanceFleetProvisioningSpecifications)2 Configuration (com.amazonaws.services.elasticmapreduce.model.Configuration)1 EbsBlockDevice (com.amazonaws.services.elasticmapreduce.model.EbsBlockDevice)1 InstanceFleet (com.amazonaws.services.elasticmapreduce.model.InstanceFleet)1 InstanceFleetProvisioningSpecifications (com.amazonaws.services.elasticmapreduce.model.InstanceFleetProvisioningSpecifications)1 InstanceFleetStateChangeReason (com.amazonaws.services.elasticmapreduce.model.InstanceFleetStateChangeReason)1 InstanceFleetStatus (com.amazonaws.services.elasticmapreduce.model.InstanceFleetStatus)1 InstanceFleetTimeline (com.amazonaws.services.elasticmapreduce.model.InstanceFleetTimeline)1 InstanceTypeSpecification (com.amazonaws.services.elasticmapreduce.model.InstanceTypeSpecification)1 ListInstanceFleetsResult (com.amazonaws.services.elasticmapreduce.model.ListInstanceFleetsResult)1 SpotProvisioningSpecification (com.amazonaws.services.elasticmapreduce.model.SpotProvisioningSpecification)1 VolumeSpecification (com.amazonaws.services.elasticmapreduce.model.VolumeSpecification)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 AbstractDaoTest (org.finra.herd.dao.AbstractDaoTest)1 EmrClusterEbsBlockDevice (org.finra.herd.model.api.xml.EmrClusterEbsBlockDevice)1 EmrClusterInstanceFleet (org.finra.herd.model.api.xml.EmrClusterInstanceFleet)1 EmrClusterInstanceFleetStateChangeReason (org.finra.herd.model.api.xml.EmrClusterInstanceFleetStateChangeReason)1 EmrClusterInstanceFleetStatus (org.finra.herd.model.api.xml.EmrClusterInstanceFleetStatus)1 EmrClusterInstanceFleetTimeline (org.finra.herd.model.api.xml.EmrClusterInstanceFleetTimeline)1