oxsean commented on code in PR #14026:
URL: https://github.com/apache/dubbo/pull/14026#discussion_r1596840246


##########
dubbo-rpc/dubbo-rpc-triple/src/main/java/org/apache/dubbo/rpc/protocol/tri/TripleHttp2Protocol.java:
##########
@@ -143,31 +149,52 @@ public void configServerProtocolHandler(URL url, 
ChannelOperator operator) {
     }
 
     private void configurerHttp1Handlers(URL url, List<ChannelHandler> 
handlers) {
-        handlers.add(new ChannelHandlerPretender(new HttpServerCodec()));
+        final HttpServerCodec sourceCodec = new HttpServerCodec();
+        handlers.add(new ChannelHandlerPretender(sourceCodec));
+        // Triple protocol http1 upgrade support
+        handlers.add(new ChannelHandlerPretender(new HttpServerUpgradeHandler(
+                sourceCodec,
+                protocol -> {
+                    if 
(AsciiString.contentEquals(Http2CodecUtil.HTTP_UPGRADE_PROTOCOL_NAME, 
protocol)) {
+                        Configuration config =
+                                
ConfigurationUtils.getGlobalConfiguration(url.getOrDefaultApplicationModel());
+                        return new Http2ServerUpgradeCodec(
+                                buildHttp2FrameCodec(config, 
url.getOrDefaultApplicationModel()),
+                                new HttpServerAfterUpgradeHandler(),
+                                new HttpWriteQueueHandler(),
+                                new FlushConsolidationHandler(64, true),
+                                new TripleServerConnectionHandler(),
+                                buildHttp2MultiplexHandler(url),
+                                new TripleTailHandler());
+                    }
+                    // Not upgrade request
+                    return null;
+                },
+                Integer.MAX_VALUE)));
+        // If the upgrade was successful, remove the message from the output 
list
+        // so that it's not propagated to the next handler. This request will
+        // be propagated as a user event instead.
         handlers.add(new ChannelHandlerPretender(new 
HttpObjectAggregator(Integer.MAX_VALUE)));
         handlers.add(new ChannelHandlerPretender(new NettyHttp1Codec()));
         handlers.add(new ChannelHandlerPretender(new 
NettyHttp1ConnectionHandler(
                 url, frameworkModel, 
DefaultHttp11ServerTransportListenerFactory.INSTANCE)));
     }
 
+    private Http2MultiplexHandler buildHttp2MultiplexHandler(URL url) {
+        return new Http2MultiplexHandler(new 
ChannelInitializer<Http2StreamChannel>() {
+            @Override
+            protected void initChannel(Http2StreamChannel ch) {
+                final ChannelPipeline p = ch.pipeline();
+                p.addLast(new NettyHttp2FrameCodec());
+                p.addLast(new NettyHttp2ProtocolSelectorHandler(
+                        url, frameworkModel, 
GenericHttp2ServerTransportListenerFactory.INSTANCE));
+            }
+        });
+    }
+
     private void configurerHttp2Handlers(URL url, List<ChannelHandler> 
handlers) {
         Configuration config = 
ConfigurationUtils.getGlobalConfiguration(url.getOrDefaultApplicationModel());
-        final Http2FrameCodec codec = TripleHttp2FrameCodecBuilder.forServer()
-                .customizeConnection((connection) -> connection
-                        .remote()
-                        .flowController(
-                                new TriHttp2RemoteFlowController(connection, 
url.getOrDefaultApplicationModel())))
-                .gracefulShutdownTimeoutMillis(10000)
-                .initialSettings(new Http2Settings()
-                        .headerTableSize(
-                                
config.getInt(H2_SETTINGS_HEADER_TABLE_SIZE_KEY, 
DEFAULT_SETTING_HEADER_LIST_SIZE))
-                        
.maxConcurrentStreams(config.getInt(H2_SETTINGS_MAX_CONCURRENT_STREAMS_KEY, 
Integer.MAX_VALUE))
-                        
.initialWindowSize(config.getInt(H2_SETTINGS_INITIAL_WINDOW_SIZE_KEY, 
DEFAULT_WINDOW_INIT_SIZE))
-                        
.maxFrameSize(config.getInt(H2_SETTINGS_MAX_FRAME_SIZE_KEY, 
DEFAULT_MAX_FRAME_SIZE))
-                        .maxHeaderListSize(
-                                
config.getInt(H2_SETTINGS_MAX_HEADER_LIST_SIZE_KEY, 
DEFAULT_MAX_HEADER_LIST_SIZE)))
-                .frameLogger(SERVER_LOGGER)
-                .build();
+        final Http2FrameCodec codec = buildHttp2FrameCodec(config, 
url.getOrDefaultApplicationModel());
         final Http2MultiplexHandler handler = new Http2MultiplexHandler(new 
ChannelInitializer<Http2StreamChannel>() {

Review Comment:
   use buildHttp2MultiplexHandler(url)



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscr...@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscr...@dubbo.apache.org
For additional commands, e-mail: notifications-h...@dubbo.apache.org

Reply via email to