T - public interface RequestAllocator<T extends Request<T>>
We assume there are a number of Requestors each one sending a finite stream of Requests.
Each such request requires a certain amount of resources, and there is a finite pool of resources available.
Additionally, some requests have higher priority than others. Our objective is to select a set of requests to satisfy
such that their total resource usage is within the bounds of the finite resource pool, and such that, as much as
possible, a request will not be selected if there was a request with a higher priority that was not selected.
We model the problem as follows:
Request. Requestor is a stream (Iterator) of Requests. We use a stream as opposed to a set or
list because the Requestor is encouraged to lazily materialize requests only as needed by the request allocator. ResourcePool is a vector of doubles representing the available resources along a sequence of dimensions
(e.g. bytes, files to copy). ResourceRequirement is a vector of doubles representing the resources need by a particular request.
We assume that resource requirements are combined exclusively through vector addition. ResourceEstimator is a class that, given a Request, computes its ResourceRequirement. Comparator which, given two Requests, determines which is higher priority
(smaller is higher priority, following the PriorityQueue model).| Modifier and Type | Interface and Description |
|---|---|
static interface |
RequestAllocator.Factory |
| Modifier and Type | Method and Description |
|---|---|
AllocatedRequestsIterator<T> |
allocateRequests(Iterator<? extends Requestor<T>> requestors,
ResourcePool resourcePool)
Compute the subset of accepted
Requests from the input Requestors which fit withing
the ResourcePool. |
AllocatedRequestsIterator<T> allocateRequests(Iterator<? extends Requestor<T>> requestors, ResourcePool resourcePool)
Requests from the input Requestors which fit withing
the ResourcePool.