类 Sampler
- java.lang.Object
-
- net.dongliu.commons.Sampler
-
public abstract class Sampler extends java.lang.ObjectUtils for run code by sampling.
-
-
构造器概要
构造器 构造器 说明 Sampler()
-
方法概要
所有方法 静态方法 实例方法 抽象方法 具体方法 修饰符和类型 方法 说明 static Samplerrandom(double rate)Return a sampler sample by randomstatic Samplerrandom(java.util.Random random, double rate)Return a random sampler, with specific random instance, and ratestatic SamplerroundRobin(double rate)Return a sampler sample by round robinvoidrun(java.lang.Runnable runnable)Run code by samplingabstract booleanshouldRun()If should really run for this time
-
-
-
方法详细资料
-
random
public static Sampler random(double rate)
Return a sampler sample by random- 参数:
rate- the rate to do really operation, should be [0,1]- 抛出:
java.lang.IllegalArgumentException- if rate value is illegal
-
random
public static Sampler random(java.util.Random random, double rate)
Return a random sampler, with specific random instance, and rate- 参数:
random- the random instancerate- the rate to do really operation, should be [0,1]- 抛出:
java.lang.IllegalArgumentException- if rate value is illegal
-
roundRobin
public static Sampler roundRobin(double rate)
Return a sampler sample by round robin- 参数:
rate- the rate to do really operation, should be [0,1]- 抛出:
java.lang.IllegalArgumentException- if rate value is illegal
-
run
public void run(java.lang.Runnable runnable)
Run code by sampling
-
shouldRun
public abstract boolean shouldRun()
If should really run for this time
-
-