[Haizea] Haizea minor additions

Mehdi Sheikhalishahi mehdi.alishahi at gmail.com
Sun Dec 19 12:19:30 CST 2010


 Hi Borja:

I think the following changes could be incorporated into the Haizea.

1. In AccountingDataCollection class, I have added a method for calculating
summation over counter.
  def __add_timeweighted_sum(self, counter):
        accum = 0
        prev_time = None
        prev_value = None
        stats = []
        for v in counter:
            time = v[0]
            lease_id = v[1]
            value = v[2]
            if prev_time != None:
                timediff = time - prev_time
                weighted_value = prev_value*timediff
                accum += weighted_value
                #avg = accum/time
            #else:
             #   avg = value
            stats.append((time, lease_id, value, accum))
            prev_time = time
            prev_value = value

        return stats

Also adding the following lines at the end of "stop" method.

       elif avgtype == AccountingDataCollection.SUM_TIMEWEIGHTED:
                self.__data.counters[counter_id] =
self.__add_timeweighted_sum(l)

        for probe in self.__probes:
            probe.finalize_accounting()

 In class AccountingProbe(object): class: defining a method like the
following to return average value.

  def _set_stat_from_avgOfcounter(self, stat_id, counter_id):
        """Convenience function that sets the value of a per-run
        stat with the last value of a counter.

        @param stat_id: Name of per-run stat
        @type stat_id: C{str}
        @param counter_id: Name of counter
        @type counter_id: C{str}
        """
        avg = self.accounting.get_last_counter_avg(counter_id)
        self.accounting.set_stat(stat_id, avg)


2.  In def __process_queue(self, nexttime): method: since Memory also is one
the main resources like CPU.

and self.slottable.is_full(nexttime, restype = constants.RES_CPU)  and
self.slottable.is_full(nexttime, restype = constants.RES_MEM):

Regards,
Mehdi
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.cs.uchicago.edu/pipermail/haizea/attachments/20101219/e38855b2/attachment.htm 


More information about the Haizea mailing list