zhenjunma / javahotfix Goto Github PK
View Code? Open in Web Editor NEW参考mosn的实现思路,基于netty实现的Java版热更新机制。主要包括连接迁移,存量数据迁移。
参考mosn的实现思路,基于netty实现的Java版热更新机制。主要包括连接迁移,存量数据迁移。
在接受完所有三种类型数据的时候,需要重新监听/tmp/hotfix.sock,当接受到热更新信号的时候,需要将ServerStatus status变更为ServerStatus.HOT_FIX,源代码补充如下
public void startHotFixServer() { new Thread(() -> { try { ServerBootstrap b = new ServerBootstrap(); b.group(bossGroup, workerGroup) .channel(EpollServerDomainSocketChannel.class) .childHandler(new ChannelInboundHandlerAdapter() { @Override public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception { ByteBuf buf = (ByteBuf) msg; if (buf.readInt() == 1){ //关闭监听 hotFixServerChannelFuture.channel().close().addListener(future -> { if (!future.isSuccess()){ future.cause().printStackTrace(); } }); /* 老者接收到迁移信号:1,开始迁移连接信息 */ System.out.println("老者接收到迁移信号:1,开始迁移连接信息"); status = ServerStatus.HOT_FIX; //这里就是遗漏的地方 startListenerTransferTask(); } } }); SocketAddress s = new DomainSocketAddress(DomainSocketAddressEnum.TAG_HOTFIX.path()); hotFixServerChannelFuture = b.bind(s).sync(); }catch (Exception e){ e.printStackTrace(); } }).start(); System.out.println("启动监听hot-fix"); }
目前我在调研Netty的fd迁移方案,有幸看到大佬的Netty实现。想请问一下,之前貌似是使用的SO_REUSEPORT的方案来实现的,后来又改成了基于uds来实现的,请问如果是基于SO_REUSEPORT来实现的话,是有什么问题吗?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.