Search in sources :

Example 1 with ResourceUtils

use of com.mesosphere.sdk.offer.ResourceUtils in project dcos-commons by mesosphere.

the class OfferEvaluatorPortsTest method getExpectedExecutorResources.

private Collection<Resource> getExpectedExecutorResources(Protos.ExecutorInfo executorInfo) {
    String executorCpuId = executorInfo.getResourcesList().stream().filter(r -> r.getName().equals("cpus")).map(ResourceUtils::getResourceId).filter(o -> o.isPresent()).map(o -> o.get()).findFirst().get();
    String executorMemId = executorInfo.getResourcesList().stream().filter(r -> r.getName().equals("mem")).map(ResourceUtils::getResourceId).filter(o -> o.isPresent()).map(o -> o.get()).findFirst().get();
    String executorDiskId = executorInfo.getResourcesList().stream().filter(r -> r.getName().equals("disk")).map(ResourceUtils::getResourceId).filter(o -> o.isPresent()).map(o -> o.get()).findFirst().get();
    Resource expectedExecutorCpu = ResourceTestUtils.getReservedCpus(0.1, executorCpuId);
    Resource expectedExecutorMem = ResourceTestUtils.getReservedMem(32, executorMemId);
    Resource expectedExecutorDisk = ResourceTestUtils.getReservedDisk(256, executorDiskId);
    return new ArrayList<>(Arrays.asList(expectedExecutorCpu, expectedExecutorMem, expectedExecutorDisk));
}
Also used : Protos(org.apache.mesos.Protos) Arrays(java.util.Arrays) Label(org.apache.mesos.Protos.Label) TestConstants(com.mesosphere.sdk.testutils.TestConstants) DiscoveryInfo(org.apache.mesos.Protos.DiscoveryInfo) Collection(java.util.Collection) TaskInfo(org.apache.mesos.Protos.TaskInfo) Operation(org.apache.mesos.Protos.Offer.Operation) PodInstanceRequirementTestUtils(com.mesosphere.sdk.scheduler.plan.PodInstanceRequirementTestUtils) Test(org.junit.Test) HashMap(java.util.HashMap) OfferTestUtils(com.mesosphere.sdk.testutils.OfferTestUtils) OfferRecommendation(com.mesosphere.sdk.offer.OfferRecommendation) ArrayList(java.util.ArrayList) Resource(org.apache.mesos.Protos.Resource) PodInstanceRequirement(com.mesosphere.sdk.scheduler.plan.PodInstanceRequirement) List(java.util.List) EnvUtils(com.mesosphere.sdk.offer.taskdata.EnvUtils) Map(java.util.Map) ResourceUtils(com.mesosphere.sdk.offer.ResourceUtils) TaskPackingUtils(com.mesosphere.sdk.offer.taskdata.TaskPackingUtils) Port(org.apache.mesos.Protos.Port) Assert(org.junit.Assert) ResourceTestUtils(com.mesosphere.sdk.testutils.ResourceTestUtils) ResourceUtils(com.mesosphere.sdk.offer.ResourceUtils) Resource(org.apache.mesos.Protos.Resource) ArrayList(java.util.ArrayList)

Aggregations

OfferRecommendation (com.mesosphere.sdk.offer.OfferRecommendation)1 ResourceUtils (com.mesosphere.sdk.offer.ResourceUtils)1 EnvUtils (com.mesosphere.sdk.offer.taskdata.EnvUtils)1 TaskPackingUtils (com.mesosphere.sdk.offer.taskdata.TaskPackingUtils)1 PodInstanceRequirement (com.mesosphere.sdk.scheduler.plan.PodInstanceRequirement)1 PodInstanceRequirementTestUtils (com.mesosphere.sdk.scheduler.plan.PodInstanceRequirementTestUtils)1 OfferTestUtils (com.mesosphere.sdk.testutils.OfferTestUtils)1 ResourceTestUtils (com.mesosphere.sdk.testutils.ResourceTestUtils)1 TestConstants (com.mesosphere.sdk.testutils.TestConstants)1 ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1 Collection (java.util.Collection)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 Protos (org.apache.mesos.Protos)1 DiscoveryInfo (org.apache.mesos.Protos.DiscoveryInfo)1 Label (org.apache.mesos.Protos.Label)1 Operation (org.apache.mesos.Protos.Offer.Operation)1 Port (org.apache.mesos.Protos.Port)1