Class 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
    • Constructor Detail

      • FixedThreadPoolBulkhead

        public FixedThreadPoolBulkhead​(java.lang.String name,
                                       @Nullable
                                       ThreadPoolBulkheadConfig bulkheadConfig)
        Creates a bulkhead using a configuration supplied
        Parameters:
        name - the name of this bulkhead
        bulkheadConfig - 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 bulkhead
        bulkheadConfig - custom bulkhead configuration
        tags - 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 bulkhead
        configSupplier - 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 bulkhead
        configSupplier - BulkheadConfig supplier
    • Method Detail

      • submit

        public <T> java.util.concurrent.CompletableFuture<T> submit​(java.util.concurrent.Callable<T> callable)
        Submits a value-returning task for execution and returns a CompletionStage representing the asynchronous computation of the task.
        Specified by:
        submit in interface ThreadPoolBulkhead
        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 BulkheadFullException when 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 a CompletionStage representing the asynchronous computation of the task.
        Specified by:
        submit in interface ThreadPoolBulkhead
        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:
        getName in interface ThreadPoolBulkhead
        Returns:
        the name 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:
        getTags in interface ThreadPoolBulkhead
        Returns:
        the tags assigned to this Retry in an unmodifiable map
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • close

        public void close()
        Specified by:
        close in interface java.lang.AutoCloseable