netty使用epoll报错:java.lang.UnsatisfiedLinkError: failed to load the required native library

2023-05-16

Caused by: java.lang.UnsatisfiedLinkError: could not load a native library: netty_transport_native_epoll_x86_64

最近修改moquette代码, NettyAcceptor类中, 如果epoll为true, m_bossGroup = new EpollEventLoopGroup();会报错(原版本默认使用NIO).代码和错误信息如下:

使用以下方法解决.最终测试,使用epoll性能远不如NIO(仅限本测试).

吞吐量上不去, 而且cpu占用高

极限都都到不了10w/s 感觉也就7w/s
用NIO能到差不多20W/s

原文:http://netty.io/wiki/native-transports.html

Netty provides the following platform specific JNI transports:

  • Linux (since 4.0.16)
  • MacOS/BSD (since 4.1.11)

These JNI transports add features specific to a particular platform, generate less garbage, and generally improve performance when compared to the NIO based transport.

Using the native transports

Note that you must specify the proper classifier for the dependency. os-maven-plugin in the extensions section in the pom.xml file will set os.detected.name and os.detected.arch properties automatically. For more information. refer to the homepage of the os-maven-plugin.

Using the Linux native transport

Because the native transport is compatible with the NIO transport, you can just do the following search-and-replace:

  • NioEventLoopGroup → EpollEventLoopGroup
  • NioEventLoop → EpollEventLoop
  • NioServerSocketChannel → EpollServerSocketChannel
  • NioSocketChannel → EpollSocketChannel

Because the native transport is not part of the Netty core, you need to pull the netty-transport-native-epoll as a dependency in your Maven pom.xml:


  <build>
    <extensions>
      <extension>
        <groupId>kr.motd.maven</groupId>
        <artifactId>os-maven-plugin</artifactId>
        <version>1.5.0.Final</version>
      </extension>
    </extensions>
    ...
  </build>

  <dependencies>
    <dependency>
      <groupId>io.netty</groupId>
      <artifactId>netty-transport-native-epoll</artifactId>
      <version>${project.version}</version>
      <classifier>${os.detected.name}-${os.detected.arch}</classifier>
    </dependency>
    ...
  </dependencies>  

For using the native transport in a sbt project, please add line below to your libraryDependencies:

"io.netty" % "netty-transport-native-epoll" % "${project.version}" classifier "linux-x86_64"

Using the MacOS/BSD native transport

Because the native transport is compatible with the NIO transport, you can just do the following search-and-replace:

  • NioEventLoopGroup → KQueueEventLoopGroup
  • NioEventLoop → KQueueEventLoop
  • NioServerSocketChannel → KQueueServerSocketChannel
  • NioSocketChannel → KQueueSocketChannel

Because the native transport is not part of the Netty core, you need to pull the netty-transport-native-kqueue as a dependency in your Maven pom.xml:


  <build>
    <extensions>
      <extension>
        <groupId>kr.motd.maven</groupId>
        <artifactId>os-maven-plugin</artifactId>
        <version>1.5.0.Final</version>
      </extension>
    </extensions>
    ...
  </build>

  <dependencies>
    <dependency>
      <groupId>io.netty</groupId>
      <artifactId>netty-transport-native-kqueue</artifactId>
      <version>${project.version}</version>
      <classifier>${os.detected.name}-${os.detected.arch}</classifier>
    </dependency>
    ...
  </dependencies>  

For using the native transport in a sbt project, please add line below to your libraryDependencies:

"io.netty" % "netty-transport-native-kqueue" % "${project.version}" classifier "osx-x86_64"

Building the native transports

If you already have the JAR file of the native transport, you should not need to build the native transport by yourself because the JAR file already contains the necessary shared library files (e.g. .so.dll.dynlib) and they will be loaded automatically.

Building the Linux native transport

To build the native transport, you need to use Linux with 64-bit kernel 2.6 or higher. Please also install the required tools and libraries:


# 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  

