Class DefaultCountBasedThrottle

  • All Implemented Interfaces:
    Throttle

    public class DefaultCountBasedThrottle
    extends java.lang.Object
    implements Throttle
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean open​(long threshold)
      打开节流器。节流器是否能打开取决于节流指标的数值是否达到或超过阈值。 节流开始的时间由实现类定义,一般情况下是节流器生成即开始,也可延迟开始。
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • DefaultCountBasedThrottle

        public DefaultCountBasedThrottle()
    • Method Detail

      • open

        public boolean open​(long threshold)
        Description copied from interface: Throttle
        打开节流器。节流器是否能打开取决于节流指标的数值是否达到或超过阈值。 节流开始的时间由实现类定义,一般情况下是节流器生成即开始,也可延迟开始。

        Throttle throttle = ...创建一个以时间为指标,单位为毫秒的节流器... ; throttle.open(300); //在时间流逝未达到300毫秒时返回false。

        Specified by:
        open in interface Throttle
        Parameters:
        threshold - 阈值的含义由实现类定义,可以是基于时间的,未达到时间阈值无法打开;也可以是基于次数的,未达到次数阈值无法打开。
        Returns:
        打开失败返回false。