[haizea-commit] r614 - in branches/TP2.0/src/haizea: core core/scheduler policies

haizea-commit at mailman.cs.uchicago.edu haizea-commit at mailman.cs.uchicago.edu
Wed Jul 22 10:03:21 CDT 2009


Author: borja
Date: 2009-07-22 10:03:19 -0500 (Wed, 22 Jul 2009)
New Revision: 614

Modified:
   branches/TP2.0/src/haizea/core/manager.py
   branches/TP2.0/src/haizea/core/scheduler/mapper.py
   branches/TP2.0/src/haizea/core/scheduler/policy.py
   branches/TP2.0/src/haizea/core/scheduler/vm_scheduler.py
   branches/TP2.0/src/haizea/policies/__init__.py
   branches/TP2.0/src/haizea/policies/admission.py
   branches/TP2.0/src/haizea/policies/host_selection.py
   branches/TP2.0/src/haizea/policies/preemption.py
Log:
Cleaned up and documented policy manager and pluggable policies

Modified: branches/TP2.0/src/haizea/core/manager.py
===================================================================
--- branches/TP2.0/src/haizea/core/manager.py	2009-07-22 12:37:36 UTC (rev 613)
+++ branches/TP2.0/src/haizea/core/manager.py	2009-07-22 15:03:19 UTC (rev 614)
@@ -171,7 +171,7 @@
         host_selection = import_class(host_selection)
         host_selection = host_selection(slottable)
 
-        self.policy = PolicyManager(slottable, admission, preemption, host_selection)
+        self.policy = PolicyManager(admission, preemption, host_selection)
 
         # Preparation scheduler
         if preparation_type == constants.PREPARATION_UNMANAGED:

Modified: branches/TP2.0/src/haizea/core/scheduler/mapper.py
===================================================================
--- branches/TP2.0/src/haizea/core/scheduler/mapper.py	2009-07-22 12:37:36 UTC (rev 613)
+++ branches/TP2.0/src/haizea/core/scheduler/mapper.py	2009-07-22 15:03:19 UTC (rev 614)
@@ -146,14 +146,12 @@
         
         # Get an ordered list of lease nodes
         vnodes = self.__sort_vnodes(requested_resources)
-        vnodes.reverse()
         
         # Get the leases that intersect with the requested interval.
         leases = aw.get_leases_until(end)
         # Ask the policy engine to sort the leases based on their
         # preemptability
         leases = self.policy.sort_leases(lease, leases, start)
-        leases.reverse()
         
         preemptable_leases = leases
         preempting = []
@@ -262,7 +260,7 @@
             norm_res[k] = norm_capacity
              
         vnodes = norm_res.items()
-        vnodes.sort(key=operator.itemgetter(1))
+        vnodes.sort(key=operator.itemgetter(1), reverse = True)
         vnodes = [k for k,v in vnodes]
         return vnodes      
                     

Modified: branches/TP2.0/src/haizea/core/scheduler/policy.py
===================================================================
--- branches/TP2.0/src/haizea/core/scheduler/policy.py	2009-07-22 12:37:36 UTC (rev 613)
+++ branches/TP2.0/src/haizea/core/scheduler/policy.py	2009-07-22 15:03:19 UTC (rev 614)
@@ -16,59 +16,230 @@
 # limitations under the License.                                             #
 # -------------------------------------------------------------------------- #
 
+"""Haizea uses a policy manager that allows certain scheduling decisions to
+be delegated to pluggable policies. This is done so scheduling policies
+can be (1) modified without having to modify core components of Haizea, and
+(2) implemented by writing a single Python class that implements a given
+interface for pluggable policies.
+
+Three policies are currently pluggable: lease preemptability ("Can lease X
+preempt lease Y?"), host selection ("I want to deploy a VM, what host should
+I select for this?") and lease admission ("Should I accept/reject this lease
+request?"). Haizea provides several simple policy modules in the
+haizea.policies package. The policy to use is selected in the configuration
+file. See the Haizea Documentation for more details on how this is done.
+
+This module provides Haizea's policy manager and the base classes for
+pluggable policies.  
+"""
+
+
 from haizea.common.utils import abstract
 from haizea.core.leases import Lease
 from mx.DateTime import DateTimeDelta
 import operator
 
 class PolicyManager(object):
-    """Base class for policy module
+    """The Policy Manager
     
