Beispiel #1
0
 def _execute(self):
     LOG.debug('Event polling thread started')
     try:
         self.listener = self.raw_listener or self._create_listener()
         while not self.stopped:
             self._handle_next_messages()
             wait_for_event(self.event, self.interval_sec)
     except InterruptedException:
         # Shutting down normally
         pass
     except Exception:
         LOG.exception('Aborting due to an error')
     finally:
         LOG.debug('HA event listener thread exited')
Beispiel #2
0
 def _execute(self, motr: Motr):
     try:
         LOG.debug('rconfc starter thread has started')
         self.consul.ensure_motr_all_started(self.event)
         while (not self.stopped) and (not motr.spiel_ready):
             started = self.consul.ensure_ioservices_running()
             if not all(started):
                 wait_for_event(self.event, 5)
                 continue
             result: int = motr.start_rconfc()
             if result == 0:
                 motr.spiel_ready = True
     except InterruptedException:
         # No op. sleep() has interrupted before the timeout exceeded:
         # the application is shutting down.
         # There are no resources that we need to dispose specially.
         pass
     except Exception:
         LOG.exception('Aborting due to an error')
     finally:
         LOG.debug('rconfc starter thread exited')
Beispiel #3
0
    def _execute(self, motr: Motr):
        try:
            LOG.info('byte-count updater thread has started')
            while not self.stopped:
                if not self.consul.am_i_rc():
                    wait_for_event(self.event, self.interval_sec)
                    continue
                if not motr.is_spiel_ready():
                    wait_for_event(self.event, self.interval_sec)
                    continue
                processes: List[Tuple[Fid, ObjHealth]] = \
                    self.consul.get_proc_fids_with_status(['ios'])
                if not processes:
                    continue
                try:
                    for ios, status in processes:
                        if status == ObjHealth.OK:
                            byte_count: ByteCountStats = \
                                motr.get_proc_bytecount(ios)
                            LOG.debug('Received bytecount: %s', byte_count)
                            if not byte_count:
                                continue
                            self.consul.update_pver_bc(byte_count)

                    pver_items = self._get_pver_with_pver_status(motr)
                    if not pver_items:
                        continue
                    pver_bc = self._calculate_bc_per_pver(pver_items)
                    self.consul.update_bc_for_dg_category(pver_bc, pver_items)
                except HAConsistencyException:
                    LOG.exception('Failed to update Consul KV '
                                  'due to an intermittent error. The '
                                  'error is swallowed since new attempts '
                                  'will be made timely')
                except BytecountException as e:
                    LOG.exception(
                        'Failed due to %s. Aborting this iteration.'
                        ' Waiting for next attempt.', e.message)
                wait_for_event(self.event, self.interval_sec)
        except InterruptedException:
            # No op. _sleep() has interrupted before the timeout exceeded:
            # the application is shutting down.
            # There are no resources that we need to dispose specially.
            pass
        except Exception:
            LOG.exception('Aborting due to an error')
        finally:
            LOG.exception('byte-count updater thread exited')
Beispiel #4
0
 def _execute(self, motr: Motr):
     try:
         ffi = motr._ffi
         LOG.info('filesystem stats updater thread has started')
         ffi.adopt_motr_thread()
         while not self.stopped:
             if not self._am_i_rc():
                 wait_for_event(self.event, self.interval_sec)
                 continue
             if not motr.is_spiel_ready():
                 wait_for_event(self.event, self.interval_sec)
                 continue
             stats = motr.get_filesystem_stats()
             if not stats:
                 continue
             LOG.debug('FS stats are as follows: %s', stats)
             now_time = datetime.datetime.now()
             data = FsStatsWithTime(stats=stats,
                                    timestamp=now_time.timestamp(),
                                    date=now_time.isoformat())
             try:
                 self.consul.update_fs_stats(data)
             except HAConsistencyException:
                 LOG.debug('Failed to update Consul KV '
                           'due to an intermittent error. The '
                           'error is swallowed since new attempts '
                           'will be made timely')
             wait_for_event(self.event, self.interval_sec)
     except InterruptedException:
         # No op. _sleep() has interrupted before the timeout exceeded:
         # the application is shutting down.
         # There are no resources that we need to dispose specially.
         pass
     except Exception:
         LOG.exception('Aborting due to an error')
     finally:
         LOG.debug('Releasing motr-related resources for this thread')
         ffi.shun_motr_thread()
         LOG.debug('filesystem stats updater thread exited')