Package haizea :: Package pluggable :: Package accounting :: Module leases
[hide private]
[frames] | no frames]

Source Code for Module haizea.pluggable.accounting.leases

  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  """Accounting probes that collect data from leases""" 
 20   
 21  from haizea.core.accounting import AccountingProbe, AccountingDataCollection 
 22  from haizea.core.leases import Lease 
 23                   
24 -class ARProbe(AccountingProbe):
25 """ 26 Collects information from Advance Reservation leases 27 28 * Counters 29 30 - "Accepted AR": Number of accepted AR leases 31 - "Rejected AR": Number of rejected AR leases 32 33 * Per-run data 34 35 - "Total accepted AR": Final number of accepted AR leases 36 - "Total rejected AR": Final number of rejected AR leases 37 38 """ 39 COUNTER_ACCEPTED="Accepted AR" 40 COUNTER_REJECTED="Rejected AR" 41 STAT_ACCEPTED="Total accepted AR" 42 STAT_REJECTED="Total rejected AR" 43
44 - def __init__(self, accounting):
51
52 - def finalize_accounting(self):
56
57 - def at_lease_request(self, lease):
58 """See AccountingProbe.at_lease_request""" 59 if lease.get_type() == Lease.ADVANCE_RESERVATION: 60 if lease.get_state() == Lease.STATE_PENDING: 61 self.accounting.incr_counter(ARProbe.COUNTER_ACCEPTED, lease.id) 62 elif lease.get_state() == Lease.STATE_REJECTED: 63 self.accounting.incr_counter(ARProbe.COUNTER_REJECTED, lease.id)
64
65 - def at_lease_done(self, lease):
66 """See AccountingProbe.at_lease_done""" 67 if lease.get_type() == Lease.ADVANCE_RESERVATION: 68 if lease.get_state() == Lease.STATE_REJECTED: 69 self.accounting.incr_counter(ARProbe.COUNTER_REJECTED, lease.id)
70 71
72 -class IMProbe(AccountingProbe):
73 """ 74 Collects information from immediate leases 75 76 * Counters 77 78 - "Accepted Immediate": Number of accepted Immediate leases 79 - "Rejected Immediate": Number of rejected Immediate leases 80 81 * Per-run data 82 83 - "Total accepted Immediate": Final number of accepted Immediate leases 84 - "Total rejected Immediate": Final number of rejected Immediate leases 85 86 """ 87 COUNTER_ACCEPTED="Accepted Immediate" 88 COUNTER_REJECTED="Rejected Immediate" 89 STAT_ACCEPTED="Total accepted Immediate" 90 STAT_REJECTED="Total rejected Immediate" 91
92 - def __init__(self, accounting):
99
100 - def finalize_accounting(self):
104
105 - def at_lease_request(self, lease):
106 """See AccountingProbe.at_lease_request""" 107 if lease.get_type() == Lease.IMMEDIATE: 108 if lease.get_state() == Lease.STATE_PENDING: 109 self.accounting.incr_counter(IMProbe.COUNTER_ACCEPTED, lease.id) 110 elif lease.get_state() == Lease.STATE_REJECTED: 111 self.accounting.incr_counter(IMProbe.COUNTER_REJECTED, lease.id)
112
113 - def at_lease_done(self, lease):
114 """See AccountingProbe.at_lease_done""" 115 if lease.get_type() == Lease.IMMEDIATE: 116 if lease.get_state() == Lease.STATE_REJECTED: 117 self.accounting.incr_counter(IMProbe.COUNTER_REJECTED, lease.id)
118 119
120 -class BEProbe(AccountingProbe):
121 """ 122 Collects information from best-effort leases 123 124 * Counters 125 126 - "Best-effort completed": Number of best-effort leases completed 127 throughout the run 128 - "Queue size": Size of the queue throughout the run 129 130 * Per-lease data 131 132 - "Waiting time": Time (in seconds) the lease waited in the queue 133 before resources were allocated to it. 134 - "Slowdown": Slowdown of the lease (time required to run the lease 135 to completion divided by the time it would have required on a 136 dedicated system) 137 138 * Per-run data 139 140 - "Total best-effort completed": Final number of completed best-effort leases 141 - "all-best-effort": The time (in seconds) when the last best-effort 142 lease was completed. 143 144 """ 145 146 COUNTER_BESTEFFORTCOMPLETED="Best-effort completed" 147 COUNTER_QUEUESIZE="Queue size" 148 LEASE_STAT_WAITINGTIME="Waiting time" 149 LEASE_STAT_SLOWDOWN="Slowdown" 150 STAT_BESTEFFORTCOMPLETED="Total best-effort completed" 151 STAT_ALLBESTEFFORT="all-best-effort" 152 153
154 - def __init__(self, accounting):
163
164 - def finalize_accounting(self):
169
170 - def at_timestep(self, lease_scheduler):
171 """See AccountingProbe.at_timestep""" 172 queue_len = lease_scheduler.queue.length() 173 self.accounting.append_to_counter(BEProbe.COUNTER_QUEUESIZE, queue_len)
174
175 - def at_lease_done(self, lease):
176 """See AccountingProbe.at_lease_done""" 177 if lease.get_type() == Lease.BEST_EFFORT: 178 wait = lease.get_waiting_time().seconds 179 self.accounting.set_lease_stat(BEProbe.LEASE_STAT_WAITINGTIME, lease.id, wait) 180 self.accounting.set_lease_stat(BEProbe.LEASE_STAT_SLOWDOWN, lease.id, lease.get_slowdown()) 181 self.accounting.incr_counter(BEProbe.COUNTER_BESTEFFORTCOMPLETED, lease.id)
182