Home / Class/ QuicheQuicCodec Class — netty Architecture

QuicheQuicCodec Class — netty Architecture

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

Entity Profile

Dependency Diagram

graph TD
  2593916d_2b0e_6fcc_eac7_86416a14767c["QuicheQuicCodec"]
  ab83a64c_7878_eab7_686b_d8b8c33c49fb["QuicheQuicCodec.java"]
  2593916d_2b0e_6fcc_eac7_86416a14767c -->|defined in| ab83a64c_7878_eab7_686b_d8b8c33c49fb
  738ca782_19ea_5423_e6e2_efabe689286a["QuicheQuicCodec()"]
  2593916d_2b0e_6fcc_eac7_86416a14767c -->|method| 738ca782_19ea_5423_e6e2_efabe689286a
  3d3d7168_712f_f7d1_ecb6_406cb87af05b["isSharable()"]
  2593916d_2b0e_6fcc_eac7_86416a14767c -->|method| 3d3d7168_712f_f7d1_ecb6_406cb87af05b
  6423dd85_b093_9417_0b32_45f39193c584["QuicheQuicChannel()"]
  2593916d_2b0e_6fcc_eac7_86416a14767c -->|method| 6423dd85_b093_9417_0b32_45f39193c584
  9e15dc20_3de4_1ecb_b005_4375cfcd303e["addMapping()"]
  2593916d_2b0e_6fcc_eac7_86416a14767c -->|method| 9e15dc20_3de4_1ecb_b005_4375cfcd303e
  966b653b_5a97_7901_954c_a7dc1583b98b["removeMapping()"]
  2593916d_2b0e_6fcc_eac7_86416a14767c -->|method| 966b653b_5a97_7901_954c_a7dc1583b98b
  cd2cb80d_560e_bd85_bf59_69ce2ff31fa6["processDelayedRemoval()"]
  2593916d_2b0e_6fcc_eac7_86416a14767c -->|method| cd2cb80d_560e_bd85_bf59_69ce2ff31fa6
  9fb2cf4a_3a63_0c39_2d09_7f8c62278c50["removeChannel()"]
  2593916d_2b0e_6fcc_eac7_86416a14767c -->|method| 9fb2cf4a_3a63_0c39_2d09_7f8c62278c50
  24307ae7_ef66_5f99_dc3b_828bd055d6a7["addChannel()"]
  2593916d_2b0e_6fcc_eac7_86416a14767c -->|method| 24307ae7_ef66_5f99_dc3b_828bd055d6a7
  9f7dd003_5d12_34b8_1d67_5a8f65986b35["handlerAdded()"]
  2593916d_2b0e_6fcc_eac7_86416a14767c -->|method| 9f7dd003_5d12_34b8_1d67_5a8f65986b35
  aa1ee80e_2d3d_7b23_9847_8019e35536c8["handlerRemoved()"]
  2593916d_2b0e_6fcc_eac7_86416a14767c -->|method| aa1ee80e_2d3d_7b23_9847_8019e35536c8
  b4b40aa7_37e1_09d9_4fa6_f666164fe98d["channelRead()"]
  2593916d_2b0e_6fcc_eac7_86416a14767c -->|method| b4b40aa7_37e1_09d9_4fa6_f666164fe98d
  ff90365d_5709_977b_5a5e_bdd13a1e7dd8["handleQuicPacket()"]
  2593916d_2b0e_6fcc_eac7_86416a14767c -->|method| ff90365d_5709_977b_5a5e_bdd13a1e7dd8
  eb356f3e_b5bc_e7dc_c521_bdfa562a6d05["channelReadComplete()"]
  2593916d_2b0e_6fcc_eac7_86416a14767c -->|method| eb356f3e_b5bc_e7dc_c521_bdfa562a6d05

Relationship Graph

Source Code

codec-classes-quic/src/main/java/io/netty/handler/codec/quic/QuicheQuicCodec.java lines 42–380

abstract class QuicheQuicCodec extends ChannelDuplexHandler {
    private static final InternalLogger LOGGER = InternalLoggerFactory.getInstance(QuicheQuicCodec.class);
    private final ConnectionIdChannelMap connectionIdToChannel = new ConnectionIdChannelMap();
    private final Set<QuicheQuicChannel> channels = new HashSet<>();
    private final Queue<QuicheQuicChannel> needsFireChannelReadComplete = new ArrayDeque<>();
    private final Queue<QuicheQuicChannel> delayedRemoval = new ArrayDeque<>();

    private final Consumer<QuicheQuicChannel> freeTask = this::removeChannel;
    private final FlushStrategy flushStrategy;
    private final int localConnIdLength;
    private final QuicheConfig config;

    private MessageSizeEstimator.Handle estimatorHandle;
    private QuicHeaderParser headerParser;
    private QuicHeaderParser.QuicHeaderProcessor parserCallback;
    private int pendingBytes;
    private int pendingPackets;
    private boolean inChannelReadComplete;
    private boolean delayRemoval;

    // This buffer is used to copy InetSocketAddress to sockaddr_storage and so pass it down the JNI layer.
    private ByteBuf senderSockaddrMemory;
    private ByteBuf recipientSockaddrMemory;

    QuicheQuicCodec(QuicheConfig config, int localConnIdLength, FlushStrategy flushStrategy) {
        this.config = config;
        this.localConnIdLength = localConnIdLength;
        this.flushStrategy = flushStrategy;
    }

    @Override
    public final boolean isSharable() {
        return false;
    }

    @Nullable
    protected final QuicheQuicChannel getChannel(ByteBuffer key) {
        return connectionIdToChannel.get(key);
    }

    private void addMapping(QuicheQuicChannel channel, ByteBuffer id) {
        QuicheQuicChannel ch = connectionIdToChannel.put(id, channel);
        assert ch == null || ch == channel;
    }

    private void removeMapping(QuicheQuicChannel channel, ByteBuffer id) {
        QuicheQuicChannel ch = connectionIdToChannel.remove(id);
        assert ch == channel;
    }

    private void processDelayedRemoval() {
        for (;;) {
            // Now remove all channels that we marked for removal.
            QuicheQuicChannel toBeRemoved = delayedRemoval.poll();
            if (toBeRemoved == null) {
                break;
            }
            removeChannel(toBeRemoved);
        }
    }

    private void removeChannel(QuicheQuicChannel channel) {
        if (delayRemoval) {
            boolean added = delayedRemoval.offer(channel);
            assert added;
        } else {
            boolean removed = channels.remove(channel);
            if (removed) {
                for (ByteBuffer id : channel.sourceConnectionIds()) {
                    QuicheQuicChannel ch = connectionIdToChannel.remove(id);
                    assert ch == channel;
                }
            }
        }
    }

    protected final void addChannel(QuicheQuicChannel channel) {
        boolean added = channels.add(channel);
        assert added;
        for (ByteBuffer id : channel.sourceConnectionIds()) {
            QuicheQuicChannel ch = connectionIdToChannel.put(id.duplicate(), channel);

Frequently Asked Questions

What is the QuicheQuicCodec class?
QuicheQuicCodec is a class in the netty codebase, defined in codec-classes-quic/src/main/java/io/netty/handler/codec/quic/QuicheQuicCodec.java.
Where is QuicheQuicCodec defined?
QuicheQuicCodec is defined in codec-classes-quic/src/main/java/io/netty/handler/codec/quic/QuicheQuicCodec.java at line 42.

Analyze Your Own Codebase

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

Try Supermodel Free