Package haizea :: Package core :: Package scheduler :: Module vm_scheduler :: Class VMScheduler
[hide private]
[frames] | no frames]

Class VMScheduler

source code


The Haizea VM Scheduler

This class is responsible for taking a lease and scheduling VMs to satisfy the requirements of that lease.

Instance Methods [hide private]
 
__init__(self, slottable, resourcepool, mapper, max_in_future)
Constructor
source code
 
schedule(self, lease, nexttime, earliest)
The scheduling function
source code
 
estimate_migration_time(self, lease)
Estimates the time required to migrate a lease's VMs
source code
 
schedule_migration(self, lease, vmrr, nexttime)
Schedules migrations for a lease
source code
 
cancel_vm(self, vmrr)
Cancels a VM resource reservation
source code
 
can_suspend_at(self, lease, t)
Determines if it is possible to suspend a lease before a given time
source code
 
preempt_vm(self, vmrr, t)
Preempts a VM reservation at a given time
source code
 
get_future_reschedulable_leases(self)
Returns a list of future leases that are reschedulable.
source code
 
can_schedule_in_future(self)
Returns True if the backfilling algorithm would allow a lease to be scheduled in the future.
source code
 
get_utilization(self, time)
Computes resource utilization (currently just CPU-based)
source code
 
__schedule_exact(self, lease, nexttime, earliest)
Schedules VMs that must start at an exact time
source code
 
__schedule_asap(self, lease, nexttime, earliest, allow_in_future=None)
Schedules VMs as soon as possible
source code
 
__find_fit_at_points(self, lease, requested_resources, changepoints, duration, min_duration)
Tries to map a lease in a given list of points in time
source code
 
__compute_susprem_times(self, vmrr, time, direction, exclusion, rate, override=None)
Computes the times at which suspend/resume operations would have to start
source code
 
__schedule_shutdown(self, vmrr)
Schedules the shutdown of a VM reservation
source code
 
__schedule_suspension(self, vmrr, suspend_by)
Schedules the suspension of a VM reservation
source code
 
__schedule_resumption(self, vmrr, resume_at)
Schedules the resumption of a VM reservation
source code
 
__compute_suspend_resume_time(self, mem, rate)
Compute the time to suspend/resume a single VM
source code
 
__estimate_suspend_time(self, lease)
Estimate the time to suspend an entire lease
source code
 
__estimate_resume_time(self, lease)
Estimate the time to resume an entire lease
source code
 
__estimate_suspend_resume_time(self, lease, rate)
Estimate the time to suspend/resume an entire lease
source code
 
__estimate_shutdown_time(self, lease)
Estimate the time to shutdown an entire lease
source code
 
__compute_scheduling_threshold(self, lease)
Compute the scheduling threshold (the 'minimum duration') of a lease
source code
 
_handle_start_vm(self, l, rr)
Handles the start of a VMResourceReservation
source code
 
_handle_end_vm(self, l, rr)
Handles the end of a VMResourceReservation
source code
 
_handle_unscheduled_end_vm(self, l, vmrr)
Handles the unexpected end of a VMResourceReservation
source code
 
_handle_start_suspend(self, l, rr)
Handles the start of a SuspensionResourceReservation
source code
 
_handle_end_suspend(self, l, rr)
Handles the end of a SuspensionResourceReservation
source code
 
_handle_start_resume(self, l, rr)
Handles the start of a ResumptionResourceReservation
source code
 
_handle_end_resume(self, l, rr)
Handles the end of a ResumptionResourceReservation
source code
 
_handle_start_shutdown(self, l, rr)
Handles the start of a ShutdownResourceReservation
source code
 
_handle_end_shutdown(self, l, rr)
Handles the end of a SuspensionResourceReservation
source code
 
_handle_start_migrate(self, l, rr)
Handles the start of a MemImageMigrationResourceReservation
source code
 
