MesosNimbus implements INimbus { protected List<Resource> getResourcesRange(final List<Resource> offerResources, final long value, final String name) { for (Resource r : offerResources) { if (r.hasReservation()) { continue; } if (r.getType() == Type.RANGES && r.getName().equals(name)) { for (Range range : r.getRanges().getRangeList()) { if (value >= range.getBegin() && value <= range.getEnd()) { return Arrays.asList(r.toBuilder() .setRanges( Ranges.newBuilder() .addRange( Range.newBuilder().setBegin(value).setEnd(value).build() ).build() ) .build() ); } } } } return new ArrayList<>(); } MesosNimbus(); static void main(String[] args); @Override IScheduler getForcedScheduler(); @Override String getHostName(Map<String, SupervisorDetails> map, String nodeId); @Override void prepare(Map conf, String localDir); void doRegistration(final SchedulerDriver driver, Protos.FrameworkID id); void shutdown(); void resourceOffers(SchedulerDriver driver, List<Protos.Offer> offers); void offerRescinded(OfferID id); void taskLost(final TaskID taskId); boolean isHostAccepted(String hostname); @Override Collection<WorkerSlot> allSlotsAvailableForScheduling(
          Collection<SupervisorDetails> existingSupervisors, Topologies topologies, Set<String> topologiesMissingAssignments); @Override void assignSlots(Topologies topologies, Map<String, Collection<WorkerSlot>> slots); static final String CONF_EXECUTOR_URI; static final String CONF_MASTER_URL; static final String CONF_MASTER_FAILOVER_TIMEOUT_SECS; static final String CONF_MESOS_ALLOWED_HOSTS; static final String CONF_MESOS_DISALLOWED_HOSTS; static final String CONF_MESOS_ROLE; static final String CONF_MESOS_PRINCIPAL; static final String CONF_MESOS_SECRET_FILE; static final String CONF_MESOS_CHECKPOINT; static final String CONF_MESOS_OFFER_LRU_CACHE_SIZE; static final String CONF_MESOS_OFFER_FILTER_SECONDS; static final String CONF_MESOS_OFFER_EXPIRY_MULTIPLIER; static final String CONF_MESOS_LOCAL_FILE_SERVER_PORT; static final String CONF_MESOS_FRAMEWORK_NAME; static final String CONF_MESOS_PREFER_RESERVED_RESOURCES; static final String CONF_MESOS_CONTAINER_DOCKER_IMAGE; static final String FRAMEWORK_ID; }
@Test public void testGetResourcesRange() throws Exception { MesosNimbus mesosNimbus = new MesosNimbus(); assertEquals( Arrays.asList( TestUtils.buildRangeResource("ports", 100, 100) ), mesosNimbus.getResourcesRange( TestUtils.buildRangeResourceList(100, 100), 100, "ports" ) ); assertEquals( Arrays.asList( TestUtils.buildRangeResource("ports", 105, 105) ), mesosNimbus.getResourcesRange( TestUtils.buildRangeResourceList(100, 200), 105, "ports" ) ); assertEquals( 0, mesosNimbus.getResourcesRange( TestUtils.buildRangeResourceList(100, 100), 200, "ports" ).size() ); }