Package haizea :: Package pluggable :: Package policies :: Module preemption
[hide private]
[frames] | no frames]

Source Code for Module haizea.pluggable.policies.preemption

 1  # -------------------------------------------------------------------------- # 
 2  # Copyright 2006-2009, University of Chicago                                 # 
 3  # Copyright 2008-2009, Distributed Systems Architecture Group, Universidad   # 
 4  # Complutense de Madrid (dsa-research.org)                                   # 
 5  #                                                                            # 
 6  # Licensed under the Apache License, Version 2.0 (the "License"); you may    # 
 7  # not use this file except in compliance with the License. You may obtain    # 
 8  # a copy of the License at                                                   # 
 9  #                                                                            # 
10  # http://www.apache.org/licenses/LICENSE-2.0                                 # 
11  #                                                                            # 
12  # Unless required by applicable law or agreed to in writing, software        # 
13  # distributed under the License is distributed on an "AS IS" BASIS,          # 
14  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   # 
15  # See the License for the specific language governing permissions and        # 
16  # limitations under the License.                                             # 
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   
28 -class NoPreemptionPolicy(PreemptabilityPolicy):
29 """Simple preemption policy: preemption is never allowed. 30 """
31 - def __init__(self, slottable):
32 """Constructor 33 34 Argument 35 slottable -- A fully constructed SlotTable 36 """ 37 PreemptabilityPolicy.__init__(self, slottable)
38
39 - def get_lease_preemptability_score(self, preemptor, preemptee, time):
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
53 -class ARPreemptsEverythingPolicy(PreemptabilityPolicy):
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 """
59 - def __init__(self, slottable):
60 """Constructor 61 62 Argument 63 slottable -- A fully constructed SlotTable 64 """ 65 PreemptabilityPolicy.__init__(self, slottable)
66
67 - def get_lease_preemptability_score(self, preemptor, preemptee, time):
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