Package haizea :: Package core :: Module leases :: Class Lease
[hide private]
[frames] | no frames]

Class Lease

source code


A resource lease

This is one of the main data structures used in Haizea. A lease is "a negotiated and renegotiable agreement between a resource provider and a resource consumer, where the former agrees to make a set of resources available to the latter, based on a set of lease terms presented by the resource consumer". All the gory details on what this means can be found on the Haizea website and on the Haizea publications.

See the __init__ method for a description of the information that is contained in a lease.

Instance Methods [hide private]
 
__init__(self, lease_id, submit_time, requested_resources, start, duration, deadline, preemptible, software, state)
Constructs a lease.
source code
 
to_xml(self)
Returns an ElementTree XML representation of the lease
source code
 
to_xml_string(self)
Returns a string XML representation of the lease
source code
 
get_type(self)
Determines the type of lease
source code
 
get_state(self)
Returns the lease's state.
source code
 
set_state(self, state)
Changes the lease's state.
source code
 
print_contents(self, loglevel=5)
Prints the lease's attributes to the log.
source code
 
print_rrs(self, loglevel=5)
Prints the lease's resource reservations to the log.
source code
 
get_active_vmrrs(self, time)
Returns the active VM resource reservations at a given time
source code
 
get_scheduled_reservations(self)
Returns all scheduled reservations
source code
 
get_last_vmrr(self)
Returns the last VM reservation for this lease.
source code
 
get_endtime(self)
Returns the time at which the last VM reservation for this lease ends.
source code
 
append_vmrr(self, vmrr)
Adds a VM resource reservation to the lease.
source code
 
remove_vmrr(self, vmrr)
Removes a VM resource reservation from the lease.
source code
 
append_preparationrr(self, preparation_rr)
Adds a preparation resource reservation to the lease.
source code
 
remove_preparationrr(self, preparation_rr)
Removes a preparation resource reservation from the lease.
source code
 
clear_rrs(self)
Removes all resource reservations for this lease (both preparation and VM)
source code
 
get_waiting_time(self)
Gets the waiting time for this lease.
source code
 
get_slowdown(self, bound=10)
Determines the bounded slowdown for this lease.
source code
 
add_boot_overhead(self, t)
Adds a boot overhead to the lease.
source code
 
add_runtime_overhead(self, percent)
Adds a runtime overhead to the lease.
source code

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

Class Methods [hide private]
 
create_new(cls, submit_time, requested_resources, start, duration, deadline, preemptible, software) source code
 
create_new_from_xml_element(cls, element) source code
 
from_xml_file(cls, xml_file)
Constructs a lease from an XML file.
source code
 
from_xml_string(cls, xml_str)
Constructs a lease from an XML string.
source code
 
