--- CircuitBreaker/src/dk/thoerup/curcuitbreaker/AccountingCircuitBreaker.java 2009/10/20 10:26:50 450 +++ CircuitBreaker/src/dk/thoerup/curcuitbreaker/AccountingCircuitBreaker.java 2009/10/21 07:56:37 460 @@ -1,6 +1,7 @@ package dk.thoerup.curcuitbreaker; import java.util.concurrent.atomic.AtomicInteger; +import java.util.concurrent.atomic.AtomicLong; public class AccountingCircuitBreaker extends CircuitBreaker { @@ -8,7 +9,7 @@ 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 long lastResetCounters = 0; public AccountingCircuitBreaker(String name, int threshold, long timeoutMS) { @@ -39,6 +40,7 @@ public void tripBreaker() { super.tripBreaker(); tripCount.incrementAndGet(); + lastTrip.set( System.currentTimeMillis() ); } public int getTripCount() { @@ -57,6 +59,10 @@ return lastResetCounters; } + public long getLastTrip() { + return lastTrip.get(); + } + public int getTotalCallCount() { return totalCallCount.get(); } @@ -66,6 +72,7 @@ blockCount.set(0); totalFailureCount.set(0); totalCallCount.set(0); + lastTrip.set(0); lastResetCounters = System.currentTimeMillis(); }