Search in sources :

Example 1 with EvaluatorDescriptor

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;
}
Also used : EvaluatorDescriptor(org.apache.reef.driver.evaluator.EvaluatorDescriptor) AllocatedEvaluator(org.apache.reef.driver.evaluator.AllocatedEvaluator)

Example 2 with EvaluatorDescriptor

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());
}
Also used : EvaluatorDescriptor(org.apache.reef.driver.evaluator.EvaluatorDescriptor) AllocatedEvaluator(org.apache.reef.driver.evaluator.AllocatedEvaluator)

Aggregations

AllocatedEvaluator (org.apache.reef.driver.evaluator.AllocatedEvaluator)2 EvaluatorDescriptor (org.apache.reef.driver.evaluator.EvaluatorDescriptor)2