本文整理汇总了Python中simulator.Simulator.handle_submission_event方法的典型用法代码示例。如果您正苦于以下问题:Python Simulator.handle_submission_event方法的具体用法?Python Simulator.handle_submission_event怎么用?Python Simulator.handle_submission_event使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类simulator.Simulator
的用法示例。
在下文中一共展示了Simulator.handle_submission_event方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: MetaScheduler
# 需要导入模块: from simulator import Simulator [as 别名]
# 或者: from simulator.Simulator import handle_submission_event [as 别名]
class MetaScheduler(object):
"""
This class is the common interface between the User, Predictor and Site Scheduler
Tasks:
- Accept job inputs from user
- Obtain predictions
- Submit jobs to scheduler
- Provide feedback (if necessary) to user and predictor
"""
def __init__(self, jobs, num_processors, scheduler):
self.num_processors = num_processors
self.jobs = jobs
self.do_pred = 0
#print "inside init of metascheduler"
#print "jobs",jobs
#print len(self.jobs)
self.terminated_jobs=[]
self.scheduler = scheduler
self.time_of_last_job_submission = 0
self.event_queue = EventQueue()
#with open('/home/siddharthsahu/Documents/scheduling/scheduling-virtualenv/prediction/prediction_time/files/tyrone_new_log') as f:
with open('/home/siddharthsahu/Documents/scheduling/scheduling-virtualenv/prediction/history_log_creation/history_log.swf') as f:
a = sum(1 for _ in f)
#print "value of history:",a
self.historySetSize = a-1
#self.historySetSize = 0
self.currentSubmitCount = 0
if EnabledWaitPred:
self.waitTimePredictor = WaitPredictor()
else:
self.waitTimePredictor = None
if EnabledRunPred:
self.runTimePredictor = RunPredictor()
else:
self.runTimePredictor = None
self.machine = ValidatingMachine(num_processors=num_processors, event_queue=self.event_queue, wait_predictor=self.waitTimePredictor, run_predictor = self.runTimePredictor, scheduler = self.scheduler)
self.event_queue.add_handler(JobSubmissionEvent, self.handle_submission_event)
self.event_queue.add_handler(JobTerminationEvent, self.handle_termination_event)
if isinstance(scheduler, EasyPlusPlusScheduler) or isinstance(scheduler, ShrinkingEasyScheduler):
self.event_queue.add_handler(JobPredictionIsOverEvent, self.handle_prediction_event)
countSubmissions = 0
for job in self.jobs:
countSubmissions += 1
self.event_queue.add_event( JobSubmissionEvent(job.submit_time, job) )
#print '** Added', countSubmissions, 'job submission events to event queue **'
self.queueSimulator = Simulator(jobs, num_processors, scheduler, self.event_queue, self.machine, )
def modify_job_attributes(self, event, newRequestSize, actual_runtime, actual_ert):
#print "modify_job_attributes"
oldRunTime = event.job.actual_run_time
event.job.num_required_processors = newRequestSize
event.job.user_estimated_run_time = actual_ert
event.job.predicted_run_time = actual_ert
if actual_runtime == 0:
event.job.actual_run_time = actual_ert
else:
event.job.actual_run_time = actual_runtime
def change_job_attributes(self, event, newRequestSize,actual_ert):
#print "change job attributes"
oldRunTime = event.job.actual_run_time
event.job.num_required_processors = newRequestSize
#event.job.user_estimated_run_time = actual_ert
#event.job.predicted_run_time = actual_ert
def decision_metrics(self, event,queuedJobs,runningJobIDs,allrunningjobevents,jobtarrun):
#print "inside decision metrics"
#print "event:",event
#queuedJobIDs = [j.id for j in self.event_queue.QueuedJobs]
#runningJobIDs = [j.id for j in self.event_queue.RunningJobs]
#queuedJobIDs.append(event.job.id)
originalRequestSize = event.job.num_required_processors
waitPredictions = {}
responsePredictions = {}
waittime_list = []
run_list = []
wait_list = []
submittime = []
#terminateval = []
ifcounter = 0
if EnabledRunPred:
run_list.append(jobtarrun)
#.........这里部分代码省略.........
开发者ID:kruthikavishwanath,项目名称:project-to-predict-wait-times-in-tyrone-cluster,代码行数:103,代码来源:metaScheduler.py