def searchFactory(maxjobs, params, time_list, uuid): spawned = 1 completed = 0 time_len = len(time_list) if maxjobs == 1: try: while time_list: st = time_list.pop() logger.info("uuid=%s Dispatching job %s for time %s (%s)" % (uuid, spawned, st, time.ctime(int(st)))) job = search.dispatchSavedSearch( params["ss_name"], sessionKey=params["sessionKey"], namespace=params["namespace"], owner=params["owner"], triggerActions=True, now=st, ttl="120", ) spawned = spawned + 1 while not job.isDone: time.sleep(0.5) completed = completed + 1 logger.info("uuid=%s Job %d of %d completed" % (uuid, completed, time_len)) logger.info("uuid=%s All jobs completed" % uuid) return except Exception, ex: logger.exception(ex) raise
def searchFactory(maxjobs, params, time_list, uuid): spawned = 1 completed = 0 time_len = len(time_list) if maxjobs == 1: try: while time_list: st = time_list.pop() logger.info('uuid=%s Dispatching job %s for time %s (%s)' \ % (uuid, spawned, st, time.ctime(int(st)))) job = search.dispatchSavedSearch(params['ss_name'], sessionKey=params['sessionKey'], namespace=params['namespace'], owner=params['owner'], triggerActions=True, now=st, ttl='120') spawned = spawned + 1 while not job.isDone: time.sleep(.5) completed = completed + 1 logger.info('uuid=%s Job %d of %d completed' \ % (uuid, completed, time_len)) logger.info('uuid=%s All jobs completed' % uuid) return except Exception, ex: logger.exception(ex) raise
curjobs = [] compjobs = [] while 1: try: while len(curjobs) >= maxjobs: (curjobs, compjobs) = updateJobList(curjobs) for j in compjobs: logger.info("uuid=%s Job %d of %d completed (id: %s)" % (uuid, completed, time_len, j.id)) completed = completed + 1 st = time_list.pop() logger.info("uuid=%s Dispatching job %s for time %s (%s)" % (uuid, spawned, st, time.ctime(int(st)))) job = search.dispatchSavedSearch( params["ss_name"], sessionKey=params["sessionKey"], namespace=params["namespace"], owner=params["owner"], triggerActions=True, now=st, ttl="120", ) spawned = spawned + 1 curjobs.append(job) (curjobs, compjobs) = updateJobList(curjobs) for j in compjobs: logger.info("uuid=%s Job %d of %d completed (id: %s)" % (uuid, completed, time_len, j.id)) completed = completed + 1 for j in curjobs: logger.info("uuid=%s Job %s still running" % (uuid, j.id)) if not time_list: logger.info("uuid=%s Encountered empty time list" % uuid) break
compjobs = [] while 1: try: while (len(curjobs) >= maxjobs): (curjobs, compjobs) = updateJobList(curjobs) for j in compjobs: logger.info('uuid=%s Job %d of %d completed (id: %s)' \ %(uuid, completed, time_len, j.id)) completed = completed + 1 st = time_list.pop() logger.info('uuid=%s Dispatching job %s for time %s (%s)' \ % (uuid, spawned, st, time.ctime(int(st)))) job = search.dispatchSavedSearch(params['ss_name'], sessionKey=params['sessionKey'], namespace=params['namespace'], owner=params['owner'], triggerActions=True, now=st, ttl='120') spawned = spawned + 1 curjobs.append(job) (curjobs, compjobs) = updateJobList(curjobs) for j in compjobs: logger.info('uuid=%s Job %d of %d completed (id: %s)' \ %(uuid, completed, time_len, j.id)) completed = completed + 1 for j in curjobs: logger.info('uuid=%s Job %s still running' % (uuid, j.id)) if not time_list: logger.info('uuid=%s Encountered empty time list' % uuid) break