Search in sources :

Example 21 with ByteAmount

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

the class TopologyUtilsTest method testGetComponentRamMapAllRamSpecified.

@Test
public void testGetComponentRamMapAllRamSpecified() {
    int componentParallelism = 2;
    Config topologyConfig = new Config();
    Map<String, Integer> spouts = new HashMap<>();
    spouts.put("spout", componentParallelism);
    Map<String, Integer> bolts = new HashMap<>();
    bolts.put("bolt", componentParallelism);
    ByteAmount boltRam = ByteAmount.fromGigabytes(1);
    ByteAmount spoutRam = ByteAmount.fromGigabytes(2);
    topologyConfig.setComponentRam("spout", spoutRam);
    topologyConfig.setComponentRam("bolt", boltRam);
    // sort the component RAM map
    Map<String, ByteAmount> ramMap = new TreeMap<>(TopologyUtils.getComponentRamMapConfig(TopologyTests.createTopology("test", topologyConfig, spouts, bolts)));
    Assert.assertArrayEquals(new String[] { "bolt", "spout" }, ramMap.keySet().toArray());
    Assert.assertArrayEquals(new ByteAmount[] { boltRam, spoutRam }, ramMap.values().toArray());
}
Also used : ByteAmount(org.apache.heron.common.basics.ByteAmount) HashMap(java.util.HashMap) Config(org.apache.heron.api.Config) TreeMap(java.util.TreeMap) Test(org.junit.Test)

Example 22 with ByteAmount

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

the class TopologyUtilsTest method testGetComponentDiskMapDefaultValue.

@Test
public void testGetComponentDiskMapDefaultValue() {
    int componentParallelism = 2;
    Config topologyConfig = new Config();
    Map<String, Integer> spouts = new HashMap<>();
    spouts.put("spout", componentParallelism);
    Map<String, Integer> bolts = new HashMap<>();
    bolts.put("bolt", componentParallelism);
    // sort the component disk map
    Map<String, ByteAmount> diskMap = new TreeMap<>(TopologyUtils.getComponentDiskMapConfig(TopologyTests.createTopology("test", topologyConfig, spouts, bolts)));
    // Component disk map is not set, the diskMap size should be 0
    Assert.assertEquals(0, diskMap.size());
}
Also used : ByteAmount(org.apache.heron.common.basics.ByteAmount) HashMap(java.util.HashMap) Config(org.apache.heron.api.Config) TreeMap(java.util.TreeMap) Test(org.junit.Test)

Example 23 with ByteAmount

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

the class TopologyUtilsTest method testGetComponentDiskMapAllDiskSpecified.

@Test
public void testGetComponentDiskMapAllDiskSpecified() {
    int componentParallelism = 2;
    Config topologyConfig = new Config();
    Map<String, Integer> spouts = new HashMap<>();
    spouts.put("spout", componentParallelism);
    Map<String, Integer> bolts = new HashMap<>();
    bolts.put("bolt", componentParallelism);
    ByteAmount boltDisk = ByteAmount.fromGigabytes(1);
    ByteAmount spoutDisk = ByteAmount.fromGigabytes(2);
    topologyConfig.setComponentDisk("spout", spoutDisk);
    topologyConfig.setComponentDisk("bolt", boltDisk);
    // sort the component disk map
    Map<String, ByteAmount> diskMap = new TreeMap<>(TopologyUtils.getComponentDiskMapConfig(TopologyTests.createTopology("test", topologyConfig, spouts, bolts)));
    Assert.assertArrayEquals(new String[] { "bolt", "spout" }, diskMap.keySet().toArray());
    Assert.assertArrayEquals(new ByteAmount[] { boltDisk, spoutDisk }, diskMap.values().toArray());
}
Also used : ByteAmount(org.apache.heron.common.basics.ByteAmount) HashMap(java.util.HashMap) Config(org.apache.heron.api.Config) TreeMap(java.util.TreeMap) Test(org.junit.Test)

Example 24 with ByteAmount

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

the class JVMMetrics method getJVMSampleRunnable.

public Runnable getJVMSampleRunnable() {
    final Runnable sampleRunnable = new Runnable() {

        @Override
        public void run() {
            updateGcMetrics();
            jvmUpTimeSecs.setValue(Duration.ofMillis(runtimeMXBean.getUptime()).getSeconds());
            processCPUTimeNs.setValue(getProcessCPUTimeNs());
            getThreadsMetrics();
            // We multiple # of processors to measure a process CPU load based on cores rather than
            // overall machine
            processCPULoad.update(getProcessCPULoad() * runtime.availableProcessors());
            updateFdMetrics();
            updateMemoryPoolMetrics();
            updateBufferPoolMetrics();
            ByteAmount freeMemory = ByteAmount.fromBytes(runtime.freeMemory());
            ByteAmount totalMemory = ByteAmount.fromBytes(runtime.totalMemory());
            jvmMemoryFreeMB.update(freeMemory.asMegabytes());
            jvmMemoryTotalMB.update(totalMemory.asMegabytes());
            jvmMemoryUsedMB.update(totalMemory.asMegabytes() - freeMemory.asMegabytes());
            jvmMemoryHeapUsedMB.update(ByteAmount.fromBytes(memoryBean.getHeapMemoryUsage().getUsed()).asMegabytes());
            jvmMemoryHeapCommittedMB.update(ByteAmount.fromBytes(memoryBean.getHeapMemoryUsage().getCommitted()).asMegabytes());
            jvmMemoryHeapMaxMB.update(ByteAmount.fromBytes(memoryBean.getHeapMemoryUsage().getMax()).asMegabytes());
            jvmMemoryNonHeapUsedMB.update(ByteAmount.fromBytes(memoryBean.getNonHeapMemoryUsage().getUsed()).asMegabytes());
            jvmMemoryNonHeapCommittedMB.update(ByteAmount.fromBytes(memoryBean.getNonHeapMemoryUsage().getCommitted()).asMegabytes());
            jvmMemoryNonHeapMaxMB.update(ByteAmount.fromBytes(memoryBean.getNonHeapMemoryUsage().getMax()).asMegabytes());
        }
    };
    return sampleRunnable;
}
Also used : ByteAmount(org.apache.heron.common.basics.ByteAmount)

Example 25 with ByteAmount

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

the class PackingTestUtils method testContainerPlan.

@SafeVarargs
public static PackingPlan.ContainerPlan testContainerPlan(int containerId, Pair<String, Integer>... instanceInfo) {
    double cpu = 1.5;
    ByteAmount ram = ByteAmount.fromGigabytes(1);
    Set<PackingPlan.InstancePlan> instancePlans = new HashSet<>();
    for (Pair<String, Integer> info : instanceInfo) {
        PackingPlan.InstancePlan instance = testInstancePlan(info.first, info.second);
        instancePlans.add(instance);
        cpu += instance.getResource().getCpu();
        ram = ram.plus(instance.getResource().getRam());
    }
    Resource resource = new Resource(cpu, ram, ram);
    return new PackingPlan.ContainerPlan(containerId, instancePlans, resource);
}
Also used : ByteAmount(org.apache.heron.common.basics.ByteAmount) PackingPlan(org.apache.heron.spi.packing.PackingPlan) Resource(org.apache.heron.spi.packing.Resource) HashSet(java.util.HashSet)

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