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

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

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

revision 1293 by torben, Sat Apr 16 11:11:07 2011 UTC revision 1306 by torben, Tue Apr 19 15:22:09 2011 UTC
# Line 14  public class LoggingCircuitBreaker exten Line 14  public class LoggingCircuitBreaker exten
14          public class LogEntry {          public class LogEntry {
15                  public long time;                  public long time;
16                  public Notifier.Event event;                  public Notifier.Event event;
17                  public int count = 0;                  public int count = 1;
18                    
19                  public LogEntry(Notifier.Event evnt) {                  public LogEntry(Notifier.Event evnt) {
20                          this.event = evnt;                          this.event = evnt;
# Line 41  public class LoggingCircuitBreaker exten Line 41  public class LoggingCircuitBreaker exten
41                    
42                    
43    
44          public LoggingCircuitBreaker(String name, int threshold, long timeoutMS) {          public LoggingCircuitBreaker(String name, int threshold, int timeoutMS) {
45                  super(name, threshold, timeoutMS);                  super(name, threshold, timeoutMS);
46    
47          }          }
# Line 68  public class LoggingCircuitBreaker exten Line 68  public class LoggingCircuitBreaker exten
68    
69          private void addEntry(Notifier.Event event) {          private void addEntry(Notifier.Event event) {
70                  synchronized(this) {                  synchronized(this) {
71                            
72                          if (log.getFirst().event != Notifier.Event.BreakerRetripped) {                          if (event != Notifier.Event.BreakerRetripped ) {
73                                                                    log.addFirst( new LogEntry(event) ); //trip and reset are added unconditionally
                                 log.addFirst( new LogEntry(event) );  
                                 if(log.size() > maxSize) {  
                                         log.removeLast();  
                                 }  
                                   
74                          } else {                          } else {
75                                  log.getFirst().newRetrip();                                  
76                                    if (log.size() == 0 || log.getFirst().event != Notifier.Event.BreakerRetripped) {
77                                            log.addFirst( new LogEntry(event) );
78                                    } else {
79                                            log.getFirst().newRetrip();
80                                    }                              
81                            }
82    
83                            if(log.size() > maxSize) {
84                                    log.removeLast();
85                          }                          }
86    
87                  }                  }
88          }          }
89    

Legend:
Removed from v.1293  
changed lines
  Added in v.1306

  ViewVC Help
Powered by ViewVC 1.1.20