Building the MacOS/BSD native transport

To build the native transport, you need to use MacOS 10.12 or higher. Please also install the required tools and libraries:


brew install autoconf automake libtool  

 

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

netty使用epoll报错:java.lang.UnsatisfiedLinkError: failed to load the required native library 的相关文章

  • Google 地图查询返回的 JSON 包含像 \x26 这样的编码字符(如何解码?)

    在 Java 应用程序中 我获取 JSON 来自 Google 地图 其中包含以下字符 x26我想将其转换为其原始字符 据我所知 这是一个 UTF 8 表示法 但我不完全确定 在源 JSON 中 可能会出现各种编码字符 例如 x3c div
  • 检查双精度值的等于和不等于条件

    我在比较两者时遇到困难double values using and 我创建了 6 个双变量并尝试进行比较If健康 状况 double a b c d e f if a b c d e f My code here in case of t
  • 如何打印整个字符串池?

    我想打印包含文字的整个字符串池String使用添加的对象intern 就在垃圾收集之前 JDK有没有隐式的方法来进行这样的操作 我们如何检查字符串池 EDIT The comment suggests that there may be a
  • java.lang.Class: 在 java 程序中初始化 log4j 属性文件时出错

    我正在尝试使用 log4j 运行独立的 java 程序 但在调试时收到以下消息 控制台上没有 log4j 相关日志 log Logger 1343 java lang Class ERROR in 18b4aac2 有人可以建议这里出了什么
  • 通过 InjectMocks Spy 注入对象

    我需要对一个类运行一系列单元测试 该类具有 Autowired Logger 实现 实现的基本思想是 Mock Logger logger InjectMocks TestedClass tested 但我想保存日志输出功能 Mockito
  • 有没有好的方法来解析用户代理字符串?

    我有一个Java接收模块User Agent来自最终用户浏览器的字符串的行为需要略有不同 具体取决于浏览器类型 浏览器版本甚至操作系统 例如 FireFox 7 0 Win7 Safari 3 2 iOS9 我明白了User Agent由于
  • 如何解决 onEditCommit 事件上的类型不匹配错误?

    我在 Fxml 中使用 onEditCommit 事件在用户编辑数据后检索数据 FXML 代码
  • PropertySources 中各种源的优先级

    Spring引入了新的注释 PropertySources对于所有标记为的类 Configuration since 4 0 需要不同的 PropertySource作为论证 PropertySources PropertySource c
  • 如何将 Spotlight for Help 插入本地化的 macOS 应用程序?

    我正在 macOS 上使用 Swing GUI 框架实现 Java 应用程序 当使用system外观和感觉以及screen菜单栏 Swing 自动插入一个搜索栏 called 聚光灯寻求帮助 https developer apple co
  • 如何在java中使jpeg无损?

    有没有人可以告诉我如何使用编写 jpeg 文件losslessjava中的压缩 我使用下面的代码读取字节来编辑字节 WritableRaster raster image getRaster DataBufferByte buffer Da
  • 覆盖 MATLAB 默认静态 javaclasspath 的最佳方法

    MATLAB 配置为在搜索用户可修改的动态路径之前搜索其静态 java 类路径 不幸的是 静态路径包含相当多非常旧的公共库 因此如果您尝试使用新版本 您可能最终会加载错误的实现并出现错误 例如 静态路径包含 google collectio
  • 如何使用 Mockito 和 Junit 模拟 ZonedDateTime

    我需要模拟一个ZonedDateTime ofInstant 方法 我知道SO中有很多建议 但对于我的具体问题 到目前为止我还没有找到任何简单的解决办法 这是我的代码 public ZonedDateTime myMethodToTest
  • 来自客户端的超时 Web 服务调用

    我正在使用 RestEasy 客户端调用网络服务 一项要求是 如果调用运行时间超过 5 秒 则中止 超时调用 我如何使用 RestEasy 客户端实现这一目标 我只看到服务器端超时 即如果在一定时间内未完成请求 Rest Easy 网络服务
  • 从java中的字符串数组中删除空值

    java中如何从字符串数组中删除空值 String firstArray test1 test2 test4 我需要像这样没有 null 空 值的 firstArray String firstArray test1 test2 test4
  • 如何移动图像(动画)?

    我正在尝试在 x 轴上移动船 还没有键盘 我如何将运动 动画与boat png而不是任何其他图像 public class Mama extends Applet implements Runnable int width height i
  • Path2D 上的鼠标指针检测

    我构建了一个Path2D http docs oracle com javase 7 docs api java awt geom Path2D html表示由直线组成的未闭合形状 我希望能够检测何时单击鼠标并且鼠标指针靠近路径 在几个像素
  • 如何将实例变量传递到 Quartz 作业中?

    我想知道如何在 Quartz 中外部传递实例变量 下面是我想写的伪代码 如何将 externalInstance 传递到此作业中 public class SimpleJob implements Job Override public v
  • Java中获取集合的幂集

    的幂集为 1 2 3 is 2 3 2 3 1 2 1 3 1 2 3 1 假设我有一个Set在爪哇中 Set
  • 为什么 BufferedWriter 不写入文件?

    我有这个代码 String strings Hi You He They Tetrabenzene Caaorine Calorine File file new File G words txt FileWriter fWriter Bu
  • Java中有类似分支/跳转表的东西吗?

    Java有类似分支表或跳转表的东西吗 分支表或跳转表是 根据维基百科 http en wikipedia org wiki Branch table 用于描述使用分支指令表将程序控制 分支 转移到程序的另一部分 或可能已动态加载的不同程序

