浏览代码

Update constructor of Sentinel cluster server statistic component

Signed-off-by: Eric Zhao <sczyh16@gmail.com>
master
Eric Zhao 6 年前
父节点
当前提交
96dac7a1e0
共有 4 个文件被更改,包括 6 次插入14 次删除
  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 查看文件

@@ -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 查看文件

@@ -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 查看文件

@@ -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 查看文件

@@ -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;
}


正在加载...
取消
保存