本文整理汇总了Python中common.CpuSnapshot.unAssignJob方法的典型用法代码示例。如果您正苦于以下问题:Python CpuSnapshot.unAssignJob方法的具体用法?Python CpuSnapshot.unAssignJob怎么用?Python CpuSnapshot.unAssignJob使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类common.CpuSnapshot
的用法示例。
在下文中一共展示了CpuSnapshot.unAssignJob方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: EasySjbfScheduler
# 需要导入模块: from common import CpuSnapshot [as 别名]
# 或者: from common.CpuSnapshot import unAssignJob [as 别名]
class EasySjbfScheduler(EasyBackfillScheduler):
""" This algorithm implements the algorithm in the paper of Tsafrir, Etzion, Feitelson, june 2007?
"""
def __init__(self, options):
super(EasySjbfScheduler, self).__init__(options)
self.cpu_snapshot = CpuSnapshot(self.num_processors, options["stats"])
def _backfill_jobs(self, current_time):
"Overriding parent method"
if len(self.unscheduled_jobs) <= 1:
return []
result = []
first_job = self.unscheduled_jobs[0]
tail = list_copy(self.unscheduled_jobs[1:])
tail_of_jobs_by_sjf_order = sorted(tail, key=sjf_sort_key)
self.cpu_snapshot.assignJobEarliest(first_job, current_time)
for job in tail_of_jobs_by_sjf_order:
if self.cpu_snapshot.canJobStartNow(job, current_time):
job.is_backfilled = 1
self.unscheduled_jobs.remove(job)
self.cpu_snapshot.assignJob(job, current_time)
result.append(job)
self.cpu_snapshot.unAssignJob(first_job)
return result
示例2: EasyBackfillScheduler
# 需要导入模块: from common import CpuSnapshot [as 别名]
# 或者: from common.CpuSnapshot import unAssignJob [as 别名]
class EasyBackfillScheduler(Scheduler):
def __init__(self, options):
super(EasyBackfillScheduler, self).__init__(options)
self.cpu_snapshot = CpuSnapshot(self.num_processors, options["stats"])
self.unscheduled_jobs = []
def new_events_on_job_submission(self, just_submitted_job, current_time):
""" Here we first add the new job to the waiting list. We then try to schedule
the jobs in the waiting list, returning a collection of new termination events """
# TODO: a probable performance bottleneck because we reschedule all the
# jobs. Knowing that only one new job is added allows more efficient
# scheduling here.
self.cpu_snapshot.archive_old_slices(current_time)
self.unscheduled_jobs.append(just_submitted_job)
retl = []
if (self.cpu_snapshot.free_processors_available_at(current_time) >= just_submitted_job.num_required_processors):
for job in self._schedule_jobs(current_time):
retl.append(JobStartEvent(current_time, job))
return retl
def new_events_on_job_termination(self, job, current_time):
""" Here we first delete the tail of the just terminated job (in case it's
done before user estimation time). We then try to schedule the jobs in the waiting list,
returning a collection of new termination events """
self.cpu_snapshot.archive_old_slices(current_time)
self.cpu_snapshot.delTailofJobFromCpuSlices(job)
return [
JobStartEvent(current_time, job)
for job in self._schedule_jobs(current_time)
]
def _schedule_jobs(self, current_time):
"Schedules jobs that can run right now, and returns them"
jobs = self._schedule_head_of_list(current_time)
jobs += self._backfill_jobs(current_time)
return jobs
def _schedule_head_of_list(self, current_time):
result = []
while True:
if len(self.unscheduled_jobs) == 0:
break
# Try to schedule the first job
if self.cpu_snapshot.free_processors_available_at(current_time) >= self.unscheduled_jobs[0].num_required_processors:
job = self.unscheduled_jobs.pop(0)
self.cpu_snapshot.assignJob(job, current_time)
result.append(job)
else:
# first job can't be scheduled
break
return result
def _backfill_jobs(self, current_time):
"""
Find jobs that can be backfilled and update the cpu snapshot.
DEPRECATED FUNCTION !!!!!!
"""
if len(self.unscheduled_jobs) <= 1:
return []
result = []
tail_of_waiting_list = list_copy(self.unscheduled_jobs[1:])
first_job = self.unscheduled_jobs[0]
self.cpu_snapshot.assignJobEarliest(first_job, current_time)
for job in tail_of_waiting_list:
if self.cpu_snapshot.canJobStartNow(job, current_time):
job.is_backfilled = 1
self.unscheduled_jobs.remove(job)
self.cpu_snapshot.assignJob(job, current_time)
result.append(job)
self.cpu_snapshot.unAssignJob(first_job)
return result