随机推荐

  • Realsense-Ros安装配置介绍与问题解决

    Realsense Ros安装配置介绍与问题解决 Realsense Ros安装配置功能包克隆与编译编译错误与问题分析解决方案 结束语 本文主要讲述在如何进行Realsense Ros的安装与配置 xff0c 以及提出在安装配置过程中遇到相
  • 树莓派3 Ubuntu Meta16.04 操作系统烧录教程及系统换源

    树莓派3 Ubuntu Meta16 04 操作系统烧录教程及系统换源 1 写在开头 xff1a 2 操作系统烧录软件下载3 Ubuntu Meta 操作系统下载4 操作系统烧录4 1 SD 存储卡格式化4 2 操作系统写入4 3 换源更新
  • Ubuntu nautilus 快速打开文件浏览器

    Ubuntu nautilus 快速打开文件浏览器 1 问题描述2 nautilus 命令说明3 bashrc 下使用 alias 创建命令别名Reference 测试时间 xff1a 2022年6月20日 测试平台 xff1a Ubunt
  • 结构体嵌套结构体,及其的初始化

    作用 xff1a 结构体的的参数成员包含另一个结构体 利用 操作符来逐级访问结构体中的元素 1 先来个普通的结构体嵌套 xff0c xff08 不涉及数组 xff09 span class token macro property span
  • Spark Streaming + Spark SQL 实现配置化ETL流程

    Spark Streaming 非常适合ETL 但是其开发模块化程度不高 xff0c 所以这里提供了一套方案 xff0c 该方案提供了新的API用于开发Spark Streaming程序 xff0c 同时也实现了模块化 xff0c 配置化
  • 程序员永远的痛之字符编码的奥秘

    字符编码相信是每个程序员的噩梦 xff0c 只要是有中文的地方 xff0c 总是会遇到各种编码的问题 xff0c 并且这种问题还非常难缠 xff0c 尤其在linux上 xff0c 因为上面很多软件都是针对英语国家开发的 xff0c 是不会
  • 2013年终总结

    年终感悟 xff1a 2013年就这样过去了 xff0c 每个人都一样 xff0c 使用了自己一年生命药水 xff0c 要知道这种药品是花多少钱都买不来的 现在回头看看 xff0c 我用这一瓶药水都做了那些事情 在这一年里 xff0c 有过
  • C++11 之for 新解

    前言 C 43 43 11这次的更新带来了令很多C 43 43 程序员期待已久的for range循环 xff0c 每次看到javascript xff0c lua里的for range xff0c 心想要是C 43 43 能有多好 xff
  • c++11之初始化列表

    一 前言 C 43 43 的学习中 xff0c 我想每个人都被变量定义和申明折磨过 xff0c 比如我在大学笔试过的几家公司 xff0c 都考察了const和变量 xff0c 类型的不同排列组合 xff0c 让你区别有啥不同 反正在学习C
  • Unity Update 详解

    0x01 简介 Unity的脚本继承了Monobehaviour类 xff0c 在脚本中定义函数 xff1a void FixedUpdate span class hljs list span void span class hljs k
  • 2016总结

    欲言又止 xff1a 每年的年终总结是要在新年之前发表在博客上 xff0c 今年的年终总结拖到现在完成 xff0c 我也是服自己 这里要感谢我的高中好友 64 万学清同学 xff0c 在我去年微信发表的有关年终总结的朋友圈下 xff0c 催
  • 阅读代码和修改别人代码的一些技巧以及注意事项

    作为刚刚走上工作岗位的fish xff0c 都要熟悉前辈们留下来的代码 这段时间是fish最痛苦的时间同时也是最轻松的时间 痛苦是因为要看大量的代码 xff0c 同时要慢慢从学生到社会人士的转变 xff08 xff0c 再不能睡懒觉了 xf
  • 一个分号引发的血案

    最近在看 Data Structures and Algorithms 这本书 xff0c 书里对数据结构和算法进行了简单的描述 xff0c 并且用伪码进行了实现 伪码毕竟和代码还是有很大不同的 xff0c 书的说明里说有C 写的源码 xf
  • Iphone客户端程序员半年工作总结

    来公司四个半月了 xff0c 从对客户端游戏编程的小白慢慢的也能写一些东西了 xff0c 当然了这里最感谢的人就是九天了 xff0c 对于九天其它的好我就不说了 xff0c 就是感觉九天为了团队 xff0c 为了项目 xff0c 他在很用心
  • Unity Android Activity控制

    前言 开发游戏 xff0c 在国内发行 xff0c 接入各个渠道SDK是一件绕不开的事情 并且这件事非常复杂琐碎 xff0c 原因如下 xff1a a 发行平台多 xff0c Android平台有30 xff0c 40家主流发行平台 b 每
  • MongoDB ODM 框架MongoMongo-简化你的数据存储

    MongMongo是一个用Java写的ODM框架 xff0c 使得对MongoDB的操作更加便捷 MongoMongo努力为Java开发者提供类似于ActiveORM 或者 Hibernate的操作API 并且保留了MongoDB的sche
  • Unity Android 加载动态库

    前言 在接入360 Android SDK时遇到在有些机型的Android机器上报错 xff0c 具体错误提示为 xff1a Failure to initialize Your hardware does not support this
  • 德鲁克谈《自我管理》笔记摘要

    一 我的长处是什么 多数人都以为他们知道自己擅长什么 xff0c 其实不然 要发现自己的长处 xff0c 唯一的途径就是分析回馈法 写下自己预期的结果 9 12个月后 xff0c 将实际结果和预期比较 总结改善自己的预期和行动 我们要以持之
  • ubuntu下搭建cocos2dx编程环境-上

    这大半年一直在开发flash游戏 xff0c 用到的编程语言是actionscript和c 43 43 所以这次公司决定开发手游端的话 xff0c C 43 43 不是很生疏 xff0c 这是个好消息 坏消息是由于现在网页游戏还没有上线 x
  • netty使用epoll报错:java.lang.UnsatisfiedLinkError: failed to load the required native library

    Caused by java lang UnsatisfiedLinkError could not load a native library netty transport native epoll x86 64 最近修改moquett