@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()); }
@Override public synchronized void submit(final EvaluatorRequest req) { if (LOG.isLoggable(Level.FINEST)) { LOG.log(Level.FINEST, "Got an EvaluatorRequest: number: {0}, memory = {1}, cores = {2}.", new Object[] {req.getNumber(), req.getMegaBytes(), req.getNumberOfCores()}); LOG.log(Level.FINEST, "Node names: " + Arrays.toString(req.getNodeNames().toArray())); } if (req.getMegaBytes() <= 0) { throw new IllegalArgumentException("Given an unsupported memory size: " + req.getMegaBytes()); } if (req.getNumberOfCores() <= 0) { throw new IllegalArgumentException("Given an unsupported core number: " + req.getNumberOfCores()); } if (req.getNumber() <= 0) { throw new IllegalArgumentException("Given an unsupported number of evaluators: " + req.getNumber()); } if (req.getNodeNames() == null) { throw new IllegalArgumentException("Node names cannot be null"); } if (req.getRackNames() == null) { throw new IllegalArgumentException("Rack names cannot be null"); } if(req.getRuntimeName() == null) { throw new IllegalArgumentException("Runtime name cannot be null"); } boolean relaxLocality = req.getRelaxLocality(); if (!req.getRackNames().isEmpty()) { for (final String rackName : req.getRackNames()) { if (Constants.ANY_RACK.equals(rackName)) { relaxLocality = true; break; } } } try (LoggingScope ls = this.loggingScopeFactory.evaluatorSubmit(req.getNumber())) { final ResourceRequestEvent request = ResourceRequestEventImpl .newBuilder() .setResourceCount(req.getNumber()) .setVirtualCores(req.getNumberOfCores()) .setMemorySize(req.getMegaBytes()) .addNodeNames(req.getNodeNames()) .addRackNames(req.getRackNames()) .setRelaxLocality(relaxLocality) .setRuntimeName(req.getRuntimeName()) .setNodeLabelExpression(req.getNodeLabelExpression()) .build(); this.resourceRequestHandler.onNext(request); } }
EvaluatorRequestorImpl implements EvaluatorRequestor { @Override public synchronized void submit(final EvaluatorRequest req) { if (LOG.isLoggable(Level.FINEST)) { LOG.log(Level.FINEST, "Got an EvaluatorRequest: number: {0}, memory = {1}, cores = {2}.", new Object[] {req.getNumber(), req.getMegaBytes(), req.getNumberOfCores()}); LOG.log(Level.FINEST, "Node names: " + Arrays.toString(req.getNodeNames().toArray())); } if (req.getMegaBytes() <= 0) { throw new IllegalArgumentException("Given an unsupported memory size: " + req.getMegaBytes()); } if (req.getNumberOfCores() <= 0) { throw new IllegalArgumentException("Given an unsupported core number: " + req.getNumberOfCores()); } if (req.getNumber() <= 0) { throw new IllegalArgumentException("Given an unsupported number of evaluators: " + req.getNumber()); } if (req.getNodeNames() == null) { throw new IllegalArgumentException("Node names cannot be null"); } if (req.getRackNames() == null) { throw new IllegalArgumentException("Rack names cannot be null"); } if(req.getRuntimeName() == null) { throw new IllegalArgumentException("Runtime name cannot be null"); } boolean relaxLocality = req.getRelaxLocality(); if (!req.getRackNames().isEmpty()) { for (final String rackName : req.getRackNames()) { if (Constants.ANY_RACK.equals(rackName)) { relaxLocality = true; break; } } } try (LoggingScope ls = this.loggingScopeFactory.evaluatorSubmit(req.getNumber())) { final ResourceRequestEvent request = ResourceRequestEventImpl .newBuilder() .setResourceCount(req.getNumber()) .setVirtualCores(req.getNumberOfCores()) .setMemorySize(req.getMegaBytes()) .addNodeNames(req.getNodeNames()) .addRackNames(req.getRackNames()) .setRelaxLocality(relaxLocality) .setRuntimeName(req.getRuntimeName()) .setNodeLabelExpression(req.getNodeLabelExpression()) .build(); this.resourceRequestHandler.onNext(request); } } }
EvaluatorRequestorImpl implements EvaluatorRequestor { @Override public synchronized void submit(final EvaluatorRequest req) { if (LOG.isLoggable(Level.FINEST)) { LOG.log(Level.FINEST, "Got an EvaluatorRequest: number: {0}, memory = {1}, cores = {2}.", new Object[] {req.getNumber(), req.getMegaBytes(), req.getNumberOfCores()}); LOG.log(Level.FINEST, "Node names: " + Arrays.toString(req.getNodeNames().toArray())); } if (req.getMegaBytes() <= 0) { throw new IllegalArgumentException("Given an unsupported memory size: " + req.getMegaBytes()); } if (req.getNumberOfCores() <= 0) { throw new IllegalArgumentException("Given an unsupported core number: " + req.getNumberOfCores()); } if (req.getNumber() <= 0) { throw new IllegalArgumentException("Given an unsupported number of evaluators: " + req.getNumber()); } if (req.getNodeNames() == null) { throw new IllegalArgumentException("Node names cannot be null"); } if (req.getRackNames() == null) { throw new IllegalArgumentException("Rack names cannot be null"); } if(req.getRuntimeName() == null) { throw new IllegalArgumentException("Runtime name cannot be null"); } boolean relaxLocality = req.getRelaxLocality(); if (!req.getRackNames().isEmpty()) { for (final String rackName : req.getRackNames()) { if (Constants.ANY_RACK.equals(rackName)) { relaxLocality = true; break; } } } try (LoggingScope ls = this.loggingScopeFactory.evaluatorSubmit(req.getNumber())) { final ResourceRequestEvent request = ResourceRequestEventImpl .newBuilder() .setResourceCount(req.getNumber()) .setVirtualCores(req.getNumberOfCores()) .setMemorySize(req.getMegaBytes()) .addNodeNames(req.getNodeNames()) .addRackNames(req.getRackNames()) .setRelaxLocality(relaxLocality) .setRuntimeName(req.getRuntimeName()) .setNodeLabelExpression(req.getNodeLabelExpression()) .build(); this.resourceRequestHandler.onNext(request); } } @Inject  EvaluatorRequestorImpl(final ResourceCatalog resourceCatalog,
                                final ResourceRequestHandler resourceRequestHandler,
                                final LoggingScopeFactory loggingScopeFactory); }
