def __init__(self, dgen, server): Thread.__init__(self) self.dgen = dgen self.server = server self.isShutdown = False self.log = sysutil.getExistingLogger("myriad.dgen")
def do_HEAD(self): self.send_response(200) self.end_headers() result = urlparse(self.path, '', False) params = dict([part.split('=') for part in result[4].split('&')]) status = int(params['status']) if (status >= DGenNode.INITIALIZING and status <= DGenNode.ABORTED): # valid values for heartbeats node = self.server.nodes[int(params['id'])] node.lock.acquire() if (status == DGenNode.READY): self.server.nonReadyLock.acquire() node.lastBeat = datetime.datetime.now() if (node.status != status and node.status < status): log = sysutil.getExistingLogger("myriad.dgen") log.info("node %05d: %s -> %s", node.id, DGenNode.STATUS_STRING[node.status], DGenNode.STATUS_STRING[status]) node.status = status if (node.status == DGenNode.ACTIVE): node.progress = float(params['progress']) elif (node.status == DGenNode.READY): node.progress = 1.0 node.finished = datetime.datetime.now() self.server.nonReady -= 1 elif (node.status == DGenNode.ABORTED or node.status == DGenNode.FAILED): pass else: log = sysutil.getExistingLogger("myriad.dgen") log.error("unknown status %d for node %d", node.status, node.id) if (status == DGenNode.READY): self.server.nonReadyLock.release() node.lock.release()
def abort(self, dgen, nodesTotal): self.lock.acquire() if (self.status < DGenNode.READY): log = sysutil.getExistingLogger("myriad.dgen") log.info("aborting node #%03d" % (self.id)) os.system("ssh -f %s '%s/bin/%s-kill %d %s > /dev/null 2> /dev/null'" % (self.host, self.dgenPath, self.dgenName, self.id, dgen.datasetID)) self.status = DGenNode.FAILED self.lock.release()
def clean(self, dgen): log = sysutil.getExistingLogger("myriad.dgen") log.info("clearing host `%s`", self.name) os.system("ssh %s 'rm -Rf %s/%s'" % (self.name, self.outputBase, dgen.datasetID))