Class FixedThreadPoolBulkhead
java.lang.Object
io.github.resilience4j.bulkhead.internal.FixedThreadPoolBulkhead
- All Implemented Interfaces:
ThreadPoolBulkhead,java.lang.AutoCloseable
public class FixedThreadPoolBulkhead extends java.lang.Object implements ThreadPoolBulkhead
A Bulkhead implementation based on a fixed ThreadPoolExecutor. which is based into the thread
pool execution handling : 1- submit service call through bulk head thread pool 2- if there is
free thread from the thread pool or the queue is not yet full , it will be permitted 3- otherwise
the thread pool will throw RejectedExecutionException which mean is not permitted
-
Nested Class Summary
Nested classes/interfaces inherited from interface io.github.resilience4j.bulkhead.ThreadPoolBulkhead
ThreadPoolBulkhead.Metrics, ThreadPoolBulkhead.ThreadPoolBulkheadEventPublisher -
Constructor Summary
Constructors Constructor Description FixedThreadPoolBulkhead(java.lang.String name)Creates a bulkhead with a default config.FixedThreadPoolBulkhead(java.lang.String name, ThreadPoolBulkheadConfig bulkheadConfig)Creates a bulkhead using a configuration suppliedFixedThreadPoolBulkhead(java.lang.String name, ThreadPoolBulkheadConfig bulkheadConfig, io.vavr.collection.Map<java.lang.String,java.lang.String> tags)Creates a bulkhead using a configuration suppliedFixedThreadPoolBulkhead(java.lang.String name, io.vavr.collection.Map<java.lang.String,java.lang.String> tags)Creates a bulkhead with a default config.FixedThreadPoolBulkhead(java.lang.String name, java.util.function.Supplier<ThreadPoolBulkheadConfig> configSupplier)Create a bulkhead using a configuration supplierFixedThreadPoolBulkhead(java.lang.String name, java.util.function.Supplier<ThreadPoolBulkheadConfig> configSupplier, io.vavr.collection.Map<java.lang.String,java.lang.String> tags)Create a bulkhead using a configuration supplier -
Method Summary
Modifier and Type Method Description voidclose()ThreadPoolBulkheadConfiggetBulkheadConfig()Returns the ThreadPoolBulkheadConfig of this Bulkhead.ThreadPoolBulkhead.ThreadPoolBulkheadEventPublishergetEventPublisher()Returns an EventPublisher which subscribes to the reactive stream of BulkheadEvent and can be used to register event consumers.ThreadPoolBulkhead.MetricsgetMetrics()Get the Metrics of this Bulkhead.java.lang.StringgetName()Returns the name of this bulkhead.io.vavr.collection.Map<java.lang.String,java.lang.String>getTags()Returns an unmodifiable map with tags assigned to this Retry.java.util.concurrent.CompletableFuture<java.lang.Void>submit(java.lang.Runnable runnable)Submits a task for execution to the ThreadPoolBulkhead and returns aCompletionStagerepresenting the asynchronous computation of the task.<T> java.util.concurrent.CompletableFuture<T>submit(java.util.concurrent.Callable<T> callable)Submits a value-returning task for execution and returns aCompletionStagerepresenting the asynchronous computation of the task.java.lang.StringtoString()Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface io.github.resilience4j.bulkhead.ThreadPoolBulkhead
decorateCallable, decorateRunnable, decorateSupplier, executeCallable, executeRunnable, executeSupplier
-
Constructor Details
-
FixedThreadPoolBulkhead
public FixedThreadPoolBulkhead(java.lang.String name, @Nullable ThreadPoolBulkheadConfig bulkheadConfig)Creates a bulkhead using a configuration supplied- Parameters:
name- the name of this bulkheadbulkheadConfig- custom bulkhead configuration
-
FixedThreadPoolBulkhead
public FixedThreadPoolBulkhead(java.lang.String name, @Nullable ThreadPoolBulkheadConfig bulkheadConfig, io.vavr.collection.Map<java.lang.String,java.lang.String> tags)Creates a bulkhead using a configuration supplied- Parameters:
name- the name of this bulkheadbulkheadConfig- custom bulkhead configurationtags- tags to add to the Bulkhead
-
FixedThreadPoolBulkhead
public FixedThreadPoolBulkhead(java.lang.String name)Creates a bulkhead with a default config.- Parameters:
name- the name of this bulkhead
-
FixedThreadPoolBulkhead
public FixedThreadPoolBulkhead(java.lang.String name, io.vavr.collection.Map<java.lang.String,java.lang.String> tags)Creates a bulkhead with a default config.- Parameters:
name- the name of this bulkhead
-
FixedThreadPoolBulkhead
public FixedThreadPoolBulkhead(java.lang.String name, java.util.function.Supplier<ThreadPoolBulkheadConfig> configSupplier)Create a bulkhead using a configuration supplier- Parameters:
name- the name of this bulkheadconfigSupplier- BulkheadConfig supplier
-
FixedThreadPoolBulkhead
public FixedThreadPoolBulkhead(java.lang.String name, java.util.function.Supplier<ThreadPoolBulkheadConfig> configSupplier, io.vavr.collection.Map<java.lang.String,java.lang.String> tags)Create a bulkhead using a configuration supplier- Parameters:
name- the name of this bulkheadconfigSupplier- BulkheadConfig supplier
-
-
Method Details
-
submit
public <T> java.util.concurrent.CompletableFuture<T> submit(java.util.concurrent.Callable<T> callable)Submits a value-returning task for execution and returns aCompletionStagerepresenting the asynchronous computation of the task.- Specified by:
submitin interfaceThreadPoolBulkhead- Type Parameters:
T- the type of the task's result- Parameters:
callable- the value-returning task to submit- Returns:
- CompletionStage representing the asynchronous computation of the task. The CompletionStage is completed exceptionally with a
BulkheadFullExceptionwhen the task could not be submitted, because the Bulkhead was full
-
submit
public java.util.concurrent.CompletableFuture<java.lang.Void> submit(java.lang.Runnable runnable)Submits a task for execution to the ThreadPoolBulkhead and returns aCompletionStagerepresenting the asynchronous computation of the task.- Specified by:
submitin interfaceThreadPoolBulkhead- Parameters:
runnable- the task to submit- Returns:
- CompletionStage representing the asynchronous computation of the task.
-
getName
public java.lang.String getName()Returns the name of this bulkhead.- Specified by:
getNamein interfaceThreadPoolBulkhead- Returns:
- the name of this bulkhead
-
getBulkheadConfig
Returns the ThreadPoolBulkheadConfig of this Bulkhead.- Specified by:
getBulkheadConfigin interfaceThreadPoolBulkhead- Returns:
- bulkhead config
-
getMetrics
Get the Metrics of this Bulkhead.- Specified by:
getMetricsin interfaceThreadPoolBulkhead- Returns:
- the Metrics of this Bulkhead
-
getTags
public io.vavr.collection.Map<java.lang.String,java.lang.String> getTags()Returns an unmodifiable map with tags assigned to this Retry.- Specified by:
getTagsin interfaceThreadPoolBulkhead- Returns:
- the tags assigned to this Retry in an unmodifiable map
-
getEventPublisher
Returns an EventPublisher which subscribes to the reactive stream of BulkheadEvent and can be used to register event consumers.- Specified by:
getEventPublisherin interfaceThreadPoolBulkhead- Returns:
- an EventPublisher
-
toString
public java.lang.String toString()- Overrides:
toStringin classjava.lang.Object
-
close
public void close()- Specified by:
closein interfacejava.lang.AutoCloseable
-