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) { |
@Deprecated |
64 |
closed.setThreshold(threshold); |
public CircuitBreaker(String name, int threshold, int timeoutMS) { |
65 |
open.setTimeout(timeoutMS); |
this(name, new StaticConfig(threshold, timeoutMS) ); |
66 |
|
} |
67 |
|
|
68 |
|
public CircuitBreaker(String name, BreakerConfig config) { |
69 |
|
closed.setThreshold(config); |
70 |
|
open.setTimeout(config); |
71 |
|
|
72 |
this.name = name; |
this.name = name; |
73 |
|
|
195 |
this.notifier = notifier; |
this.notifier = notifier; |
196 |
} |
} |
197 |
|
|
198 |
public String getNotifierName() { |
public String getNotifierName() { |
199 |
return notifier.getClass().getName(); |
return NotiferHelper.getName(notifier); |
200 |
} |
} |
201 |
|
|
202 |
public synchronized ExecutorService getExecutor() { |
public synchronized ExecutorService getExecutor() { |