Package org.jgroups.util
Class DistributionSampler
- java.lang.Object
-
- org.jgroups.util.DistributionSampler
-
public class DistributionSampler extends java.lang.Object
Records 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.4.9
- Author:
- Bela Ban
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
DistributionSampler.Bucket
-
Field Summary
Fields Modifier and Type Field Description protected DistributionSampler.Bucket[]
buckets
protected boolean
exception_on_missing_bucket
protected long
max_value
protected long
min_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 DistributionSampler
add(long value)
protected DistributionSampler.Bucket
binarySearch(int from, int to, long value)
DistributionSampler.Bucket[]
buckets()
boolean
exceptionOnMissingBucket()
DistributionSampler
exceptionOnMissingBucket(boolean b)
protected DistributionSampler.Bucket
getBucket(long value)
protected static long[]
listToArray(java.util.List<java.lang.Long> buckets)
long
maxValue()
long
minValue()
DistributionSampler
reset()
protected static void
sanityCheck(long... buckets)
int
size()
java.lang.String
toString()
long
total()
-
-
-
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:
toString
in 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)
-
-