Search in sources :

Example 11 with ResourceDimension

use of com.netflix.titus.api.model.ResourceDimension in project titus-control-plane by Netflix.

the class Representation2ModelConvertions method asCoreEntity.

public static ApplicationSLA asCoreEntity(ApplicationSlaRepresentation representation) {
    ResourceDimension resourceDimension = ResourceDimension.newBuilder().withCpus(representation.getInstanceCPU()).withMemoryMB(representation.getInstanceMemoryMB()).withDiskMB(representation.getInstanceDiskMB()).withNetworkMbs(representation.getInstanceNetworkMbs()).withGpu(representation.getInstanceGPU()).build();
    Tier tier;
    if (representation.getTier() != null) {
        tier = Tier.valueOf(representation.getTier().name());
    } else {
        tier = Tier.Flex;
    }
    return ApplicationSLA.newBuilder().withAppName(representation.getAppName()).withTier(tier).withResourceDimension(resourceDimension).withInstanceCount(representation.getInstanceCount()).withSchedulerName(representation.getSchedulerName()).withResourcePool(representation.getResourcePool()).build();
}
Also used : Tier(com.netflix.titus.api.model.Tier) ResourceDimension(com.netflix.titus.api.model.ResourceDimension)

Example 12 with ResourceDimension

use of com.netflix.titus.api.model.ResourceDimension in project titus-control-plane by Netflix.

the class ResourceDimensionsTest method testAligningUpToHigherCPU.

@Test
public void testAligningUpToHigherCPU() throws Exception {
    ResourceDimension small2X = ResourceDimensionSample.SmallWithGpuAndOpportunisticX2.build();
    ResourceDimension original = ResourceDimensionSample.SmallWithGpuAndOpportunistic.builder().withCpus(small2X.getCpu()).build();
    assertThat(ResourceDimensions.alignUp(original, small2X)).isEqualTo(small2X);
}
Also used : ResourceDimension(com.netflix.titus.api.model.ResourceDimension) Test(org.junit.Test)

Example 13 with ResourceDimension

use of com.netflix.titus.api.model.ResourceDimension in project titus-control-plane by Netflix.

the class ResourceDimensionsTest method testResourceDimensionAddition.

@Test
public void testResourceDimensionAddition() throws Exception {
    ResourceDimension small = ResourceDimensionSample.SmallWithGpuAndOpportunistic.build();
    ResourceDimension expected = ResourceDimensionSample.SmallWithGpuAndOpportunisticX2.build();
    assertThat(ResourceDimensions.add(small, small)).isEqualTo(expected);
}
Also used : ResourceDimension(com.netflix.titus.api.model.ResourceDimension) Test(org.junit.Test)

Example 14 with ResourceDimension

use of com.netflix.titus.api.model.ResourceDimension in project titus-control-plane by Netflix.

the class ResourceDimensionsTest method testResourceDimensionSubtraction.

@Test
public void testResourceDimensionSubtraction() throws Exception {
    ResourceDimension large = ResourceDimensionSample.SmallWithGpuAndOpportunisticX2.build();
    ResourceDimension small = ResourceDimensionSample.SmallWithGpuAndOpportunistic.build();
    assertThat(ResourceDimensions.subtractPositive(large, small)).isEqualTo(small);
}
Also used : ResourceDimension(com.netflix.titus.api.model.ResourceDimension) Test(org.junit.Test)

Example 15 with ResourceDimension

use of com.netflix.titus.api.model.ResourceDimension in project titus-control-plane by Netflix.

the class ResourceDimensionsTest method testResourceDimensionDivideAndRoundUp.

@Test
public void testResourceDimensionDivideAndRoundUp() throws Exception {
    ResourceDimension large = ResourceDimensionSample.SmallWithGpuAndOpportunisticX2.build();
    ResourceDimension largePlus = ResourceDimensionSample.SmallWithGpuAndOpportunisticX2.builder().withCpus(large.getCpu() + 1).build();
    ResourceDimension small = ResourceDimensionSample.SmallWithGpuAndOpportunistic.build();
    assertThat(ResourceDimensions.divideAndRoundUp(large, small)).isEqualTo(2);
    assertThat(ResourceDimensions.divideAndRoundUp(largePlus, small)).isEqualTo(3);
}
Also used : ResourceDimension(com.netflix.titus.api.model.ResourceDimension) Test(org.junit.Test)

Aggregations

ResourceDimension (com.netflix.titus.api.model.ResourceDimension)18 Test (org.junit.Test)8 HashMap (java.util.HashMap)6 CompositeResourceConsumption (com.netflix.titus.master.service.management.CompositeResourceConsumption)5 ArrayList (java.util.ArrayList)5 Tier (com.netflix.titus.api.model.Tier)4 ResourceDimensions (com.netflix.titus.master.model.ResourceDimensions)4 ResourceConsumption (com.netflix.titus.master.service.management.ResourceConsumption)4 Collections (java.util.Collections)4 List (java.util.List)4 Map (java.util.Map)4 Collectors (java.util.stream.Collectors)4 ContainerResources (com.netflix.titus.api.jobmanager.model.job.ContainerResources)3 ApplicationSLA (com.netflix.titus.api.model.ApplicationSLA)3 CollectionsExt (com.netflix.titus.common.util.CollectionsExt)3 ConsumptionLevel (com.netflix.titus.master.service.management.ResourceConsumption.ConsumptionLevel)3 ResourceConsumptions (com.netflix.titus.master.service.management.ResourceConsumptions)3 Collection (java.util.Collection)3 HashSet (java.util.HashSet)3 Set (java.util.Set)3