--- CircuitBreaker/src/dk/thoerup/circuitbreaker/AccountingCircuitBreaker.java 2010/03/08 09:11:13 623 +++ CircuitBreaker/src/dk/thoerup/circuitbreaker/AccountingCircuitBreaker.java 2010/03/08 09:46:10 624 @@ -9,8 +9,11 @@ private AtomicInteger blockCount = new AtomicInteger(0); //how many times has this CB blocked a call that would otherwise go to the backend private AtomicInteger totalFailureCount = new AtomicInteger(0); //how many times has the backend thrown an exception private AtomicInteger totalCallCount = new AtomicInteger(0); + private AtomicLong lastTrip = new AtomicLong(0); private AtomicLong lastFailure = new AtomicLong(0); + private AtomicLong lastReset = new AtomicLong(0); + private long lastResetCounters = 0; public AccountingCircuitBreaker(String name, int threshold, long timeoutMS) { @@ -45,6 +48,14 @@ lastTrip.set( System.currentTimeMillis() ); } + + + @Override + public void reset() { + super.reset(); + lastReset.set( System.currentTimeMillis()); + } + public int getTripCount() { return tripCount.get(); } @@ -69,6 +80,10 @@ return lastFailure.get(); } + public long getLastReset() { + return lastReset.get(); + } + public int getTotalCallCount() { return totalCallCount.get(); } @@ -79,6 +94,7 @@ totalFailureCount.set(0); totalCallCount.set(0); lastTrip.set(0); + lastReset.set(0); lastFailure.set(0); lastResetCounters = System.currentTimeMillis();