当前位置: 首页>>代码示例>>Python>>正文


Python Stats.set_low_threshold方法代码示例

本文整理汇总了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)
开发者ID:inocybe,项目名称:odl-affinity,代码行数:44,代码来源:demo3.py


注:本文中的stats.Stats.set_low_threshold方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。