瀏覽代碼

Update sample count for ParameterMetric

Signed-off-by: Eric Zhao <sczyh16@gmail.com>
master
Eric Zhao 6 年之前
父節點
當前提交
5f5443a546
共有 2 個文件被更改,包括 9 次插入3 次删除
  1. +1
    -1
      sentinel-extension/sentinel-parameter-flow-control/src/main/java/com/alibaba/csp/sentinel/slots/block/flow/param/ParameterMetric.java
  2. +8
    -2
      sentinel-extension/sentinel-parameter-flow-control/src/main/java/com/alibaba/csp/sentinel/slots/statistic/data/ParamMapBucket.java

+ 1
- 1
sentinel-extension/sentinel-parameter-flow-control/src/main/java/com/alibaba/csp/sentinel/slots/block/flow/param/ParameterMetric.java 查看文件

@@ -51,7 +51,7 @@ public class ParameterMetric {
// putIfAbsent
if (rollingParameters.get(index) == null) {
rollingParameters.put(index, new HotParameterLeapArray(
1000 / 2, IntervalProperty.INTERVAL));
1000 / SampleCountProperty.SAMPLE_COUNT, IntervalProperty.INTERVAL));
}
}
}


+ 8
- 2
sentinel-extension/sentinel-parameter-flow-control/src/main/java/com/alibaba/csp/sentinel/slots/statistic/data/ParamMapBucket.java 查看文件

@@ -21,6 +21,7 @@ import java.util.concurrent.atomic.AtomicInteger;
import com.alibaba.csp.sentinel.slots.block.flow.param.RollingParamEvent;
import com.alibaba.csp.sentinel.slots.statistic.cache.CacheMap;
import com.alibaba.csp.sentinel.slots.statistic.cache.ConcurrentLinkedHashMapWrapper;
import com.alibaba.csp.sentinel.util.AssertUtil;

/**
* Represents metric bucket of frequent parameters in a period of time window.
@@ -32,12 +33,17 @@ public class ParamMapBucket {

private final CacheMap<Object, AtomicInteger>[] data;

@SuppressWarnings("unchecked")
public ParamMapBucket() {
this(DEFAULT_MAX_CAPACITY);
}

@SuppressWarnings("unchecked")
public ParamMapBucket(int capacity) {
AssertUtil.isTrue(capacity > 0, "capacity should be positive");
RollingParamEvent[] events = RollingParamEvent.values();
this.data = new CacheMap[events.length];
for (RollingParamEvent event : events) {
data[event.ordinal()] = new ConcurrentLinkedHashMapWrapper<Object, AtomicInteger>(DEFAULT_MAX_CAPACITY);
data[event.ordinal()] = new ConcurrentLinkedHashMapWrapper<Object, AtomicInteger>(capacity);
}
}



Loading…
取消
儲存