EvaluatorRequestorImpl implements EvaluatorRequestor { @Override public synchronized void submit(final EvaluatorRequest req) { if (LOG.isLoggable(Level.FINEST)) { LOG.log(Level.FINEST, "Got an EvaluatorRequest: number: {0}, memory = {1}, cores = {2}.", new Object[] {req.getNumber(), req.getMegaBytes(), req.getNumberOfCores()}); LOG.log(Level.FINEST, "Node names: " + Arrays.toString(req.getNodeNames().toArray())); } if (req.getMegaBytes() <= 0) { throw new IllegalArgumentException("Given an unsupported memory size: " + req.getMegaBytes()); } if (req.getNumberOfCores() <= 0) { throw new IllegalArgumentException("Given an unsupported core number: " + req.getNumberOfCores()); } if (req.getNumber() <= 0) { throw new IllegalArgumentException("Given an unsupported number of evaluators: " + req.getNumber()); } if (req.getNodeNames() == null) { throw new IllegalArgumentException("Node names cannot be null"); } if (req.getRackNames() == null) { throw new IllegalArgumentException("Rack names cannot be null"); } if(req.getRuntimeName() == null) { throw new IllegalArgumentException("Runtime name cannot be null"); } boolean relaxLocality = req.getRelaxLocality(); if (!req.getRackNames().isEmpty()) { for (final String rackName : req.getRackNames()) { if (Constants.ANY_RACK.equals(rackName)) { relaxLocality = true; break; } } } try (LoggingScope ls = this.loggingScopeFactory.evaluatorSubmit(req.getNumber())) { final ResourceRequestEvent request = ResourceRequestEventImpl .newBuilder() .setResourceCount(req.getNumber()) .setVirtualCores(req.getNumberOfCores()) .setMemorySize(req.getMegaBytes()) .addNodeNames(req.getNodeNames()) .addRackNames(req.getRackNames()) .setRelaxLocality(relaxLocality) .setRuntimeName(req.getRuntimeName()) .setNodeLabelExpression(req.getNodeLabelExpression()) .build(); this.resourceRequestHandler.onNext(request); } } @Inject  EvaluatorRequestorImpl(final ResourceCatalog resourceCatalog,
                                final ResourceRequestHandler resourceRequestHandler,
                                final LoggingScopeFactory loggingScopeFactory); @Override synchronized void submit(final EvaluatorRequest req); @Override Builder newRequest(); }
EvaluatorRequestorImpl implements EvaluatorRequestor { @Override public synchronized void submit(final EvaluatorRequest req) { if (LOG.isLoggable(Level.FINEST)) { LOG.log(Level.FINEST, "Got an EvaluatorRequest: number: {0}, memory = {1}, cores = {2}.", new Object[] {req.getNumber(), req.getMegaBytes(), req.getNumberOfCores()}); LOG.log(Level.FINEST, "Node names: " + Arrays.toString(req.getNodeNames().toArray())); } if (req.getMegaBytes() <= 0) { throw new IllegalArgumentException("Given an unsupported memory size: " + req.getMegaBytes()); } if (req.getNumberOfCores() <= 0) { throw new IllegalArgumentException("Given an unsupported core number: " + req.getNumberOfCores()); } if (req.getNumber() <= 0) { throw new IllegalArgumentException("Given an unsupported number of evaluators: " + req.getNumber()); } if (req.getNodeNames() == null) { throw new IllegalArgumentException("Node names cannot be null"); } if (req.getRackNames() == null) { throw new IllegalArgumentException("Rack names cannot be null"); } if(req.getRuntimeName() == null) { throw new IllegalArgumentException("Runtime name cannot be null"); } boolean relaxLocality = req.getRelaxLocality(); if (!req.getRackNames().isEmpty()) { for (final String rackName : req.getRackNames()) { if (Constants.ANY_RACK.equals(rackName)) { relaxLocality = true; break; } } } try (LoggingScope ls = this.loggingScopeFactory.evaluatorSubmit(req.getNumber())) { final ResourceRequestEvent request = ResourceRequestEventImpl .newBuilder() .setResourceCount(req.getNumber()) .setVirtualCores(req.getNumberOfCores()) .setMemorySize(req.getMegaBytes()) .addNodeNames(req.getNodeNames()) .addRackNames(req.getRackNames()) .setRelaxLocality(relaxLocality) .setRuntimeName(req.getRuntimeName()) .setNodeLabelExpression(req.getNodeLabelExpression()) .build(); this.resourceRequestHandler.onNext(request); } } @Inject  EvaluatorRequestorImpl(final ResourceCatalog resourceCatalog,
                                final ResourceRequestHandler resourceRequestHandler,
                                final LoggingScopeFactory loggingScopeFactory); @Override synchronized void submit(final EvaluatorRequest req); @Override Builder newRequest();  }