def record_master_scheduler_tick(self): """Records the master's last scheduler tick timestamp. """ try: worker = Worker.localhost() if worker.on_master(): worker.record_last_master_scheduler_tick() except Exception as err: self.logger.error("Unable to record last master scheduler tick.") self.logger.error("Details: %s", err)
def put_heartbeat_data(self, restart=False): """Puts heartbeat data via the xmlrpc api. If the scheduler daemon was restarted identified by RESTART, populate the complete worker data, else populate minimal worker data, if it is too long since the last heartbeat data was updated. """ try: localhost = Worker.localhost() if localhost.too_long_since_last_heartbeat(): self.populate_minimal_worker_data() elif restart: self.populate_complete_worker_data() else: return except ValueError: self.logger.debug("Worker %s unavailable" % utils.get_fqdn()) self.populate_complete_worker_data() MAX_RETRIES = 3 data = simplejson.dumps(self.worker) for retry in range(MAX_RETRIES): try: server = _get_scheduler_rpc() server.worker_heartbeat(data) self.logger.debug("Heartbeat updated") return except (CommandError, URLError, IOError) as err: self.logger.debug("Error message: %s" % str(err)) except xmlrpclib.Fault as err: time.sleep(1) self.logger.debug("Retrying heartbeat update (%d) ..." % retry) except xmlrpclib.ProtocolError as err: self.logger.error("Protocol error occured") self.logger.error("URL: %s" % err.url) self.logger.error("HTTP/HTTPS headers: %s" % err.headers) self.logger.error("Error code: %d" % err.errcode) self.logger.error("Error message: %s" % err.errmsg) raise err self.logger.error("Unable to update the Heartbeat, trying later")
def put_heartbeat_data(self, restart=False): """Puts heartbeat data via the xmlrpc api. If the scheduler daemon was restarted identified by RESTART, populate the complete worker data, else populate minimal worker data, if it is too long since the last heartbeat data was updated. """ try: localhost = Worker.localhost() if restart: self.populate_complete_worker_data() elif localhost.too_long_since_last_heartbeat(): self.populate_minimal_worker_data() else: return except ValueError: self.logger.debug("Worker %s unavailable", utils.get_fqdn()) self.populate_complete_worker_data() MAX_RETRIES = 3 data = simplejson.dumps(self.worker) for retry in range(MAX_RETRIES): try: server = _get_scheduler_rpc() server.worker_heartbeat(data) self.logger.debug("Heartbeat updated") return except (CommandError, URLError, IOError) as err: self.logger.debug("Error message: %s", str(err)) except xmlrpclib.Fault as err: time.sleep(1) self.logger.debug("Retrying heartbeat update (%d) ...", retry) except xmlrpclib.ProtocolError as err: self.logger.error("Protocol error occured") self.logger.error("URL: %s", err.url) self.logger.error("HTTP/HTTPS headers: %s", err.headers) self.logger.error("Error code: %d", err.errcode) self.logger.error("Error message: %s", err.errmsg) raise err self.logger.error("Unable to update the Heartbeat, trying later")