4 |
import java.util.concurrent.ExecutorService; |
import java.util.concurrent.ExecutorService; |
5 |
import java.util.concurrent.Executors; |
import java.util.concurrent.Executors; |
6 |
|
|
7 |
|
import dk.thoerup.circuitbreaker.config.BreakerConfig; |
8 |
|
import dk.thoerup.circuitbreaker.config.StaticConfig; |
9 |
|
import dk.thoerup.circuitbreaker.notification.NotiferHelper; |
10 |
import dk.thoerup.circuitbreaker.notification.Notifier; |
import dk.thoerup.circuitbreaker.notification.Notifier; |
11 |
import dk.thoerup.circuitbreaker.notification.NullNotifier; |
import dk.thoerup.circuitbreaker.notification.NullNotifier; |
12 |
|
|
60 |
private ExecutorService executor = null; |
private ExecutorService executor = null; |
61 |
private Notifier notifier = new NullNotifier(); |
private Notifier notifier = new NullNotifier(); |
62 |
|
|
63 |
public CircuitBreaker(String name, int threshold, long timeoutMS) { |
/*public CircuitBreaker(String name, int threshold, int timeoutMS) { |
64 |
closed.setThreshold(threshold); |
this(name, new StaticConfig(threshold, timeoutMS) ); |
65 |
open.setTimeout(timeoutMS); |
}*/ |
66 |
|
|
67 |
|
public CircuitBreaker(String name, BreakerConfig config) { |
68 |
|
closed.setThreshold(config); |
69 |
|
open.setTimeout(config); |
70 |
|
|
71 |
this.name = name; |
this.name = name; |
72 |
|
|
194 |
this.notifier = notifier; |
this.notifier = notifier; |
195 |
} |
} |
196 |
|
|
197 |
public String getNotifierName() { |
public String getNotifierName() { |
198 |
return notifier.getClass().getName(); |
return NotiferHelper.getName(notifier); |
199 |
} |
} |
200 |
|
|
201 |
public synchronized ExecutorService getExecutor() { |
public synchronized ExecutorService getExecutor() { |