Top Inners Fields Constructors Methods
com.oracle.bmc.circuitbreaker.internal.resilience4j

public Class OciCircuitBreakerImpl

extends Object
implements OciCircuitBreaker
Class Inheritance
All Implemented Interfaces
com.oracle.bmc.circuitbreaker.OciCircuitBreaker
Imports
java.time.Clock, .Duration, java.util.ArrayDeque, .ArrayList, .Collections, .Deque, .List, .Map, .Objects, java.util.concurrent.TimeUnit, java.util.function.Function, .Predicate, java.util.stream.Collectors, com.oracle.bmc.circuitbreaker.CallNotAllowedException, .CircuitBreakerConfiguration, .OciCircuitBreaker, io.github.resilience4j.circuitbreaker.CircuitBreaker, .CircuitBreakerConfig

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class

Field Summary

Modifier and TypeField and Description
private Deque<OciCircuitBreaker.ErrorHistoryItem>
private static final Logger
private final int
private volatile long
private final CircuitBreaker

Constructor Summary

AccessConstructor and Description
public
OciCircuitBreakerImpl(CircuitBreaker r4jCircuitBreaker, int numberOfRecordedHistoryResponses)

public
OciCircuitBreakerImpl(CircuitBreakerConfiguration circuitBreakerConfiguration, Predicate<Throwable> recordExceptionPredicate)

Method Summary

Modifier and TypeMethod and Description
public void
acquirePermission()

Implements com.oracle.bmc.circuitbreaker.OciCircuitBreaker.acquirePermission.

Try to obtain a permission to execute a call.

public synchronized void
public String

Returns:

a message with error details
circuitBreakerCallNotPermittedErrorMessage
(String
the request URI, or null if not known
requestUri
)

Implements com.oracle.bmc.circuitbreaker.OciCircuitBreaker.circuitBreakerCallNotPermittedErrorMessage.

Generates CircuitBreaker message when it's open.

public CallNotAllowedException
public boolean
equals(Object
the reference object with which to compare.
o
)

Overrides java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

public OciCircuitBreaker.Config
getCircuitBreakerConfig()

Implements com.oracle.bmc.circuitbreaker.OciCircuitBreaker.getCircuitBreakerConfig.

Returns the CircuitBreakerConfig of this CircuitBreaker.

private long

Returns:

time since last opening in milliseconds
getCircuitBreakerOpenTime
()

Returns the time in milliseconds since the last opening of the circuit breaker.

public long
getCurrentTimestamp()

Implements com.oracle.bmc.circuitbreaker.OciCircuitBreaker.getCurrentTimestamp.

Returns the current time with respect to the CircuitBreaker currentTimeFunction.

public synchronized List<OciCircuitBreaker.ErrorHistoryItem>
public synchronized String
public String
getName()

Implements com.oracle.bmc.circuitbreaker.OciCircuitBreaker.getName.

Returns the name of this CircuitBreaker.

public CircuitBreaker
public CircuitBreaker.State
getState()

Implements com.oracle.bmc.circuitbreaker.OciCircuitBreaker.getState.

Returns the state of this CircuitBreaker.

public TimeUnit
getTimestampUnit()

Implements com.oracle.bmc.circuitbreaker.OciCircuitBreaker.getTimestampUnit.

Returns the timeUnit of current timestamp.

public int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for this object.

public void
onError(long
The elapsed time duration of the call
duration
,
TimeUnit
The duration unit
durationUnit
,
Throwable
The throwable which must be recorded
throwable
)

Implements com.oracle.bmc.circuitbreaker.OciCircuitBreaker.onError.

Records a failed call.

public void
onResult(long
The elapsed time duration of the call
duration
,
TimeUnit
The duration unit
durationUnit
,
Object
The result of the protected function
result
)

Implements com.oracle.bmc.circuitbreaker.OciCircuitBreaker.onResult.

This method must be invoked when a call returned a result and the result predicate should decide if the call was successful or not.

public void
onSuccess(long
The elapsed time duration of the call
duration
,
TimeUnit
The duration unit
durationUnit
)

Implements com.oracle.bmc.circuitbreaker.OciCircuitBreaker.onSuccess.

Records a successful call.

public void
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

public boolean
tryAcquirePermission()

Implements com.oracle.bmc.circuitbreaker.OciCircuitBreaker.tryAcquirePermission.

Acquires a permission to execute a call, only if one is available at the time of invocation.

Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAllwaitwaitwait

Field Detail

historyQueueback to summary
private Deque<OciCircuitBreaker.ErrorHistoryItem> historyQueue
LOGback to summary
private static final Logger LOG
numberOfRecordedHistoryResponsesback to summary
private final int numberOfRecordedHistoryResponses
openedTimestampMillisback to summary
private volatile long openedTimestampMillis
r4jCircuitBreakerback to summary
private final CircuitBreaker r4jCircuitBreaker

