1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 """This module provides pluggable lease preemption policies. See the documentation
20 for haizea.core.schedule.policy.PreemptabilityPolicy for more details on
21 lease preemption policies.
22 """
23
24 from haizea.core.leases import Lease
25 from haizea.core.scheduler.policy import PreemptabilityPolicy
26
27
29 """Simple preemption policy: preemption is never allowed.
30 """
38
40 """Computes the lease preemptability score
41
42 See class documentation for details on what policy is implemented here.
43 See documentation of PreemptabilityPolicy.get_lease_preemptability_score
44 for more details on this function.
45
46 Arguments:
47 preemptor -- Preemptor lease
48 preemptee -- Preemptee lease
49 time -- Time at which preemption would take place
50 """
51 return -1
52
54 """A simple preemption policy where AR leases can always preempt
55 every other type of lease. Given two possible leases to preempt,
56 the "youngest" one is preferred (i.e., the one that was most recently
57 submitted).
58 """
66
68 """Computes the lease preemptability score
69
70 See class documentation for details on what policy is implemented here.
71 See documentation of PreemptabilityPolicy.get_lease_preemptability_score
72 for more details on this function.
73
74 Arguments:
75 preemptor -- Preemptor lease
76 preemptee -- Preemptee lease
77 time -- Time at which preemption would take place
78 """
79 if preemptor.get_type() == Lease.ADVANCE_RESERVATION and preemptee.get_type() == Lease.BEST_EFFORT:
80 return self._get_aging_factor(preemptee, time)
81 else:
82 return -1
83