use of org.apache.reef.driver.evaluator.AllocatedEvaluator in project heron by twitter.
the class HeronMasterDriverTest method fitBiggestContainerIgnoresCoresIfMissing.
@Test
public void fitBiggestContainerIgnoresCoresIfMissing() {
Set<HeronMasterDriver.HeronWorker> workers = new HashSet<>();
workers.add(new HeronMasterDriver.HeronWorker(1, 3, ByteAmount.fromGigabytes(3)));
AllocatedEvaluator mockEvaluator = createMockEvaluator("test", 1, ByteAmount.fromGigabytes(3));
Optional<HeronMasterDriver.HeronWorker> result = spyDriver.findLargestFittingWorker(mockEvaluator, workers, false);
Assert.assertFalse(result.isPresent());
result = spyDriver.findLargestFittingWorker(mockEvaluator, workers, true);
assertTrue(result.isPresent());
assertEquals(1, result.get().getWorkerId());
}
use of org.apache.reef.driver.evaluator.AllocatedEvaluator in project heron by twitter.
the class HeronMasterDriverTest method onNextAllocatedEvaluatorDiscardsExtraWorker.
@Test
public void onNextAllocatedEvaluatorDiscardsExtraWorker() throws Exception {
AllocatedEvaluator mockEvaluator = createMockEvaluator("test", 1, ByteAmount.fromMegabytes(123));
assertFalse(spyDriver.lookupByEvaluatorId("test").isPresent());
spyDriver.new ContainerAllocationHandler().onNext(mockEvaluator);
assertFalse(spyDriver.lookupByEvaluatorId("test").isPresent());
verify(mockEvaluator, never()).submitContext(any(Configuration.class));
}
use of org.apache.reef.driver.evaluator.AllocatedEvaluator in project heron by twitter.
the class HeronMasterDriverTest method verifyFittingContainer.
private void verifyFittingContainer(Set<HeronMasterDriver.HeronWorker> containers, int ram, int cores, int expectedContainer) {
EvaluatorDescriptor evaluatorDescriptor = mock(EvaluatorDescriptor.class);
AllocatedEvaluator mockEvaluator = mock(AllocatedEvaluator.class);
when(mockEvaluator.getEvaluatorDescriptor()).thenReturn(evaluatorDescriptor);
when(evaluatorDescriptor.getMemory()).thenReturn(ram);
when(evaluatorDescriptor.getNumberOfCores()).thenReturn(cores);
Optional<HeronMasterDriver.HeronWorker> worker = spyDriver.findLargestFittingWorker(mockEvaluator, containers, false);
assertTrue(worker.isPresent());
assertEquals(expectedContainer, worker.get().getWorkerId());
}
use of org.apache.reef.driver.evaluator.AllocatedEvaluator in project heron by twitter.
the class HeronMasterDriverTest method onNextFailedEvaluatorRestartsContainer.
@Test
public void onNextFailedEvaluatorRestartsContainer() throws Exception {
int numContainers = 3;
AllocatedEvaluator[] mockEvaluators = createApplicationWithContainers(numContainers);
FailedEvaluator mockFailedContainer = mock(FailedEvaluator.class);
when(mockFailedContainer.getId()).thenReturn("e1");
verify(spyDriver, never()).requestContainerForWorker(anyInt(), anyHeronWorker());
spyDriver.new FailedContainerHandler().onNext(mockFailedContainer);
for (int id = 0; id < numContainers; id++) {
if (id == 1) {
verify(spyDriver, times(1)).requestContainerForWorker(eq(id), anyHeronWorker());
assertFalse(spyDriver.lookupByEvaluatorId("e" + id).isPresent());
continue;
}
verify(mockEvaluators[id], never()).close();
assertEquals(Integer.valueOf(id), spyDriver.lookupByEvaluatorId("e" + id).get());
}
}
use of org.apache.reef.driver.evaluator.AllocatedEvaluator in project heron by twitter.
the class HeronMasterDriverTest method killWorkersTerminatesSpecificContainers.
@Test
public void killWorkersTerminatesSpecificContainers() throws Exception {
int numContainers = 5;
Set<PackingPlan.ContainerPlan> containers = new HashSet<>();
for (int id = 0; id < numContainers; id++) {
containers.add(PackingTestUtils.testContainerPlan(id));
}
PackingPlan packingPlan = new PackingPlan("packing", containers);
spyDriver.scheduleHeronWorkers(packingPlan);
for (int id = 0; id < numContainers; id++) {
verify(spyDriver, times(1)).requestContainerForWorker(eq(id), anyHeronWorker());
assertTrue(spyDriver.lookupByContainerPlan(id).isPresent());
}
verify(mockRequestor, times(numContainers)).submit(any(EvaluatorRequest.class));
AllocatedEvaluator[] mockEvaluators = createApplicationWithContainers(numContainers);
Set<PackingPlan.ContainerPlan> containersTobeDeleted = new HashSet<>();
containersTobeDeleted.add(PackingTestUtils.testContainerPlan(2));
containersTobeDeleted.add(PackingTestUtils.testContainerPlan(3));
spyDriver.killWorkers(containersTobeDeleted);
for (int id = 0; id < numContainers; id++) {
if (id == 2 || id == 3) {
verify(mockEvaluators[id], times(1)).close();
assertFalse(spyDriver.lookupByContainerPlan(id).isPresent());
assertFalse(spyDriver.lookupByEvaluatorId("e" + id).isPresent());
continue;
}
verify(mockEvaluators[id], never()).close();
assertTrue(spyDriver.lookupByContainerPlan(id).isPresent());
assertTrue(spyDriver.lookupByEvaluatorId("e" + id).isPresent());
}
}
Aggregations