docs: public List<Protos.Resource> takeRanges(String resourceName, int amount, Set<String> roles) {
  		if (LOG.isDebugEnabled()) {
  			LOG.debug("Allocating {} {}", amount, resourceName);
  		}
  
  		List<Protos.Resource> result = new ArrayList<>(1);
  		for (ListIterator<Protos.Resource> i = resources.listIterator(); i.hasNext();) {
  			if (amount <= 0) {
  				break;
  			}
  
  			// take from next available range resource that is unreserved or reserved for an applicable role
  			Protos.Resource available = i.next();
  			if (!resourceName.equals(available.getName()) || !available.hasRanges()) {
  				continue;
  			}
  			if (!UNRESERVED_ROLE.equals(available.getRole()) && !roles.contains(available.getRole())) {
  				continue;
  			}
  
  			List<Protos.Value.Range> takenRanges = new ArrayList<>();
  			List<Protos.Value.Range> remainingRanges = new ArrayList<>(available.getRanges().getRangeList());
  			for (ListIterator<Protos.Value.Range> j = remainingRanges.listIterator(); j.hasNext();) {
  				if (amount <= 0) {
  					break;
  				}
  
  				// take from next available range (note: ranges are inclusive)
  				Protos.Value.Range availableRange = j.next();
  				long amountToTake = Math.min(availableRange.getEnd() - availableRange.getBegin() + 1, amount);
  				Protos.Value.Range takenRange = availableRange.toBuilder().setEnd(availableRange.getBegin() + amountToTake - 1).build();
  				amount -= amountToTake;
  				takenRanges.add(takenRange);
  
  				// keep remaining range (if any)
  				long remaining = availableRange.getEnd() - takenRange.getEnd();
  				if (remaining > 0) {
  					j.set(availableRange.toBuilder().setBegin(takenRange.getEnd() + 1).build());
  				}
  				else {
  					j.remove();
  				}
  			}
  			Protos.Resource taken = available.toBuilder().setRanges(Protos.Value.Ranges.newBuilder().addAllRange(takenRanges)).build();
  			if (LOG.isDebugEnabled()) {
  				LOG.debug("Taking {} from {}", Utils.toString(taken.getRanges()), Utils.toString(available));
  			}
  			result.add(taken);
  
  			// keep remaining ranges (if any)
  			if (remainingRanges.size() > 0) {
  				i.set(available.toBuilder().setRanges(Protos.Value.Ranges.newBuilder().addAllRange(remainingRanges)).build());
  			}
  			else {
  				i.remove();
  			}
  		}
  
  		if (LOG.isDebugEnabled()) {
  			LOG.debug("Allocated: {}, unsatisfied: {}", Utils.toString(result), amount);
  		}
  		return result;
  	}