Home / Function/ compositeBufSizeEstimationGuaranteesSynchronousWrite() — netty Function Reference

compositeBufSizeEstimationGuaranteesSynchronousWrite() — netty Function Reference

Architecture documentation for the compositeBufSizeEstimationGuaranteesSynchronousWrite() function in ParameterizedSslHandlerTest.java from the netty codebase.

Function java Buffer Allocators calls 3 called by 1

Entity Profile

Dependency Diagram

graph TD
  f520a1a6_f743_e43e_b161_6512d3e242bf["compositeBufSizeEstimationGuaranteesSynchronousWrite()"]
  4741a6a1_c002_17c2_c8d8_747d98eb437c["ParameterizedSslHandlerTest"]
  f520a1a6_f743_e43e_b161_6512d3e242bf -->|defined in| 4741a6a1_c002_17c2_c8d8_747d98eb437c
  aa845c12_91e2_3c30_7548_04c9b1df7a6b["testCompositeBufSizeEstimationGuaranteesSynchronousWrite()"]
  aa845c12_91e2_3c30_7548_04c9b1df7a6b -->|calls| f520a1a6_f743_e43e_b161_6512d3e242bf
  a7cf000b_1728_2ae2_77e7_f00f03be737d["SslHandler()"]
  f520a1a6_f743_e43e_b161_6512d3e242bf -->|calls| a7cf000b_1728_2ae2_77e7_f00f03be737d
  34385cfd_5b94_5f19_20c9_139fe1185827["userEventTriggered()"]
  f520a1a6_f743_e43e_b161_6512d3e242bf -->|calls| 34385cfd_5b94_5f19_20c9_139fe1185827
  8012c2ef_ec06_9bdf_064e_3c1e7ba7f4b8["exceptionCaught()"]
  f520a1a6_f743_e43e_b161_6512d3e242bf -->|calls| 8012c2ef_ec06_9bdf_064e_3c1e7ba7f4b8
  style f520a1a6_f743_e43e_b161_6512d3e242bf fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

handler/src/test/java/io/netty/handler/ssl/ParameterizedSslHandlerTest.java lines 127–274

    private static void compositeBufSizeEstimationGuaranteesSynchronousWrite(
            SslProvider serverProvider, SslProvider clientProvider,
            final boolean serverDisableWrapSize,
            final boolean letHandlerCreateServerEngine, final boolean letHandlerCreateClientEngine)
            throws CertificateException, SSLException, ExecutionException, InterruptedException {
        SelfSignedCertificate ssc = CachedSelfSignedCertificate.getCachedCertificate();

        final SslContext sslServerCtx = SslContextBuilder.forServer(ssc.certificate(), ssc.privateKey())
                .sslProvider(serverProvider)
                .build();

        final SslContext sslClientCtx = SslContextBuilder.forClient()
                .trustManager(InsecureTrustManagerFactory.INSTANCE)
                .sslProvider(clientProvider).build();

        EventLoopGroup group = new MultiThreadIoEventLoopGroup(NioIoHandler.newFactory());
        Channel sc = null;
        Channel cc = null;
        try {
            final Promise<Void> donePromise = group.next().newPromise();
            // The goal is to provide the SSLEngine with many ByteBuf components to ensure that the overhead for wrap
            // is correctly accounted for on each component.
            final int numComponents = 150;
            // This is the TLS packet size. The goal is to divide the maximum amount of application data that can fit
            // into a single TLS packet into many components to ensure the overhead is correctly taken into account.
            final int desiredBytes = 16384;
            final int singleComponentSize = desiredBytes / numComponents;
            final int expectedBytes = numComponents * singleComponentSize;

            sc = new ServerBootstrap()
                    .group(group)
                    .channel(NioServerSocketChannel.class)
                    .childHandler(new ChannelInitializer<Channel>() {
                        @Override
                        protected void initChannel(Channel ch) throws Exception {
                            final SslHandler handler = letHandlerCreateServerEngine
                                    ? sslServerCtx.newHandler(ch.alloc())
                                    : new SslHandler(sslServerCtx.newEngine(ch.alloc()));
                            if (serverDisableWrapSize) {
                                handler.setWrapDataSize(-1);
                            }
                            ch.pipeline().addLast(handler);
                            ch.pipeline().addLast(new ChannelInboundHandlerAdapter() {
                                private boolean sentData;
                                private Throwable writeCause;

                                @Override
                                public void userEventTriggered(ChannelHandlerContext ctx, Object evt) {
                                    if (evt instanceof SslHandshakeCompletionEvent) {
                                        SslHandshakeCompletionEvent sslEvt = (SslHandshakeCompletionEvent) evt;
                                        if (sslEvt.isSuccess()) {
                                            CompositeByteBuf content = ctx.alloc().compositeDirectBuffer(numComponents);
                                            for (int i = 0; i < numComponents; ++i) {
                                                ByteBuf buf = ctx.alloc().directBuffer(singleComponentSize);
                                                buf.writerIndex(buf.writerIndex() + singleComponentSize);
                                                content.addComponent(true, buf);
                                            }
                                            ctx.writeAndFlush(content).addListener(future -> {
                                                writeCause = future.cause();
                                                if (writeCause == null) {
                                                    sentData = true;
                                                }
                                            });
                                        } else {
                                            donePromise.tryFailure(sslEvt.cause());
                                        }
                                    }
                                    ctx.fireUserEventTriggered(evt);
                                }

                                @Override
                                public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
                                    donePromise.tryFailure(new IllegalStateException("server exception sentData: " +
                                            sentData + " writeCause: " + writeCause, cause));
                                }

                                @Override
                                public void channelInactive(ChannelHandlerContext ctx) {
                                    donePromise.tryFailure(new IllegalStateException("server closed sentData: " +
                                            sentData + " writeCause: " + writeCause));
                                }

Domain

Subdomains

Frequently Asked Questions

What does compositeBufSizeEstimationGuaranteesSynchronousWrite() do?
compositeBufSizeEstimationGuaranteesSynchronousWrite() is a function in the netty codebase, defined in handler/src/test/java/io/netty/handler/ssl/ParameterizedSslHandlerTest.java.
Where is compositeBufSizeEstimationGuaranteesSynchronousWrite() defined?
compositeBufSizeEstimationGuaranteesSynchronousWrite() is defined in handler/src/test/java/io/netty/handler/ssl/ParameterizedSslHandlerTest.java at line 127.
What does compositeBufSizeEstimationGuaranteesSynchronousWrite() call?
compositeBufSizeEstimationGuaranteesSynchronousWrite() calls 3 function(s): SslHandler, exceptionCaught, userEventTriggered.
What calls compositeBufSizeEstimationGuaranteesSynchronousWrite()?
compositeBufSizeEstimationGuaranteesSynchronousWrite() is called by 1 function(s): testCompositeBufSizeEstimationGuaranteesSynchronousWrite.

Analyze Your Own Codebase

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

Try Supermodel Free