_handle_end_migrate(self, l, rr)
Handles the end of a MemImageMigrationResourceReservation
source code

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

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, slottable, resourcepool, mapper, max_in_future)
(Constructor)

source code 

Constructor

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

Arguments: slottable -- Slot table resourcepool -- Resource pool where enactment commands will be sent to mapper -- Mapper

Overrides: object.__init__

schedule(self, lease, nexttime, earliest)

source code 

The scheduling function

This particular function doesn't do much except call __schedule_asap and __schedule_exact (which do all the work).

Arguments: lease -- Lease to schedule nexttime -- The next time at which the scheduler can allocate resources. earliest -- The earliest possible starting times on each physical node

estimate_migration_time(self, lease)

source code 

Estimates the time required to migrate a lease's VMs

This function conservatively estimates that all the VMs are going to be migrated to other nodes. Since all the transfers are intra-node, the bottleneck is the transfer from whatever node has the most memory to transfer.

Note that this method only estimates the time to migrate the memory state files for the VMs. Migrating the software environment (which may or may not be a disk image) is the responsibility of the preparation scheduler, which has it's own set of migration scheduling methods.

Arguments: lease -- Lease that might be migrated

schedule_migration(self, lease, vmrr, nexttime)

source code 

Schedules migrations for a lease

Arguments: lease -- Lease being migrated vmrr -- The VM reservation before which the migration will take place nexttime -- The next time at which the scheduler can allocate resources.

cancel_vm(self, vmrr)

source code 

Cancels a VM resource reservation

Arguments: vmrr -- VM RR to be cancelled

can_suspend_at(self, lease, t)

source code 

Determines if it is possible to suspend a lease before a given time

Arguments: vmrr -- VM RR to be preempted t -- Time by which the VM must be preempted

preempt_vm(self, vmrr, t)

source code 

Preempts a VM reservation at a given time

This method assumes that the lease is, in fact, preemptable, that the VMs are running at the given time, and that there is enough time to suspend the VMs before the given time (all these checks are done in the lease scheduler).

Arguments: vmrr -- VM RR to be preempted t -- Time by which the VM must be preempted

get_future_reschedulable_leases(self)

source code 

Returns a list of future leases that are reschedulable.

Currently, this list is just the best-effort leases scheduled in the future as determined by the backfilling algorithm. Advance reservation leases, by their nature, cannot be rescheduled to find a "better" starting time.

get_utilization(self, time)

source code 

Computes resource utilization (currently just CPU-based)

This utilization information shows what portion of the physical resources is used by each type of reservation (e.g., 70% are running a VM, 5% are doing suspensions, etc.)

Arguments: time -- Time at which to determine utilization

__schedule_exact(self, lease, nexttime, earliest)

source code 

Schedules VMs that must start at an exact time

This type of lease is "easy" to schedule because we know the exact start time, which means that's the only starting time we have to check. So, this method does little more than call the mapper.

Arguments: lease -- Lease to schedule nexttime -- The next time at which the scheduler can allocate resources. earliest -- The earliest possible starting times on each physical node

__schedule_asap(self, lease, nexttime, earliest, allow_in_future=None)

source code 

Schedules VMs as soon as possible

This method is a bit more complex that __schedule_exact because we need to figure out what "as soon as possible" actually is. This involves attempting several mappings, at different points in time, before we can schedule the lease.

This method will always check, at least, if the lease can be scheduled at the earliest possible moment at which the lease could be prepared (e.g., if the lease can't start until 1 hour in the future because that's the earliest possible time at which the disk images it requires can be transferred, then that's when the scheduler will check). Note, however, that this "earliest possible moment" is determined by the preparation scheduler.

Additionally, if the lease can't be scheduled at the earliest possible moment, it can also check if the lease can be scheduled in the future. This partially implements a backfilling algorithm (the maximum number of future leases is stored in the max_in_future attribute of VMScheduler), the other part being implemented in the __process_queue method of LeaseScheduler.

Note that, if the method is allowed to scheduled in the future, and assuming that the lease doesn't request more resources than the site itself, this method will always schedule the VMs succesfully (since there's always an empty spot somewhere in the future).

