Sfoglia il codice sorgente

Update sample count for ParameterMetric

Signed-off-by: Eric Zhao <sczyh16@gmail.com>
master
Eric Zhao 6 anni fa
parent
commit
5f5443a546
2 ha cambiato i file con 9 aggiunte e 3 eliminazioni
  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 Vedi File

@@ -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 Vedi File

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