--- CircuitBreaker/src/dk/thoerup/curcuitbreaker/AccountingCircuitBreaker.java 2009/10/21 07:56:37 460 +++ CircuitBreaker/src/dk/thoerup/circuitbreaker/AccountingCircuitBreaker.java 2010/03/08 08:38:36 621 @@ -1,4 +1,4 @@ -package dk.thoerup.curcuitbreaker; +package dk.thoerup.circuitbreaker; import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicLong; @@ -10,6 +10,7 @@ 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 long lastResetCounters = 0; public AccountingCircuitBreaker(String name, int threshold, long timeoutMS) { @@ -29,6 +30,7 @@ blockCount.incrementAndGet(); } else { totalFailureCount.incrementAndGet(); + lastFailure.set( System.currentTimeMillis() ); } throw e; } @@ -63,6 +65,10 @@ return lastTrip.get(); } + public long getLastFailure() { + return lastFailure.get(); + } + public int getTotalCallCount() { return totalCallCount.get(); } @@ -73,6 +79,7 @@ totalFailureCount.set(0); totalCallCount.set(0); lastTrip.set(0); + lastFailure.set(0); lastResetCounters = System.currentTimeMillis(); }