|
|
@@ -15,6 +15,8 @@ |
|
|
|
*/ |
|
|
|
package com.alibaba.csp.sentinel.slots.statistic.base; |
|
|
|
|
|
|
|
import com.alibaba.csp.sentinel.Constants; |
|
|
|
|
|
|
|
/** |
|
|
|
* Represents metrics data in a period of time window. |
|
|
|
* |
|
|
@@ -28,14 +30,15 @@ public class Window { |
|
|
|
private final LongAdder exception = new LongAdder(); |
|
|
|
private final LongAdder rt = new LongAdder(); |
|
|
|
private final LongAdder success = new LongAdder(); |
|
|
|
private final LongAdder minRt = new LongAdder(); |
|
|
|
|
|
|
|
private volatile long minRt; |
|
|
|
|
|
|
|
public Window() { |
|
|
|
initMinRt(); |
|
|
|
} |
|
|
|
|
|
|
|
private void initMinRt() { |
|
|
|
minRt.add(4900); |
|
|
|
this.minRt = Constants.TIME_DROP_VALVE; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
@@ -49,7 +52,6 @@ public class Window { |
|
|
|
exception.reset(); |
|
|
|
rt.reset(); |
|
|
|
success.reset(); |
|
|
|
minRt.reset(); |
|
|
|
initMinRt(); |
|
|
|
return this; |
|
|
|
} |
|
|
@@ -71,7 +73,7 @@ public class Window { |
|
|
|
} |
|
|
|
|
|
|
|
public long minRt() { |
|
|
|
return minRt.longValue(); |
|
|
|
return minRt; |
|
|
|
} |
|
|
|
|
|
|
|
public long success() { |
|
|
@@ -97,8 +99,9 @@ public class Window { |
|
|
|
public void addRT(long rt) { |
|
|
|
this.rt.add(rt); |
|
|
|
|
|
|
|
if (minRt.longValue() > rt) { |
|
|
|
minRt.internalReset(rt); |
|
|
|
// Not thread-safe, but it's okay. |
|
|
|
if (rt < minRt) { |
|
|
|
minRt = rt; |
|
|
|
} |
|
|
|
} |
|
|
|
} |