Arguments: lease -- Lease to schedule nexttime -- The next time at which the scheduler can allocate resources. earliest -- The earliest possible starting times on each physical node allow_in_future -- Boolean indicating whether the scheduler is allowed to schedule the VMs in the future.

__find_fit_at_points(self, lease, requested_resources, changepoints, duration, min_duration)

source code 

Tries to map a lease in a given list of points in time

This method goes through a given list of points in time and tries to find the earliest time at which that lease can be allocated resources.

Arguments: lease -- Lease to schedule requested_resources -- A dictionary of lease node -> ResourceTuple. changepoints -- The list of changepoints duration -- The amount of time requested min_duration -- The minimum amount of time that should be allocated

Returns: start -- The time at which resources have been found for the lease actualend -- The time at which the resources won't be available. Note that this is not necessarily (start + duration) since the mapper might be unable to find enough resources for the full requested duration. mapping -- A mapping of lease nodes to physical nodes preemptions -- A list of (if no mapping is found, all these values are set to None)

__compute_susprem_times(self, vmrr, time, direction, exclusion, rate, override=None)

source code 

Computes the times at which suspend/resume operations would have to start

When suspending or resuming a VM, the VM's memory is dumped to a file on disk. To correctly estimate the time required to suspend a lease with multiple VMs, Haizea makes sure that no two suspensions/resumptions happen at the same time (e.g., if eight memory files were being saved at the same time to disk, the disk's performance would be reduced in a way that is not as easy to estimate as if only one file were being saved at a time). Based on a number of parameters, this method estimates the times at which the suspend/resume commands would have to be sent to guarantee this exclusion.

Arguments: vmrr -- The VM reservation that will be suspended/resumed time -- The time at which the suspend should end or the resume should start. direction -- DIRECTION_BACKWARD: start at "time" and compute the times going backward (for suspensions) DIRECTION_FORWARD: start at time "time" and compute the times going forward. exclusion -- SUSPRES_EXCLUSION_GLOBAL (memory is saved to global filesystem) or SUSPRES_EXCLUSION_LOCAL (saved to local filesystem) rate -- The rate at which an individual VM is suspended/resumed override -- If specified, then instead of computing the time to suspend/resume VM based on its memory and the "rate" parameter, use this override value.

__schedule_shutdown(self, vmrr)

source code 

Schedules the shutdown of a VM reservation

Arguments: vmrr -- The VM reservation that will be shutdown

__schedule_suspension(self, vmrr, suspend_by)

source code 

Schedules the suspension of a VM reservation

Most of the work is done in __compute_susprem_times. See that method's documentation for more details.

Arguments: vmrr -- The VM reservation that will be suspended suspend_by -- The time by which the VMs should be suspended.

__schedule_resumption(self, vmrr, resume_at)

source code 

Schedules the resumption of a VM reservation

Most of the work is done in __compute_susprem_times. See that method's documentation for more details.

Arguments: vmrr -- The VM reservation that will be resumed resume_at -- The time at which the resumption should start

__compute_suspend_resume_time(self, mem, rate)

source code 

Compute the time to suspend/resume a single VM

Arguments: mem -- Amount of memory used by the VM rate -- The rate at which an individual VM is suspended/resumed

__estimate_suspend_time(self, lease)

source code 

Estimate the time to suspend an entire lease

Most of the work is done in __estimate_suspend_resume_time. See that method's documentation for more details.

Arguments: lease -- Lease that is going to be suspended

__estimate_resume_time(self, lease)

source code 

Estimate the time to resume an entire lease

Most of the work is done in __estimate_suspend_resume_time. See that method's documentation for more details.

Arguments: lease -- Lease that is going to be resumed

__estimate_suspend_resume_time(self, lease, rate)

source code 

Estimate the time to suspend/resume an entire lease

