Package haizea :: Package core :: Package scheduler :: Module lease_scheduler :: Class LeaseScheduler
[hide private]
[frames] | no frames]

Class LeaseScheduler

source code


The Haizea Lease Scheduler

This is the main scheduling class in Haizea. It handles lease scheduling which, in turn, involves VM scheduling, preparation scheduling (such as transferring a VM image), and numerous bookkeeping operations. All these operations are handled by other classes, so this class acts mostly as an orchestrator that coordinates all the different operations involved in scheduling a lease.

Instance Methods [hide private]
 
__init__(self, vm_scheduler, preparation_scheduler, slottable, accounting)
Constructor
source code
 
request_lease(self, lease)
Requests a leases.
source code
 
schedule(self, nexttime)
The main scheduling function
source code
 
process_starting_reservations(self, nowtime)
Processes starting reservations
source code
 
process_ending_reservations(self, nowtime)
Processes ending reservations
source code
 
get_lease_by_id(self, lease_id)
Gets a lease with the given ID
source code
 
cancel_lease(self, lease)
Cancels a lease.
source code
 
fail_lease(self, lease, exc=None)
Transitions a lease to a failed state, and does any necessary cleaning up
source code
 
notify_event(self, lease, event)
Notifies an event that affects a lease.
source code
 
reevaluate_schedule(self, nexttime)
Reevaluates the schedule.
source code
 
is_queue_empty(self)
Return True is the queue is empty, False otherwise
source code
 
exists_scheduled_leases(self)
Return True if there are any leases scheduled in the future
source code
 
__process_queue(self, nexttime)
Traverses the queue in search of leases that can be scheduled.
source code
 
__schedule_lease(self, lease, nexttime)
Schedules a lease.
source code
 
__preempt_lease(self, lease, preemption_time)
Preempts a lease.
source code
 
__enqueue(self, lease)
Queues a best-effort lease request
source code
 
__enqueue_in_order(self, lease)
Queues a lease in order (currently, time of submission)
source code
 
_handle_end_rr(self, rr)
Performs actions that have to be done each time a reservation ends.
source code
 
_handle_end_lease(self, l)
Performs actions that have to be done each time a lease ends.
source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Instance Variables [hide private]
VMScheduler vm_scheduler
VM Scheduler
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, vm_scheduler, preparation_scheduler, slottable, accounting)
(Constructor)

source code 

Constructor

The constructor does little more than create the lease scheduler's attributes. However, it does expect (in the arguments) a fully-constructed VMScheduler, PreparationScheduler, SlotTable, and PolicyManager (these are constructed in the Manager's constructor).

Arguments: vm_scheduler -- VM scheduler preparation_scheduler -- Preparation scheduler slottable -- Slottable accounting -- AccountingDataCollection object

Overrides: object.__init__

request_lease(self, lease)

source code 

Requests a leases. This is the entry point of leases into the scheduler.

Request a lease. The decision on whether to accept or reject a lease is deferred to the policy manager (through its admission control policy).

If the policy determines the lease can be accepted, it is marked as "Pending". This still doesn't guarantee that the lease will be scheduled (e.g., an AR lease could still be rejected if the scheduler determines there are no resources for it; but that is a *scheduling* decision, not a admission control policy decision). The ultimate fate of the lease is determined the next time the scheduling function is called.

If the policy determines the lease cannot be accepted, it is marked as rejected.

Arguments: lease -- Lease object. Its state must be STATE_NEW.

schedule(self, nexttime)

source code 

The main scheduling function

The scheduling function looks at all pending requests and schedules them. Note that most of the actual scheduling code is contained in the __schedule_lease method and in the VMScheduler and PreparationScheduler classes.

Arguments: nexttime -- The next time at which the scheduler can allocate resources.

process_starting_reservations(self, nowtime)

source code 

Processes starting reservations

This method checks the slottable to see if there are any reservations that are starting at "nowtime". If so, the appropriate handler is called.

Arguments: nowtime -- Time at which to check for starting reservations.

process_ending_reservations(self, nowtime)

source code 

Processes ending reservations

This method checks the slottable to see if there are any reservations that are ending at "nowtime". If so, the appropriate handler is called.

Arguments: nowtime -- Time at which to check for starting/ending reservations.

get_lease_by_id(self, lease_id)

source code 

Gets a lease with the given ID

This method is useful for UIs (like the CLI) that operate on the lease ID. If no lease with a given ID is found, None is returned.

Arguments: lease_id -- The ID of the lease

cancel_lease(self, lease)

source code 

Cancels a lease.

Arguments: lease -- Lease to cancel

fail_lease(self, lease, exc=None)

source code 

Transitions a lease to a failed state, and does any necessary cleaning up

Arguments: lease -- Lease to fail exc -- The exception that made the lease fail

notify_event(self, lease, event)

source code 

Notifies an event that affects a lease.

This is the entry point of asynchronous events into the scheduler. Currently, the only supported event is the premature end of a VM (i.e., before its scheduled end). Other events will emerge when we integrate Haizea with OpenNebula 1.4, since that version will support sending asynchronous events to Haizea.

Arguments: lease -- Lease the event refers to event -- Event type

reevaluate_schedule(self, nexttime)

source code 

Reevaluates the schedule.

This method can be called whenever resources are freed up unexpectedly (e.g., a lease than ends earlier than expected)) to check if any leases scheduled in the future could be rescheduled to start earlier on the freed up resources.

Currently, this method only checks if best-effort leases scheduled in the future (using a backfilling algorithm) can be rescheduled

Arguments: nexttime -- The next time at which the scheduler can allocate resources.

__process_queue(self, nexttime)

source code 

Traverses the queue in search of leases that can be scheduled.

This method processes the queue in order, but takes into account that it may be possible to schedule leases in the future (using a backfilling algorithm)

Arguments: nexttime -- The next time at which the scheduler can allocate resources.

__schedule_lease(self, lease, nexttime)

source code 

Schedules a lease.

This method orchestrates the preparation and VM scheduler to schedule a lease.

Arguments: lease -- Lease to schedule. nexttime -- The next time at which the scheduler can allocate resources.

__preempt_lease(self, lease, preemption_time)

source code 

Preempts a lease.

This method preempts a lease such that any resources allocated to that lease after a given time are freed up. This may require scheduling the lease to suspend before that time, or cancelling the lease altogether.

Arguments: lease -- Lease to schedule. preemption_time -- Time at which lease must be preempted

__enqueue(self, lease)

source code 

Queues a best-effort lease request

Arguments: lease -- Lease to be queued

__enqueue_in_order(self, lease)

source code 

Queues a lease in order (currently, time of submission)

Arguments: lease -- Lease to be queued

_handle_end_rr(self, rr)

source code 

Performs actions that have to be done each time a reservation ends.

Arguments: rr -- Reservation that ended

_handle_end_lease(self, l)

source code 

Performs actions that have to be done each time a lease ends.

Arguments: lease -- Lease that has ended