+    This class manages the policy modules and provides methods to
+    access these modules.
+    
     """    
-    def __init__(self, slottable, admission, preemption, host_selection):
-        # Dinamically load policy modules
+    def __init__(self, admission, preemption, host_selection):
+        """Constructor
+        
+        Expects fully-constructed policies (these are currently
+        loaded in the Manager class, based on the config file).
+        
+        Arguments:
+        admission -- A child of LeaseAdmissionPolicy
+        preemption -- A child of PreemptabilityPolicy
+        host_selection -- A child of HostSelectionPolicy
+        
+        """
         self.admission = admission
         self.preemption = preemption
         self.host_selection = host_selection
     
     def sort_leases(self, preemptor, preemptees, time):
+        """Sorts a list of leases by their preemptability
+        
+        Takes a list of leases (the "preemptees"), determines their preemptability
+        by another lease (the "preemptor"), and returns a list with the
+        leases sorted by decreasing preemptability score (most preemptable
+        leases first)
+        
+        See documentation of PreemptabilityPolicy.get_lease_preemptability_score
+        for more details on the preemptability score.
+        
+        Argument
+        preemptor -- Preemptor lease
+        preemptees -- List of preemptee leases
+        time -- Time at which preemption would take place        
+        """              
         leases_score = [(preemptee, self.get_lease_preemptability_score(preemptor,preemptee, time)) for preemptee in preemptees]
         leases_score = [(preemptee,score) for preemptee,score in leases_score if score != -1]
         leases_score.sort(key=operator.itemgetter(1), reverse=True)
         return [preemptee for preemptee,score in leases_score]
 
-    def sort_hosts(self, nodes, start, lease):
-        nodes_score = [(node, self.get_host_score(node, start, lease)) for node in nodes]
+
+    def sort_hosts(self, nodes, time, lease):
+        """Sorts a list of hosts by their score
+        
+        Takes a list of hosts, determines their score, and sorts them in
+        order of decreasing score (most desireable hosts first)
+        
+        See documentation of HostSelectionPolicy.get_host_score for more details.
+        
+        Arguments:
+        nodes -- List of physical node (the integer identifier used in the slot table)
+        time -- Time at which the lease might be scheduled
+        lease -- Lease that is being scheduled.
+        """        
+        nodes_score = [(node, self.get_host_score(node, time, lease)) for node in nodes]
         nodes_score.sort(key=operator.itemgetter(1), reverse=True)
         return [node for node,score in nodes_score]
     
+    
     def accept_lease(self, lease):
+        """Lease admission function
+        
+        Returns True if the lease can be accepted, False if it should be rejected.
+        
+        Argument
+        lease -- Lease request
+        """        
         return self.admission.accept_lease(lease)
     
+    
     def get_lease_preemptability_score(self, preemptor, preemptee, time):
+        """Computes the lease preemptability score
+        
+        See documentation of PreemptabilityPolicy.get_lease_preemptability_score
+        for more details.
+        
+        Arguments:
+        preemptor -- Preemptor lease
+        preemptee -- Preemptee lease
+        time -- Time at which preemption would take place
+        """                
         return self.preemption.get_lease_preemptability_score(preemptor, preemptee, time)
 
+
     def get_host_score(self, node, time, lease):
+        """Computes the score of a host
+        
+        See documentation of HostSelectionPolicy.get_host_score for more details.
+        
+        Arguments:
+        node -- Physical node (the integer identifier used in the slot table)
+        time -- Time at which the lease might be scheduled
+        lease -- Lease that is being scheduled.
+        """               
         return self.host_selection.get_host_score(node, time, lease)
     
+    
 
-class LeaseAdmissionPolicyBase(object):
+class LeaseAdmissionPolicy(object):
+    """Lease Admission policy
+    
+    This is the parent class of lease admission policies. A lease admission
+    policy determines whether a given lease request should be accepted or not
+    by Haizea. Note that this is distinct from whether the lease can be
+    scheduled or not (although this could certainly be a part of the
+    policy); the policy simply decides whether the lease can be considered for
+    scheduling or not. For example, a user could submit an AR lease that must
+    start in 5 hours, but the policy could dictate that all ARs must be notified
+    at least 24 hours in advance (and the lease would be rejected, regardless of
+    whether there was resources available for it in 5 hours). Similarly, an
+    AR lease could be requested 48 hours in advance, be accepted by the lease
+    admission policy, but then be rejected by the scheduler if there are no
+    resources available.
+    
+    """       
     def __init__(self, slottable):
+        """Constructor
+        
+        Argument
+        slottable -- A fully constructed SlotTable
+        """
         self.slottable = slottable
     
+    
     def accept_lease(self, lease):
+        """Lease admission function
+        
+        Returns True if the lease can be accepted, False if it should be rejected.
+        
+        Argument
+        lease -- Lease request
+        """        
         abstract()
     
     
-class PreemptabilityPolicyBase(object):
+    
+class PreemptabilityPolicy(object):
+    """Lease Preemptability policy
+    
+    This is the parent class of lease preemptability policies. This type of
+    policy is used to determine whether a lease can be preempted by another
+    lease at a given time. However, the policy doesn't return True or False but,
+    rather, a "preemptability score" (see get_lease_preemptability_score for
+    more details)
+    
+    """           
     def __init__(self, slottable):
+        """Constructor
+        
+        Argument
+        slottable -- A fully constructed SlotTable
+        """        
         self.slottable = slottable
     
+    
     def get_lease_preemptability_score(self, preemptor, preemptee, time):
+        """Computes the lease preemptability score
+        
+        Given a lease that needs to preempt resources (the "preemptor"),
+        another lease (the "preemptee") that may be preempted by it, and a time,
+        this method determines the preemptability score of the preemptee or
+        "how preemptable is the preemptee by the preemptor at the given time".
+        The score can be the following:
+        
+        -1 : Cannot be preempted under any circumstances
+        0.0 <= x <= 1.0: Lease can be preempted. The higher the score,
+        the "more preemptable" it is (this is a relative measure; the score
+        should be used to determine which of several leases is a better
+        candidate for preemption)
+        
+        Arguments:
+        preemptor -- Preemptor lease
+        preemptee -- Preemptee lease
+        time -- Time at which preemption would take place
+        """             
         abstract()    
 
-    def _get_aged_score(self, lease, time):
-        horizon = time - DateTimeDelta(31)
+
+    def _get_aging_factor(self, lease, time):
+        """Returns an aging factor for the preemptability score
+        
+        This is a convenience function that can be used to "age" a
+        preemptability score (allowing leases that have been submitted
+        long ago to avoid preemption). The method returns a factor
+        between 0 and 1 that can be multiplied by the score, reducing
+        the score based on the lease's "age".
+        
+        Currently, this method uses a hard-coded horizon of 31 days
+        (any lease older than 7 days cannot be preempted, and leases
+        less than 7 days are assigned a factor proportional to their age)
+        
+        Arguments:
+        lease -- Lease that is going to be preempted
+        time -- Time at which preemption would take place        
+        """            
+        # TODO: Make horizon configurable
+        horizon = time - DateTimeDelta(7)
         if lease.submit_time <= horizon:
             return -1
         else:
@@ -76,9 +247,44 @@
             horizon_seconds = DateTimeDelta(31).seconds
             return float(horizon_seconds - seconds) / horizon_seconds        
         
-class HostSelectionPolicyBase(object):
+        
+class HostSelectionPolicy(object):
+    """Host Selection policy
+    
+    This is the parent class of host selection policies. When mapping VMs
+    to physical hosts, this policy determines what hosts are more desireable.
+    For example, an energy-saving policy might value hosts that already have
+    VMs running (to leave as many empty machines as possible, which could then
+    be turned off), whereas another policy might prefer empty hosts to make
+    sure that VMs are spread out across nodes.
+    
+    To do this, the policy will assign a score to each host. See the documentation
+    for get_host_score for more details.
+        
+    """             
     def __init__(self, slottable):
+        """Constructor
+        
+        Argument
+        slottable -- A fully constructed SlotTable
+        """        
         self.slottable = slottable
     
+    
     def get_host_score(self, node, time, lease):
+        """Computes the score of a host
+        
+        Given a physical host, a time, and a lease we would like to
+        schedule at that time, this method returns a score indicating
+        how desireable that host is for that lease at that time.
+        The score can be between 0.0 and 1.0. The higher the score,
+        the "more desireable" the physical host is (this is a relative measure; 
+        the score should be used to determine which of several physical hosts
+        is more desireable for this lease).
+        
+        Arguments:
+        node -- Physical node (the integer identifier used in the slot table)
+        time -- Time at which the lease might be scheduled
+        lease -- Lease that is being scheduled.
+        """               
         abstract()    

Modified: branches/TP2.0/src/haizea/core/scheduler/vm_scheduler.py
===================================================================
--- branches/TP2.0/src/haizea/core/scheduler/vm_scheduler.py	2009-07-22 12:37:36 UTC (rev 613)
+++ branches/TP2.0/src/haizea/core/scheduler/vm_scheduler.py	2009-07-22 15:03:19 UTC (rev 614)
@@ -29,7 +29,6 @@
 from haizea.core.leases import Lease, Capacity
 from haizea.core.scheduler.slottable import ResourceReservation, ResourceTuple
 from haizea.core.scheduler import ReservationEventHandler, RescheduleLeaseException, NormalEndLeaseException, EnactmentError, NotSchedulableException, InconsistentScheduleError, InconsistentLeaseStateError, MigrationResourceReservation
-from haizea.core.scheduler.mapper import GreedyMapper
 from operator import attrgetter, itemgetter
 from mx.DateTime import TimeDelta
 

Modified: branches/TP2.0/src/haizea/policies/__init__.py
===================================================================
--- branches/TP2.0/src/haizea/policies/__init__.py	2009-07-22 12:37:36 UTC (rev 613)
+++ branches/TP2.0/src/haizea/policies/__init__.py	2009-07-22 15:03:19 UTC (rev 614)
@@ -1,3 +1,27 @@
+# -------------------------------------------------------------------------- #
+# Copyright 2006-2008, University of Chicago                                 #
+# Copyright 2008, Distributed Systems Architecture Group, Universidad        #
+# Complutense de Madrid (dsa-research.org)                                   #
+#                                                                            #
+# Licensed under the Apache License, Version 2.0 (the "License"); you may    #
+# not use this file except in compliance with the License. You may obtain    #
+# a copy of the License at                                                   #
+#                                                                            #
+# http://www.apache.org/licenses/LICENSE-2.0                                 #
+#                                                                            #
+# Unless required by applicable law or agreed to in writing, software        #
+# distributed under the License is distributed on an "AS IS" BASIS,          #
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   #
+# See the License for the specific language governing permissions and        #
+# limitations under the License.                                             #
+# -------------------------------------------------------------------------- #
+
+"""This module includes sub-modules with pluggable policies for Haizea.
+"""
+
+# The following dictionaries provide a shorthand notation to refer to
+# the policy classes (this shorthand is used in the configuration file,
+# so the fully-qualified class name doesn't have to be written)
 admission_class_mappings = {"accept-all": "haizea.policies.admission.AcceptAllPolicy",
                             "no-ARs": "haizea.policies.admission.NoARsPolicy"}
 
@@ -4,5 +28,5 @@
 preemption_class_mappings = {"no-preemption": "haizea.policies.preemption.NoPreemptionPolicy",
                              "ar-preempts-everything": "haizea.policies.preemption.ARPreemptsEverythingPolicy"}
 
-host_class_mappings = {"sequential": "haizea.policies.host_selection.SequentialPolicy",
+host_class_mappings = {"no-policy": "haizea.policies.host_selection.NoPolicy",
                        "greedy": "haizea.policies.host_selection.GreedyPolicy"}
\ No newline at end of file

Modified: branches/TP2.0/src/haizea/policies/admission.py
===================================================================
--- branches/TP2.0/src/haizea/policies/admission.py	2009-07-22 12:37:36 UTC (rev 613)
+++ branches/TP2.0/src/haizea/policies/admission.py	2009-07-22 15:03:19 UTC (rev 614)
@@ -1,16 +1,72 @@
-from haizea.core.scheduler.policy import LeaseAdmissionPolicyBase
+# -------------------------------------------------------------------------- #
+# Copyright 2006-2008, University of Chicago                                 #
+# Copyright 2008, Distributed Systems Architecture Group, Universidad        #
+# Complutense de Madrid (dsa-research.org)                                   #
+#                                                                            #
+# Licensed under the Apache License, Version 2.0 (the "License"); you may    #
+# not use this file except in compliance with the License. You may obtain    #
+# a copy of the License at                                                   #
+#                                                                            #
+# http://www.apache.org/licenses/LICENSE-2.0                                 #
+#                                                                            #
+# Unless required by applicable law or agreed to in writing, software        #
+# distributed under the License is distributed on an "AS IS" BASIS,          #
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   #
+# See the License for the specific language governing permissions and        #
+# limitations under the License.                                             #
+# -------------------------------------------------------------------------- #
+
+"""This module provides pluggable lease admission policies. See the documentation
+for haizea.core.schedule.policy.LeaseAdmissionPolicy for more details on
+lease admission policies.
+"""
+
+
+from haizea.core.scheduler.policy import LeaseAdmissionPolicy
 from haizea.core.leases import Lease
 
-class AcceptAllPolicy(LeaseAdmissionPolicyBase):
+class AcceptAllPolicy(LeaseAdmissionPolicy):
+    """A simple admission policy: all lease requests are accepted.
+    """
     def __init__(self, slottable):
-        LeaseAdmissionPolicyBase.__init__(self, slottable)
+        """Constructor
         
