Java Code Examples for org.apache.reef.driver.evaluator.EvaluatorRequestor#submit()

The following examples show how to use org.apache.reef.driver.evaluator.EvaluatorRequestor#submit() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: EvaluatorRequestorImplTest.java    From reef with Apache License 2.0 5 votes vote down vote up
/**
 * If only memory, no count is given, 1 evaluator should be requested.
 */
@Test
public void testMemoryOnly() {
  final int memory = 777;
  final DummyRequestHandler requestHandler = new DummyRequestHandler();
  final EvaluatorRequestor evaluatorRequestor =
      new EvaluatorRequestorImpl(resourceCatalog, requestHandler, loggingScopeFactory);
  evaluatorRequestor.submit(EvaluatorRequest.newBuilder().setMemory(memory).build());
  Assert.assertEquals("Memory request did not make it",
      memory, requestHandler.get().getMemorySize().get().intValue());
  Assert.assertEquals("Number of requests did not make it", 1, requestHandler.get().getResourceCount());
}
 
Example 2
Source File: EvaluatorRequestorImplTest.java    From reef with Apache License 2.0 5 votes vote down vote up
/**
 * Checks whether memory and count make it correctly.
 */
@Test
public void testMemoryAndCount() {
  final int memory = 777;
  final int count = 9;
  final DummyRequestHandler requestHandler = new DummyRequestHandler();
  final EvaluatorRequestor evaluatorRequestor =
      new EvaluatorRequestorImpl(resourceCatalog, requestHandler, loggingScopeFactory);
  evaluatorRequestor.submit(EvaluatorRequest.newBuilder().setMemory(memory).setNumber(count).build());
  Assert.assertEquals("Memory request did not make it",
      memory, requestHandler.get().getMemorySize().get().intValue());
  Assert.assertEquals("Number of requests did not make it", count, requestHandler.get().getResourceCount());
}
 
Example 3
Source File: EvaluatorRequestorImplTest.java    From reef with Apache License 2.0 5 votes vote down vote up
/**
 * Expect an IllegalArgumentException when a non-positive memory amount is passed.
 */
@Test(expected = IllegalArgumentException.class)
public void testIllegalMemory() {
  final int memory = 0;
  final int count = 1;
  final DummyRequestHandler requestHandler = new DummyRequestHandler();
  final EvaluatorRequestor evaluatorRequestor =
      new EvaluatorRequestorImpl(resourceCatalog, requestHandler, loggingScopeFactory);
  evaluatorRequestor.submit(EvaluatorRequest.newBuilder().setMemory(memory).setNumberOfCores(1).setNumber(count)
      .build());
}
 
Example 4
Source File: EvaluatorRequestorImplTest.java    From reef with Apache License 2.0 5 votes vote down vote up
/**
 * Expect an IllegalArgumentException when a non-positive evaluator count is passed.
 */
@Test(expected = IllegalArgumentException.class)
public void testIllegalCount() {
  final int memory = 128;
  final int count = 0;
  final DummyRequestHandler requestHandler = new DummyRequestHandler();
  final EvaluatorRequestor evaluatorRequestor =
      new EvaluatorRequestorImpl(resourceCatalog, requestHandler, loggingScopeFactory);
  evaluatorRequestor.submit(EvaluatorRequest.newBuilder().setMemory(memory).setNumberOfCores(1).setNumber(count)
      .build());
}
 
Example 5
Source File: YarnResourceRequestHandlerTest.java    From reef with Apache License 2.0 5 votes vote down vote up
/**
 * Tests whether the amount of memory is transferred correctly.
 */
@Test
public void testDifferentMemory() throws InjectionException {

  final LoggingScopeFactory loggingScopeFactory =
      Tang.Factory.getTang().newInjector().getInstance(LoggingScopeFactory.class);

  final EvaluatorRequestor evaluatorRequestor =
      new EvaluatorRequestorImpl(resourceCatalog, resourceRequestHandler, loggingScopeFactory);

  final EvaluatorRequest requestOne = EvaluatorRequest.newBuilder()
      .setNumber(1)
      .setMemory(64)
      .setNumberOfCores(1)
      .build();

  final EvaluatorRequest requestTwo = EvaluatorRequest.newBuilder()
      .setNumber(1)
      .setMemory(128)
      .setNumberOfCores(2)
      .build();

  evaluatorRequestor.submit(requestOne);
  Assert.assertEquals("Request in REEF and YARN form should have the same amount of memory",
      requestOne.getMegaBytes(),
      containerRequestHandler.getRequests()[0].getCapability().getMemory());

  evaluatorRequestor.submit(requestTwo);
  Assert.assertEquals("Request in REEF and YARN form should have the same amount of memory",
      requestTwo.getMegaBytes(),
      containerRequestHandler.getRequests()[0].getCapability().getMemory());

  evaluatorRequestor.submit(requestOne);
  Assert.assertNotEquals("Second YARN request should have different amount of memory",
      requestTwo.getMegaBytes(),
      containerRequestHandler.getRequests()[0].getCapability().getMemory());
}
 
Example 6
Source File: YarnResourceRequestHandlerTest.java    From reef with Apache License 2.0 5 votes vote down vote up
@Test
public void testEvaluatorCount() throws InjectionException {

  final LoggingScopeFactory loggingScopeFactory =
      Tang.Factory.getTang().newInjector().getInstance(LoggingScopeFactory.class);

  final EvaluatorRequestor evaluatorRequestor =
      new EvaluatorRequestorImpl(resourceCatalog, resourceRequestHandler, loggingScopeFactory);

  final EvaluatorRequest requestOne = EvaluatorRequest.newBuilder()
      .setNumber(1)
      .setMemory(64)
      .setNumberOfCores(1)
      .build();

  final EvaluatorRequest requestTwo = EvaluatorRequest.newBuilder()
      .setNumber(2)
      .setMemory(128)
      .setNumberOfCores(2)
      .build();

  evaluatorRequestor.submit(requestOne);
  Assert.assertEquals("Request in REEF and YARN form should have the same number of Evaluators",
      requestOne.getNumber(),
      containerRequestHandler.getRequests().length);

  evaluatorRequestor.submit(requestTwo);
  Assert.assertEquals("Request in REEF and YARN form should have the same number of Evaluators",
      requestTwo.getNumber(),
      containerRequestHandler.getRequests().length);

  evaluatorRequestor.submit(requestTwo);
  Assert.assertNotEquals("Second YARN request should have different number of Evaluators",
      requestOne.getNumber(),
      containerRequestHandler.getRequests().length);
}