Skip to content

Commit 97861c9

Browse files
committed
1 parent 11f914c commit 97861c9

File tree

6 files changed

+10
-34
lines changed

6 files changed

+10
-34
lines changed

dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/migration/MigrationRuleListener.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ public synchronized void onRefer(RegistryProtocol registryProtocol, ClusterInvok
100100

101101
@Override
102102
public void onDestroy() {
103-
configuration.removeListener(RULE_KEY, this);
103+
if (configuration != null)
104+
configuration.removeListener(RULE_KEY, this);
104105
}
105106
}

dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/netty4/PortUnificationServer.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,6 @@ protected void doClose() throws Throwable {
163163
}
164164

165165
channelGroup.close();
166-
Thread.sleep(1000000);
167166
} catch (Throwable e) {
168167
logger.warn(e.getMessage(), e);
169168
}

dubbo-rpc/dubbo-rpc-triple/src/main/java/org/apache/dubbo/rpc/protocol/tri/GracefulShutdown.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ public void gracefulShutdown() {
3333
.writeAscii(ctx.alloc(), goAwayMessage));
3434
goAwayFrame.setExtraStreamIds(Integer.MAX_VALUE);
3535
ctx.write(goAwayFrame);
36-
3736
pingFuture = ctx.executor().schedule(
3837
() -> secondGoAwayAndClose(ctx),
3938
GRACEFUL_SHUTDOWN_PING_TIMEOUT_NANOS,
@@ -53,6 +52,10 @@ void secondGoAwayAndClose(ChannelHandlerContext ctx) {
5352
pingFuture.cancel(false);
5453

5554
try {
55+
Http2GoAwayFrame goAwayFrame = new DefaultHttp2GoAwayFrame(Http2Error.NO_ERROR, ByteBufUtil.writeAscii(this.ctx.alloc(), this.goAwayMessage));
56+
ctx.write(goAwayFrame);
57+
ctx.flush();
58+
//gracefulShutdownTimeoutMillis
5659
ctx.close();
5760
} catch (Exception e) {
5861
ctx.fireExceptionCaught(e);
Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,15 @@
11
package org.apache.dubbo.rpc.protocol.tri;
22

3-
import io.netty.channel.ChannelDuplexHandler;
4-
import io.netty.channel.ChannelHandler.Sharable;
3+
54
import io.netty.channel.ChannelHandlerContext;
6-
import io.netty.channel.ChannelInboundHandlerAdapter;
7-
import io.netty.channel.ChannelPipeline;
85
import io.netty.channel.ChannelPromise;
9-
import io.netty.handler.codec.http2.Http2ConnectionDecoder;
10-
import io.netty.handler.codec.http2.Http2ConnectionEncoder;
11-
import io.netty.handler.codec.http2.Http2FrameCodec;
12-
import io.netty.handler.codec.http2.Http2FrameCodecBuilder;
13-
import io.netty.handler.codec.http2.Http2MultiplexHandler;
14-
import io.netty.handler.codec.http2.Http2Settings;
15-
import io.netty.handler.ssl.SslContext;
16-
import org.apache.dubbo.common.extension.Activate;
17-
import org.apache.dubbo.remoting.netty4.Http2WireProtocol;
18-
6+
import io.netty.handler.codec.http2.Http2ChannelDuplexHandler;
197

20-
public class GracefulShutdownHandler extends Http2FrameCodec {
218

22-
public GracefulShutdownHandler() {
23-
}
9+
public class GracefulShutdownHandler extends Http2ChannelDuplexHandler {
2410

2511
@Override
2612
public void close(ChannelHandlerContext ctx, ChannelPromise promise) throws Exception {
27-
super.close(ctx, promise);
2813
new GracefulShutdown(ctx,"app_requested", null).gracefulShutdown();
2914
}
3015
}

dubbo-rpc/dubbo-rpc-triple/src/main/java/org/apache/dubbo/rpc/protocol/tri/TripleHttp2FrameServerHandler.java

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -131,15 +131,4 @@ public void onHeadersRead(ChannelHandlerContext ctx, Http2HeadersFrame msg) {
131131
serverStream.halfClose();
132132
}
133133
}
134-
135-
private GracefulShutdown gracefulShutdown;
136-
137-
@Override
138-
public void close(ChannelHandlerContext ctx, ChannelPromise promise) throws Exception {
139-
if (gracefulShutdown == null) {
140-
gracefulShutdown = new GracefulShutdown(ctx,"app_requested", null);
141-
gracefulShutdown.gracefulShutdown();
142-
ctx.flush();
143-
}
144-
}
145134
}

dubbo-rpc/dubbo-rpc-triple/src/main/java/org/apache/dubbo/rpc/protocol/tri/TripleHttp2Protocol.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,7 @@ public void configServerPipeline(ChannelPipeline pipeline) {
2828
.frameLogger(SERVER_LOGGER)
2929
.build();
3030
final Http2MultiplexHandler handler = new Http2MultiplexHandler(new TripleServerInitializer());
31-
pipeline.addLast("gracefulShutdown", new GracefulShutdownHandler());
32-
pipeline.addLast(codec, handler);
31+
pipeline.addLast(codec, new GracefulShutdownHandler(), handler);
3332
}
3433

3534
@Override

0 commit comments

Comments
 (0)