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());
}
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());
}
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());
}
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;
}
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);
}
Aggregations