Exemple #1
0
 def cb_assigned(self, uow):
     params = uow.get_params()
     stage = uow.get_stage()
     prime = params['p']
     self.logger_.plog("assigned worker %s %s(%s)\n" % (str(uow.get_worker().worker()),
                                                        str(stage),
                                                        str(prime)))
     metrics = self.metrics_['assigned']
     metrics[uow.get_worker().worker()] = (prime, stage)
Exemple #2
0
    def cb_done(self, uow):
        """Handle the output of the final filter."""
        self.track_metrics(uow, dropped=False)

        params = uow.get_params()
        prime = params['p']
        M = params['M']
        
        self.logger_.plog("%s finished: %s\n" % (str(uow.get_worker().worker()), str(params['M'])))
        
        self.mersenne_list_.append(M)
        msg = "Welcome to your 2**%d-1 M: %d" % (prime, M)
        self.logger_.flog(msg)
        self.logger_.flog(str(uow.get_access_time()))
        print(msg)
        M_abbrv = str(M)
        M_digits = len(M_abbrv)
        max_digits_before_abbreviation = 12

        if M > 10**max_digits_before_abbreviation:
            M_abbrv = M_abbrv[0:4] + '...' + M_abbrv[-4:-1]

        msg_fmt = '| {0:2d} | {1:5d} | {2:10} | {3:8d} | {4:14} | {5:14} |'
        msg = msg_fmt.format(len(self.mersenne_list_),
                             prime,
                             M_abbrv,
                             M_digits,
                             str(int(uow.get_access_time() -
                                     uow.get_created_time())),
                             time.strftime("%D %T",
                                           time.gmtime(uow.get_access_time())))
        self.logger_.slog(msg)
Exemple #3
0
    def track_metrics(self, uow, dropped=True):
        self.metrics_['work_seen'] += 1            
        worker_name = str(uow.get_worker().worker())
        worker_metrics = self.metrics_['workers'].get(worker_name, {}) 
        if dropped:
            worker_metrics['work_seen'] = 1+ worker_metrics.get('work_seen', 0)
            worker_metrics['work_dropped']= 1+ worker_metrics.get('work_dropped', 0)
            self.metrics_['work_dropped'] += 1
        else:
            worker_metrics['work_seen'] = 1+ worker_metrics.get('work_seen', 0)
            worker_metrics['work_done']= 1+ worker_metrics.get('work_done', 0)
            self.metrics_['work_done'] += 1

        self.metrics_['workers'][worker_name] = worker_metrics

        # if last-known job for worker was this task, clear out assignment.
        current = self.metrics_['assigned'].get(worker_name, (0, None))
        if current[0] == uow.get_params()['p']:
            self.metrics_['assigned'] = None
Exemple #4
0
 def cb_dropped(self, uow):
     self.track_metrics(uow)
     params = uow.get_params()
     prime = params['p']
     self.logger_.plog("worker %s dropped prime %s\n" % (str(uow.get_worker().worker()), str(prime)))