7 |
import javax.servlet.annotation.WebListener; |
import javax.servlet.annotation.WebListener; |
8 |
|
|
9 |
import dk.thoerup.circuitbreaker.AccountingCircuitBreaker; |
import dk.thoerup.circuitbreaker.AccountingCircuitBreaker; |
10 |
|
import dk.thoerup.circuitbreaker.LoggingCircuitBreaker; |
11 |
import dk.thoerup.circuitbreaker.CircuitBreakerManager; |
import dk.thoerup.circuitbreaker.CircuitBreakerManager; |
12 |
import dk.thoerup.circuitbreaker.jmx.JMXWrapper; |
import dk.thoerup.circuitbreaker.jmx.JMXWrapper; |
13 |
import dk.thoerup.circuitbreaker.notification.*; |
import dk.thoerup.circuitbreaker.notification.*; |
35 |
int timeout = Integer.parseInt( sce.getServletContext().getInitParameter("banedk_timeout") ); |
int timeout = Integer.parseInt( sce.getServletContext().getInitParameter("banedk_timeout") ); |
36 |
CircuitBreakerManager mgr = CircuitBreakerManager.getManager(); |
CircuitBreakerManager mgr = CircuitBreakerManager.getManager(); |
37 |
|
|
|
|
|
|
AccountingCircuitBreaker banedk = new AccountingCircuitBreaker("banedk", threshold, timeout); |
|
38 |
CompositeNotifier notif = new CompositeNotifier(); |
CompositeNotifier notif = new CompositeNotifier(); |
39 |
notif.addNotifier( new JavaLogNotifier() ); |
notif.addNotifier( new JavaLogNotifier() ); |
40 |
notif.addNotifier( new MailNotifier(banedk,"traininfo@t-hoerup.dk", "torben@t-hoerup.dk", "192.168.10.5") ); |
notif.addNotifier( new MailNotifier("traininfo@t-hoerup.dk", "torben@t-hoerup.dk", "192.168.10.5") ); |
41 |
|
|
42 |
|
|
43 |
|
LoggingCircuitBreaker banedk = new LoggingCircuitBreaker("banedk", threshold, timeout); |
44 |
banedk.setNotifier(notif); |
banedk.setNotifier(notif); |
45 |
mgr.addCircuitBreaker( banedk ); |
mgr.addCircuitBreaker( banedk ); |
46 |
|
|
47 |
|
|
48 |
AccountingCircuitBreaker metro = new AccountingCircuitBreaker("metro", threshold, timeout); |
AccountingCircuitBreaker metro = new AccountingCircuitBreaker("metro", threshold, timeout); |
49 |
notif = new CompositeNotifier(); |
metro.setNotifier(notif); |
|
notif.addNotifier( new JavaLogNotifier() ); |
|
|
notif.addNotifier( new MailNotifier(banedk,"traininfo@t-hoerup.dk", "torben@t-hoerup.dk", "192.168.10.5") ); |
|
|
banedk.setNotifier(notif); |
|
50 |
mgr.addCircuitBreaker( metro ); |
mgr.addCircuitBreaker( metro ); |
51 |
|
|
52 |
JMXWrapper.registerAllCircuitBreakers(); |
JMXWrapper.registerAllCircuitBreakers(); |