本文整理汇总了Python中Cobalt.Proxy.ComponentProxy.get_current_time方法的典型用法代码示例。如果您正苦于以下问题:Python ComponentProxy.get_current_time方法的具体用法?Python ComponentProxy.get_current_time怎么用?Python ComponentProxy.get_current_time使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cobalt.Proxy.ComponentProxy
的用法示例。
在下文中一共展示了ComponentProxy.get_current_time方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: metricmon
# 需要导入模块: from Cobalt.Proxy import ComponentProxy [as 别名]
# 或者: from Cobalt.Proxy.ComponentProxy import get_current_time [as 别名]
class metricmon(Component):
"""metrics mointor: monitors the real time statistics of interested metrics such as average waiting time and system utilization rate"""
implementation = "imon"
name = "imon"
def __init__(self, *args, **kwargs):
Component.__init__(self, *args, **kwargs)
self.event_manager = ComponentProxy("event-manager")
self.bqsim = ComponentProxy("queue-manager")
self.mmon_logger = None
def get_current_time_sec(self):
return self.event_manager.get_current_time()
def get_current_time_date(self):
return self.event_manager.get_current_date_time()
def init_mmon_logger(self):
if self.mon_logger == None:
self.mmon_logger = PBSlogger(self.bqsim.get_outputlog_string() + "-mmon")
def metric_monitor(self):
self.bqsim.monitor_metrics()
示例2: ClusterQsim
# 需要导入模块: from Cobalt.Proxy import ComponentProxy [as 别名]
# 或者: from Cobalt.Proxy.ComponentProxy import get_current_time [as 别名]
#.........这里部分代码省略.........
elif self.mate_ratio:
print "start init mate job dict, mate_ratio=", self.mate_ratio
self.init_mate_job_dict_by_ratio(self.mate_ratio)
else:
self.logger.error("fail to initialize mate job dict!")
matejobs = len(self.mate_job_dict.keys())
proportion = float(matejobs) / self.total_job
#recording holding job id and holden resource
self.job_hold_dict = {}
#record holding job's holding time jobid:first hold (sec)
self.first_hold_time_dict = {}
#record yield jobs's first yielding time, for calculating the extra waiting time
self.first_yield_hold_time_dict = {}
#record yield job ids. update dynamically
self.yielding_job_list = []
if self.coscheduling:
remote_mate_job_dict = dict((v,k) for k, v in self.mate_job_dict.iteritems())
try:
ComponentProxy(REMOTE_QUEUE_MANAGER).set_mate_job_dict(remote_mate_job_dict)
except:
self.logger.error("failed to connect to remote queue-manager component!")
self.coscheduling = False
print "number of mate job pairs: %s, proportion in cluster jobs: %s%%" \
% (len(self.mate_job_dict.keys()), round(proportion *100, 1) )
self.max_holding_sys_util = DEFAULT_MAX_HOLDING_SYS_UTIL
def get_current_time(self):
'''this function overrid the get_current_time in bgsched, bg_base_system, and cluster_base_system'''
return self.event_manager.get_current_time()
def get_current_time_sec(self):
return self.event_manager.get_current_time()
def get_current_time_date(self):
return self.event_manager.get_current_date_time()
def insert_time_stamp(self, timestamp, type, info):
'''insert time stamps in the same order'''
if type not in SET_event:
print "invalid event type,", type
return
evspec = {}
evspec['jobid'] = info.get('jobid', 0)
evspec['type'] = type
evspec['datetime'] = sec_to_date(timestamp)
evspec['unixtime'] = timestamp
evspec['machine'] = MACHINE_ID
self.event_manager.add_event(evspec)
def _get_queuing_jobs(self):
return [job for job in self.queues.get_jobs([{'is_runnable':True}])]
queuing_jobs = property(_get_queuing_jobs)
def _get_running_jobs(self):
return [job for job in self.queues.get_jobs([{'has_resources':True}])]
running_jobs = property(_get_running_jobs)
示例3: PowerMonitor
# 需要导入模块: from Cobalt.Proxy import ComponentProxy [as 别名]
# 或者: from Cobalt.Proxy.ComponentProxy import get_current_time [as 别名]
class PowerMonitor(Component):
""" Power Monitor. Monitor runtime power consumption, logging into output log or provide to scheduler for power-aware job scheduling"""
implementation = "powmonitor"
name = "powmonitor"
def __init__(self, *args, **kwargs):
Component.__init__(self, *args, **kwargs)
self.event_manager = ComponentProxy("event-manager")
self.bqsim = ComponentProxy("queue-manager")
self.powmon_logger = None
self.total_cost = 0.0
self.time_power_list =[{"unixtime":0, "power":0, "count":0, "utilization":0}]
def init_powmon_logger(self):
if self.iomon_logger == None:
self.iomon_logger = PBSlogger(self.bqsim.get_outputlog_string() + "-powmon")
def get_log_title(self):
''' generate a log file title '''
power_budget = self.bqsim.get_power_budget()
return ("BGP_power_aware_"+
str(self.bqsim.is_power_aware())+
"_power_budget_"+ str(power_budget)+
"_refill_"+
str(self.bqsim.get_refill())+"_"+
str(self.bqsim.get_sim_start())+"_"+
str(self.bqsim.get_sim_end())+
".list")
def log_avg_info(self, spec):
''' log average power and utilization information '''
power_budget = self.bqsim.get_power_budget()
print "power budget: ", power_budget
f=open("BGP_avg_power_"+ self.get_log_title(), "a")
print "Length: ", len(spec)
for item in spec:
print >> f, "unixtime", item["unixtime"], "power", item["power"], "utilization", item["utilization"]
f.close()
return True
def log_info1(self, spec, filename):
''' log a certain string into file specified by filename '''
f=open(filename, "a")
print >> f, spec
f.close()
return True
def insert_tag(self, tag):
''' insert power & util tag into timeline '''
pos = len(self.time_power_list)
while tag["unixtime"] < self.time_power_list[pos-1].get("unixtime"):
pos = pos - 1
if tag["unixtime"] == self.time_power_list[pos-1].get("unixtime"):
pos = pos -1
# compute average power consumption
power = self.time_power_list[pos].get("power")
count = self.time_power_list[pos].get("count")
power_avg = (power*count+tag["power"]) / (count+1)
self.time_power_list[pos]["power"] = int(power_avg)
# compute average utilization
util = self.time_power_list[pos].get("utilization")
util_avg = (util*count+tag["utilization"]) / (count+1)
self.time_power_list[pos]["count"]= count+1
self.time_power_list[pos]["utilization"] = util_avg
else:
self.time_power_list.insert(pos, {"unixtime":tag["unixtime"], "power":tag["power"],"count":1,"utilization":tag["utilization"]})
return pos
def get_current_price_level(self):
''' return price level '''
time = self.event_manager.get_current_time()
tmp = datetime.fromtimestamp(time)
fmtdate = int(tmp.strftime("%H"))
#print tmp, " ",fmtdate
if fmtdate >= 9 and fmtdate <=23:
return HIGH_PRICE
else:
return LOW_PRICE
get_current_price_level = exposed(get_current_price_level)
def monitor_power(self):
''' log current system running information including power '''
time = self.event_manager.get_current_time()
total_power = self.bqsim.get_running_job_power_usage()
price = self.get_current_price_level()
#.........这里部分代码省略.........