1 |
torben |
393 |
package dk.thoerup.curcuitbreaker; |
2 |
|
|
|
3 |
|
|
|
4 |
|
|
|
5 |
torben |
424 |
public final class HalfOpenState implements CircuitBreakerState { |
6 |
torben |
393 |
|
7 |
torben |
450 |
public void preInvoke(CircuitBreaker circuitBreaker) throws Exception |
8 |
torben |
393 |
{ |
9 |
|
|
// NO OP |
10 |
|
|
} |
11 |
|
|
|
12 |
torben |
450 |
public void postInvoke(CircuitBreaker circuitBreaker) throws Exception |
13 |
torben |
393 |
{ |
14 |
|
|
circuitBreaker.reset(); |
15 |
|
|
} |
16 |
|
|
|
17 |
torben |
450 |
public void onError(CircuitBreaker circuitBreaker, Exception e) throws Exception |
18 |
torben |
393 |
{ |
19 |
|
|
circuitBreaker.tripBreaker(); |
20 |
torben |
459 |
throw new CircuitBreakerException("Circuitbreaker, failed in half-open", e); |
21 |
torben |
393 |
} |
22 |
torben |
397 |
|
23 |
|
|
public String getName() { |
24 |
|
|
return "Half-open"; |
25 |
|
|
} |
26 |
torben |
393 |
} |