Top Inners Methods
com.oracle.bmc.circuitbreaker

public Interface OciCircuitBreaker

Known Direct Implementers
com.oracle.bmc.circuitbreaker.internal.resilience4j.OciCircuitBreakerImpl
Imports
java.time.Duration, java.util.List, .Map, java.util.concurrent.TimeUnit, java.util.function.Function, .Predicate, io.github.resilience4j.circuitbreaker.CallNotPermittedException, .CircuitBreaker

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static interface
public static class

Method Summary

Modifier and TypeMethod and Description
public void
acquirePermission()

Try to obtain a permission to execute a call.

public void
addToHistory(Throwable throwable, Integer status, Map<String, String> messages)

public String
public CallNotAllowedException
public OciCircuitBreaker.Config

Returns:

the CircuitBreakerConfig of this CircuitBreaker
getCircuitBreakerConfig
()

Returns the CircuitBreakerConfig of this CircuitBreaker.

public long

Returns:

current timestamp
getCurrentTimestamp
()

Returns the current time with respect to the CircuitBreaker currentTimeFunction.

public List<OciCircuitBreaker.ErrorHistoryItem>
public String
public String

Returns:

the name of this CircuitBreaker
getName
()

Returns the name of this CircuitBreaker.

public CircuitBreaker
public CircuitBreaker.State

Returns:

the state of this CircuitBreaker
getState
()

Returns the state of this CircuitBreaker.

public TimeUnit

Returns:

the timeUnit of current timestamp
getTimestampUnit
()

Returns the timeUnit of current timestamp.

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
)

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
)

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
)

Records a successful call.

public void
releasePermission()

Releases a permission.

public boolean

Returns:

true if a permission was acquired and false otherwise
tryAcquirePermission
()

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

Method Detail

acquirePermissionback to summary
public void 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.

Exceptions
CallNotPermittedException:
when CircuitBreaker is OPEN or HALF_OPEN and no further test calls are permitted.
addToHistoryback to summary
public void addToHistory(Throwable throwable, Integer status, Map<String, String> messages)
circuitBreakerCallNotPermittedErrorMessageback to summary
public String circuitBreakerCallNotPermittedErrorMessage(String requestUri)
createCallNotAllowedExceptionback to summary
public CallNotAllowedException createCallNotAllowedException()
getCircuitBreakerConfigback to summary
public OciCircuitBreaker.Config getCircuitBreakerConfig()

Returns the CircuitBreakerConfig of this CircuitBreaker.

Returns:OciCircuitBreaker.Config

the CircuitBreakerConfig of this CircuitBreaker

getCurrentTimestampback to summary
public long getCurrentTimestamp()

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

Returns:long

current timestamp

getHistoryback to summary
public List<OciCircuitBreaker.ErrorHistoryItem> getHistory()
getHistoryAsStringback to summary
public String getHistoryAsString()
getNameback to summary
public String getName()

Returns the name of this CircuitBreaker.

Returns:String

the name of this CircuitBreaker

getR4jCircuitBreakerback to summary
public CircuitBreaker getR4jCircuitBreaker()
getStateback to summary
public CircuitBreaker.State getState()

Returns the state of this CircuitBreaker.

Returns:CircuitBreaker.State

the state of this CircuitBreaker

getTimestampUnitback to summary
public TimeUnit getTimestampUnit()

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

Returns:TimeUnit

the timeUnit of current timestamp

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

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

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

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

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

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

releasePermissionback to summary
public void 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.

tryAcquirePermissionback to summary
public boolean 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

com.oracle.bmc.circuitbreaker back to summary

public Interface OciCircuitBreaker.Config

Known Direct Implementers
com.oracle.bmc.circuitbreaker.internal.resilience4j.OciCircuitBreakerImpl.OciCircuitBreakerConfigImpl

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static interface
OciCircuitBreaker.Config.IntervalFunction

An IntervalFunction which can be used to calculate the wait interval.

public static enum

Method Summary

Modifier and TypeMethod and Description
public float
public int
public int
public Predicate<Throwable>
public int
public OciCircuitBreaker.Config.SlidingWindowType
public Duration
public float
public boolean

Method Detail

getFailureRateThresholdback to summary
public float getFailureRateThreshold()
getMinimumNumberOfCallsback to summary
public int getMinimumNumberOfCalls()
getPermittedNumberOfCallsInHalfOpenStateback to summary
public int getPermittedNumberOfCallsInHalfOpenState()
getRecordExceptionPredicateback to summary
public Predicate<Throwable> getRecordExceptionPredicate()
getSlidingWindowSizeback to summary
public int getSlidingWindowSize()
getSlidingWindowTypeback to summary
public OciCircuitBreaker.Config.SlidingWindowType getSlidingWindowType()
getSlowCallDurationThresholdback to summary
public Duration getSlowCallDurationThreshold()
getSlowCallRateThresholdback to summary
public float getSlowCallRateThreshold()
isWritableStackTraceEnabledback to summary
public boolean isWritableStackTraceEnabled()
com.oracle.bmc.circuitbreaker back to summary

public Interface OciCircuitBreaker.Config.IntervalFunction

extends Function<Integer, Long>
Annotations
@FunctionalInterface

An IntervalFunction which can be used to calculate the wait interval. The input parameter of the function is the number of attempts (attempt), the output parameter the wait interval in milliseconds. The attempt parameter starts at 1 and increases with every further attempt.
com.oracle.bmc.circuitbreaker back to summary

public final Enum OciCircuitBreaker.Config.SlidingWindowType

extends Enum<OciCircuitBreaker.Config.SlidingWindowType>
Class Inheritance

Field Summary

Modifier and TypeField and Description
public static final OciCircuitBreaker.Config.SlidingWindowType
public static final OciCircuitBreaker.Config.SlidingWindowType

Constructor Summary

AccessConstructor and Description
private

Field Detail

COUNT_BASEDback to summary
public static final OciCircuitBreaker.Config.SlidingWindowType COUNT_BASED
TIME_BASEDback to summary
public static final OciCircuitBreaker.Config.SlidingWindowType TIME_BASED

Constructor Detail

SlidingWindowTypeback to summary
private SlidingWindowType()

Method Detail

valueOfback to summary
public static OciCircuitBreaker.Config.SlidingWindowType valueOf(String name)
valuesback to summary
public static OciCircuitBreaker.Config.SlidingWindowType[] values()
com.oracle.bmc.circuitbreaker back to summary

public Class OciCircuitBreaker.ErrorHistoryItem

extends Object
Class Inheritance
  • java.lang.Object
  • com.oracle.bmc.circuitbreaker.OciCircuitBreaker.ErrorHistoryItem

Field Summary

Modifier and TypeField and Description
private final Map<String, String>
private final Integer
private final Throwable

Constructor Summary

AccessConstructor and Description
public
ErrorHistoryItem(Throwable throwable, Integer status, Map<String, String> messages)

Method Summary

Modifier and TypeMethod and Description
public Map<String, String>
public int
public Throwable
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

messagesback to summary
private final Map<String, String> messages
statusback to summary
private final Integer status
throwableback to summary
private final Throwable throwable

Constructor Detail

ErrorHistoryItemback to summary
public ErrorHistoryItem(Throwable throwable, Integer status, Map<String, String> messages)

Method Detail

getMessagesback to summary
public Map<String, String> getMessages()
getStatusback to summary
public int getStatus()
getThrowableback to summary
public Throwable getThrowable()
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