Constructor Detail

OciCircuitBreakerImplback to summary
public OciCircuitBreakerImpl(CircuitBreaker r4jCircuitBreaker, int numberOfRecordedHistoryResponses)
OciCircuitBreakerImplback to summary
public OciCircuitBreakerImpl(CircuitBreakerConfiguration circuitBreakerConfiguration, Predicate<Throwable> recordExceptionPredicate)

Method Detail

acquirePermissionback to summary
public void acquirePermission()

Implements com.oracle.bmc.circuitbreaker.OciCircuitBreaker.acquirePermission.

Doc from com.oracle.bmc.circuitbreaker.OciCircuitBreaker.acquirePermission.

Try to obtain a permission to execute a call. If a call is not permitted, the number of not permitted calls is increased.

Throws a CallNotPermittedException when the state is OPEN or FORCED_OPEN. Returns when the state is CLOSED or DISABLED. Returns when the state is HALF_OPEN and further test calls are allowed. Throws a CallNotPermittedException when the state is HALF_OPEN and the number of test calls has been reached. If the state is HALF_OPEN, the number of allowed test calls is decreased.

Important Note

Make sure to call onSuccess or onError after the call is finished. If the call is cancelled before it is invoked, you have to release the permission again.

Annotations
@Override
addToHistoryback to summary
public synchronized void addToHistory(Throwable throwable, Integer status, Map<String, String> messages)

Implements com.oracle.bmc.circuitbreaker.OciCircuitBreaker.addToHistory.

Annotations
@Override
circuitBreakerCallNotPermittedErrorMessageback to summary
public String circuitBreakerCallNotPermittedErrorMessage(String requestUri)

Implements com.oracle.bmc.circuitbreaker.OciCircuitBreaker.circuitBreakerCallNotPermittedErrorMessage.

Generates CircuitBreaker message when it's open.

Parameters
requestUri:String

the request URI, or null if not known

Returns:String

a message with error details

Annotations
@Override
createCallNotAllowedExceptionback to summary
public CallNotAllowedException createCallNotAllowedException()

Implements com.oracle.bmc.circuitbreaker.OciCircuitBreaker.createCallNotAllowedException.

Annotations
@Override
equalsback to summary
public boolean equals(Object o)

Overrides java.lang.Object.equals.

Doc from java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.

Parameters
o:Object

the reference object with which to compare.

Returns:boolean

true if this object is the same as the obj argument; false otherwise.

Annotations
@Override
getCircuitBreakerConfigback to summary
public OciCircuitBreaker.Config getCircuitBreakerConfig()

Implements com.oracle.bmc.circuitbreaker.OciCircuitBreaker.getCircuitBreakerConfig.

Doc from com.oracle.bmc.circuitbreaker.OciCircuitBreaker.getCircuitBreakerConfig.

Returns the CircuitBreakerConfig of this CircuitBreaker.

Returns:OciCircuitBreaker.Config

the CircuitBreakerConfig of this CircuitBreaker

Annotations
@Override
getCircuitBreakerOpenTimeback to summary
private long getCircuitBreakerOpenTime()

Returns the time in milliseconds since the last opening of the circuit breaker. If the circuit breaker has never been opened, then System.currentTimeMillis() is returned, which makes it seem like the circuit breaker has been opened since the beginning of epoch. Therefore, this should only be used if the circuit breaker is open.

Returns:long

time since last opening in milliseconds

getCurrentTimestampback to summary
public long getCurrentTimestamp()

Implements com.oracle.bmc.circuitbreaker.OciCircuitBreaker.getCurrentTimestamp.

Doc from com.oracle.bmc.circuitbreaker.OciCircuitBreaker.getCurrentTimestamp.

Returns the current time with respect to the CircuitBreaker currentTimeFunction. Returns System.nanoTime() by default.

Returns:long

current timestamp

Annotations
@Override
getHistoryback to summary
public synchronized List<OciCircuitBreaker.ErrorHistoryItem> getHistory()

Implements com.oracle.bmc.circuitbreaker.OciCircuitBreaker.getHistory.

Annotations
@Override
getHistoryAsStringback to summary
public synchronized String getHistoryAsString()

Implements com.oracle.bmc.circuitbreaker.OciCircuitBreaker.getHistoryAsString.

Annotations
@Override
getNameback to summary
public String getName()

Implements com.oracle.bmc.circuitbreaker.OciCircuitBreaker.getName.

Doc from com.oracle.bmc.circuitbreaker.OciCircuitBreaker.getName.

