Package org.jgroups.util
Class DistributionSampler
- java.lang.Object
-
- org.jgroups.util.DistributionSampler
-
public class DistributionSampler extends java.lang.ObjectRecords samples (e.g. message sizes or times) by buckets, e.g. 0-10,11-100,101-1000 etc. All buckets are defined at creation time.- Since:
- 5.5.0
- Author:
- Bela Ban
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classDistributionSampler.Bucket
-
Field Summary
Fields Modifier and Type Field Description protected DistributionSampler.Bucket[]bucketsprotected booleanexception_on_missing_bucketprotected longmax_valueprotected longmin_value
-
Constructor Summary
Constructors Constructor Description DistributionSampler(long... buckets)Creates a new samplerDistributionSampler(java.util.List<java.lang.Long> buckets)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description DistributionSampleradd(long value)protected DistributionSampler.BucketbinarySearch(int from, int to, long value)DistributionSampler.Bucket[]buckets()booleanexceptionOnMissingBucket()DistributionSamplerexceptionOnMissingBucket(boolean b)protected DistributionSampler.BucketgetBucket(long value)protected static long[]listToArray(java.util.List<java.lang.Long> buckets)longmaxValue()longminValue()DistributionSamplerreset()protected static voidsanityCheck(long... buckets)intsize()java.lang.StringtoString()longtotal()
-
-
-
Field Detail
-
buckets
protected final DistributionSampler.Bucket[] buckets
-
min_value
protected long min_value
-
max_value
protected long max_value
-
exception_on_missing_bucket
protected boolean exception_on_missing_bucket
-
-
Constructor Detail
-
DistributionSampler
public DistributionSampler(long... buckets)
Creates a new sampler- Parameters:
buckets- The buckets. Needs to be an even number. Each tuple defines min-max size. Needs to be in ascending order of size and adjacent.
-
DistributionSampler
public DistributionSampler(java.util.List<java.lang.Long> buckets)
-
-
Method Detail
-
minValue
public long minValue()
-
maxValue
public long maxValue()
-
buckets
public DistributionSampler.Bucket[] buckets()
-
exceptionOnMissingBucket
public boolean exceptionOnMissingBucket()
-
exceptionOnMissingBucket
public DistributionSampler exceptionOnMissingBucket(boolean b)
-
add
public DistributionSampler add(long value)
-
reset
public DistributionSampler reset()
-
total
public long total()
-
size
public int size()
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
getBucket
protected DistributionSampler.Bucket getBucket(long value)
-
binarySearch
protected DistributionSampler.Bucket binarySearch(int from, int to, long value)
-
listToArray
protected static long[] listToArray(java.util.List<java.lang.Long> buckets)
-
sanityCheck
protected static void sanityCheck(long... buckets)
-
-