Home / Class/ DefaultChannelPipeline Class — netty Architecture

DefaultChannelPipeline Class — netty Architecture

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

Entity Profile

Dependency Diagram

graph TD
  12185bde_01b4_fad0_496c_1d27b952b797["DefaultChannelPipeline"]
  c48eeee1_03a5_bd10_43c4_393bf83109a4["DefaultChannelPipeline.java"]
  12185bde_01b4_fad0_496c_1d27b952b797 -->|defined in| c48eeee1_03a5_bd10_43c4_393bf83109a4
  c2488dcc_c8a3_4c65_c739_5dfffc4edac7["DefaultChannelPipeline()"]
  12185bde_01b4_fad0_496c_1d27b952b797 -->|method| c2488dcc_c8a3_4c65_c739_5dfffc4edac7
  c151655c_8e6e_1f13_ceb0_fde3a81d1b10["estimatorHandle()"]
  12185bde_01b4_fad0_496c_1d27b952b797 -->|method| c151655c_8e6e_1f13_ceb0_fde3a81d1b10
  6f996fde_21a4_96f5_9480_ec87b3412033["Object()"]
  12185bde_01b4_fad0_496c_1d27b952b797 -->|method| 6f996fde_21a4_96f5_9480_ec87b3412033
  db926aac_1541_ffd1_034b_e9ba25b48455["AbstractChannelHandlerContext()"]
  12185bde_01b4_fad0_496c_1d27b952b797 -->|method| db926aac_1541_ffd1_034b_e9ba25b48455
  377e0ed3_6041_b33d_69d8_e0cc1d1401dc["EventExecutor()"]
  12185bde_01b4_fad0_496c_1d27b952b797 -->|method| 377e0ed3_6041_b33d_69d8_e0cc1d1401dc
  0c1546d8_fcf4_c930_d3ee_9f24e781f648["Channel()"]
  12185bde_01b4_fad0_496c_1d27b952b797 -->|method| 0c1546d8_fcf4_c930_d3ee_9f24e781f648
  456303ff_99e9_46dc_1dd4_e08abd32e132["ChannelPipeline()"]
  12185bde_01b4_fad0_496c_1d27b952b797 -->|method| 456303ff_99e9_46dc_1dd4_e08abd32e132
  eb606ef9_2612_d6dc_9fa4_d64680191aba["addFirst0()"]
  12185bde_01b4_fad0_496c_1d27b952b797 -->|method| eb606ef9_2612_d6dc_9fa4_d64680191aba
  12fce99f_80b0_59f8_18d4_107577e45450["addLast0()"]
  12185bde_01b4_fad0_496c_1d27b952b797 -->|method| 12fce99f_80b0_59f8_18d4_107577e45450
  5fdeeefd_6b33_50dd_210a_35a678d0b01a["addBefore0()"]
  12185bde_01b4_fad0_496c_1d27b952b797 -->|method| 5fdeeefd_6b33_50dd_210a_35a678d0b01a
  5ac42c9c_cb72_22f7_2d25_8faa7694336a["String()"]
  12185bde_01b4_fad0_496c_1d27b952b797 -->|method| 5ac42c9c_cb72_22f7_2d25_8faa7694336a
  87c66ab0_6f40_2b0c_acb6_5fb7f57e577b["addAfter0()"]
  12185bde_01b4_fad0_496c_1d27b952b797 -->|method| 87c66ab0_6f40_2b0c_acb6_5fb7f57e577b
  53925787_6b4f_0476_dece_0db30a06101e["ChannelHandler()"]
  12185bde_01b4_fad0_496c_1d27b952b797 -->|method| 53925787_6b4f_0476_dece_0db30a06101e

Relationship Graph

Source Code

transport/src/main/java/io/netty/channel/DefaultChannelPipeline.java lines 45–1530

public class DefaultChannelPipeline implements ChannelPipeline {

    static final InternalLogger logger = InternalLoggerFactory.getInstance(DefaultChannelPipeline.class);

    private static final String HEAD_NAME = generateName0(HeadContext.class);
    private static final String TAIL_NAME = generateName0(TailContext.class);

    private static final FastThreadLocal<Map<Class<?>, String>> nameCaches =
            new FastThreadLocal<Map<Class<?>, String>>() {
        @Override
        protected Map<Class<?>, String> initialValue() {
            return new WeakHashMap<Class<?>, String>();
        }
    };

    private static final AtomicReferenceFieldUpdater<DefaultChannelPipeline, MessageSizeEstimator.Handle> ESTIMATOR =
            AtomicReferenceFieldUpdater.newUpdater(
                    DefaultChannelPipeline.class, MessageSizeEstimator.Handle.class, "estimatorHandle");
    final HeadContext head;
    final TailContext tail;

    private final Channel channel;
    private final ChannelFuture succeededFuture;
    private final VoidChannelPromise voidPromise;
    private final boolean touch = ResourceLeakDetector.isEnabled();

    private Map<EventExecutorGroup, EventExecutor> childExecutors;
    private volatile MessageSizeEstimator.Handle estimatorHandle;
    private boolean firstRegistration = true;

    /**
     * This is the head of a linked list that is processed by {@link #callHandlerAddedForAllHandlers()} and so process
     * all the pending {@link #callHandlerAdded0(AbstractChannelHandlerContext)}.
     * <p>
     * We only keep the head because it is expected that the list is used infrequently and its size is small.
     * Thus full iterations to do insertions is assumed to be a good compromised to saving memory and tail management
     * complexity.
     */
    private PendingHandlerCallback pendingHandlerCallbackHead;

    /**
     * Set to {@code true} once the {@link AbstractChannel} is registered.Once set to {@code true} the value will never
     * change.
     */
    private boolean registered;

    protected DefaultChannelPipeline(Channel channel) {
        this.channel = ObjectUtil.checkNotNull(channel, "channel");
        succeededFuture = new SucceededChannelFuture(channel, null);
        voidPromise = new VoidChannelPromise(channel, true);

        tail = new TailContext(this);
        head = new HeadContext(this);

        head.next = tail;
        tail.prev = head;
    }

    final MessageSizeEstimator.Handle estimatorHandle() {
        MessageSizeEstimator.Handle handle = estimatorHandle;
        if (handle == null) {
            handle = channel.config().getMessageSizeEstimator().newHandle();
            if (!ESTIMATOR.compareAndSet(this, null, handle)) {
                handle = estimatorHandle;
            }
        }
        return handle;
    }

    final Object touch(Object msg, AbstractChannelHandlerContext next) {
        return touch ? ReferenceCountUtil.touch(msg, next) : msg;
    }

    private AbstractChannelHandlerContext newContext(EventExecutorGroup group, String name, ChannelHandler handler) {
        return new DefaultChannelHandlerContext(this, childExecutor(group), name, handler);
    }

    private EventExecutor childExecutor(EventExecutorGroup group) {
        if (group == null) {
            return null;
        }

Frequently Asked Questions

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

Analyze Your Own Codebase

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

Try Supermodel Free