6 |
|
|
7 |
private AtomicInteger tripCount = new AtomicInteger(0); // how many times ahs the CB tripped |
private AtomicInteger tripCount = new AtomicInteger(0); // how many times ahs the CB tripped |
8 |
private AtomicInteger blockCount = new AtomicInteger(0); //how many times has this CB blocked a call that would otherwise go to the backend |
private AtomicInteger blockCount = new AtomicInteger(0); //how many times has this CB blocked a call that would otherwise go to the backend |
9 |
private AtomicInteger failureCount = new AtomicInteger(0); //how many times has the backend thrown an exception |
private AtomicInteger totalFailureCount = new AtomicInteger(0); //how many times has the backend thrown an exception |
10 |
|
private AtomicInteger totalCallCount = new AtomicInteger(0); |
11 |
|
|
12 |
private long lastReset = 0; |
private long lastReset = 0; |
13 |
|
|
19 |
public Object invoke(CircuitInvocation invocation) throws Throwable { |
public Object invoke(CircuitInvocation invocation) throws Throwable { |
20 |
Object result; |
Object result; |
21 |
try { |
try { |
22 |
|
totalCallCount.incrementAndGet(); |
23 |
result = super.invoke(invocation); |
result = super.invoke(invocation); |
24 |
} catch (Throwable t) { |
} catch (Throwable t) { |
25 |
if (t instanceof CircuitBreakerException) { |
if (t instanceof CircuitBreakerException) { |
26 |
blockCount.incrementAndGet(); |
blockCount.incrementAndGet(); |
27 |
} else { |
} else { |
28 |
failureCount.incrementAndGet(); |
totalFailureCount.incrementAndGet(); |
29 |
} |
} |
30 |
throw t; |
throw t; |
31 |
} |
} |
47 |
return blockCount.get(); |
return blockCount.get(); |
48 |
} |
} |
49 |
|
|
50 |
public int getFailureCount() { |
public int getTotalFailureCount() { |
51 |
return failureCount.get(); |
return totalFailureCount.get(); |
52 |
} |
} |
53 |
|
|
54 |
public long getLastReset() { |
public long getLastReset() { |
55 |
return lastReset; |
return lastReset; |
56 |
} |
} |
57 |
|
|
58 |
|
public int getTotalCallCount() { |
59 |
|
return totalCallCount.get(); |
60 |
|
} |
61 |
|
|
62 |
public void resetCounters() { |
public void resetCounters() { |
63 |
tripCount.set(0); |
tripCount.set(0); |
64 |
blockCount.set(0); |
blockCount.set(0); |
65 |
failureCount.set(0); |
totalFailureCount.set(0); |
66 |
|
totalCallCount.set(0); |
67 |
|
|
68 |
lastReset = System.currentTimeMillis(); |
lastReset = System.currentTimeMillis(); |
69 |
} |
} |