1Reservation
2===========
3
4Introduction
5------------
6After the director set up a job on the SD it will then issue a "use" command to tell the SD what storage device it wants to use.
7The SD then checks the list of devices the director sent and tries to reserve a suitable device.
8In the end the SD either tells the director which device to use or that there is no device available for the job.
9
10There is a so-called reservation context that is passed to every function that has a swimlane in this diagram.
11This context is basically a bunch of flags that are set and cleared to change the behaviour of the rest of the code.
12
13For example CanReserveDevice() from the second diagram sets the flag low_use_drive which is then evaluated in UseDeviceCmd().
14
15Diagram Conventions
16~~~~~~~~~~~~~~~~~~~
17Each swimlane denotes a separate function.
18
19.. uml:: reservation/legend.puml
20
21UseDeviceCmd
22~~~~~~~~~~~~
23This function reads the list of storages and devices the director is willing to use for this job.
24Afterwards several different methods of finding a device to reseve are used.
25If no device could be reserved the function waits for up to a minute or until ReleaseDeviceCond() is called and then tries again.
26
27.. uml:: reservation/UseDeviceCmd.puml
28
29ReserveDevice
30~~~~~~~~~~~~~
31Here we see wether the media type matches and actually try to open the device.
32The actual reservation is delegated to ReserveDeviceForRead() or ReserveDeviceForAppend().
33While the first one is more or less trivial, the latter one is really complicated.
34
35.. uml:: reservation/ReserveDevice.puml
36