首页 | 新闻 | 新品 | 文库 | 方案 | 视频 | 下载 | 商城 | 开发板 | 数据中心 | 座谈新版 | 培训 | 工具 | 博客 | 论坛 | 百科 | GEC | 活动 | 主题月 | 电子展
返回列表 回复 发帖

dubbo源码分析二:服务发布(3)

dubbo源码分析二:服务发布(3)

b.NettyServer

protected void doOpen() throws Throwable {    NettyHelper.setNettyLoggerFactory();    ExecutorService boss = Executors.newCachedThreadPool(new NamedThreadFactory("NettyServerBoss", true));//boss线程池    ExecutorService worker = Executors.newCachedThreadPool(new NamedThreadFactory("NettyServerWorker", true));//工作线程池    ChannelFactory channelFactory = new NioServerSocketChannelFactory(boss, worker, getUrl().getPositiveParameter(Constants.IO_THREADS_KEY, Constants.DEFAULT_IO_THREADS));    bootstrap = new ServerBootstrap(channelFactory);//服务启动类         final NettyHandler nettyHandler = new NettyHandler(getUrl(), this);    channels = nettyHandler.getChannels();    // https://issues.jboss.org/browse/NETTY-365    // https://issues.jboss.org/browse/NETTY-379    // final Timer timer = new HashedWheelTimer(new NamedThreadFactory("NettyIdleTimer", true));    bootstrap.setPipelineFactory(new ChannelPipelineFactory() {        public ChannelPipeline getPipeline() {            NettyCodecAdapter adapter = new NettyCodecAdapter(getCodec() ,getUrl(), NettyServer.this);            ChannelPipeline pipeline = Channels.pipeline();            /*int idleTimeout = getIdleTimeout();            if (idleTimeout > 10000) {                pipeline.addLast("timer", new IdleStateHandler(timer, idleTimeout / 1000, 0, 0));            }*/            pipeline.addLast("decoder", adapter.getDecoder());//增加解码器            pipeline.addLast("encoder", adapter.getEncoder());//增加编码器            pipeline.addLast("handler", nettyHandler);//业务处理类            return pipeline;        }    });    // bind    channel = bootstrap.bind(getBindAddress());}


返回列表