You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@dubbo.apache.org by GitBox <gi...@apache.org> on 2021/10/20 03:17:01 UTC

[GitHub] [dubbo] EarthChen commented on a change in pull request #9057: [3.0-Triple] Refactor transport state and other code

EarthChen commented on a change in pull request #9057:
URL: https://github.com/apache/dubbo/pull/9057#discussion_r732385483



##########
File path: dubbo-rpc/dubbo-rpc-triple/src/main/java/org/apache/dubbo/rpc/protocol/tri/ClientTransportObserver.java
##########
@@ -20,62 +20,35 @@
 import io.netty.buffer.ByteBuf;
 import io.netty.channel.ChannelHandlerContext;
 import io.netty.channel.ChannelPromise;
-import io.netty.handler.codec.http.HttpMethod;
 import io.netty.handler.codec.http2.DefaultHttp2DataFrame;
 import io.netty.handler.codec.http2.DefaultHttp2Headers;
 import io.netty.handler.codec.http2.DefaultHttp2HeadersFrame;
 import io.netty.handler.codec.http2.DefaultHttp2ResetFrame;
 import io.netty.handler.codec.http2.Http2Error;
 import io.netty.handler.codec.http2.Http2Headers;
 import io.netty.handler.codec.http2.Http2StreamChannel;
-import io.netty.handler.codec.http2.Http2StreamChannelBootstrap;
-import io.netty.util.AsciiString;
 
 public class ClientTransportObserver implements TransportObserver {
-    private final AsciiString SCHEME;
     private final ChannelHandlerContext ctx;
-    private final Http2StreamChannel streamChannel;
     private final ChannelPromise promise;
-    private boolean headerSent = false;
-    private boolean endStreamSent = false;
-    private boolean resetSent = false;
+    private volatile Http2StreamChannel streamChannel;
 
+    public void setStreamChannel(Http2StreamChannel streamChannel) {
+        this.streamChannel = streamChannel;
+    }
 
-    public ClientTransportObserver(ChannelHandlerContext ctx, AbstractClientStream stream, ChannelPromise promise) {
+    public ClientTransportObserver(ChannelHandlerContext ctx, ChannelPromise promise) {
         this.ctx = ctx;
         this.promise = promise;
-        Boolean ssl = ctx.channel().attr(TripleConstant.SSL_ATTRIBUTE_KEY).get();
-        if (ssl != null && ssl) {
-            SCHEME = TripleConstant.HTTPS_SCHEME;
-        } else {
-            SCHEME = TripleConstant.HTTP_SCHEME;
-        }
-
-        final Http2StreamChannelBootstrap streamChannelBootstrap = new Http2StreamChannelBootstrap(ctx.channel());
-        streamChannel = streamChannelBootstrap.open().syncUninterruptibly().getNow();
-
-        final TripleHttp2ClientResponseHandler responseHandler = new TripleHttp2ClientResponseHandler();
-        streamChannel.pipeline().addLast(responseHandler)
-            .addLast(new GrpcDataDecoder(Integer.MAX_VALUE, true))
-            .addLast(new TripleClientInboundHandler());
-        streamChannel.attr(TripleConstant.CLIENT_STREAM_KEY).set(stream);
     }
 
     @Override
     public void onMetadata(Metadata metadata, boolean endStream) {
-        if (headerSent) {
-            return;
+        while (streamChannel == null) {
+            // wait channel initialized

Review comment:
       Change the next PR to send using a queue




-- 
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-unsubscribe@dubbo.apache.org

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



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