@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()); }
private synchronized int getMemory(final int requestedMemory) { final int result; if (!this.registration.isPresent()) { LOG.log(Level.WARNING, "AM doesn't seem to be registered. Proceed with fingers crossed."); result = requestedMemory; } else { final int maxMemory = registration.getRegistration().getMaximumResourceCapability().getMemory(); if (requestedMemory > maxMemory) { LOG.log(Level.WARNING, "Asking for {0}MB of memory, but max on this cluster is {1}MB ", new Object[]{requestedMemory, maxMemory}); result = maxMemory; } else { result = requestedMemory; } } return result; }
YarnResourceRequestHandler implements ResourceRequestHandler { private synchronized int getMemory(final int requestedMemory) { final int result; if (!this.registration.isPresent()) { LOG.log(Level.WARNING, "AM doesn't seem to be registered. Proceed with fingers crossed."); result = requestedMemory; } else { final int maxMemory = registration.getRegistration().getMaximumResourceCapability().getMemory(); if (requestedMemory > maxMemory) { LOG.log(Level.WARNING, "Asking for {0}MB of memory, but max on this cluster is {1}MB ", new Object[]{requestedMemory, maxMemory}); result = maxMemory; } else { result = requestedMemory; } } return result; } }
YarnResourceRequestHandler implements ResourceRequestHandler { private synchronized int getMemory(final int requestedMemory) { final int result; if (!this.registration.isPresent()) { LOG.log(Level.WARNING, "AM doesn't seem to be registered. Proceed with fingers crossed."); result = requestedMemory; } else { final int maxMemory = registration.getRegistration().getMaximumResourceCapability().getMemory(); if (requestedMemory > maxMemory) { LOG.log(Level.WARNING, "Asking for {0}MB of memory, but max on this cluster is {1}MB ", new Object[]{requestedMemory, maxMemory}); result = maxMemory; } else { result = requestedMemory; } } return result; } @Inject  YarnResourceRequestHandler(final YarnContainerRequestHandler yarnContainerRequestHandler,
                             final ApplicationMasterRegistration registration); }
YarnResourceRequestHandler implements ResourceRequestHandler { private synchronized int getMemory(final int requestedMemory) { final int result; if (!this.registration.isPresent()) { LOG.log(Level.WARNING, "AM doesn't seem to be registered. Proceed with fingers crossed."); result = requestedMemory; } else { final int maxMemory = registration.getRegistration().getMaximumResourceCapability().getMemory(); if (requestedMemory > maxMemory) { LOG.log(Level.WARNING, "Asking for {0}MB of memory, but max on this cluster is {1}MB ", new Object[]{requestedMemory, maxMemory}); result = maxMemory; } else { result = requestedMemory; } } return result; } @Inject  YarnResourceRequestHandler(final YarnContainerRequestHandler yarnContainerRequestHandler,
                             final ApplicationMasterRegistration registration); @Override synchronized void onNext(final ResourceRequestEvent resourceRequestEvent); }
YarnResourceRequestHandler implements ResourceRequestHandler { private synchronized int getMemory(final int requestedMemory) { final int result; if (!this.registration.isPresent()) { LOG.log(Level.WARNING, "AM doesn't seem to be registered. Proceed with fingers crossed."); result = requestedMemory; } else { final int maxMemory = registration.getRegistration().getMaximumResourceCapability().getMemory(); if (requestedMemory > maxMemory) { LOG.log(Level.WARNING, "Asking for {0}MB of memory, but max on this cluster is {1}MB ", new Object[]{requestedMemory, maxMemory}); result = maxMemory; } else { result = requestedMemory; } } return result; } @Inject  YarnResourceRequestHandler(final YarnContainerRequestHandler yarnContainerRequestHandler,
                             final ApplicationMasterRegistration registration); @Override synchronized void onNext(final ResourceRequestEvent resourceRequestEvent);  }