Search in sources :

Example 61 with ByteAmount

use of org.apache.heron.common.basics.ByteAmount in project heron by twitter.

the class FirstFitDecreasingPackingTest method testCompleteRamMapRequested2.

/**
 * Test the scenario RAM map config is fully set
 */
@Test
public void testCompleteRamMapRequested2() throws Exception {
    ByteAmount maxContainerRam = ByteAmount.fromGigabytes(10);
    // Explicit set component RAM map
    ByteAmount boltRam = ByteAmount.fromGigabytes(1);
    ByteAmount spoutRam = ByteAmount.fromGigabytes(2);
    topologyConfig.setContainerRamRequested(maxContainerRam);
    topologyConfig.setComponentRam(BOLT_NAME, boltRam);
    topologyConfig.setComponentRam(SPOUT_NAME, spoutRam);
    topology = getTopology(spoutParallelism, boltParallelism, topologyConfig);
    doPackingTest(topology, instanceDefaultResources.cloneWithRam(boltRam), boltParallelism, instanceDefaultResources.cloneWithRam(spoutRam), spoutParallelism, 3, getDefaultMaxContainerResource().cloneWithRam(maxContainerRam));
}
Also used : ByteAmount(org.apache.heron.common.basics.ByteAmount) Test(org.junit.Test)

Example 62 with ByteAmount

use of org.apache.heron.common.basics.ByteAmount in project heron by twitter.

the class MesosSchedulerTest method testGetBaseContainer.

@Test
public void testGetBaseContainer() throws Exception {
    final double CPU = 0.5;
    final ByteAmount MEM = ByteAmount.fromMegabytes(100);
    final ByteAmount DISK = ByteAmount.fromMegabytes(100);
    Resource containerResources = new Resource(CPU, MEM, DISK);
    PackingPlan.ContainerPlan containerPlan = new PackingPlan.ContainerPlan(0, new HashSet<PackingPlan.InstancePlan>(), containerResources);
    Set<PackingPlan.ContainerPlan> containerPlans = new HashSet<>();
    containerPlans.add(containerPlan);
    PackingPlan packingPlan = new PackingPlan(TOPOLOGY_NAME, containerPlans);
    BaseContainer container = scheduler.getBaseContainer(0, packingPlan);
    // Assert we have constructed the correct BaseContainer structure
    Assert.assertEquals(ROLE, container.runAsUser);
    Assert.assertEquals(CPU, container.cpu, 0.01);
    Assert.assertEquals(MEM, ByteAmount.fromMegabytes(((Double) container.memInMB).longValue()));
    Assert.assertEquals(DISK, ByteAmount.fromMegabytes(((Double) container.diskInMB).longValue()));
    Assert.assertEquals(SchedulerUtils.ExecutorPort.getRequiredPorts().size(), container.ports);
    Assert.assertEquals(2, container.dependencies.size());
    Assert.assertTrue(container.dependencies.contains(CORE_PACKAGE_URI));
    Assert.assertTrue(container.dependencies.contains(TOPOLOGY_PACKAGE_URI));
    Assert.assertTrue(container.environmentVariables.isEmpty());
    Assert.assertTrue(container.name.startsWith("container_0"));
    // Convert to JSON
    String str = container.toString();
    String json = BaseContainer.getJobDefinitionInJSON(container);
    Assert.assertEquals(json, str);
    // Convert the JSON back to BaseContainer
    BaseContainer newContainer = BaseContainer.getJobFromJSONString(json);
    Assert.assertEquals(json, BaseContainer.getJobDefinitionInJSON(newContainer));
}
Also used : ByteAmount(org.apache.heron.common.basics.ByteAmount) PackingPlan(org.apache.heron.spi.packing.PackingPlan) Resource(org.apache.heron.spi.packing.Resource) BaseContainer(org.apache.heron.scheduler.mesos.framework.BaseContainer) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 63 with ByteAmount

use of org.apache.heron.common.basics.ByteAmount in project heron by twitter.

the class PackingPlan method getMaxContainerResources.

/**
 * Computes the maximum of all the resources required by the containers in the packing plan. If
 * the PackingPlan has already been scheduled, the scheduled resources will be used over the
 * required resources.
 *
 * @return maximum Resources found in all containers.
 */
public Resource getMaxContainerResources() {
    double maxCpu = 0;
    ByteAmount maxRam = ByteAmount.ZERO;
    ByteAmount maxDisk = ByteAmount.ZERO;
    for (ContainerPlan containerPlan : getContainers()) {
        Resource containerResource = containerPlan.getScheduledResource().or(containerPlan.getRequiredResource());
        maxCpu = Math.max(maxCpu, containerResource.getCpu());
        maxRam = maxRam.max(containerResource.getRam());
        maxDisk = maxDisk.max(containerResource.getDisk());
    }
    return new Resource(maxCpu, maxRam, maxDisk);
}
Also used : ByteAmount(org.apache.heron.common.basics.ByteAmount)

Aggregations

ByteAmount (org.apache.heron.common.basics.ByteAmount)63 Test (org.junit.Test)41 HashMap (java.util.HashMap)17 Resource (org.apache.heron.spi.packing.Resource)17 PackingPlan (org.apache.heron.spi.packing.PackingPlan)14 HashSet (java.util.HashSet)11 TreeMap (java.util.TreeMap)6 Config (org.apache.heron.api.Config)6 VisibleForTesting (com.google.common.annotations.VisibleForTesting)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 EvaluatorRequest (org.apache.reef.driver.evaluator.EvaluatorRequest)2 BufferPoolMXBean (java.lang.management.BufferPoolMXBean)1 Duration (java.time.Duration)1 Map (java.util.Map)1 TopologyAPI (org.apache.heron.api.generated.TopologyAPI)1 ResourceRequirement (org.apache.heron.packing.builder.ResourceRequirement)1 BaseContainer (org.apache.heron.scheduler.mesos.framework.BaseContainer)1 InstanceId (org.apache.heron.spi.packing.InstanceId)1 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)1