Note that, unlike __compute_suspend_resume_time, this estimates the time to suspend/resume an entire lease (which may involve suspending several VMs)

Arguments: lease -- Lease that is going to be suspended/resumed rate -- The rate at which an individual VM is suspended/resumed

__estimate_shutdown_time(self, lease)

source code 

Estimate the time to shutdown an entire lease

Arguments: lease -- Lease that is going to be shutdown

__compute_scheduling_threshold(self, lease)

source code 

Compute the scheduling threshold (the 'minimum duration') of a lease

To avoid thrashing, Haizea will not schedule a lease unless all overheads can be correctly scheduled (which includes image transfers, suspensions, etc.). However, this can still result in situations where a lease is prepared, and then immediately suspended because of a blocking lease in the future. The scheduling threshold is used to specify that a lease must not be scheduled unless it is guaranteed to run for a minimum amount of time (the rationale behind this is that you ideally don't want leases to be scheduled if they're not going to be active for at least as much time as was spent in overheads).

An important part of computing this value is the "scheduling threshold factor". The default value is 1, meaning that the lease will be active for at least as much time T as was spent on overheads (e.g., if preparing the lease requires 60 seconds, and we know that it will have to be suspended, requiring 30 seconds, Haizea won't schedule the lease unless it can run for at least 90 minutes). In other words, a scheduling factor of F required a minimum duration of F*T. A value of 0 could lead to thrashing, since Haizea could end up with situations where a lease starts and immediately gets suspended.

Arguments: lease -- Lease for which we want to find the scheduling threshold

_handle_start_vm(self, l, rr)

source code 

Handles the start of a VMResourceReservation

Arguments: l -- Lease the VMResourceReservation belongs to rr -- THe VMResourceReservation

_handle_end_vm(self, l, rr)

source code 

Handles the end of a VMResourceReservation

Arguments: l -- Lease the VMResourceReservation belongs to rr -- THe VMResourceReservation

_handle_unscheduled_end_vm(self, l, vmrr)

source code 

Handles the unexpected end of a VMResourceReservation

Arguments: l -- Lease the VMResourceReservation belongs to rr -- THe VMResourceReservation

_handle_start_suspend(self, l, rr)

source code 

Handles the start of a SuspensionResourceReservation

Arguments: l -- Lease the SuspensionResourceReservation belongs to rr -- The SuspensionResourceReservation

_handle_end_suspend(self, l, rr)

source code 

Handles the end of a SuspensionResourceReservation

Arguments: l -- Lease the SuspensionResourceReservation belongs to rr -- The SuspensionResourceReservation

_handle_start_resume(self, l, rr)

source code 

Handles the start of a ResumptionResourceReservation

Arguments: l -- Lease the ResumptionResourceReservation belongs to rr -- The ResumptionResourceReservation

_handle_end_resume(self, l, rr)

source code 

Handles the end of a ResumptionResourceReservation

Arguments: l -- Lease the ResumptionResourceReservation belongs to rr -- The ResumptionResourceReservation

_handle_start_shutdown(self, l, rr)

source code 

Handles the start of a ShutdownResourceReservation

Arguments: l -- Lease the SuspensionResourceReservation belongs to rr -- The SuspensionResourceReservation

_handle_end_shutdown(self, l, rr)

source code 

Handles the end of a SuspensionResourceReservation

Arguments: l -- Lease the SuspensionResourceReservation belongs to rr -- The SuspensionResourceReservation

_handle_start_migrate(self, l, rr)

source code 

Handles the start of a MemImageMigrationResourceReservation

Arguments: l -- Lease the MemImageMigrationResourceReservation belongs to rr -- The MemImageMigrationResourceReservation

_handle_end_migrate(self, l, rr)

source code 

Handles the end of a MemImageMigrationResourceReservation

Arguments: l -- Lease the MemImageMigrationResourceReservation belongs to rr -- The MemImageMigrationResourceReservation