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