use of com.twitter.heron.common.basics.ByteAmount in project heron by twitter.
the class MesosScheduler method fillResourcesRequirementForBaseContainer.
/**
* Fill the the resources requirement, i.e. cpu, memory and disk for the given container.
* This method changes the BaseContainer passed in.
* <p>
* Notice: Currently we just make every container homogeneous,
* requiring maximum resources for every container.
*
* @param container the BaseContainer to fill value in
* @param containerIndex the index of the container
* @param packing the packing plan
*/
protected void fillResourcesRequirementForBaseContainer(BaseContainer container, Integer containerIndex, PackingPlan packing) {
PackingPlan updatedPackingPlan = packing.cloneWithHomogeneousScheduledResource();
Resource maxResourceContainer = updatedPackingPlan.getContainers().iterator().next().getRequiredResource();
double cpu = 0;
ByteAmount disk = ByteAmount.ZERO;
ByteAmount mem = ByteAmount.ZERO;
for (PackingPlan.ContainerPlan cp : packing.getContainers()) {
Resource containerResource = cp.getRequiredResource();
cpu = Math.max(cpu, containerResource.getCpu());
disk = disk.max(containerResource.getDisk());
mem = mem.max(containerResource.getRam());
}
container.cpu = maxResourceContainer.getCpu();
// Convert them from bytes to MB
container.diskInMB = maxResourceContainer.getDisk().asMegabytes();
container.memInMB = maxResourceContainer.getRam().asMegabytes();
container.ports = SchedulerUtils.PORTS_REQUIRED_FOR_EXECUTOR;
}
use of com.twitter.heron.common.basics.ByteAmount in project incubator-heron by apache.
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 com.twitter.heron.common.basics.ByteAmount in project incubator-heron by apache.
the class TopologyUtilsTest method testGetComponentRamMapDefaultValue.
@Test
public void testGetComponentRamMapDefaultValue() {
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 ram map
Map<String, ByteAmount> ramMap = new TreeMap<>(TopologyUtils.getComponentRamMapConfig(TopologyTests.createTopology("test", topologyConfig, spouts, bolts)));
// Component ram map is not set, the ramMap size should be 0
Assert.assertEquals(0, ramMap.size());
}
use of com.twitter.heron.common.basics.ByteAmount in project incubator-heron by apache.
the class TopologyUtilsTest method testGetComponentDiskMapSomeDiskSpecified.
@Test
public void testGetComponentDiskMapSomeDiskSpecified() {
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 spoutDisk = ByteAmount.fromGigabytes(2);
topologyConfig.setComponentDisk("spout", spoutDisk);
// sort the component disk map
Map<String, ByteAmount> diskMap = new TreeMap<>(TopologyUtils.getComponentDiskMapConfig(TopologyTests.createTopology("test", topologyConfig, spouts, bolts)));
// Component disk map sets only spout's disk
Assert.assertArrayEquals(new String[] { "spout" }, diskMap.keySet().toArray());
Assert.assertArrayEquals(new ByteAmount[] { spoutDisk }, diskMap.values().toArray());
}
use of com.twitter.heron.common.basics.ByteAmount in project incubator-heron by apache.
the class MesosScheduler method fillResourcesRequirementForBaseContainer.
/**
* Fill the the resources requirement, i.e. cpu, memory and disk for the given container.
* This method changes the BaseContainer passed in.
* <p>
* Notice: Currently we just make every container homogeneous,
* requiring maximum resources for every container.
*
* @param container the BaseContainer to fill value in
* @param containerIndex the index of the container
* @param packing the packing plan
*/
protected void fillResourcesRequirementForBaseContainer(BaseContainer container, Integer containerIndex, PackingPlan packing) {
PackingPlan updatedPackingPlan = packing.cloneWithHomogeneousScheduledResource();
Resource maxResourceContainer = updatedPackingPlan.getContainers().iterator().next().getRequiredResource();
double cpu = 0;
ByteAmount disk = ByteAmount.ZERO;
ByteAmount mem = ByteAmount.ZERO;
for (PackingPlan.ContainerPlan cp : packing.getContainers()) {
Resource containerResource = cp.getRequiredResource();
cpu = Math.max(cpu, containerResource.getCpu());
disk = disk.max(containerResource.getDisk());
mem = mem.max(containerResource.getRam());
}
container.cpu = maxResourceContainer.getCpu();
// Convert them from bytes to MB
container.diskInMB = maxResourceContainer.getDisk().asMegabytes();
container.memInMB = maxResourceContainer.getRam().asMegabytes();
container.ports = SchedulerUtils.ExecutorPort.getRequiredPorts().size();
}
Aggregations