Interface FaultToleranceMethodContext
-
- All Known Implementing Classes:
FaultToleranceMethodContextImpl
public interface FaultToleranceMethodContext
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static classFaultToleranceMethodContext.AsyncFuture
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description FaultToleranceMethodContextboundTo(jakarta.interceptor.InvocationContext context, FaultTolerancePolicy policy)voiddelay(long delayMillis)Delays the current thread by the given duration.voidendTrace()Ends the innermost trace.ObjectfallbackHandle(Class<? extends org.eclipse.microprofile.faulttolerance.FallbackHandler<?>> fallbackClass, Throwable ex)ObjectfallbackInvoke(Method fallbackMethod)Invokes the given fallbackMethodin the given context.BlockingQueue<Thread>getConcurrentExecutions()Get or create theBlockingQueuefor bulkhead.FaultToleranceMetricsgetMetrics()Returns theFaultToleranceMetricsto use.AtomicIntegergetQueuingOrRunningPopulation()Get the bulkhead thread count.CircuitBreakerStategetState()Get or create theCircuitBreakerState.Objectproceed()Proceeds execution to the annotated method body.voidrunAsynchronous(FaultToleranceMethodContext.AsyncFuture asyncResult, Callable<Object> task)Runs the task asynchronously and completes the given asyncResult with the its outcome.Future<?>runDelayed(long delayMillis, Runnable task)Runs a given task after a certain waiting time.voidtrace(String method)Starts tracing the given context named with the given method label.
-
-
-
Method Detail
-
boundTo
FaultToleranceMethodContext boundTo(jakarta.interceptor.InvocationContext context, FaultTolerancePolicy policy)
-
getMetrics
FaultToleranceMetrics getMetrics()
Returns theFaultToleranceMetricsto use.- Returns:
- the
FaultToleranceMetricsto use,FaultToleranceMetrics.DISABLEDwhen not enabled.
-
getState
CircuitBreakerState getState()
Get or create theCircuitBreakerState.- Returns:
- the created or existing state, or null if non existed and requestVolumeThreshold was null
-
getConcurrentExecutions
BlockingQueue<Thread> getConcurrentExecutions()
Get or create theBlockingQueuefor bulkhead.- Returns:
- the created or existing queue, or null if non existed and requestVolumeThreshold was null
-
getQueuingOrRunningPopulation
AtomicInteger getQueuingOrRunningPopulation()
Get the bulkhead thread count.- Returns:
- This are number of threads that are either waiting or running in the bulkhead.
-
delay
void delay(long delayMillis) throws InterruptedExceptionDelays the current thread by the given duration. The delay is traced.- Parameters:
delayMillis- the time to sleep in millisecondscontext- current context delayed- Throws:
InterruptedException- In case waiting is interrupted
-
runDelayed
Future<?> runDelayed(long delayMillis, Runnable task) throws Exception
Runs a given task after a certain waiting time.- Parameters:
delayMillis- time to wait in milliseconds before running the given tasktask- operation to run- Returns:
- A future that can be cancelled if the operation should no longer be run
- Throws:
Exception
-
runAsynchronous
void runAsynchronous(FaultToleranceMethodContext.AsyncFuture asyncResult, Callable<Object> task) throws RejectedExecutionException
Runs the task asynchronously and completes the given asyncResult with the its outcome.- Parameters:
asyncResult- a not yet completedCompletableFuturethat should receive the result of the operation when it is executedcontext- the currently processed context (for e.g. tracing)task- an operation that must compute a value of typeFutureorCompletionStage.- Throws:
RejectedExecutionException- In case the task could not be accepted for execution. Usually due to too many work in progress.
-
fallbackHandle
Object fallbackHandle(Class<? extends org.eclipse.microprofile.faulttolerance.FallbackHandler<?>> fallbackClass, Throwable ex) throws Exception
Invokes the instance of the givenFallbackHandlerClassdefined in the given context to handle the givenException.- Parameters:
fallbackClass- the type ofFallbackHandlerto resolve or instantiate and usecontext- the currently processed context to use for argumentsex- theExceptionthrown by the FT processing to handle by theFallbackHandler- Returns:
- the result returned by the invoked
FallbackHandler - Throws:
Exception- in case resolving, instantiating or invoking the handler method fails
-
fallbackInvoke
Object fallbackInvoke(Method fallbackMethod) throws Exception
Invokes the given fallbackMethodin the given context.
-
trace
void trace(String method)
Starts tracing the given context named with the given method label.- Parameters:
method- the label to use for the tracecontext- the currently processed context
-
endTrace
void endTrace()
Ends the innermost trace.
-
-