Package haizea :: Package core :: Module accounting :: Class AccountingDataCollection
[hide private]
[frames] | no frames]

Class AccountingDataCollection

source code


Accounting data collection

This class provides a framework to collect data while Haizea is running. It is designed so that the code that collects the data is placed in separate classes (the "probes"; a probe must be a child class of AccountingProbe). Probes can collect three types of data:

Accounting probes can collect three types of data:

The the AccountingDataCollection class takes care of calling these probes at three points when Haizea is running: (1) at every time step, (2) when a lease is requested, and (3) when a lease is done.

Instance Methods [hide private]
 
__init__(self, datafile, attrs)
Constructor
source code
 
add_probe(self, probe)
Adds a new accounting probe
source code
 
create_counter(self, counter_id, avgtype)
Adds a new counter.
source code
 
create_lease_stat(self, stat_id)
Adds a new per-lease type of data ("stat").
source code
 
create_stat(self, stat_id)
Adds a new per-run type of data ("stat").
source code
 
incr_counter(self, counter_id, lease_id=None)
Increment a counter
source code
 
decr_counter(self, counter_id, lease_id=None)
Decrement a counter
source code
 
append_to_counter(self, counter_id, value, lease_id=None)
Append a value to a counter
source code
 
get_last_counter_time(self, counter_id)
Get the time of the last entry in a counter
source code
 
get_last_counter_value(self, counter_id)
Get the value of the last entry in a counter
source code
 
set_lease_stat(self, stat_id, lease_id, value)
Set the value of a per-lease datum
source code
 
set_stat(self, stat_id, value)
Set the value of a per-run datum
source code
 
start(self, time)
Start collecting data
source code
 
stop(self)
Stop collecting data
source code
 
save_to_disk(self, leases)
Save accounting data to disk.
source code
 
at_timestep(self, lease_scheduler)
Invoke the probes' at_timestep handlers.
source code
 
at_lease_request(self, lease)
Invoke the probes' at_lease_request handlers.
source code
 
at_lease_done(self, lease)
Invoke the probes' at_lease_done handlers.
source code
 
__normalize_times(self, counter) source code
 
__add_no_average(self, counter) source code
 
__add_timeweighted_average(self, counter) source code
 
__add_average(self, counter) source code

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

Class Variables [hide private]
  AVERAGE_NONE = 0
  AVERAGE_NORMAL = 1
  AVERAGE_TIMEWEIGHTED = 2
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, datafile, attrs)
(Constructor)

source code 

Constructor

Parameters:
  • datafile (str) - Path to file where accounting data will be saved
  • attrs (dict) - Run attributes
Overrides: object.__init__

add_probe(self, probe)

source code 

Adds a new accounting probe

Parameters:

create_counter(self, counter_id, avgtype)

source code 

Adds a new counter.

Counters can store not just the value of the counter throughout time, but also a running average. This is specified with the avgtype parameter, which can be equal to:

  • AccountingDataCollection.AVERAGE_NONE: Don't compute an average
  • AccountingDataCollection.AVERAGE_NORMAL: For each entry, compute the average of all the values including and preceding that entry.
  • AccountingDataCollection.AVERAGE_TIMEWEIGHTED: For each entry, compute the average of all the values including and preceding that entry, weighing the average according to the time between each entry.
Parameters:
  • counter_id (str) - Name of the counter
  • avgtype (int) - Type of average to compute

create_lease_stat(self, stat_id)

source code 

Adds a new per-lease type of data ("stat").

Parameters:
  • stat_id (str) - Name of the stat

create_stat(self, stat_id)

source code 

Adds a new per-run type of data ("stat").

Parameters:
  • stat_id (str) - Name of the stat

incr_counter(self, counter_id, lease_id=None)

source code 

Increment a counter

Parameters:
  • counter_id (str) - Name of the counter
  • lease_id (int) - Optionally, the lease that caused this increment.

decr_counter(self, counter_id, lease_id=None)

source code 

Decrement a counter

Parameters:
  • counter_id (str) - Name of the counter
  • lease_id (int) - Optionally, the ID of the lease that caused this increment.

append_to_counter(self, counter_id, value, lease_id=None)

source code 

Append a value to a counter

Parameters:
  • counter_id (str) - Name of the counter
  • value (int or float) - Value to append
  • lease_id (int) - Optionally, the ID of the lease that caused this increment.

set_lease_stat(self, stat_id, lease_id, value)

source code 

Set the value of a per-lease datum

Parameters:
  • stat_id (str) - Name of the stat
  • lease_id (int) - The ID of the lease the value is associated to
  • value (int or float) - Value of the stat

set_stat(self, stat_id, value)

source code 

Set the value of a per-run datum

Parameters:
  • stat_id (str) - Name of the stat
  • value (int or float) - Value of the stat

start(self, time)

source code 

Start collecting data

Parameters:
  • time (mx.DateTime) - Time at which data started being collected

save_to_disk(self, leases)

source code 

Save accounting data to disk.

Parameters:
  • leases (List of Leases) - List of leases to be saved to disk

at_timestep(self, lease_scheduler)

source code 

Invoke the probes' at_timestep handlers.

Parameters:

at_lease_request(self, lease)

source code 

Invoke the probes' at_lease_request handlers.

Parameters:
  • lease (Lease) - Requested lease

at_lease_done(self, lease)

source code 

Invoke the probes' at_lease_done handlers.

Parameters:
  • lease (Lease) - Lease that was completed