Ejemplo n.º 1
0
 def start_collecting(self):
     # TODO: Add a check to ensure that start_collecting for a metric is called only once by the client code
     initialize()
     global event_ds
     self.next_run_time = getUTCmillis() + (self.sampling_interval_sec *
                                            1000)
     event_ds.put_and_notify(self)
Ejemplo n.º 2
0
 def set_properties(self, registered_gw, properties):
     log.info("Properties defined for resource {0}".format(
         registered_gw.resource.res_name))
     self.con.send(
         self.properties(self.con.next_id(),
                         registered_gw.resource.res_uuid,
                         registered_gw.resource.res_kind, getUTCmillis(),
                         properties))
Ejemplo n.º 3
0
 def get_next_element_when_ready(self):
     self.first_element_changed.acquire()
     try:
         isNotReady = True
         while isNotReady:
             if self._qsize() > 0:
                 first_element = heapq.nsmallest(1, self.queue)[0]
                 timeout = (first_element.get_next_run_time() - getUTCmillis()) / 1000.0
                 log.info("Waiting on acquired first_element_changed LOCK for: " + str(timeout))
                 self.first_element_changed.wait(timeout)
             else:
                 self.first_element_changed.wait()
                 first_element = heapq.nsmallest(1, self.queue)[0]
             if (first_element.get_next_run_time() - getUTCmillis()) <= 0:
                 isNotReady = False
                 first_element = self._get()
         return first_element
     finally:
         self.first_element_changed.release()
Ejemplo n.º 4
0
 def get_next_element_when_ready(self):
     self.first_element_changed.acquire()
     try:
         isNotReady = True
         while isNotReady:
             if self._qsize() > 0:
                 first_element = heapq.nsmallest(1, self.queue)[0]
                 timeout = (first_element.get_next_run_time() -
                            getUTCmillis()) / 1000.0
                 log.info(
                     "Waiting on acquired first_element_changed LOCK for: "
                     + str(timeout))
                 self.first_element_changed.wait(timeout)
             else:
                 self.first_element_changed.wait()
                 first_element = heapq.nsmallest(1, self.queue)[0]
             if (first_element.get_next_run_time() - getUTCmillis()) <= 0:
                 isNotReady = False
                 first_element = self._get()
         return first_element
     finally:
         self.first_element_changed.release()
Ejemplo n.º 5
0
 def set_properties(self, registered_gw, properties):
     log.info("Properties defined for resource {0}".format(registered_gw.resource.res_name))
     self.con.send(self.properties(self.con.next_id(), registered_gw.resource.res_uuid, registered_gw.resource.res_kind, getUTCmillis(), properties))
Ejemplo n.º 6
0
 def set_properties(self, key, value):
     log.info("Properties defined for resource {0}".format(self.res_name))
     self.con.send(
         self.properties(self.con.next_id(), self.res_uuid, self.res_kind,
                         getUTCmillis(), key, value))
Ejemplo n.º 7
0
 def write_map_values(self, v):
     self.write_full(getUTCmillis(), v)
Ejemplo n.º 8
0
 def start_collecting(self):
     # TODO: Add a check to ensure that start_collecting for a metric is called only once by the client code
     initialize()
     global event_ds
     self.next_run_time = getUTCmillis() + (self.sampling_interval_sec * 1000)
     event_ds.put_and_notify(self)
Ejemplo n.º 9
0
 def write_map_values(self, v):
     self.write_full(getUTCmillis(), v)