Returns the name of this CircuitBreaker.

Returns:String

the name of this CircuitBreaker

Annotations
@Override
getR4jCircuitBreakerback to summary
public CircuitBreaker getR4jCircuitBreaker()

Implements com.oracle.bmc.circuitbreaker.OciCircuitBreaker.getR4jCircuitBreaker.

Annotations
@Override
getStateback to summary
public CircuitBreaker.State getState()

Implements com.oracle.bmc.circuitbreaker.OciCircuitBreaker.getState.

Doc from com.oracle.bmc.circuitbreaker.OciCircuitBreaker.getState.

Returns the state of this CircuitBreaker.

Returns:CircuitBreaker.State

the state of this CircuitBreaker

Annotations
@Override
getTimestampUnitback to summary
public TimeUnit getTimestampUnit()

Implements com.oracle.bmc.circuitbreaker.OciCircuitBreaker.getTimestampUnit.

Doc from com.oracle.bmc.circuitbreaker.OciCircuitBreaker.getTimestampUnit.

Returns the timeUnit of current timestamp. Default is TimeUnit.NANOSECONDS.

Returns:TimeUnit

the timeUnit of current timestamp

Annotations
@Override
hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Doc from java.lang.Object.hashCode.

Returns a hash code value for this object. This method is supported for the benefit of hash tables such as those provided by java.util.HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
Returns:int

a hash code value for this object

Annotations
@Override
onErrorback to summary
public void onError(long duration, TimeUnit durationUnit, Throwable throwable)

Implements com.oracle.bmc.circuitbreaker.OciCircuitBreaker.onError.

Doc from com.oracle.bmc.circuitbreaker.OciCircuitBreaker.onError.

Records a failed call. This method must be invoked when a call failed.

Parameters
duration:long

The elapsed time duration of the call

durationUnit:TimeUnit

The duration unit

throwable:Throwable

The throwable which must be recorded

Annotations
@Override
onResultback to summary
public void onResult(long duration, TimeUnit durationUnit, Object result)

Implements com.oracle.bmc.circuitbreaker.OciCircuitBreaker.onResult.

Doc from com.oracle.bmc.circuitbreaker.OciCircuitBreaker.onResult.

This method must be invoked when a call returned a result and the result predicate should decide if the call was successful or not.

Parameters
duration:long

The elapsed time duration of the call

durationUnit:TimeUnit

The duration unit

result:Object

The result of the protected function

Annotations
@Override
onSuccessback to summary
public void onSuccess(long duration, TimeUnit durationUnit)

Implements com.oracle.bmc.circuitbreaker.OciCircuitBreaker.onSuccess.

Doc from com.oracle.bmc.circuitbreaker.OciCircuitBreaker.onSuccess.

Records a successful call. This method must be invoked when a call was successful.

Parameters
duration:long

The elapsed time duration of the call

durationUnit:TimeUnit

The duration unit

Annotations
@Override
releasePermissionback to summary
public void releasePermission()

Implements com.oracle.bmc.circuitbreaker.OciCircuitBreaker.releasePermission.

Doc from com.oracle.bmc.circuitbreaker.OciCircuitBreaker.releasePermission.

Releases a permission.

Should only be used when a permission was acquired but not used. Otherwise use CircuitBreaker#onSuccess(long, TimeUnit) or CircuitBreaker#onError(long, TimeUnit, Throwable) to signal a completed or failed call.

If the state is HALF_OPEN, the number of allowed test calls is increased by one.

Annotations
@Override
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Returns:String

a string representation of the object

Annotations
@Override
tryAcquirePermissionback to summary
public boolean tryAcquirePermission()

Implements com.oracle.bmc.circuitbreaker.OciCircuitBreaker.tryAcquirePermission.

Doc from com.oracle.bmc.circuitbreaker.OciCircuitBreaker.tryAcquirePermission.

Acquires a permission to execute a call, only if one is available at the time of invocation. If a call is not permitted, the number of not permitted calls is increased.

Returns false when the state is OPEN or FORCED_OPEN. Returns true when the state is CLOSED or DISABLED. Returns true when the state is HALF_OPEN and further test calls are allowed. Returns false when the state is HALF_OPEN and the number of test calls has been reached. If the state is HALF_OPEN, the number of allowed test calls is decreased.

Important Note

Make sure to call onSuccess or onError after the call is finished. If the call is cancelled before it is invoked, you have to release the permission again.

Returns:boolean

true if a permission was acquired and false otherwise

Annotations
@Override
com.oracle.bmc.circuitbreaker.internal.resilience4j back to summary

public Class OciCircuitBreakerImpl.OciCircuitBreakerConfigImpl

