package org.ehcache.core.statistics;
import java.time.Duration;
import java.util.Objects;
public class LatencyHistogramConfiguration {
public static final double DEFAULT_PHI = 0.63;
public static final int DEFAULT_BUCKET_COUNT = 20;
public static final Duration DEFAULT_WINDOW = Duration.ofMinutes(1) ;
public static final LatencyHistogramConfiguration DEFAULT = new LatencyHistogramConfiguration(DEFAULT_PHI, DEFAULT_BUCKET_COUNT, DEFAULT_WINDOW);
private final double phi;
private final int bucketCount;
private final Duration window;
public LatencyHistogramConfiguration(double phi, int bucketCount, Duration window) {
this.phi = phi;
this.bucketCount = bucketCount;
this.window = Objects.requireNonNull(window);
}
public double getPhi() {
return phi;
}
public int getBucketCount() {
return bucketCount;
}
public Duration getWindow() {
return window;
}
@Override
public String toString() {
return "LatencyHistogramConfiguration{" +
"phi=" + phi +
", bucketCount=" + bucketCount +
", window=" + window +
'}';
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
LatencyHistogramConfiguration that = (LatencyHistogramConfiguration) o;
if (that.phi != phi) return false;
if (bucketCount != that.bucketCount) return false;
return window.equals(that.window);
}
@Override
public int hashCode() {
int result;
long temp;
temp = Double.doubleToLongBits(phi);
result = (int) (temp ^ (temp >>> 32));
result = 31 * result + bucketCount;
result = 31 * result + window.hashCode();
return result;
}
}