Example #1
0
 def invertKeepOutput(self, name):
     printDebug(3, "Invert keep output for batch %s" % name)
     if name in self.listBatch:
         self.listBatch[name]["monitor"].invertKeepOutput()
         header = self.listBatch[name]["monitor"].config.getHeaders()
         header['keep'] = self.listBatch[name]["monitor"].keepOutput
         return header
Example #2
0
 def getBatchList(self):
     printDebug(3, "Sending batch list")
     l = []
     orderedNames = sorted(self.listBatch.keys())
     for name in orderedNames:
         l.append({'name':name, 'stats':self.listBatch[name]["monitor"].config.getStatusStats()})
     return l
Example #3
0
 def loadBatch(self, jsonFile, name, keep, limit):
     printDebug(3, "Loading new batch %s from %s" % (name, jsonFile))
     if name in self.listBatch:
         printDebug(2, "Batch %s already exists" % name)
         return
     batch = Monitor2(keep, limit)
     batch.loadBatch(str(jsonFile))
     self.listBatch[name] = {"monitor":batch, "clients":[]}
Example #4
0
 def addBatch(self, cardFile, name, queue, test, keep, limit):
     printDebug(3, "Adding new batch %s" % name)
     if name in self.listBatch:
         printDebug(2, "Batch %s already exists" % name)
         return
     batch = Monitor2(keep, limit)
     batch.newBatch(cardFile, name, queue, test)
     self.listBatch[name] = {"monitor":batch, "clients":[]}
Example #5
0
 def disconnectAllClients(self):
     printDebug(3, "Disconnecting all clients")
     for _,batch in self.listBatch.iteritems():
         #list of clients can be manipulated by one thread at a time
         self.mutex.acquire()
         for client in batch["clients"]:
             client._pyroRelease()
             batch["clients"].remove(client)
         self.mutex.release()
Example #6
0
 def disconnectClient(self, name, clientUri):
     printDebug(3, "Disconnecting client %s for %s" % (clientUri, name))
     if name in self.listBatch:
         #list of clients can be manipulated by one thread at a time
         self.mutex.acquire()
         for client in self.listBatch[name]["clients"]:
             if client._pyroUri == clientUri:
                 client._pyroRelease()
                 self.listBatch[name]["clients"].remove(client)
         self.mutex.release()
Example #7
0
 def generateJobs(self):
     printDebug(3, "Monitor generating jobs")
     self.submitting = True
     if len(self.submitList)==0:
         subList = [job for job in self.config.jobsList if job.attempts==-1]
     else:
         subList = [self.config.jobsList[i] for i in self.submitList]
     for job in subList:
         yield job
         self.activeJobs+=1
         if self.jobsLimit>0 and self.activeJobs>=self.jobsLimit:
             break
     self.submitList = []
     self.submitReady = False
     self.submitting = False
Example #8
0
 def registerClient(self, name, clientUri):
     printDebug(3, "Registering client %s for %s" % (clientUri, name))
     if name in self.listBatch:
         #List of clients can be manipulated only by one thread at a time
         self.mutex.acquire()
         client = Pyro4.Proxy(clientUri)
         #Set the timeout for the calls. Client might not be running anymore and cannot block server indefinitely. 
         client._pyroTimeout = 1
         
         self.listBatch[name]["clients"].append(client)
         
         #Get the basic info about the batch and return them to the client
         header = self.listBatch[name]["monitor"].config.getHeaders()
         header['keep'] = self.listBatch[name]["monitor"].keepOutput
         self.mutex.release()
         return self.listBatch[name]["monitor"].config.startTime, header, len(self.listBatch[name]["monitor"].config.jobsList), self.listBatch[name]["monitor"].config.getStatusStats()
Example #9
0
 def submitInit(self):
     printDebug(3, "Monitor initial submit")
     self.config.enableNew()
     self.submitReady = True
Example #10
0
 def reSubmitFailed(self):
     printDebug(3, "Monitor resubmitting failed jobs")
     self.config.resetFailed()
     self.submitReady = True
Example #11
0
 def submit(self, jobs):
     printDebug(3, "Monitor submitting jobs")
     return getLSFMonitorInstance().submitJob(jobs, self.config)
Example #12
0
 def saveBatch(self, jsonFile):
     printDebug(3, "Saving batch")
     self.config.save(jsonFile)
Example #13
0
 def loadBatch(self, jsonFile):
     printDebug(3, "Monitor loading new batch")
     self.config.load(jsonFile)
     self.submitReady = False
Example #14
0
 def newBatch(self, cfgFile, batchName, queue, test):
     printDebug(3, "Monitor creating new batch")
     self.config.initCardFile(cfgFile, batchName, queue, test)
     self.submitReady = False
Example #15
0
 def deleteJobs(self):
     printDebug(3, "Delete jobs " + self.config.name)
     getLSFMonitorInstance().deleteJobs(self.config.name)
Example #16
0
 def submitInit(self, name):
     printDebug(3, "Initial submit for batch %s" % name)
     if name in self.listBatch:
         self.listBatch[name]["monitor"].submitInit()
Example #17
0
 def stop(self):
     global stopAll
     printDebug(3, "Stopping server")
     stopAll = True
Example #18
0
def _shutilFunc(func, src, dst):
    u.printDebug( 'shutil.'+ func.func_name +'('+ src +', '+ dst +')' )
    func(src, dst)
Example #19
0
 def removeBatch(self, name):
     printDebug(3, "Removing batch %s" % name)
     t = threading.Thread(target=self.doRemove, args=(name,))
     t.setName(name)
     t.daemon = True
     t.start()
Example #20
0
 def submitLoopArrayed(self, batch):
     cThread = threading.currentThread()
     printDebug(3, "["+cThread.name+"] Enter submit loop")
     try:
         #Reset submit flag
         batch["monitor"].submitting = False
         printDebug(3, "["+cThread.name+"] Number of jobs in Ready state: " + str(batch["monitor"].config.getJobsNumberReady()))
         
         #Go through all the jobs that are ready and submit them
         jList = [];
         for i, job in enumerate(batch["monitor"].generateJobs()):
                     printDebug(3, "["+cThread.name+"] Generate job " + str(i))
                     jList.append(job)
         
         lsfID,index = batch["monitor"].submit(jList)
         printDebug(3, "["+cThread.name+"] acquire mutex")
                     
         #Notify the clients that the job was submitted
         if self.mutex.acquire():
             try:
                 for clients in batch["clients"]:
                     clients.displayJobSent(lsfID, index, len(jList)-1)
             except Exception:
                 printDebug(1, "["+cThread.name+"] Exception:")
                 printDebug(1, "".join(Pyro4.util.getPyroTraceback()))
             finally:
                 printDebug(3, "["+cThread.name+"] release mutex")
                 self.mutex.release()
     except Exception:
         printDebug(1, "["+cThread.name+"] Exception")
         printDebug(1, "".join(Pyro4.util.getPyroTraceback()))
Example #21
0
 def kill(self):
     printDebug(3, "Killing server properly")
     self.disconnectAllClients()
     self.saveAllBatches()
Example #22
0
def removeFile(src):
    u.printDebug( 'os.remove('+ src +')' )
    os.remove(src)
Example #23
0
 def resubmitFailed(self, name):
     printDebug(3, "Resubmiting failed jobs for batch %s" % name)
     if name in self.listBatch:
         self.listBatch[name]["monitor"].reSubmitFailed()