use of org.apache.reef.driver.evaluator.EvaluatorDescriptor in project heron by twitter.
the class HeronMasterDriverTest method createMockEvaluator.
private AllocatedEvaluator createMockEvaluator(String evaluatorId, int cores, ByteAmount mem) {
EvaluatorDescriptor descriptor = mock(EvaluatorDescriptor.class);
when(descriptor.getMemory()).thenReturn(((Long) mem.asMegabytes()).intValue());
when(descriptor.getNumberOfCores()).thenReturn(cores);
AllocatedEvaluator mockEvaluator = mock(AllocatedEvaluator.class);
when(mockEvaluator.getEvaluatorDescriptor()).thenReturn(descriptor);
when(mockEvaluator.getId()).thenReturn(evaluatorId);
return mockEvaluator;
}
use of org.apache.reef.driver.evaluator.EvaluatorDescriptor 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());
}
Aggregations