Add atomic operations for manipulating multiple reservations
This originally turned up in the context of elastic slices, though after further discussion it turns out it's not strictly necessary for those. There are some other applications (e.g., eager creation of pools of reservations to be subdivided in future, maybe for independent projects all working on papers for the same deadline) so it's worth remembering the idea even though we no longer have immediate demand.
GreedyReserve( pid, t0, t1, nodetype )
Establishes a reservation to project pid
starting at time t0
and ending at t1
, for as many nodes of type nodetype
as possible.
Maybe this doesn't need to be a standalone function at all... just add an option to the existing Reservation::Create() allowing the count to be "as many as possible".
Reservation->Split( newpid, count )
Carves off count
nodes from an existing reservation into a new one belonging to newpid
. If that leaves the original reservation empty, it is destroyed. Obviously this can be called as many times as necessary to split a reservation into as many chunks as desired.
There's probably justification for a counterpart where reservations are split by time instead of by node count, too.
Neither of these functions should ever fail except in case of invalid input (e.g., trying to split 10 nodes out of a 5 node reservation). In particular, attempting a valid split will never lose all or part of a reservation, even if concurrent operations muck with other reservations.