欢迎访问 生活随笔!

生活随笔

当前位置: 首页 > 编程资源 > 编程问答 >内容正文

编程问答

ZkServer服务启动的逻辑-ServerCnxnFactory.createFactory

发布时间:2024/4/13 编程问答 36 豆豆
生活随笔 收集整理的这篇文章主要介绍了 ZkServer服务启动的逻辑-ServerCnxnFactory.createFactory 小编觉得挺不错的,现在分享给大家,帮大家做个参考.

这个方法里面是根据ZOOKEEPER_SERVER_CNXN_FACTORY 来决定创建NIO server还是Netty Server

而默认情况下,应该是创建一个NIOServerCnxnFactory 

static public ServerCnxnFactory createFactory() throws IOException { String serverCnxnFactoryName = System.getProperty(ZOOKEEPER_SERVER_CNXN_FACTORY); if (serverCnxnFactoryName == null) { serverCnxnFactoryName = NIOServerCnxnFactory.class.getName(); } try { ServerCnxnFactory serverCnxnFactory = (ServerCnxnFactory) Class.forName(serverCnxnFactoryName).getDeclaredConstructor().newInstance(); LOG.info("Using {} as server connection factory", serverCnxnFactoryName); return serverCnxnFactory; } catch (Exception e) { IOException ioe = new IOException("Couldn't instantiate " + serverCnxnFactoryName); ioe.initCause(e); throw ioe; } }

 

总结

以上是生活随笔为你收集整理的ZkServer服务启动的逻辑-ServerCnxnFactory.createFactory的全部内容,希望文章能够帮你解决所遇到的问题。

如果觉得生活随笔网站内容还不错,欢迎将生活随笔推荐给好友。