netty冲突 play sbt_《Netty官方文档》本地传输接口
原文鏈接?譯者:gm777
自4.016版本以來, Netty提供了本地的socket傳輸使Linux系統可以使用JNI(JAVA本地接口)。這個傳輸接口不僅有著高性能并且產生更少的垃圾,所以你也許會想嘗試使用一下。
使用本地傳輸接口
由于這個本地傳輸接口是與NIO傳輸接口兼容的,你只需要查詢并替代以下的內容:
NioEventLoopGroup → EpollEventLoopGroup
NioEventLoop → EpollEventLoop
NioServerSocketChannel → EpollServerSocketChannel
NioSocketChannel → EpollSocketChannel
由于這個本地傳輸接口不在Netty core 核心代碼中,你需要修改你的pom.xml文件拉出netty-transport-native-epoll這部分代碼作為依賴:
kr.motd.maven
os-maven-plugin
1.5.0.Final
...
io.netty
netty-transport-native-epoll
${project.version}
${os.detected.name}-${os.detected.arch}
...
注意以上, 你需要指定正確的classifier配置作為依賴。在pom.xml文件extensions 擴展部分os-maven-plugin的os..detected.name和os.detected.arch 配置屬性會自動配置。需要更多信息,涉及the homepage of the os-maven-plugin.
想在一個 sbt項目中使用本地傳輸接口,請在加上線在libraryDependencies:
配置
“io.netty” % “netty-transport-native-epoll” % “${project.version}” classifier “linux-x86_64”
構建本地傳輸接口包
如果你已經有了本地傳輸接口的jar包,那你將不用自己去構建本地接口包了,因為jar包中已經包含了已經所需要的包并且會自動加載上。
去構建本地傳輸接口包,你需要使用64-bit核心的2.6及其以上版本的linux操作系統。并請安裝所需要的工具和庫:
# RHEL/CentOS/Fedora:
sudo yum install autoconf automake libtool make tar \ glibc-devel libaio-devel \ libgcc.i686 glibc-devel.i686
# Debian/Ubuntu:
sudo apt-get install autoconf automake libtool make tar \ gcc-multilib libaio-dev
總結
以上是生活随笔為你收集整理的netty冲突 play sbt_《Netty官方文档》本地传输接口的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Java字符串替换前缀,从Bash中的字
- 下一篇: 共模电感适用的频率_分析共模电感和差模电