Package haizea :: Package core :: Package scheduler
[hide private]
[frames] | no frames]

Source Code for Package haizea.core.scheduler

  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  from haizea.core.scheduler.slottable import ResourceReservation 
 20  import haizea.common.constants as constants 
 21  import sys 
 22   
23 -class SchedException(Exception):
24 """The base class for scheduling exceptions""" 25 pass
26
27 -class NotSchedulableException(SchedException):
28 """A simple exception class used when a lease cannot be scheduled 29 30 This exception must be raised when a lease cannot be scheduled 31 """ 32
33 - def __init__(self, reason):
34 self.reason = reason
35
36 -class CancelLeaseException(SchedException):
37 pass
38
39 -class NormalEndLeaseException(SchedException):
40 pass
41
42 -class RescheduleLeaseException(SchedException):
43 pass
44 45
46 -class SchedulingError(Exception):
47 """The base class for scheduling errors""" 48 pass
49
50 -class InconsistentScheduleError(SchedulingError):
51 pass
52
53 -class InconsistentLeaseStateError(SchedulingError):
54 - def __init__(self, lease, doing):
55 self.lease = lease 56 self.doing = doing 57 58 self.message = "Lease %i is in an inconsistent state (%i) when %s" % (lease.id, lease.get_state(), doing)
59
60 -class EnactmentError(SchedulingError):
61 pass
62
63 -class UnrecoverableError(SchedulingError):
64 - def __init__(self, exc):
65 self.exc = exc 66 self.exc_info = sys.exc_info()
67
68 - def get_traceback(self):
69 return self.exc_info[2]
70 71
72 -class ReservationEventHandler(object):
73 """A wrapper for reservation event handlers. 74 75 Reservations (in the slot table) can start and they can end. This class 76 provides a convenient wrapper around the event handlers for these two 77 events (see Scheduler.__register_handler for details on event handlers) 78 """
79 - def __init__(self, sched, on_start, on_end):
80 self.sched = sched 81 self.on_start_method = on_start 82 self.on_end_method = on_end
83
84 - def on_start(self, lease, rr):
85 self.on_start_method(self.sched, lease, rr)
86
87 - def on_end(self, lease, rr):
88 self.on_end_method(self.sched, lease, rr)
89
90 -class EarliestStartingTime(object):
91 EARLIEST_NOPREPARATION = 0 92 EARLIEST_MIGRATION = 1 93
94 - def __init__(self, time, type):
95 self.time = time 96 self.type = type
97
98 -class MigrationResourceReservation(ResourceReservation):
99 - def __init__(self, lease, start, end, res, vmrr, transfers):
100 ResourceReservation.__init__(self, lease, start, end, res) 101 self.vmrr = vmrr 102 self.transfers = transfers
103