use of com.twitter.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 com.twitter.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);
}
use of com.twitter.heron.common.basics.ByteAmount in project heron by twitter.
the class Resource method plus.
/**
* Adds a given resource from the current resource.
*/
public Resource plus(Resource other) {
double totalCpu = this.getCpu() + other.getCpu();
ByteAmount totalRam = this.getRam().plus(other.getRam());
ByteAmount totalDisk = this.getDisk().plus(other.getDisk());
return new Resource(totalCpu, totalRam, totalDisk);
}
use of com.twitter.heron.common.basics.ByteAmount in project heron by twitter.
the class Resource method subtractAbsolute.
/**
* Subtracts a given resource from the current resource. The results is never negative.
*/
public Resource subtractAbsolute(Resource other) {
double cpuDifference = this.getCpu() - other.getCpu();
double extraCpu = Math.max(0, cpuDifference);
ByteAmount ramDifference = this.getRam().minus(other.getRam());
ByteAmount extraRam = ByteAmount.ZERO.max(ramDifference);
ByteAmount diskDifference = this.getDisk().minus(other.getDisk());
ByteAmount extraDisk = ByteAmount.ZERO.max(diskDifference);
return new Resource(extraCpu, extraRam, extraDisk);
}
use of com.twitter.heron.common.basics.ByteAmount in project heron by twitter.
the class HeronMasterDriver method requestContainerForWorker.
@VisibleForTesting
void requestContainerForWorker(int id, final HeronWorker worker) {
int cpu = worker.cores;
ByteAmount mem = worker.mem;
EvaluatorRequest evaluatorRequest = createEvaluatorRequest(cpu, mem);
LOG.info(String.format("Requesting container for worker: %d, mem: %s, cpu: %d", id, mem, cpu));
requestor.submit(evaluatorRequest);
}
Aggregations