/[projects]/CircuitBreaker/src/dk/thoerup/circuitbreaker/AccountingCircuitBreaker.java
ViewVC logotype

Diff of /CircuitBreaker/src/dk/thoerup/circuitbreaker/AccountingCircuitBreaker.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 620 by torben, Thu Oct 22 06:01:35 2009 UTC revision 621 by torben, Mon Mar 8 08:38:36 2010 UTC
# Line 10  public class AccountingCircuitBreaker ex Line 10  public class AccountingCircuitBreaker ex
10          private AtomicInteger totalFailureCount = 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
11          private AtomicInteger totalCallCount = new AtomicInteger(0);          private AtomicInteger totalCallCount = new AtomicInteger(0);
12          private AtomicLong lastTrip = new AtomicLong(0);          private AtomicLong lastTrip = new AtomicLong(0);
13            private AtomicLong lastFailure = new AtomicLong(0);
14          private long lastResetCounters = 0;          private long lastResetCounters = 0;
15                    
16          public AccountingCircuitBreaker(String name, int threshold, long timeoutMS) {          public AccountingCircuitBreaker(String name, int threshold, long timeoutMS) {
# Line 29  public class AccountingCircuitBreaker ex Line 30  public class AccountingCircuitBreaker ex
30                                  blockCount.incrementAndGet();                                  blockCount.incrementAndGet();
31                          } else {                          } else {
32                                  totalFailureCount.incrementAndGet();                                  totalFailureCount.incrementAndGet();
33                                    lastFailure.set( System.currentTimeMillis() );
34                          }                          }
35                          throw e;                          throw e;
36                  }                  }
# Line 63  public class AccountingCircuitBreaker ex Line 65  public class AccountingCircuitBreaker ex
65                  return lastTrip.get();                  return lastTrip.get();
66          }          }
67                    
68            public long getLastFailure() {
69                    return lastFailure.get();
70            }
71            
72          public int getTotalCallCount() {          public int getTotalCallCount() {
73                  return totalCallCount.get();                  return totalCallCount.get();
74          }          }
# Line 73  public class AccountingCircuitBreaker ex Line 79  public class AccountingCircuitBreaker ex
79                  totalFailureCount.set(0);                  totalFailureCount.set(0);
80                  totalCallCount.set(0);                  totalCallCount.set(0);
81                  lastTrip.set(0);                  lastTrip.set(0);
82                    lastFailure.set(0);
83                                    
84                  lastResetCounters = System.currentTimeMillis();                  lastResetCounters = System.currentTimeMillis();
85          }          }

Legend:
Removed from v.620  
changed lines
  Added in v.621

  ViewVC Help
Powered by ViewVC 1.1.20