You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+36-8Lines changed: 36 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -45,7 +45,7 @@ loop
45
45
46
46
**Important**: `callSucceeded()` or `callFailed()` must always be invoked after `isClosedForThisCall()`. Otherwise breaker in HALF-OPEN state will never move to another state, waiting for the results of the permittedNumberOfCallsInHalfOpenState calls.
47
47
48
-
To avoid this situation a new property maxDurationOpenInHalfOpenState is introduced. In HALF-OPEN state, after permittedNumberOfCallsInHalfOpenState calls (`isClosedForThisCall()` returns true), all its subsequent calls (`isClosedForThisCall()` returns false) won't be executed as the circuit is opened. If this situation lasts longer than maxDurationOpenInHalfOpenState ms, the breaker goes back automatically to the CLOSED state.
48
+
To avoid this situation a new property called maxDurationOpenInHalfOpenState is introduced. In HALF-OPEN state, after permittedNumberOfCallsInHalfOpenState calls (`isClosedForThisCall()` returns true), all its subsequent calls (`isClosedForThisCall()` returns false) should not be executed as the circuit is opened. If this situation lasts longer than maxDurationOpenInHalfOpenState ms, the breaker goes back automatically to the CLOSED state.
49
49
50
50
## Circuit Breaker Configuration using Properties
51
51
The circuit breaker can easily be configured using `java.util.Properties`, possibly adding prefix, for example:
@@ -66,8 +66,14 @@ SVC1.failureRateThreshold=20
66
66
SVC1.slidingWindowSize=150
67
67
```
68
68
69
-
## Log File
70
-
Log file contains information about the breaker state change as well as reason. Here is simple content. Log monitoring can be used to capture events.
69
+
## Concurrency
70
+
The code has 3 synchronized methods, it has minimum impact to initial code performance. Actual business logic is not included in the synchronized code, so blocking time is minimum
71
+
-`boolean isClosedForThisCall()` to check the state of the breaker for this current call
72
+
-`void callFailed(long callDuration)` to inform the breaker that the call failed
73
+
-`void callSucceeded(long callDuration)` to inform the breaker that the call succeeded
74
+
75
+
## Log File Output
76
+
Log file contains information about the breaker state change as well as the reason and simple statistics. Here is simple content. Log monitoring can be used to capture events.
71
77
72
78
```
73
79
Mar. 07, 2020 6:56:21 PM com.geckotechnology.simpleCircuitBreaker.CircuitBreakerConfig logInfoConfigProperties
@@ -118,8 +124,30 @@ INFO: Breaker state changed to: CLOSED
118
124
...
119
125
```
120
126
121
-
## Concurrency
122
-
The code has 3 synchronized methods, it has minimum impact to initial code performance. Actual business logic is not included in the synchronized code, so blocking time is minimum
123
-
-`boolean isClosedForThisCall()` to check the state of the breaker for this current call
124
-
-`void callFailed(long callDuration)` to inform the breaker that the call failed
125
-
-`void callSucceeded(long callDuration)` to inform the breaker that the call succeeded
127
+
Another example showing the behavior of maxDurationOpenInHalfOpenState.
128
+
129
+
```
130
+
...
131
+
...
132
+
Mar. 08, 2020 5:02:27 PM com.geckotechnology.simpleCircuitBreaker.CircuitBreaker moveToClosedState
133
+
INFO: Breaker state changed to: CLOSED
134
+
...
135
+
...
136
+
Mar. 08, 2020 5:02:52 PM com.geckotechnology.simpleCircuitBreaker.CircuitBreaker isExceedFailureOrSlowRateThreshold
137
+
WARNING: High slowCallRate: 45.299145%, slowCallDurationCount: 53, callCount: 117
138
+
Mar. 08, 2020 5:02:52 PM com.geckotechnology.simpleCircuitBreaker.CircuitBreaker moveToOpenState
139
+
INFO: Breaker state changed to: OPEN
140
+
...
141
+
...
142
+
Mar. 08, 2020 5:02:54 PM com.geckotechnology.simpleCircuitBreaker.CircuitBreaker moveToHalfOpenState
143
+
INFO: Breaker state changed to: HALF_OPEN
144
+
...
145
+
...
146
+
Mar. 08, 2020 5:02:55 PM com.geckotechnology.simpleCircuitBreaker.BreakerHalfOpenState isClosedForThisCall
147
+
WARNING: maxDurationOpenInHalfOpenState is reached. CallCount: 4, failureCallCount: 1, slowCallDurationCount: 1
148
+
Mar. 08, 2020 5:02:55 PM com.geckotechnology.simpleCircuitBreaker.CircuitBreaker moveToClosedState
0 commit comments