Update constructor of Sentinel cluster server statistic component
Signed-off-by: Eric Zhao <sczyh16@gmail.com>
This commit is contained in:
parent
a2b91a9030
commit
96dac7a1e0
|
|
@ -33,8 +33,7 @@ public class ClusterMetric {
|
|||
AssertUtil.isTrue(sampleCount > 0, "sampleCount should be positive");
|
||||
AssertUtil.isTrue(intervalInMs > 0, "interval should be positive");
|
||||
AssertUtil.isTrue(intervalInMs % sampleCount == 0, "time span needs to be evenly divided");
|
||||
int windowLengthInMs = intervalInMs / sampleCount;
|
||||
this.metric = new ClusterMetricLeapArray(windowLengthInMs, intervalInMs);
|
||||
this.metric = new ClusterMetricLeapArray(sampleCount, intervalInMs);
|
||||
}
|
||||
|
||||
public void add(ClusterFlowEvent event, long count) {
|
||||
|
|
|
|||
|
|
@ -30,14 +30,8 @@ public class ClusterMetricLeapArray extends LeapArray<ClusterMetricBucket> {
|
|||
private final LongAdder[] occupyCounter;
|
||||
private boolean hasOccupied = false;
|
||||
|
||||
/**
|
||||
* The total bucket count is: {@link #sampleCount} = intervalInMs / windowLengthInMs.
|
||||
*
|
||||
* @param windowLengthInMs a single window bucket's time length in milliseconds.
|
||||
* @param intervalInMs the total time span of this {@link LeapArray} in milliseconds.
|
||||
*/
|
||||
public ClusterMetricLeapArray(int windowLengthInMs, int intervalInMs) {
|
||||
super(windowLengthInMs, intervalInMs / 1000);
|
||||
public ClusterMetricLeapArray(int sampleCount, int intervalInMs) {
|
||||
super(sampleCount, intervalInMs);
|
||||
ClusterFlowEvent[] events = ClusterFlowEvent.values();
|
||||
this.occupyCounter = new LongAdder[events.length];
|
||||
for (ClusterFlowEvent event : events) {
|
||||
|
|
|
|||
|
|
@ -39,8 +39,7 @@ public class ClusterParamMetric {
|
|||
AssertUtil.isTrue(sampleCount > 0, "sampleCount should be positive");
|
||||
AssertUtil.isTrue(intervalInMs > 0, "interval should be positive");
|
||||
AssertUtil.isTrue(intervalInMs % sampleCount == 0, "time span needs to be evenly divided");
|
||||
int windowLengthInMs = intervalInMs / sampleCount;
|
||||
this.metric = new ClusterParameterLeapArray<>(windowLengthInMs, intervalInMs, maxCapacity);
|
||||
this.metric = new ClusterParameterLeapArray<>(sampleCount, intervalInMs, maxCapacity);
|
||||
}
|
||||
|
||||
public long getSum(Object value) {
|
||||
|
|
|
|||
|
|
@ -30,8 +30,8 @@ public class ClusterParameterLeapArray<C> extends LeapArray<CacheMap<Object, C>>
|
|||
|
||||
private final int maxCapacity;
|
||||
|
||||
public ClusterParameterLeapArray(int windowLengthInMs, int intervalInMs, int maxCapacity) {
|
||||
super(windowLengthInMs, intervalInMs / 1000);
|
||||
public ClusterParameterLeapArray(int sampleCount, int intervalInMs, int maxCapacity) {
|
||||
super(sampleCount, intervalInMs);
|
||||
AssertUtil.isTrue(maxCapacity > 0, "maxCapacity of LRU map should be positive");
|
||||
this.maxCapacity = maxCapacity;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue