Exemplo n.º 1
0
    def send_retry(self, event_message, event_id, max_n_tries,
                   retry_intvl_secs):
        """CLI external trigger interface."""

        max_n_tries = int(max_n_tries or self.__class__.MAX_N_TRIES)
        retry_intvl_secs = float(retry_intvl_secs
                                 or self.__class__.RETRY_INTVL_SECS)

        sent = False
        i_try = 0
        while not sent and i_try < max_n_tries:
            i_try += 1
            try:
                self.put(event_message, event_id)
            except Exception as exc:
                ERR.error(exc)
                OUT.info(self.__class__.MSG_SEND_FAILED % (
                    i_try,
                    max_n_tries,
                ))
                if i_try >= max_n_tries:
                    break
                OUT.info(self.__class__.MSG_SEND_RETRY %
                         (retry_intvl_secs, self.timeout))
                sleep(retry_intvl_secs)
            else:
                if i_try > 1:
                    OUT.info(self.__class__.MSG_SEND_SUCCEEDED %
                             (i_try, max_n_tries))
                sent = True
                break
        if not sent:
            sys.exit('ERROR: send failed')
        return sent
Exemplo n.º 2
0
 def load_db_broadcast_states(self, row_idx, row):
     """Load broadcast variables from runtime DB broadcast states row."""
     if row_idx == 0:
         OUT.info("LOADING broadcast states")
     point, namespace, key, value = row
     sections = []
     cur_key = key
     if "]" in cur_key:
         sections = self.REC_SECTION.findall(cur_key)
         cur_key = cur_key.rsplit(r"]", 1)[-1]
     with self.lock:
         self.settings.setdefault(point, {})
         self.settings[point].setdefault(namespace, {})
         dict_ = self.settings[point][namespace]
         for section in sections:
             dict_.setdefault(section, {})
             dict_ = dict_[section]
         dict_[cur_key] = value
     OUT.info(CHANGE_FMT.strip() % {
         "change": CHANGE_PREFIX_SET,
         "point": point,
         "namespace": namespace,
         "key": key,
         "value": value})
Exemplo n.º 3
0
    def send_retry(self, event_message, event_id,
                   max_n_tries, retry_intvl_secs):
        """CLI external trigger interface."""

        max_n_tries = int(max_n_tries or self.__class__.MAX_N_TRIES)
        retry_intvl_secs = float(
            retry_intvl_secs or self.__class__.RETRY_INTVL_SECS)

        sent = False
        i_try = 0
        while not sent and i_try < max_n_tries:
            i_try += 1
            try:
                self.put(event_message, event_id)
            except Exception as exc:
                ERR.error(exc)
                OUT.info(self.__class__.MSG_SEND_FAILED % (
                    i_try,
                    max_n_tries,
                ))
                if i_try >= max_n_tries:
                    break
                OUT.info(self.__class__.MSG_SEND_RETRY % (
                    retry_intvl_secs,
                    self.timeout
                ))
                sleep(retry_intvl_secs)
            else:
                if i_try > 1:
                    OUT.info(self.__class__.MSG_SEND_SUCCEEDED % (
                        i_try,
                        max_n_tries
                    ))
                sent = True
                break
        if not sent:
            sys.exit('ERROR: send failed')
        return sent
Exemplo n.º 4
0
 def load_xtrigger_for_restart(self, row_idx, row):
     """Load satisfied xtrigger results from suite DB."""
     if row_idx == 0:
         OUT.info("LOADING satisfied xtriggers")
     sig, results = row
     self.sat_xtrig[sig] = json.loads(results)
Exemplo n.º 5
0
 def dump(self):
     # for debugging
     log_msg = "BROKER DUMP:"
     for msg in self.all_outputs:
         log_msg += "\n+ " + self.all_outputs[msg] + '\t' + msg
     OUT.info(log_msg)