This is an automated email from the ASF dual-hosted git repository.
crazyhzm pushed a commit to branch 3.1
in repository https://gitbox.apache.org/repos/asf/dubbo.git
The following commit(s) were added to refs/heads/3.1 by this push:
new 63848bed74 make configServerPipeline independent (#10361)
63848bed74 is described below
commit 63848bed74445ae0b931a32abc6be4d2965f9989
Author: TrueAbc <[email protected]>
AuthorDate: Mon Aug 1 10:50:51 2022 +0800
make configServerPipeline independent (#10361)
* make configServerPipeline independent
* fix comments
* fix comments(trigger workflow)
* comments fix(default codec)
* remove useless if statement
* case test url have null side
* adjust logic of Operator load codec2
---
.../apache/dubbo/remoting/api/WireProtocol.java | 3 +-
.../remoting/api/pu/ChannelHandlerPretender.java | 21 ++---
.../dubbo/remoting/api/pu/ChannelOperator.java | 20 ++---
.../apache/dubbo/remoting/api/pu/DefaultCodec.java | 6 +-
.../dubbo/remoting/transport/AbstractEndpoint.java | 4 +-
.../internal/org.apache.dubbo.remoting.Codec2 | 3 +-
.../apache/dubbo/remoting/api/EmptyProtocol.java | 3 +-
.../remoting/transport/netty4/NettyChannel.java | 3 +
.../transport/netty4/NettyConfigOperator.java | 97 ++++++++++++++++++++++
.../netty4/NettyPortUnificationServer.java | 2 +-
.../netty4/NettyPortUnificationServerHandler.java | 13 ++-
.../transport/netty4/EmptyWireProtocol.java | 3 +-
.../rpc/protocol/tri/TripleHttp2Protocol.java | 17 +++-
.../internal/org.apache.dubbo.remoting.Codec2 | 1 -
14 files changed, 153 insertions(+), 43 deletions(-)
diff --git
a/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/api/WireProtocol.java
b/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/api/WireProtocol.java
index 96f74595ae..fe615f8210 100644
---
a/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/api/WireProtocol.java
+++
b/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/api/WireProtocol.java
@@ -19,6 +19,7 @@ package org.apache.dubbo.remoting.api;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.extension.ExtensionScope;
import org.apache.dubbo.common.extension.SPI;
+import org.apache.dubbo.remoting.api.pu.ChannelOperator;
import io.netty.channel.ChannelPipeline;
import io.netty.handler.ssl.SslContext;
@@ -28,7 +29,7 @@ public interface WireProtocol {
ProtocolDetector detector();
- void configServerPipeline(URL url, ChannelPipeline pipeline, SslContext
sslContext);
+ void configServerProtocolHandler(URL url, ChannelOperator operator);
void configClientPipeline(URL url, ChannelPipeline pipeline, SslContext
sslContext);
diff --git
a/dubbo-rpc/dubbo-rpc-triple/src/main/java/org/apache/dubbo/rpc/protocol/tri/DefaultTriCodec.java
b/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/api/pu/ChannelHandlerPretender.java
similarity index 62%
copy from
dubbo-rpc/dubbo-rpc-triple/src/main/java/org/apache/dubbo/rpc/protocol/tri/DefaultTriCodec.java
copy to
dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/api/pu/ChannelHandlerPretender.java
index 259c986fc7..b17dd7c7be 100644
---
a/dubbo-rpc/dubbo-rpc-triple/src/main/java/org/apache/dubbo/rpc/protocol/tri/DefaultTriCodec.java
+++
b/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/api/pu/ChannelHandlerPretender.java
@@ -14,22 +14,19 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.dubbo.rpc.protocol.tri;
+package org.apache.dubbo.remoting.api.pu;
-import org.apache.dubbo.remoting.Channel;
-import org.apache.dubbo.remoting.Codec2;
-import org.apache.dubbo.remoting.buffer.ChannelBuffer;
-import java.io.IOException;
+import org.apache.dubbo.remoting.transport.ChannelHandlerAdapter;
-public class DefaultTriCodec implements Codec2 {
-
- @Override
- public void encode(Channel channel, ChannelBuffer buffer, Object message)
throws IOException {
+public class ChannelHandlerPretender extends ChannelHandlerAdapter {
+ private final Object realHandler;
+ public ChannelHandlerPretender(Object realHandler) {
+ this.realHandler = realHandler;
}
- @Override
- public Object decode(Channel channel, ChannelBuffer buffer) throws
IOException {
- return null;
+ public Object getRealHandler() {
+ return realHandler;
}
+
}
diff --git
a/dubbo-rpc/dubbo-rpc-triple/src/main/java/org/apache/dubbo/rpc/protocol/tri/DefaultTriCodec.java
b/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/api/pu/ChannelOperator.java
similarity index 61%
copy from
dubbo-rpc/dubbo-rpc-triple/src/main/java/org/apache/dubbo/rpc/protocol/tri/DefaultTriCodec.java
copy to
dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/api/pu/ChannelOperator.java
index 259c986fc7..82a3bde8fa 100644
---
a/dubbo-rpc/dubbo-rpc-triple/src/main/java/org/apache/dubbo/rpc/protocol/tri/DefaultTriCodec.java
+++
b/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/api/pu/ChannelOperator.java
@@ -14,22 +14,12 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.dubbo.rpc.protocol.tri;
+package org.apache.dubbo.remoting.api.pu;
-import org.apache.dubbo.remoting.Channel;
-import org.apache.dubbo.remoting.Codec2;
-import org.apache.dubbo.remoting.buffer.ChannelBuffer;
-import java.io.IOException;
+import org.apache.dubbo.remoting.ChannelHandler;
-public class DefaultTriCodec implements Codec2 {
+import java.util.List;
- @Override
- public void encode(Channel channel, ChannelBuffer buffer, Object message)
throws IOException {
-
- }
-
- @Override
- public Object decode(Channel channel, ChannelBuffer buffer) throws
IOException {
- return null;
- }
+public interface ChannelOperator {
+ void configChannelHandler(List<ChannelHandler> handlerList);
}
diff --git
a/dubbo-rpc/dubbo-rpc-triple/src/main/java/org/apache/dubbo/rpc/protocol/tri/DefaultTriCodec.java
b/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/api/pu/DefaultCodec.java
similarity index 92%
rename from
dubbo-rpc/dubbo-rpc-triple/src/main/java/org/apache/dubbo/rpc/protocol/tri/DefaultTriCodec.java
rename to
dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/api/pu/DefaultCodec.java
index 259c986fc7..4756dd38ef 100644
---
a/dubbo-rpc/dubbo-rpc-triple/src/main/java/org/apache/dubbo/rpc/protocol/tri/DefaultTriCodec.java
+++
b/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/api/pu/DefaultCodec.java
@@ -14,15 +14,15 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.dubbo.rpc.protocol.tri;
+package org.apache.dubbo.remoting.api.pu;
import org.apache.dubbo.remoting.Channel;
import org.apache.dubbo.remoting.Codec2;
import org.apache.dubbo.remoting.buffer.ChannelBuffer;
-import java.io.IOException;
-public class DefaultTriCodec implements Codec2 {
+import java.io.IOException;
+public class DefaultCodec implements Codec2 {
@Override
public void encode(Channel channel, ChannelBuffer buffer, Object message)
throws IOException {
diff --git
a/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/transport/AbstractEndpoint.java
b/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/transport/AbstractEndpoint.java
index fbba37839b..4e0af746d9 100644
---
a/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/transport/AbstractEndpoint.java
+++
b/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/transport/AbstractEndpoint.java
@@ -56,9 +56,11 @@ public abstract class AbstractEndpoint extends AbstractPeer
implements Resetable
FrameworkModel frameworkModel = getFrameworkModel(url.getScopeModel());
if
(frameworkModel.getExtensionLoader(Codec2.class).hasExtension(codecName)) {
return
frameworkModel.getExtensionLoader(Codec2.class).getExtension(codecName);
- } else {
+ } else
if(frameworkModel.getExtensionLoader(Codec.class).hasExtension(codecName)){
return new
CodecAdapter(frameworkModel.getExtensionLoader(Codec.class)
.getExtension(codecName));
+ }else {
+ return
frameworkModel.getExtensionLoader(Codec2.class).getExtension("default");
}
}
diff --git
a/dubbo-remoting/dubbo-remoting-api/src/main/resources/META-INF/dubbo/internal/org.apache.dubbo.remoting.Codec2
b/dubbo-remoting/dubbo-remoting-api/src/main/resources/META-INF/dubbo/internal/org.apache.dubbo.remoting.Codec2
index b4ba960565..98046f8f1e 100644
---
a/dubbo-remoting/dubbo-remoting-api/src/main/resources/META-INF/dubbo/internal/org.apache.dubbo.remoting.Codec2
+++
b/dubbo-remoting/dubbo-remoting-api/src/main/resources/META-INF/dubbo/internal/org.apache.dubbo.remoting.Codec2
@@ -1,3 +1,4 @@
transport=org.apache.dubbo.remoting.transport.codec.TransportCodec
telnet=org.apache.dubbo.remoting.telnet.codec.TelnetCodec
-exchange=org.apache.dubbo.remoting.exchange.codec.ExchangeCodec
\ No newline at end of file
+exchange=org.apache.dubbo.remoting.exchange.codec.ExchangeCodec
+default=org.apache.dubbo.remoting.api.pu.DefaultCodec
diff --git
a/dubbo-remoting/dubbo-remoting-api/src/test/java/org/apache/dubbo/remoting/api/EmptyProtocol.java
b/dubbo-remoting/dubbo-remoting-api/src/test/java/org/apache/dubbo/remoting/api/EmptyProtocol.java
index 7d3b5cf7d6..5c69d9b945 100644
---
a/dubbo-remoting/dubbo-remoting-api/src/test/java/org/apache/dubbo/remoting/api/EmptyProtocol.java
+++
b/dubbo-remoting/dubbo-remoting-api/src/test/java/org/apache/dubbo/remoting/api/EmptyProtocol.java
@@ -17,6 +17,7 @@
package org.apache.dubbo.remoting.api;
import org.apache.dubbo.common.URL;
+import org.apache.dubbo.remoting.api.pu.ChannelOperator;
import io.netty.channel.ChannelPipeline;
import io.netty.handler.ssl.SslContext;
@@ -28,7 +29,7 @@ public class EmptyProtocol implements WireProtocol {
}
@Override
- public void configServerPipeline(URL url, ChannelPipeline
pipeline,SslContext sslContext) {
+ public void configServerProtocolHandler(URL url, ChannelOperator operator)
{
}
diff --git
a/dubbo-remoting/dubbo-remoting-netty4/src/main/java/org/apache/dubbo/remoting/transport/netty4/NettyChannel.java
b/dubbo-remoting/dubbo-remoting-netty4/src/main/java/org/apache/dubbo/remoting/transport/netty4/NettyChannel.java
index 780ae9d8fe..4493bb3a6c 100644
---
a/dubbo-remoting/dubbo-remoting-netty4/src/main/java/org/apache/dubbo/remoting/transport/netty4/NettyChannel.java
+++
b/dubbo-remoting/dubbo-remoting-netty4/src/main/java/org/apache/dubbo/remoting/transport/netty4/NettyChannel.java
@@ -273,4 +273,7 @@ final class NettyChannel extends AbstractChannel {
return "NettyChannel [channel=" + channel + "]";
}
+ public Channel getNioChannel() {
+ return channel;
+ }
}
diff --git
a/dubbo-remoting/dubbo-remoting-netty4/src/main/java/org/apache/dubbo/remoting/transport/netty4/NettyConfigOperator.java
b/dubbo-remoting/dubbo-remoting-netty4/src/main/java/org/apache/dubbo/remoting/transport/netty4/NettyConfigOperator.java
new file mode 100644
index 0000000000..dca821ea68
--- /dev/null
+++
b/dubbo-remoting/dubbo-remoting-netty4/src/main/java/org/apache/dubbo/remoting/transport/netty4/NettyConfigOperator.java
@@ -0,0 +1,97 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.dubbo.remoting.transport.netty4;
+
+import org.apache.dubbo.common.URL;
+import org.apache.dubbo.common.constants.CommonConstants;
+import org.apache.dubbo.common.utils.StringUtils;
+import org.apache.dubbo.remoting.Channel;
+import org.apache.dubbo.remoting.ChannelHandler;
+import org.apache.dubbo.remoting.Codec;
+import org.apache.dubbo.remoting.Codec2;
+import org.apache.dubbo.remoting.Constants;
+import org.apache.dubbo.remoting.api.pu.ChannelHandlerPretender;
+import org.apache.dubbo.remoting.api.pu.ChannelOperator;
+import org.apache.dubbo.remoting.api.pu.DefaultCodec;
+import org.apache.dubbo.remoting.transport.codec.CodecAdapter;
+
+import java.util.List;
+
+public class NettyConfigOperator implements ChannelOperator {
+
+ private final Channel channel;
+ private ChannelHandler handler;
+
+ public NettyConfigOperator(NettyChannel channel, ChannelHandler handler) {
+ this.channel = channel;
+ this.handler = handler;
+ }
+
+ @Override
+ public void configChannelHandler(List<ChannelHandler> handlerList) {
+ URL url = channel.getUrl();
+ Codec2 codec2;
+ String codecName = url.getParameter(Constants.CODEC_KEY);
+ if (StringUtils.isEmpty(codecName)) {
+ // codec extension name must stay the same with protocol name
+ codecName = url.getProtocol();
+ }
+ if
(url.getOrDefaultFrameworkModel().getExtensionLoader(Codec2.class).hasExtension(codecName))
{
+ codec2 =
url.getOrDefaultFrameworkModel().getExtensionLoader(Codec2.class).getExtension(codecName);
+ } else
if(url.getOrDefaultFrameworkModel().getExtensionLoader(Codec.class).hasExtension(codecName)){
+ codec2 = new
CodecAdapter(url.getOrDefaultFrameworkModel().getExtensionLoader(Codec.class)
+ .getExtension(codecName));
+ }else {
+ codec2 =
url.getOrDefaultFrameworkModel().getExtensionLoader(Codec2.class).getExtension("default");
+ }
+
+ if (!(codec2 instanceof DefaultCodec)){
+ NettyCodecAdapter codec = new NettyCodecAdapter(codec2,
channel.getUrl(), handler);
+ ((NettyChannel) channel).getNioChannel().pipeline().addLast(
+ codec.getDecoder()
+ ).addLast(
+ codec.getEncoder()
+ );
+ }
+
+ for (ChannelHandler handler: handlerList) {
+ if (handler instanceof ChannelHandlerPretender) {
+ Object realHandler = ((ChannelHandlerPretender)
handler).getRealHandler();
+ if(realHandler instanceof io.netty.channel.ChannelHandler) {
+ ((NettyChannel)
channel).getNioChannel().pipeline().addLast(
+ (io.netty.channel.ChannelHandler) realHandler
+ );
+ }
+ }
+ }
+
+ // todo distinguish between client and server channel
+ if( isClientSide(channel)){
+ //todo config client channel handler
+ }else {
+ NettyServerHandler sh = new NettyServerHandler(channel.getUrl(),
handler);
+ ((NettyChannel) channel).getNioChannel().pipeline().addLast(
+ sh
+ );
+ }
+ }
+
+ private boolean isClientSide(Channel channel) {
+ return
channel.getUrl().getSide("").equalsIgnoreCase(CommonConstants.CONSUMER);
+ }
+
+}
diff --git
a/dubbo-remoting/dubbo-remoting-netty4/src/main/java/org/apache/dubbo/remoting/transport/netty4/NettyPortUnificationServer.java
b/dubbo-remoting/dubbo-remoting-netty4/src/main/java/org/apache/dubbo/remoting/transport/netty4/NettyPortUnificationServer.java
index 1c017d577d..e732f96128 100644
---
a/dubbo-remoting/dubbo-remoting-netty4/src/main/java/org/apache/dubbo/remoting/transport/netty4/NettyPortUnificationServer.java
+++
b/dubbo-remoting/dubbo-remoting-netty4/src/main/java/org/apache/dubbo/remoting/transport/netty4/NettyPortUnificationServer.java
@@ -127,7 +127,7 @@ public class NettyPortUnificationServer extends
AbstractPortUnificationServer {
final ChannelPipeline p = ch.pipeline();
final NettyPortUnificationServerHandler puHandler;
puHandler = new
NettyPortUnificationServerHandler(getUrl(), sslContext, true, getProtocols(),
- channels);
+ channels, NettyPortUnificationServer.this);
p.addLast("negotiation-protocol", puHandler);
}
});
diff --git
a/dubbo-remoting/dubbo-remoting-netty4/src/main/java/org/apache/dubbo/remoting/transport/netty4/NettyPortUnificationServerHandler.java
b/dubbo-remoting/dubbo-remoting-netty4/src/main/java/org/apache/dubbo/remoting/transport/netty4/NettyPortUnificationServerHandler.java
index 0db96b09fa..f30f840496 100644
---
a/dubbo-remoting/dubbo-remoting-netty4/src/main/java/org/apache/dubbo/remoting/transport/netty4/NettyPortUnificationServerHandler.java
+++
b/dubbo-remoting/dubbo-remoting-netty4/src/main/java/org/apache/dubbo/remoting/transport/netty4/NettyPortUnificationServerHandler.java
@@ -20,8 +20,10 @@ import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.io.Bytes;
import org.apache.dubbo.common.logger.Logger;
import org.apache.dubbo.common.logger.LoggerFactory;
+import org.apache.dubbo.remoting.ChannelHandler;
import org.apache.dubbo.remoting.api.ProtocolDetector;
import org.apache.dubbo.remoting.api.WireProtocol;
+import org.apache.dubbo.remoting.api.pu.ChannelOperator;
import org.apache.dubbo.remoting.buffer.ChannelBuffer;
import io.netty.buffer.ByteBuf;
@@ -44,16 +46,19 @@ public class NettyPortUnificationServerHandler extends
ByteToMessageDecoder {
private final SslContext sslCtx;
private final URL url;
+ private final ChannelHandler handler;
private final boolean detectSsl;
private final List<WireProtocol> protocols;
public NettyPortUnificationServerHandler(URL url, SslContext sslCtx,
boolean detectSsl,
- List<WireProtocol> protocols,
ChannelGroup channels) {
+ List<WireProtocol> protocols,
ChannelGroup channels,
+ ChannelHandler handler) {
this.url = url;
this.sslCtx = sslCtx;
this.protocols = protocols;
this.detectSsl = detectSsl;
this.channels = channels;
+ this.handler = handler;
}
@Override
@@ -70,6 +75,7 @@ public class NettyPortUnificationServerHandler extends
ByteToMessageDecoder {
@Override
protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object>
out)
throws Exception {
+ NettyChannel channel = NettyChannel.getOrAddChannel(ctx.channel(),
url, handler);
// Will use the first five bytes to detect a protocol.
if (in.readableBytes() < 5) {
return;
@@ -87,7 +93,8 @@ public class NettyPortUnificationServerHandler extends
ByteToMessageDecoder {
case UNRECOGNIZED:
continue;
case RECOGNIZED:
- protocol.configServerPipeline(url, ctx.pipeline(),
sslCtx);
+ ChannelOperator operator = new
NettyConfigOperator(channel, handler);
+ protocol.configServerProtocolHandler(url, operator);
ctx.pipeline().remove(this);
case NEED_MORE_DATA:
return;
@@ -115,7 +122,7 @@ public class NettyPortUnificationServerHandler extends
ByteToMessageDecoder {
ChannelPipeline p = ctx.pipeline();
p.addLast("ssl", sslCtx.newHandler(ctx.alloc()));
p.addLast("unificationA",
- new NettyPortUnificationServerHandler(url, sslCtx, false,
protocols, channels));
+ new NettyPortUnificationServerHandler(url, sslCtx, false,
protocols, channels, handler));
p.remove(this);
}
diff --git
a/dubbo-remoting/dubbo-remoting-netty4/src/test/java/org/apache/dubbo/remoting/transport/netty4/EmptyWireProtocol.java
b/dubbo-remoting/dubbo-remoting-netty4/src/test/java/org/apache/dubbo/remoting/transport/netty4/EmptyWireProtocol.java
index 322b524b85..9482287bc7 100644
---
a/dubbo-remoting/dubbo-remoting-netty4/src/test/java/org/apache/dubbo/remoting/transport/netty4/EmptyWireProtocol.java
+++
b/dubbo-remoting/dubbo-remoting-netty4/src/test/java/org/apache/dubbo/remoting/transport/netty4/EmptyWireProtocol.java
@@ -19,6 +19,7 @@ package org.apache.dubbo.remoting.transport.netty4;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.remoting.api.ProtocolDetector;
import org.apache.dubbo.remoting.api.WireProtocol;
+import org.apache.dubbo.remoting.api.pu.ChannelOperator;
import io.netty.channel.ChannelPipeline;
import io.netty.handler.ssl.SslContext;
@@ -30,7 +31,7 @@ public class EmptyWireProtocol implements WireProtocol {
}
@Override
- public void configServerPipeline(URL url, ChannelPipeline pipeline,
SslContext sslContext) {
+ public void configServerProtocolHandler(URL url, ChannelOperator operator)
{
}
diff --git
a/dubbo-rpc/dubbo-rpc-triple/src/main/java/org/apache/dubbo/rpc/protocol/tri/TripleHttp2Protocol.java
b/dubbo-rpc/dubbo-rpc-triple/src/main/java/org/apache/dubbo/rpc/protocol/tri/TripleHttp2Protocol.java
index 2c1c051c7e..6fba53857c 100644
---
a/dubbo-rpc/dubbo-rpc-triple/src/main/java/org/apache/dubbo/rpc/protocol/tri/TripleHttp2Protocol.java
+++
b/dubbo-rpc/dubbo-rpc-triple/src/main/java/org/apache/dubbo/rpc/protocol/tri/TripleHttp2Protocol.java
@@ -23,7 +23,10 @@ import org.apache.dubbo.common.config.ConfigurationUtils;
import org.apache.dubbo.common.extension.Activate;
import org.apache.dubbo.common.extension.ExtensionLoader;
import org.apache.dubbo.common.threadpool.manager.ExecutorRepository;
+import org.apache.dubbo.remoting.ChannelHandler;
import org.apache.dubbo.remoting.api.AbstractWireProtocol;
+import org.apache.dubbo.remoting.api.pu.ChannelHandlerPretender;
+import org.apache.dubbo.remoting.api.pu.ChannelOperator;
import org.apache.dubbo.rpc.HeaderFilter;
import org.apache.dubbo.rpc.model.ApplicationModel;
import org.apache.dubbo.rpc.model.FrameworkModel;
@@ -45,6 +48,7 @@ import io.netty.handler.codec.http2.Http2Settings;
import io.netty.handler.logging.LogLevel;
import io.netty.handler.ssl.SslContext;
+import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.Executor;
@@ -99,7 +103,8 @@ public class TripleHttp2Protocol extends
AbstractWireProtocol implements ScopeMo
}
@Override
- public void configServerPipeline(URL url, ChannelPipeline pipeline,
SslContext sslContext) {
+ public void configServerProtocolHandler(URL url, ChannelOperator operator)
{
+
final List<HeaderFilter> headFilters;
if (filtersLoader != null) {
headFilters = filtersLoader.getActivateExtension(url,
@@ -130,8 +135,14 @@ public class TripleHttp2Protocol extends
AbstractWireProtocol implements ScopeMo
headFilters));
}
});
- pipeline.addLast(codec, new TripleServerConnectionHandler(), handler,
- new TripleTailHandler());
+ List<ChannelHandler> handlers = new ArrayList<>();
+ handlers.add(new ChannelHandlerPretender(codec));
+ handlers.add(new ChannelHandlerPretender(new
TripleServerConnectionHandler()));
+ handlers.add(new ChannelHandlerPretender(handler));
+ handlers.add(new ChannelHandlerPretender(new TripleTailHandler()));
+ operator.configChannelHandler(handlers);
+
+
}
diff --git
a/dubbo-rpc/dubbo-rpc-triple/src/main/resources/META-INF/dubbo/internal/org.apache.dubbo.remoting.Codec2
b/dubbo-rpc/dubbo-rpc-triple/src/main/resources/META-INF/dubbo/internal/org.apache.dubbo.remoting.Codec2
deleted file mode 100644
index bd58299466..0000000000
---
a/dubbo-rpc/dubbo-rpc-triple/src/main/resources/META-INF/dubbo/internal/org.apache.dubbo.remoting.Codec2
+++ /dev/null
@@ -1 +0,0 @@
-tri=org.apache.dubbo.rpc.protocol.tri.DefaultTriCodec