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