def process_todo( self, senderid, data ): coredata = self.cores[ senderid ] work = self.hw.grab_work_item() if work != None: msg = remap_utils.pack_msg( "%s._work.%s"%(senderid, self.nodeid), work ) logger.info( "A core was given some work to do: %s"%( senderid )) self.lpub.send( msg )
def refresh_nodes(self, priority): self.nodes = {} self.priority = priority self.refreshed = time.time() msg = remap_utils.pack_msg("local.showhands.%s" % (self.jobid), {"priority": self.priority}) self.forward_to_broker(msg)
def process_todo(self, senderid, data): coredata = self.cores[senderid] work = self.hw.grab_work_item() if work != None: msg = remap_utils.pack_msg("%s._work.%s" % (senderid, self.nodeid), work) logger.info("A core was given some work to do: %s" % (senderid)) self.lpub.send(msg)
def process_hello( self, data ): msgid = remap_utils.safe_get(data, "msgid") pid = remap_utils.safe_get(data, "pid") priority = remap_utils.safe_get( data, "priority" ) coreid = remap_utils.core_id( self.nodeid, pid ) self.cores[ coreid ] = {"coreid":coreid,"ts_last_seen":time.time(),"progress":-1,"pid":pid,"priority":priority} msg = remap_utils.pack_msg( "%s._hey.%s"%(coreid, self.nodeid), {"msgid":msgid,"coreid":coreid} ) logger.info( "A core registered %s"%( coreid )) self.lpub.send( msg )
def handle_showhands(self, recipientid, senderid, data): avail, interruptable = self.hw.available_cpus( remap_utils.safe_get(data, "priority"), self.cores) if avail > 0 or interruptable > 0: logger.info("Volunteering with %d cores, %d interruptable" % (avail, interruptable)) msg = remap_utils.pack_msg("tracker.raisehand.%s" % (self.nodeid), { "free": avail, "interruptable": interruptable }) self.forward_to_broker(msg)
def handle_jobstart( self, recipientid, senderid, data ): avail, interruptable = self.hw.available_cpus( remap_utils.safe_get( data, "priority" ), self.cores ) numcores = len(remap_utils.safe_get( data, "cores" )) if (avail + interruptable) >= numcores: logger.info("Starting job with %d cores"%( numcores )) if not self.hw.start_job( self.remaproot, senderid, numcores, data ): logger.error("Error starting job") else: # Something changed in the meantime. Reject logger.info( "Initiator requested %d cores, %d can be committed. Rejecting"%( numcores, avail + interruptable )) msg = remap_utils.pack_msg( "%s.rejectjob.%s"%( senderid, self.nodeid ), {} ) self.forward_to_broker( msg ) self.coresChanged = True
def handle_jobstart(self, recipientid, senderid, data): avail, interruptable = self.hw.available_cpus( remap_utils.safe_get(data, "priority"), self.cores) numcores = len(remap_utils.safe_get(data, "cores")) if (avail + interruptable) >= numcores: logger.info("Starting job with %d cores" % (numcores)) if not self.hw.start_job(self.remaproot, senderid, numcores, data): logger.error("Error starting job") else: # Something changed in the meantime. Reject logger.info( "Initiator requested %d cores, %d can be committed. Rejecting" % (numcores, avail + interruptable)) msg = remap_utils.pack_msg( "%s.rejectjob.%s" % (senderid, self.nodeid), {}) self.forward_to_broker(msg) self.coresChanged = True
def process_hello(self, data): msgid = remap_utils.safe_get(data, "msgid") pid = remap_utils.safe_get(data, "pid") priority = remap_utils.safe_get(data, "priority") coreid = remap_utils.core_id(self.nodeid, pid) self.cores[coreid] = { "coreid": coreid, "ts_last_seen": time.time(), "progress": -1, "pid": pid, "priority": priority } msg = remap_utils.pack_msg("%s._hey.%s" % (coreid, self.nodeid), { "msgid": msgid, "coreid": coreid }) logger.info("A core registered %s" % (coreid)) self.lpub.send(msg)
def outbound_work(self, jobs): nodes = {} for key, job in jobs.items(): nodeid = job["nodeid"] if nodeid in nodes: nodes[nodeid]["cores"].append(job["jobdata"]) else: tasks = {} tasklist = [] job["ts_start"] = time.time() job["ts_finish"] = time.time() + 7 tasklist.append(job["jobdata"]) tasks["cores"] = tasklist tasks["priority"] = self.priority nodes[nodeid] = tasks for nodeid, tasks in nodes.items(): msg = remap_utils.pack_msg("%s.jobstart.%s" % (nodeid, self.jobid), tasks) self.forward_to_broker(msg)
def handle_showhands( self, recipientid, senderid, data ): avail, interruptable = self.hw.available_cpus( remap_utils.safe_get( data, "priority" ), self.cores ) if avail > 0 or interruptable > 0: logger.info( "Volunteering with %d cores, %d interruptable"%( avail, interruptable )) msg = remap_utils.pack_msg( "tracker.raisehand.%s"%( self.nodeid ), {"free":avail,"interruptable":interruptable} ) self.forward_to_broker( msg )
def req_registration( self ): msg = remap_utils.pack_msg( "node._plzreg.%s"%(self.nodeid), {} ) self.lpub.send( msg )
def forward( self, prefix, data ): msg = remap_utils.pack_msg( prefix, data ) self.pub.send( msg )
def req_registration(self): msg = remap_utils.pack_msg("node._plzreg.%s" % (self.nodeid), {}) self.lpub.send(msg)