Home / Class/ FixedChannelPool Class — netty Architecture

FixedChannelPool Class — netty Architecture

Architecture documentation for the FixedChannelPool class in FixedChannelPool.java from the netty codebase.

Entity Profile

Dependency Diagram

graph TD
  379a0f3e_d35d_8054_6f12_48a2cfebefb5["FixedChannelPool"]
  4b30891f_00e9_b07c_2218_4f447886cfdd["FixedChannelPool.java"]
  379a0f3e_d35d_8054_6f12_48a2cfebefb5 -->|defined in| 4b30891f_00e9_b07c_2218_4f447886cfdd
  042c49b1_3970_851b_6732_1c9d4df9b1bb["FixedChannelPool()"]
  379a0f3e_d35d_8054_6f12_48a2cfebefb5 -->|method| 042c49b1_3970_851b_6732_1c9d4df9b1bb
  ce62bad1_7020_b2b1_e8b7_27fd8e0ad946["acquiredChannelCount()"]
  379a0f3e_d35d_8054_6f12_48a2cfebefb5 -->|method| ce62bad1_7020_b2b1_e8b7_27fd8e0ad946
  1d51fd53_2c69_0470_07c7_4631383a891c["acquire()"]
  379a0f3e_d35d_8054_6f12_48a2cfebefb5 -->|method| 1d51fd53_2c69_0470_07c7_4631383a891c
  58ce3254_7910_e246_bd60_e2c3b0165bc0["acquire0()"]
  379a0f3e_d35d_8054_6f12_48a2cfebefb5 -->|method| 58ce3254_7910_e246_bd60_e2c3b0165bc0
  a905bd75_f3aa_5ff9_a666_21be6688b3a8["tooManyOutstanding()"]
  379a0f3e_d35d_8054_6f12_48a2cfebefb5 -->|method| a905bd75_f3aa_5ff9_a666_21be6688b3a8
  315745f1_dcf7_b5f2_a7bf_6256c54b99a0["release()"]
  379a0f3e_d35d_8054_6f12_48a2cfebefb5 -->|method| 315745f1_dcf7_b5f2_a7bf_6256c54b99a0
  21d08587_1275_d708_de67_34ff59c3d946["decrementAndRunTaskQueue()"]
  379a0f3e_d35d_8054_6f12_48a2cfebefb5 -->|method| 21d08587_1275_d708_de67_34ff59c3d946
  f449fa2c_e258_1aba_423a_5369445ba398["runTaskQueue()"]
  379a0f3e_d35d_8054_6f12_48a2cfebefb5 -->|method| f449fa2c_e258_1aba_423a_5369445ba398
  9ac1ba40_078b_abc6_6da9_14f7a9e33ed8["close()"]
  379a0f3e_d35d_8054_6f12_48a2cfebefb5 -->|method| 9ac1ba40_078b_abc6_6da9_14f7a9e33ed8
  82816a6e_9b06_c34a_e9c2_c740b5363f67["closeAsync()"]
  379a0f3e_d35d_8054_6f12_48a2cfebefb5 -->|method| 82816a6e_9b06_c34a_e9c2_c740b5363f67
  95e658c7_942f_e6e6_11e0_8027e4c5999a["close0()"]
  379a0f3e_d35d_8054_6f12_48a2cfebefb5 -->|method| 95e658c7_942f_e6e6_11e0_8027e4c5999a

Relationship Graph

Source Code

transport/src/main/java/io/netty/channel/pool/FixedChannelPool.java lines 42–526

public class FixedChannelPool extends SimpleChannelPool {

    public enum AcquireTimeoutAction {
        /**
         * Create a new connection when the timeout is detected.
         */
        NEW,

        /**
         * Fail the {@link Future} of the acquire call with a {@link TimeoutException}.
         */
        FAIL
    }

    private final EventExecutor executor;
    private final long acquireTimeoutNanos;
    private final Runnable timeoutTask;

    // There is no need to worry about synchronization as everything that modified the queue or counts is done
    // by the above EventExecutor.
    private final Queue<AcquireTask> pendingAcquireQueue = new ArrayDeque<AcquireTask>();
    private final int maxConnections;
    private final int maxPendingAcquires;
    private final AtomicInteger acquiredChannelCount = new AtomicInteger();
    private int pendingAcquireCount;
    private boolean closed;

    /**
     * Creates a new instance using the {@link ChannelHealthChecker#ACTIVE}.
     *
     * @param bootstrap         the {@link Bootstrap} that is used for connections
     * @param handler           the {@link ChannelPoolHandler} that will be notified for the different pool actions
     * @param maxConnections    the number of maximal active connections, once this is reached new tries to acquire
     *                          a {@link Channel} will be delayed until a connection is returned to the pool again.
     */
    public FixedChannelPool(Bootstrap bootstrap,
                            ChannelPoolHandler handler, int maxConnections) {
        this(bootstrap, handler, maxConnections, Integer.MAX_VALUE);
    }

    /**
     * Creates a new instance using the {@link ChannelHealthChecker#ACTIVE}.
     *
     * @param bootstrap             the {@link Bootstrap} that is used for connections
     * @param handler               the {@link ChannelPoolHandler} that will be notified for the different pool actions
     * @param maxConnections        the number of maximal active connections, once this is reached new tries to
     *                              acquire a {@link Channel} will be delayed until a connection is returned to the
     *                              pool again.
     * @param maxPendingAcquires    the maximum number of pending acquires. Once this is exceed acquire tries will
     *                              be failed.
     */
    public FixedChannelPool(Bootstrap bootstrap,
                            ChannelPoolHandler handler, int maxConnections, int maxPendingAcquires) {
        this(bootstrap, handler, ChannelHealthChecker.ACTIVE, null, -1, maxConnections, maxPendingAcquires);
    }

    /**
     * Creates a new instance.
     *
     * @param bootstrap             the {@link Bootstrap} that is used for connections
     * @param handler               the {@link ChannelPoolHandler} that will be notified for the different pool actions
     * @param healthCheck           the {@link ChannelHealthChecker} that will be used to check if a {@link Channel} is
     *                              still healthy when obtain from the {@link ChannelPool}
     * @param action                the {@link AcquireTimeoutAction} to use or {@code null} if non should be used.
     *                              In this case {@param acquireTimeoutMillis} must be {@code -1}.
     * @param acquireTimeoutMillis  the time (in milliseconds) after which an pending acquire must complete or
     *                              the {@link AcquireTimeoutAction} takes place.
     * @param maxConnections        the number of maximal active connections, once this is reached new tries to
     *                              acquire a {@link Channel} will be delayed until a connection is returned to the
     *                              pool again.
     * @param maxPendingAcquires    the maximum number of pending acquires. Once this is exceed acquire tries will
     *                              be failed.
     */
    public FixedChannelPool(Bootstrap bootstrap,
                            ChannelPoolHandler handler,
                            ChannelHealthChecker healthCheck, AcquireTimeoutAction action,
                            final long acquireTimeoutMillis,
                            int maxConnections, int maxPendingAcquires) {
        this(bootstrap, handler, healthCheck, action, acquireTimeoutMillis, maxConnections, maxPendingAcquires, true);
    }

Frequently Asked Questions

What is the FixedChannelPool class?
FixedChannelPool is a class in the netty codebase, defined in transport/src/main/java/io/netty/channel/pool/FixedChannelPool.java.
Where is FixedChannelPool defined?
FixedChannelPool is defined in transport/src/main/java/io/netty/channel/pool/FixedChannelPool.java at line 42.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free