code: public List<Protos.Resource> takeScalar(String resourceName, double 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 <= EPSILON) {
  				break;
  			}
  
  			// take from next available scalar resource that is unreserved or reserved for an applicable role
  			Protos.Resource available = i.next();
  			if (!resourceName.equals(available.getName()) || !available.hasScalar()) {
  				continue;
  			}
  			if (!UNRESERVED_ROLE.equals(available.getRole()) && !roles.contains(available.getRole())) {
  				continue;
  			}
  
  			double amountToTake = Math.min(available.getScalar().getValue(), amount);
  			Protos.Resource taken = available.toBuilder().setScalar(Protos.Value.Scalar.newBuilder().setValue(amountToTake)).build();
  			amount -= amountToTake;
  			result.add(taken);
  			if (LOG.isDebugEnabled()) {
  				LOG.debug("Taking {} from {}", amountToTake, Utils.toString(available));
  			}
  
  			// keep remaining amount (if any)
  			double remaining = available.getScalar().getValue() - taken.getScalar().getValue();
  			if (remaining > EPSILON) {
  				i.set(available.toBuilder().setScalar(Protos.Value.Scalar.newBuilder().setValue(remaining)).build());
  			}
  			else {
  				i.remove();
  			}
  		}
  
  		if (LOG.isDebugEnabled()) {
  			LOG.debug("Allocated: {}, unsatisfied: {}", Utils.toString(result), amount);
  		}
  		return result;
  	}
docs: Takes some amount of scalar resources (e.g. cpus, mem).
  
  @param amount the (approximate) amount to take from the available quantity.
  @param roles the roles to accept