Sfoglia il codice sorgente

Update constructor of Sentinel cluster server statistic component

Signed-off-by: Eric Zhao <sczyh16@gmail.com>
master
Eric Zhao 6 anni fa
parent
commit
96dac7a1e0
4 ha cambiato i file con 6 aggiunte e 14 eliminazioni
  1. +1
    -2
      sentinel-cluster/sentinel-cluster-server-default/src/main/java/com/alibaba/csp/sentinel/cluster/flow/statistic/metric/ClusterMetric.java
  2. +2
    -8
      sentinel-cluster/sentinel-cluster-server-default/src/main/java/com/alibaba/csp/sentinel/cluster/flow/statistic/metric/ClusterMetricLeapArray.java
  3. +1
    -2
      sentinel-cluster/sentinel-cluster-server-default/src/main/java/com/alibaba/csp/sentinel/cluster/flow/statistic/metric/ClusterParamMetric.java
  4. +2
    -2
      sentinel-cluster/sentinel-cluster-server-default/src/main/java/com/alibaba/csp/sentinel/cluster/flow/statistic/metric/ClusterParameterLeapArray.java

+ 1
- 2
sentinel-cluster/sentinel-cluster-server-default/src/main/java/com/alibaba/csp/sentinel/cluster/flow/statistic/metric/ClusterMetric.java Vedi File

@@ -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) {


+ 2
- 8
sentinel-cluster/sentinel-cluster-server-default/src/main/java/com/alibaba/csp/sentinel/cluster/flow/statistic/metric/ClusterMetricLeapArray.java Vedi File

@@ -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) {


+ 1
- 2
sentinel-cluster/sentinel-cluster-server-default/src/main/java/com/alibaba/csp/sentinel/cluster/flow/statistic/metric/ClusterParamMetric.java Vedi File

@@ -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) {


+ 2
- 2
sentinel-cluster/sentinel-cluster-server-default/src/main/java/com/alibaba/csp/sentinel/cluster/flow/statistic/metric/ClusterParameterLeapArray.java Vedi File

@@ -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…
Annulla
Salva