extends Object
implements Config
Class Inheritance
  • java.lang.Object
  • com.oracle.bmc.circuitbreaker.internal.resilience4j.OciCircuitBreakerImpl.OciCircuitBreakerConfigImpl
All Implemented Interfaces
com.oracle.bmc.circuitbreaker.OciCircuitBreaker.Config

Field Summary

Modifier and TypeField and Description
private final CircuitBreakerConfig

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public boolean
equals(Object
the reference object with which to compare.
o
)

Overrides java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

public Function<Clock, Long>
public float
public Predicate<Throwable>
public Duration
public int
public int
public Predicate<Throwable>
public Predicate<Object>
public int
public OciCircuitBreaker.Config.SlidingWindowType
public Duration
public float
public TimeUnit
public OciCircuitBreaker.Config.IntervalFunction
public int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for this object.

public boolean
public boolean
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAllwaitwaitwait

Field Detail

r4jConfigback to summary
private final CircuitBreakerConfig r4jConfig

Constructor Detail

OciCircuitBreakerConfigImplback to summary
public OciCircuitBreakerConfigImpl(CircuitBreakerConfig r4jConfig)

Method Detail

equalsback to summary
public boolean equals(Object o)

Overrides java.lang.Object.equals.

Doc from java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.

Parameters
o:Object

the reference object with which to compare.

Returns:boolean

true if this object is the same as the obj argument; false otherwise.

Annotations
@Override
getCurrentTimestampFunctionback to summary
public Function<Clock, Long> getCurrentTimestampFunction()
getFailureRateThresholdback to summary
public float getFailureRateThreshold()

Implements com.oracle.bmc.circuitbreaker.OciCircuitBreaker.Config.getFailureRateThreshold.

Annotations
@Override
getIgnoreExceptionPredicateback to summary
public Predicate<Throwable> getIgnoreExceptionPredicate()
getMaxWaitDurationInHalfOpenStateback to summary
public Duration getMaxWaitDurationInHalfOpenState()
getMinimumNumberOfCallsback to summary
public int getMinimumNumberOfCalls()

Implements com.oracle.bmc.circuitbreaker.OciCircuitBreaker.Config.getMinimumNumberOfCalls.

Annotations
@Override
getPermittedNumberOfCallsInHalfOpenStateback to summary
public int getPermittedNumberOfCallsInHalfOpenState()

Implements com.oracle.bmc.circuitbreaker.OciCircuitBreaker.Config.getPermittedNumberOfCallsInHalfOpenState.

Annotations
@Override
getRecordExceptionPredicateback to summary
public Predicate<Throwable> getRecordExceptionPredicate()

Implements com.oracle.bmc.circuitbreaker.OciCircuitBreaker.Config.getRecordExceptionPredicate.

Annotations
@Override
getRecordResultPredicateback to summary
public Predicate<Object> getRecordResultPredicate()
getSlidingWindowSizeback to summary
public int getSlidingWindowSize()

Implements com.oracle.bmc.circuitbreaker.OciCircuitBreaker.Config.getSlidingWindowSize.

Annotations
@Override
getSlidingWindowTypeback to summary
public OciCircuitBreaker.Config.SlidingWindowType getSlidingWindowType()

Implements com.oracle.bmc.circuitbreaker.OciCircuitBreaker.Config.getSlidingWindowType.

Annotations
@Override
getSlowCallDurationThresholdback to summary
public Duration getSlowCallDurationThreshold()

Implements com.oracle.bmc.circuitbreaker.OciCircuitBreaker.Config.getSlowCallDurationThreshold.

Annotations
@Override
getSlowCallRateThresholdback to summary
public float getSlowCallRateThreshold()

Implements com.oracle.bmc.circuitbreaker.OciCircuitBreaker.Config.getSlowCallRateThreshold.

Annotations
@Override
getTimestampUnitback to summary
public TimeUnit getTimestampUnit()
getWaitIntervalFunctionInOpenStateback to summary
public OciCircuitBreaker.Config.IntervalFunction getWaitIntervalFunctionInOpenState()
hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Doc from java.lang.Object.hashCode.

Returns a hash code value for this object. This method is supported for the benefit of hash tables such as those provided by java.util.HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
Returns:int

a hash code value for this object

Annotations
@Override
isAutomaticTransitionFromOpenToHalfOpenEnabledback to summary
public boolean isAutomaticTransitionFromOpenToHalfOpenEnabled()
isWritableStackTraceEnabledback to summary
public boolean isWritableStackTraceEnabled()

Implements com.oracle.bmc.circuitbreaker.OciCircuitBreaker.Config.isWritableStackTraceEnabled.

Annotations
@Override
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Returns:String

a string representation of the object

Annotations
@Override