+        Argument
+        slottable -- A fully constructed SlotTable
+        """  
+        LeaseAdmissionPolicy.__init__(self, slottable)
+        
     def accept_lease(self, lease):
+        """Lease admission function
+        
+        See class documentation for details on what policy is implemented here.
+        Returns True if the lease can be accepted, False if it should be rejected.
+        
+        Argument
+        lease -- Lease request
+        """           
         return True  
     
-class NoARsPolicy(LeaseAdmissionPolicyBase):
+class NoARsPolicy(LeaseAdmissionPolicy):
+    """A simple admission policy: all lease requests, except AR requests,
+    are accepted.
+    """
+    
     def __init__(self, slottable):
-        LeaseAdmissionPolicyBase.__init__(self, slottable)
+        """Constructor
         
+        Argument
+        slottable -- A fully constructed SlotTable
+        """  
+        LeaseAdmissionPolicy.__init__(self, slottable)
+        
     def accept_lease(self, lease):
+        """Lease admission function
+        
+        See class documentation for details on what policy is implemented here.
+        Returns True if the lease can be accepted, False if it should be rejected.
+        
+        Argument
+        lease -- Lease request
+        """        
         return lease.get_type() != Lease.ADVANCE_RESERVATION
\ No newline at end of file

Modified: branches/TP2.0/src/haizea/policies/host_selection.py
===================================================================
--- branches/TP2.0/src/haizea/policies/host_selection.py	2009-07-22 12:37:36 UTC (rev 613)
+++ branches/TP2.0/src/haizea/policies/host_selection.py	2009-07-22 15:03:19 UTC (rev 614)
@@ -1,18 +1,84 @@
-from haizea.core.scheduler.policy import HostSelectionPolicyBase
+# -------------------------------------------------------------------------- #
+# Copyright 2006-2008, University of Chicago                                 #
+# Copyright 2008, Distributed Systems Architecture Group, Universidad        #
+# Complutense de Madrid (dsa-research.org)                                   #
+#                                                                            #
+# Licensed under the Apache License, Version 2.0 (the "License"); you may    #
+# not use this file except in compliance with the License. You may obtain    #
+# a copy of the License at                                                   #
+#                                                                            #
+# http://www.apache.org/licenses/LICENSE-2.0                                 #
+#                                                                            #
+# Unless required by applicable law or agreed to in writing, software        #
+# distributed under the License is distributed on an "AS IS" BASIS,          #
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   #
+# See the License for the specific language governing permissions and        #
+# limitations under the License.                                             #
+# -------------------------------------------------------------------------- #
 
-class SequentialPolicy(HostSelectionPolicyBase):
+"""This module provides pluggable host selection policies. See the documentation
+for haizea.core.schedule.policy.HostSelectionPolicy for more details on
+host selection policies.
+"""
+
+from haizea.core.scheduler.policy import HostSelectionPolicy
+
+class NoPolicy(HostSelectionPolicy):
+    """A simple host selection policy: all hosts have the same score
+    """
     def __init__(self, slottable):
-        HostSelectionPolicyBase.__init__(self, slottable)
+        """Constructor
+        
+        Argument
+        slottable -- A fully constructed SlotTable
+        """  
+        HostSelectionPolicy.__init__(self, slottable)
     
+    
     def get_host_score(self, node, time, lease):
+        """Computes the score of a host
+        
+        See class documentation for details on what policy is implemented here.
+        See documentation of HostSelectionPolicy.get_host_score for more details
+        on this method.
+        
+        Arguments:
+        node -- Physical node (the integer identifier used in the slot table)
+        time -- Time at which the lease might be scheduled
+        lease -- Lease that is being scheduled.
+        """             
         return 1 
     
+    
 
-class GreedyPolicy(HostSelectionPolicyBase):
+class GreedyPolicy(HostSelectionPolicy):
+    """A greedy host selection policy.
+    
+    This policy scores hosts such that hosts with fewer leases already
+    scheduled on them, with the highest capacity, and with fewest leases
+    scheduled in the future are scored highest.
+    
+    """
     def __init__(self, slottable):
-        HostSelectionPolicyBase.__init__(self, slottable)
+        """Constructor
+        
+        Argument
+        slottable -- A fully constructed SlotTable
+        """  
+        HostSelectionPolicy.__init__(self, slottable)
     
     def get_host_score(self, node, time, lease):
+        """Computes the score of a host
+        
+        See class documentation for details on what policy is implemented here.
+        See documentation of HostSelectionPolicy.get_host_score for more details
+        on this method.
+        
+        Arguments:
+        node -- Physical node (the integer identifier used in the slot table)
+        time -- Time at which the lease might be scheduled
+        lease -- Lease that is being scheduled.
+        """                     
         aw = self.slottable.get_availability_window(time)
 
         leases_in_node_horizon = 4

Modified: branches/TP2.0/src/haizea/policies/preemption.py
===================================================================
--- branches/TP2.0/src/haizea/policies/preemption.py	2009-07-22 12:37:36 UTC (rev 613)
+++ branches/TP2.0/src/haizea/policies/preemption.py	2009-07-22 15:03:19 UTC (rev 614)
@@ -1,20 +1,82 @@
+# -------------------------------------------------------------------------- #
+# Copyright 2006-2008, University of Chicago                                 #
+# Copyright 2008, Distributed Systems Architecture Group, Universidad        #
+# Complutense de Madrid (dsa-research.org)                                   #
+#                                                                            #
+# Licensed under the Apache License, Version 2.0 (the "License"); you may    #
+# not use this file except in compliance with the License. You may obtain    #
+# a copy of the License at                                                   #
+#                                                                            #
+# http://www.apache.org/licenses/LICENSE-2.0                                 #
+#                                                                            #
+# Unless required by applicable law or agreed to in writing, software        #
+# distributed under the License is distributed on an "AS IS" BASIS,          #
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   #
+# See the License for the specific language governing permissions and        #
+# limitations under the License.                                             #
+# -------------------------------------------------------------------------- #
+
+"""This module provides pluggable lease preemption policies. See the documentation
+for haizea.core.schedule.policy.PreemptabilityPolicy for more details on
+lease preemption policies.
+"""
+
 from haizea.core.leases import Lease
-from haizea.core.scheduler.policy import PreemptabilityPolicyBase
+from haizea.core.scheduler.policy import PreemptabilityPolicy
 
 
-class NoPreemptionPolicy(PreemptabilityPolicyBase):
+class NoPreemptionPolicy(PreemptabilityPolicy):
+    """Simple preemption policy: preemption is never allowed.
+    """
     def __init__(self, slottable):
-        PreemptabilityPolicyBase.__init__(self, slottable)
+        """Constructor
+        
+        Argument
+        slottable -- A fully constructed SlotTable
+        """        
+        PreemptabilityPolicy.__init__(self, slottable)
     
     def get_lease_preemptability_score(self, preemptor, preemptee, time):
+        """Computes the lease preemptability score
+        
+        See class documentation for details on what policy is implemented here.
+        See documentation of PreemptabilityPolicy.get_lease_preemptability_score
+        for more details on this function.
+        
+        Arguments:
+        preemptor -- Preemptor lease
+        preemptee -- Preemptee lease
+        time -- Time at which preemption would take place
+        """                    
         return -1
 
-class ARPreemptsEverythingPolicy(PreemptabilityPolicyBase):
+class ARPreemptsEverythingPolicy(PreemptabilityPolicy):
+    """A simple preemption policy where AR leases can always preempt
+    every other type of lease. Given two possible leases to preempt,
+    the "youngest" one is preferred (i.e., the one that was most recently
+    submitted).
+    """    
     def __init__(self, slottable):
-        PreemptabilityPolicyBase.__init__(self, slottable)
+        """Constructor
+        
+        Argument
+        slottable -- A fully constructed SlotTable
+        """        
+        PreemptabilityPolicy.__init__(self, slottable)
     
     def get_lease_preemptability_score(self, preemptor, preemptee, time):
+        """Computes the lease preemptability score
+        
+        See class documentation for details on what policy is implemented here.
+        See documentation of PreemptabilityPolicy.get_lease_preemptability_score
+        for more details on this function.
+        
+        Arguments:
+        preemptor -- Preemptor lease
+        preemptee -- Preemptee lease
+        time -- Time at which preemption would take place
+        """        
         if preemptor.get_type() == Lease.ADVANCE_RESERVATION and preemptee.get_type() == Lease.BEST_EFFORT:
-            return self._get_aged_score(preemptee, time)
+            return self._get_aging_factor(preemptee, time)
         else:
             return -1
\ No newline at end of file



More information about the Haizea-commit mailing list