def __mt_bulk_submit__(self, node_jdls): '''submitting jobs in multiple threads''' job = self.getJobObject() logger.warning('submitting %d subjobs ... it may take a while' % len(node_jdls)) # the algorithm for submitting a single bulk job class MyAlgorithm(Algorithm): def __init__(self, cred_req, masterInputWorkspace, ce, arcverbose): Algorithm.__init__(self) self.inpw = masterInputWorkspace self.cred_req = cred_req self.ce = ce self.arcverbose = arcverbose def process(self, jdl_info): my_sj_id = jdl_info[0] my_sj_jdl = jdl_info[1] my_sj_jid = Grid.arc_submit(my_sj_jdl, self.ce, self.arcverbose, self.cred_req) if not my_sj_jid: return False else: self.__appendResult__(my_sj_id, my_sj_jid) return True mt_data = [] for id, jdl in node_jdls.items(): mt_data.append((id, jdl)) myAlg = MyAlgorithm(cred_req=self.credential_requirements, masterInputWorkspace=job.getInputWorkspace(), ce=self.CE, arcverbose=self.verbose) myData = Data(collection=mt_data) runner = MTRunner(name='arc_jsubmit', algorithm=myAlg, data=myData, numThread=config['SubmissionThread']) runner.start() runner.join(timeout=-1) if len(runner.getDoneList()) < len(mt_data): # not all bulk jobs are successfully submitted. canceling the # submitted jobs on WMS immediately logger.error( 'some bulk jobs not successfully (re)submitted, canceling submitted jobs on WMS' ) Grid.arc_cancel_multiple(runner.getResults().values(), self.credential_requirements) return None else: return runner.getResults()
def __mt_bulk_submit__(self, node_jdls): '''submitting jobs in multiple threads''' job = self.getJobObject() logger.warning( 'submitting %d subjobs ... it may take a while' % len(node_jdls)) # the algorithm for submitting a single bulk job class MyAlgorithm(Algorithm): def __init__(self, cred_req, masterInputWorkspace, ce, arcverbose): Algorithm.__init__(self) self.inpw = masterInputWorkspace self.cred_req = cred_req self.ce = ce self.arcverbose = arcverbose def process(self, jdl_info): my_sj_id = jdl_info[0] my_sj_jdl = jdl_info[1] my_sj_jid = Grid.arc_submit(my_sj_jdl, self.ce, self.arcverbose, self.cred_req) if not my_sj_jid: return False else: self.__appendResult__(my_sj_id, my_sj_jid) return True mt_data = [] for id, jdl in node_jdls.items(): mt_data.append((id, jdl)) myAlg = MyAlgorithm(cred_req=self.credential_requirements, masterInputWorkspace=job.getInputWorkspace( ), ce=self.CE, arcverbose=self.verbose) myData = Data(collection=mt_data) runner = MTRunner(name='arc_jsubmit', algorithm=myAlg, data=myData, numThread=config['SubmissionThread']) runner.start() runner.join(timeout=-1) if len(runner.getDoneList()) < len(mt_data): # not all bulk jobs are successfully submitted. canceling the # submitted jobs on WMS immediately logger.error( 'some bulk jobs not successfully (re)submitted, canceling submitted jobs on WMS') Grid.arc_cancel_multiple(runner.getResults().values(), self.credential_requirements) return None else: return runner.getResults()
def master_bulk_kill(self): '''GLITE bulk resubmission''' job = self.getJobObject() # killing the individually re-submitted subjobs logger.debug('cancelling running/submitted subjobs.') # 1. collect job ids ids = [] for sj in job.subjobs: if sj.status in ['submitted', 'running'] and sj.backend.id: ids.append(sj.backend.id) # 2. cancel the collected jobs ck = Grid.arc_cancel_multiple(ids, self.credential_requirements) if not ck: logger.warning('Job cancellation failed') return False else: for sj in job.subjobs: if sj.backend.id in ids: sj.updateStatus('killed') return True