from_xml_element(cls, element)
Constructs a lease from an ElementTree element.
source code
Class Variables [hide private]
  STATE_NEW = 0
  STATE_PENDING = 1
  STATE_REJECTED = 2
  STATE_SCHEDULED = 3
  STATE_QUEUED = 4
  STATE_CANCELLED = 5
  STATE_PREPARING = 6
  STATE_READY = 7
  STATE_ACTIVE = 8
  STATE_SUSPENDING = 9
  STATE_SUSPENDED_PENDING = 10
  STATE_SUSPENDED_QUEUED = 11
  STATE_SUSPENDED_SCHEDULED = 12
  STATE_MIGRATING = 13
  STATE_RESUMING = 14
  STATE_RESUMED_READY = 15
  STATE_DONE = 16
  STATE_FAIL = 17
  state_str = {0: 'New', 1: 'Pending', 2: 'Rejected', 3: 'Schedu...
  BEST_EFFORT = 1
  ADVANCE_RESERVATION = 2
  IMMEDIATE = 3
  UNKNOWN = -1
  type_str = {-1: 'Unknown', 1: 'Best-effort', 2: 'AR', 3: 'Imme...
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, lease_id, submit_time, requested_resources, start, duration, deadline, preemptible, software, state)
(Constructor)

source code 
Constructs a lease.

The arguments are the fundamental attributes of a lease.
The attributes that are not specified by the arguments are
the lease ID (which is an autoincremented integer), the
lease state (a lease always starts out in state "NEW").
A lease also has several bookkeeping attributes that are
only meant to be consumed by other Haizea objects.

Arguments:
id -- Unique identifier for the lease. If None, one
will be provided.
submit_time -- The time at which the lease was submitted
requested_resources -- A dictionary (int -> Capacity) mapping
  each requested node to a capacity (i.e., the amount of
  resources requested for that node)
start -- A Timestamp object containing the requested time.
duration -- A Duration object containing the requested duration.
deadline -- A Timestamp object containing the deadline by which
  this lease must be completed.
preemptible -- A boolean indicating whether this lease can be
  preempted or not.
software -- A SoftwareEnvironment object specifying the
  software environment required by the lease.

Overrides: object.__init__

from_xml_file(cls, xml_file)
Class Method

source code 

Constructs a lease from an XML file.

See the Haizea documentation for details on the lease XML format.

Argument: xml_file -- XML file containing the lease in XML format.

from_xml_string(cls, xml_str)
Class Method

source code 

Constructs a lease from an XML string.

See the Haizea documentation for details on the lease XML format.

Argument: xml_str -- String containing the lease in XML format.

from_xml_element(cls, element)
Class Method

source code 

Constructs a lease from an ElementTree element.

See the Haizea documentation for details on the lease XML format.

Argument: element -- Element object containing a "<lease>" element.

to_xml(self)

source code 

Returns an ElementTree XML representation of the lease

See the Haizea documentation for details on the lease XML format.

to_xml_string(self)

source code 

Returns a string XML representation of the lease

See the Haizea documentation for details on the lease XML format.

get_type(self)

source code 

Determines the type of lease

Based on the lease's attributes, determines the lease's type. Can return Lease.BEST_EFFORT, Lease.ADVANCE_RESERVATION, or Lease.IMMEDIATE

set_state(self, state)

source code 

Changes the lease's state.

The state machine will throw an exception if the requested transition is illegal.

Argument: state -- The new state

print_contents(self, loglevel=5)

source code 

Prints the lease's attributes to the log.

Argument: loglevel -- The loglevel at which to print the information

print_rrs(self, loglevel=5)

source code 

Prints the lease's resource reservations to the log.

Argument: loglevel -- The loglevel at which to print the information

get_active_vmrrs(self, time)

source code 

Returns the active VM resource reservations at a given time

Argument: time -- Time to look for active reservations

get_endtime(self)

source code 

Returns the time at which the last VM reservation for this lease ends.

Note that this is not necessarily the time at which the lease will end, just the time at which the last currently scheduled VM will end.

append_vmrr(self, vmrr)

source code 

Adds a VM resource reservation to the lease.

Argument: vmrr -- The VM RR to add.

remove_vmrr(self, vmrr)

source code 

Removes a VM resource reservation from the lease.

Argument: vmrr -- The VM RR to remove.

append_preparationrr(self, preparation_rr)

source code 

Adds a preparation resource reservation to the lease.

Argument: preparation_rr -- The preparation RR to add.

remove_preparationrr(self, preparation_rr)

source code 

Removes a preparation resource reservation from the lease.

Argument: preparation_rr -- The preparation RR to remove.

get_waiting_time(self)

source code 

Gets the waiting time for this lease.

The waiting time is the difference between the submission time and the time at which the lease start. This method mostly makes sense for best-effort leases, where the starting time is determined by Haizea.

get_slowdown(self, bound=10)

source code 

Determines the bounded slowdown for this lease.

Slowdown is a normalized measure of how much time a request takes to make it through a queue (thus, like get_waiting_time, the slowdown makes sense mostly for best-effort leases). Slowdown is equal to the time the lease took to run on a loaded system (i.e., a system where it had to compete with other leases for resources) divided by the time it would take if it just had the system all to itself (i.e., starts running immediately without having to wait in a queue and without the possibility of being preempted).

"Bounded" slowdown is one where leases with very short durations are rounded up to a bound, to prevent the metric to be affected by reasonable but disproportionate waiting times (e.g., a 5-second lease with a 15 second waiting time -an arguably reasonable waiting time- has a slowdown of 4, the same as 10 hour lease having to wait 30 hours for resources).

Argument: bound -- The bound, specified in seconds. All leases with a duration less than this parameter are rounded up to the bound.

add_boot_overhead(self, t)

source code 

Adds a boot overhead to the lease.

Increments the requested duration to account for the fact that some time will be spent booting up the resources.

Argument: t -- Time to add

add_runtime_overhead(self, percent)

source code 

Adds a runtime overhead to the lease.

This method is mostly meant for simulations. Since VMs run slower than physical hardware, this increments the duration of a lease by a percent to observe the effect of having all the leases run slower on account of running on a VM.

Note: the whole "runtime overhead" problem is becoming increasingly moot as people have lost their aversion to VMs thanks to the cloud computing craze. Anecdotal evidence suggests that most people don't care that VMs will run X % slower (compared to a physical machine) because they know full well that what they're getting is a virtual machine (the same way a user of an HPC system would know that he/she's getting processors with speed X as opposed to those on some other site, with speed X*0.10)

Argument: percent -- Runtime overhead (in percent of requested duration) to add to the lease.


Class Variable Details [hide private]

state_str

Value:
{0: 'New',
 1: 'Pending',
 2: 'Rejected',
 3: 'Scheduled',
 4: 'Queued',
 5: 'Cancelled',
 6: 'Preparing',
 7: 'Ready',
...

type_str

Value:
{-1: 'Unknown', 1: 'Best-effort', 2: 'AR', 3: 'Immediate'}