本文整理汇总了Python中stats.Stats.set_low_threshold方法的典型用法代码示例。如果您正苦于以下问题:Python Stats.set_low_threshold方法的具体用法?Python Stats.set_low_threshold怎么用?Python Stats.set_low_threshold使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类stats.Stats
的用法示例。
在下文中一共展示了Stats.set_low_threshold方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: WaypointMonitor
# 需要导入模块: from stats import Stats [as 别名]
# 或者: from stats.Stats import set_low_threshold [as 别名]
class WaypointMonitor(Thread):
def __init__(self, monitor_type, **kwargs):
Thread.__init__(self)
self.stat = Stats(monitor_type, **kwargs)
self.stat_type = monitor_type
self.waypoint_address = None
print "Created waypoint monitor for %s" % self.stat
def set_waypoint(self, waypoint_ip):
self.waypoint_address = waypoint_ip
print "Registered waypoint for %s. Any large flows will be redirected to %s." % (self.stat, waypoint_ip)
def set_high_threshold(self, s):
self.stat.set_high_threshold(s)
print "Set high threshold for flow rate to %3.3f Mbps" % (int(s) * (1.0/1000000))
print("-------------------------")
def set_low_threshold(self, s):
self.stat.set_low_threshold(s)
print "Set low threshold for flow rate to %3.3f Mbps" % (int(s) * (1.0/1000000))
print("-------------------------")
def run(self):
global sigint
high_rate_set = False
while not sigint:
is_high, is_low = self.stat.refresh()
if is_high and not high_rate_set:
ac = AffinityControl()
high_rate_set = True
# ac.add_waypoint(link_name, self.waypoint_address)
ac.add_isolate(link_name)
ac.enable_affinity()
print "Adding isolate affinity to link: %s" % (link_name)
# time.sleep(3)
elif is_low and high_rate_set:
high_rate_set = False
ac.remove_isolate(link_name)
ac.enable_affinity()
print "Adding isolate affinity to link: %s" % (link_name)
time.sleep(10)