SimpleChannelPool Class — netty Architecture
Architecture documentation for the SimpleChannelPool class in SimpleChannelPool.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD e441b5b0_fbd9_848c_9624_3e21f7c56e58["SimpleChannelPool"] 1bea672a_b007_6ef8_802d_63150ec1b96e["SimpleChannelPool.java"] e441b5b0_fbd9_848c_9624_3e21f7c56e58 -->|defined in| 1bea672a_b007_6ef8_802d_63150ec1b96e 0eed62a7_87e2_7965_0da2_174f1ef5f226["SimpleChannelPool()"] e441b5b0_fbd9_848c_9624_3e21f7c56e58 -->|method| 0eed62a7_87e2_7965_0da2_174f1ef5f226 8fad4656_9c7b_cda9_e393_fcbce09ed735["Bootstrap()"] e441b5b0_fbd9_848c_9624_3e21f7c56e58 -->|method| 8fad4656_9c7b_cda9_e393_fcbce09ed735 36bd970c_3aee_9d1b_59a4_a0d9e677dc37["ChannelPoolHandler()"] e441b5b0_fbd9_848c_9624_3e21f7c56e58 -->|method| 36bd970c_3aee_9d1b_59a4_a0d9e677dc37 54137349_08a1_ef52_c6b5_7683de96cc05["ChannelHealthChecker()"] e441b5b0_fbd9_848c_9624_3e21f7c56e58 -->|method| 54137349_08a1_ef52_c6b5_7683de96cc05 7541b4c3_c7f2_4239_4e0f_8d50736a9a5b["releaseHealthCheck()"] e441b5b0_fbd9_848c_9624_3e21f7c56e58 -->|method| 7541b4c3_c7f2_4239_4e0f_8d50736a9a5b 4dfbb6a3_fad3_e1b0_2d99_91320e356877["acquire()"] e441b5b0_fbd9_848c_9624_3e21f7c56e58 -->|method| 4dfbb6a3_fad3_e1b0_2d99_91320e356877 c89f5af0_c810_693d_6240_cf574acc05b1["acquireHealthyFromPoolOrNew()"] e441b5b0_fbd9_848c_9624_3e21f7c56e58 -->|method| c89f5af0_c810_693d_6240_cf574acc05b1 d8986b0c_0cd0_31a4_8611_1debe6366195["notifyConnect()"] e441b5b0_fbd9_848c_9624_3e21f7c56e58 -->|method| d8986b0c_0cd0_31a4_8611_1debe6366195 b79f6ac0_3d07_2cc1_f3d6_7ca1488e3fa0["doHealthCheck()"] e441b5b0_fbd9_848c_9624_3e21f7c56e58 -->|method| b79f6ac0_3d07_2cc1_f3d6_7ca1488e3fa0 7ba4c5b6_3e78_dd98_af42_a908940f0803["notifyHealthCheck()"] e441b5b0_fbd9_848c_9624_3e21f7c56e58 -->|method| 7ba4c5b6_3e78_dd98_af42_a908940f0803 45f63cf0_56c6_82f4_ac4c_14b9f9e5e988["ChannelFuture()"] e441b5b0_fbd9_848c_9624_3e21f7c56e58 -->|method| 45f63cf0_56c6_82f4_ac4c_14b9f9e5e988 f7de2118_7e0e_1138_b047_455dbc2dd98f["release()"] e441b5b0_fbd9_848c_9624_3e21f7c56e58 -->|method| f7de2118_7e0e_1138_b047_455dbc2dd98f edd5c18f_fdf6_5dbc_4d9f_3143ea1106e2["doReleaseChannel()"] e441b5b0_fbd9_848c_9624_3e21f7c56e58 -->|method| edd5c18f_fdf6_5dbc_4d9f_3143ea1106e2
Relationship Graph
Source Code
transport/src/main/java/io/netty/channel/pool/SimpleChannelPool.java lines 43–425
public class SimpleChannelPool implements ChannelPool {
private static final AttributeKey<SimpleChannelPool> POOL_KEY =
AttributeKey.newInstance("io.netty.channel.pool.SimpleChannelPool");
private final Deque<Channel> deque = PlatformDependent.newConcurrentDeque();
private final ChannelPoolHandler handler;
private final ChannelHealthChecker healthCheck;
private final Bootstrap bootstrap;
private final boolean releaseHealthCheck;
private final boolean lastRecentUsed;
/**
* 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
*/
public SimpleChannelPool(Bootstrap bootstrap, final ChannelPoolHandler handler) {
this(bootstrap, handler, ChannelHealthChecker.ACTIVE);
}
/**
* 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}
*/
public SimpleChannelPool(Bootstrap bootstrap, final ChannelPoolHandler handler, ChannelHealthChecker healthCheck) {
this(bootstrap, handler, healthCheck, true);
}
/**
* 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 releaseHealthCheck will check channel health before offering back if this parameter set to {@code true};
* otherwise, channel health is only checked at acquisition time
*/
public SimpleChannelPool(Bootstrap bootstrap, final ChannelPoolHandler handler, ChannelHealthChecker healthCheck,
boolean releaseHealthCheck) {
this(bootstrap, handler, healthCheck, releaseHealthCheck, true);
}
/**
* 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 releaseHealthCheck will check channel health before offering back if this parameter set to {@code true};
* otherwise, channel health is only checked at acquisition time
* @param lastRecentUsed {@code true} {@link Channel} selection will be LIFO, if {@code false} FIFO.
*/
public SimpleChannelPool(Bootstrap bootstrap, final ChannelPoolHandler handler, ChannelHealthChecker healthCheck,
boolean releaseHealthCheck, boolean lastRecentUsed) {
this.handler = checkNotNull(handler, "handler");
this.healthCheck = checkNotNull(healthCheck, "healthCheck");
this.releaseHealthCheck = releaseHealthCheck;
// Clone the original Bootstrap as we want to set our own handler
this.bootstrap = checkNotNull(bootstrap, "bootstrap").clone();
this.bootstrap.handler(new ChannelInitializer<Channel>() {
@Override
protected void initChannel(Channel ch) throws Exception {
assert ch.eventLoop().inEventLoop();
handler.channelCreated(ch);
}
});
this.lastRecentUsed = lastRecentUsed;
}
/**
* Returns the {@link Bootstrap} this pool will use to open new connections.
*
* @return the {@link Bootstrap} this pool will use to open new connections
*/
protected Bootstrap bootstrap() {
Source
Frequently Asked Questions
What is the SimpleChannelPool class?
SimpleChannelPool is a class in the netty codebase, defined in transport/src/main/java/io/netty/channel/pool/SimpleChannelPool.java.
Where is SimpleChannelPool defined?
SimpleChannelPool is defined in transport/src/main/java/io/netty/channel/pool/SimpleChannelPool.java at line 43.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free