示例#1
0
 def _sendPing(self, first, last):
     """Do the actual sending"""
     changed=self.cmdsChanged
     self.cmdsChanged=False
     with self.runCondVar:
         # first write the items to xml
         cmds=self.worker._getWorkloads()
         co=StringIO()
         co.write('<heartbeat worker_id="%s">'%self.workerID)
         for item in cmds:
             if item.running:
                 item.hbi.writeXML(co)
                 for subwl in item.joinedTo:
                     subwl.hbi.writeXML(co)
         co.write("</heartbeat>")
     clnt=WorkerMessage()
     resp=clnt.workerHeartbeatRequest(self.workerID, self.workerDir, 
                                      first, last, changed, 
                                      co.getvalue())
     presp=ProcessedResponse(resp)
     if last:
         timestr=" last"
     else:
         timestr="" 
     if first:
         timestr+=" first"
     if changed:
         timestr+=" update"
     log.debug("Sent%s heartbeat signal. Result was %s"%
               (timestr, presp.getStatus()))
     if presp.getStatus() != "OK":
         # if the response was not OK, the upstream server thinks we're 
         # dead and has signaled that to the originating server. We 
         # should just die now.
         faulty=presp.getData()
         log.info("Error from heartbeat request. Stopping %s"%str(faulty))
         #log.error("Got error from heartbeat request. Stopping worker.")
         if ( type(faulty) == type(dict()) and 'faulty' in faulty): 
             for faultyItem in faulty['faulty']:
                 self.worker.killWorkload(faultyItem)
         else:
             pass
             #sys.exit(1)
     respData=presp.getData()
     if type(respData) == type(dict()):
         rettime=int(respData['heartbeat-time'])
         self.randomFile=respData['random-file']
         self._createRandomFile()
     else:
         rettime=int(respData)
     #rettime=int(presp.getData())
     log.debug("Waiting %s seconds for next ping"%(rettime))
     return rettime
示例#2
0
 def _sendPing(self, first, last):
     """Do the actual sending"""
     changed = self.cmdsChanged
     self.cmdsChanged = False
     with self.runCondVar:
         # first write the items to xml
         cmds = self.worker._getWorkloads()
         co = StringIO()
         co.write('<heartbeat worker_id="%s">' % self.workerID)
         for item in cmds:
             if item.running:
                 item.hbi.writeXML(co)
                 for subwl in item.joinedTo:
                     subwl.hbi.writeXML(co)
         co.write("</heartbeat>")
     clnt = WorkerMessage()
     resp = clnt.workerHeartbeatRequest(self.workerID, self.workerDir,
                                        first, last, changed, co.getvalue())
     presp = ProcessedResponse(resp)
     if last:
         timestr = " last"
     else:
         timestr = ""
     if first:
         timestr += " first"
     if changed:
         timestr += " update"
     log.debug("Sent%s heartbeat signal. Result was %s" %
               (timestr, presp.getStatus()))
     if presp.getStatus() != "OK":
         # if the response was not OK, the upstream server thinks we're
         # dead and has signaled that to the originating server. We
         # should just die now.
         faulty = presp.getData()
         log.info("Error from heartbeat request. Stopping %s" % str(faulty))
         #log.error("Got error from heartbeat request. Stopping worker.")
         if (type(faulty) == type(dict()) and 'faulty' in faulty):
             for faultyItem in faulty['faulty']:
                 self.worker.killWorkload(faultyItem)
         else:
             pass
             #sys.exit(1)
     respData = presp.getData()
     if type(respData) == type(dict()):
         rettime = int(respData['heartbeat-time'])
         self.randomFile = respData['random-file']
         self._createRandomFile()
     else:
         rettime = int(respData)
     #rettime=int(presp.getData())
     log.debug("Waiting %s seconds for next ping" % (rettime))
     return rettime
示例#3
0
 def _obtainCommands(self):
     """Obtain a command from the up-most server given a list of
        platforms and exelist. Returns the client response object."""
     # Send a run request with our arch+binaries
     req = u'<?xml version="1.0"?>\n'
     req += u"<worker-request>\n"
     req += u"<worker-arch-capabilities>\n"
     for platform in self.remainingPlatforms:
         req += platform.printXML()
     req += "\n"
     req += self.exelist.printPartialXML()
     req += u"\n</worker-arch-capabilities>"
     # Append optional project specifics
     req += u"\n<worker-requirements>\n"
     if "project" in self.opts:
         req += u'  <option key="project" value="%s"/>\n' % self.opts["project"]
     req += u"</worker-requirements>\n"
     req += u"</worker-request>\n"
     log.debug("request string is: %s" % req)
     runreq_clnt = WorkerMessage()
     resp = runreq_clnt.workerRequest(self.id, req)
     # print "Got %s"%(resp.read(len(resp)))
     return resp
示例#4
0
 def _obtainCommands(self):
     """Obtain a command from the up-most server given a list of
        platforms and exelist. Returns the client response object."""
     # Send a run request with our arch+binaries
     req = u'<?xml version="1.0"?>\n'
     req += u'<worker-request>\n'
     req += u'<worker-arch-capabilities>\n'
     for platform in self.remainingPlatforms:
         req += platform.printXML()
     req += '\n'
     req += self.exelist.printPartialXML()
     req += u'\n</worker-arch-capabilities>'
     #Append optional project specifics
     req += u'\n<worker-requirements>\n'
     if "project" in self.opts:
         req += u'  <option key="project" value="%s"/>\n' % self.opts[
             'project']
     req += u'</worker-requirements>\n'
     req += u'</worker-request>\n'
     log.debug('request string is: %s' % req)
     runreq_clnt = WorkerMessage()
     resp = runreq_clnt.workerRequest(self.id, req)
     #print "Got %s"%(resp.read(len(resp)))
     return resp