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 的相关文章

  • 使用 Java 编辑 jpeg EXIF 数据

    我想编辑 jpg 文件的属性 例如 评论 标题 拍摄日期 相机制造商等 我找到了读取这些数据的库 但我需要一个free带有示例的库edit them 我知道 apache 的成像 sanselan 但我无法用它编辑数据 如果您以前自己使用过
  • Java NIO Pipe 与 BlockingQueue

    我刚刚发现它只有一个 NIO 工具 即 Java NIO Pipe 它是为在线程之间传递数据而设计的 与通过队列 例如 ArrayBlockingQueue 传递的更传统的消息相比 使用此机制是否有任何优势 通常 将数据传递给另一个线程进行
  • Java 访问被拒绝

    C Program Files x86 Java jdk1 6 0 17 bin gt javac VendingMachine java VendingMachine java 27 error while writing Vending
  • 如何为带有未确定的“?”的Java通用Map添加值值类型?

    我在 JDK 8 示例中看到过这种声明 Map
  • Android - 检测电容式触摸屏上的触摸压力?

    我听说过 MotionEvent e float press e getPressure 但这只会在没有触摸时返回 0 当我的手指触摸屏幕时返回 1 是否可以找到手指在触摸电容屏上施加的压力值 或者我的预感是否正确 即这只适用于电阻屏幕 M
  • Java 区域设置区分大小写

    我有以下代码来显示当前区域设置 System out println Locale getDefault System out println new Locale en US 上面给出的输出如下 en US en us 如何构造一个 Lo
  • 高负载应用程序的数据库可扩展性?

    我见过一些应用程序拥有集群 Web 服务器 例如 10 到 20 个服务器 以具有可扩展性 可以在其中分发 在网络服务器之间加载 但我总是看到所有网络服务器都使用单个数据库 现在考虑任何电子商务或铁路 Web 应用程序 其中有数百万用户在任
  • 如何设置Java线程的CPU核心亲和力?

    我搜索了以前关于类似主题的帖子 但找不到合适的答案 因此提出这个问题 非常感谢您帮助回答 我知道在 Linux 中通过任务集命令设置进程与特定 CPU 核心的关联性 但我想设置 Java 线程与特定 cpu 核心的亲和力 以便属于同一进程的
  • 从java应用程序发送电子邮件时出现异常:中继被拒绝

    我们正在使用 Spring Mail 从 java 应用程序发送电子邮件 org springframework mail javamail JavaMailSenderImpl Spring电子邮件配置是
  • 创建UML图时应该编写构造函数吗?

    我有一项作业要求我为实际的 Java 程序创建 UML 图 但程序中有几个构造函数方法 我很困惑 我是否应该将这些构造函数方法添加到图中 根据 UML 规范 2 5 版第 11 4 4 节 构造函数是一个具有所属类类型的单个返回结果参数的操
  • 如何从网上获取源代码?

    我正在尝试从 Web 获取 HTML 源代码 我尝试这样做 u new URL url URLConnection con u openConnection con setRequestProperty User Agent Mozilla
  • Java DocumentBuilder - XML 文件中的缩进错误

    我尝试使用 DocumentBuilder 用 Ja va 编写一个简单的 XML 文件 我期望 XML 文件如下所示
  • Java 8 中函数类型全等 lambda 表达式的用法

    我对 的定义和用法感到困惑 Stream collect Supplier
  • 使用 GSON 将 JSON 字符串转换为 Java 对象

    我正在尝试将 json 解析为 java 根据 jsonlint com 我有以下字符串 该字符串是有效的 json private final static String LOC JSON lat1 39 737567 lat2 32 7
  • 在 Tomcat 中触发内部 ServletRequest

    我正在使用 Quartz 来安排 Web 应用程序的后台任务 其中一些任务只是针对同一 Web 应用程序发出请求 我想避免依赖于任何类型的网络设置 例如 如果从数据中心内发出带有我自己域名的请求 则可能无法正确路由 是否有一个 Java A
  • Spring Hibernate中的@Transient方法调用

    我有一个 Pojo 类 在其中创建一个未与数据库表映射的字段 所以我必须声明字段Declaration和setter和getter方法 Transient 否则会显示错误 Transient private String docHistor
  • 使用 testcontainer 作为 Dockerfile 的一部分运行测试

    我的 dockerfile 看起来像这样 FROM maven 3 jdk 11 slim COPY pom xml COPY src src RUN mvn clean install 这意味着构建的一部分是单元测试的执行 一些单元测试使
  • 解析XML文件以获取所有命名空间信息

    我希望能够从给定的 XML 文件中获取所有名称空间信息 例如 如果输入 XML 文件类似于
  • Xuggler 未转换 .webm 文件?

    我只是尝试使用 Xuggler 将 mov 文件转换为 webm 这应该可以工作 因为 FFMPEG 支持 webm 文件 这是我的代码 IMediaReader reader ToolFactory makeReader home use
  • Android 调整图片大小

    我的图像存储在 SD 卡上 每个大小约为 4MB 我想调整每个的大小 而不是将其设置为 ImageView 但我不能使用BitmapFactory decodeFile path 因为异常 java lang OutOfMemoryErro

随机推荐

  • 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