在Spring boot (2.3.11) 项目中批量初始化 redis 遇到如下警告信息,大致意思就是创建了过多的 HashedWheelTimer ,由于该类需要跨JVM共享,所以建议只创建一个实例,其实这个提示个人觉得有点矛盾,因为这里有一个最大实例64的判断,也就是说可以创建多个实例,所以这个提示更多的是提示资源浪费问题,超过之后就打印该信息,但是不影响实例创建,当然处于资源浪费考虑还是少创建比较好,目前对项目没有影响

io.netty.util.HashedWheelTimer | You are creating too many HashedWheelTimer instances. HashedWheelTimer is a shared resource that must be reused across the JVM,so that only a few instances are created.

查看io.netty.util.HashedWheelTimer 源码找到以下代码块

// 这里是创建上限值(警告阈值)
private static final int INSTANCE_COUNT_LIMIT = 64;public HashedWheelTimer(ThreadFactory threadFactory,long tickDuration, TimeUnit unit, int ticksPerWheel, boolean leakDetection,long maxPendingTimeouts) {ObjectUtil.checkNotNull(threadFactory, "threadFactory");ObjectUtil.checkNotNull(unit, "unit");ObjectUtil.checkPositive(tickDuration, "tickDuration");ObjectUtil.checkPositive(ticksPerWheel, "ticksPerWheel");// Normalize ticksPerWheel to power of two and initialize the wheel.wheel = createWheel(ticksPerWheel);mask = wheel.length - 1;// Convert tickDuration to nanos.long duration = unit.toNanos(tickDuration);// Prevent overflow.if (duration >= Long.MAX_VALUE / wheel.length) {throw new IllegalArgumentException(String.format("tickDuration: %d (expected: 0 < tickDuration in nanos < %d",tickDuration, Long.MAX_VALUE / wheel.length));}if (duration < MILLISECOND_NANOS) {logger.warn("Configured tickDuration {} smaller then {}, using 1ms.",tickDuration, MILLISECOND_NANOS);this.tickDuration = MILLISECOND_NANOS;} else {this.tickDuration = duration;}workerThread = threadFactory.newThread(worker);leak = leakDetection || !workerThread.isDaemon() ? leakDetector.track(this) : null;this.maxPendingTimeouts = maxPendingTimeouts;//  这里判断创建了多少实例if (INSTANCE_COUNTER.incrementAndGet() > INSTANCE_COUNT_LIMIT &&WARNED_TOO_MANY_INSTANCES.compareAndSet(false, true)) {// 打印警告日志reportTooManyInstances();}}// 这是打印警告日志的方法(实际打印的是error日志)private static void reportTooManyInstances() {if (logger.isErrorEnabled()) {String resourceType = simpleClassName(HashedWheelTimer.class);logger.error("You are creating too many " + resourceType + " instances. " +resourceType + " is a shared resource that must be reused across the JVM," +"so that only a few instances are created.");}}

You are creating too many HashedWheelTimer instances.相关推荐

  1. Netty时间轮源码解析

      Netty主要应用用于网络通信,Netty还有一个非常重要的应用领域,即时通信系统IM, 在IM聊天系统中,有成千上万条条链路, Netty是如何管理这些链路的呢 ? Netty还有一套自带的心跳 ...

  2. Dubbo源码——时间轮算法

    定时任务 /*** A task which is executed after the delay specified with* {@link Timer#newTimeout(TimerTask ...

  3. payara 创建 集群_高可用性(HA),会话复制,多VM Payara群集

    payara 创建 集群 抽象 在研究如何创建高可用性(HA)时,我发现了会话复制,多机处理的Payara / GlassFish群集,无法在单个参考中找到所需的一切. 我认为这将是一个普遍的需求并且 ...

  4. 高可用性(HA),会话复制,多VM Payara群集

    抽象 在研究如何创建高可用性(HA)时,我发现了会话复制的多机Payara / GlassFish群集,无法在一个参考中找到所需的一切. 我认为这将是一个普遍的需求并且很容易找到. 不幸的是,我的假设 ...

  5. Swift中文教程(十四) 初始化

    初始化是类,结构体和枚举类型实例化的准备阶段.这个阶段设置这个实例存储的属性的初始化数值和做一些使用实例之前的准备以及必须要做的其他一些设置工作. 通过定义构造器(initializers)实现这个实 ...

  6. 使用Handlerf发送消息或使用Handler轮询时,报错IllegalStateException:This message is already in use.;...

    java.lang.IllegalStateException: { when=-107ms what=9 obj=com.saicmaxus.maxuslife.model.CarInfo@be47 ...

  7. iOS中的中间人-NSURLProtocol 的原理和使用实例

    Part 1: 使用范围 能拦截NSURLRequest请求 When an NSURLSession, NSURLConnection, or NSURLDownload object initia ...

  8. [Android]Handler的消息机制

    最经面试中,技术面试中有一个是Handler的消息机制,细细想想,我经常用到的Handler无非是在主线程(或者说Activity)新建一个Handler对象,另外一个Thread是异步加载数据,同时 ...

  9. 在.net 当中如何XML序列化一个Collection

    Collection主要是指像Array, ArrayList, List, Dictionary, HashTable这些数据类型,大家平时用的很多.如果一个类中有一个Collection类型的成员 ...

  10. boto3 连接aws_Python,Boto3和AWS S3:神秘化

    boto3 连接aws Amazon Web Services (AWS) has become a leader in cloud computing. One of its core compon ...

最新文章

  1. ASP.NET程序中常用的三十三种代码
  2. 在ASP.NET MVC5中使用特性路由
  3. 盘点几种数据库的分页SQL的写法(转)
  4. 哈工大未来计算机院士,2017年中国高校新增工程院院士名单出炉,哈工大依然很强!...
  5. windows installer 3.2搞定
  6. python回溯算法全排列_python 回溯法 子集树模板 系列 —— 11、全排列
  7. 想知道PDF转Word软件哪个好?向你推荐3个自用软件
  8. Stored Outline
  9. 关于命运(详细娱乐诠释)
  10. 1984-1999:中国电影的黄金十五年
  11. 电信aep平台是什么意思_亚马逊电商平台是什么意思?亚马逊注册技巧
  12. 直接序列扩频通信系统
  13. 鸡兔同笼python程序怎么写_鸡(土从)
  14. zxing 二维码、带logo二维码生成
  15. ROS系统之安装系列(一):安装步骤
  16. html 按钮默认值,button_标签 | Elements_HTML_参考手册_非常教程
  17. 打开 WORD 报错“无法创建工作文件, 请检查临时环境变量”
  18. 【iOS与EV3混合机器人编程系列之六】iOS_WiFi_EV3_Library 剖析之发送命令给EV3
  19. 使用caffe训练自己的CNN
  20. BP神经网络+c代码

热门文章

  1. c语言 虚拟摄像头设备_c++ 虚拟摄像头驱动程序
  2. hosts文件位置在哪里?(3种打开hosts文件的方法)
  3. [BZOJ5470][模拟]FJOI2018:所罗门王的宝藏
  4. (转载)yocto相关class总结
  5. AM调制解调matlab实验报告,基于MATLAB的AM调制解调系统仿真报告
  6. 2019软件工程专业大学排名附官网-奥怪的小栈
  7. 飞凌OK6410A 多媒体视频编解码 player-qt4 QT视频播放器
  8. 金山毒霸11,更新内容,问题修复了什么?
  9. win10重置计算机网络设置,win10网络重置后,win10网络重置怎么恢复
  10. 【C语言】- 关机小程序