flink源码分析-获取最大可以打开的文件句柄

news/2024/10/22 9:36:18/

flink版本: flink-1.11.2

代码位置: org.apache.flink.runtime.util.EnvironmentInformation

调用位置:   taskmanager启动类:  

org.apache.flink.runtime.taskexecutor.TaskManagerRunner

long maxOpenFileHandles = EnvironmentInformation.getOpenFileHandlesLimit();

注意,该方法主要调用了com.sun.management.UnixOperatingSystemMXBean接口下的getMaxFileDescriptorCount方法,所以一定要在Sun/Oracle的JDK下才能使用。另外只能在基于Unix内核的操作系统中生效,其他系统下默认返回-1.

	/*** Tries to retrieve the maximum number of open file handles. This method will only work on* UNIX-based operating systems with Sun/Oracle Java versions.** <p>If the number of max open file handles cannot be determined, this method returns {@code -1}.</p>** @return The limit of open file handles, or {@code -1}, if the limit could not be determined.*/public static long getOpenFileHandlesLimit() {if(OperatingSystem.isWindows()) { // getMaxFileDescriptorCount method is not available on Windowsreturn -1L;}Class<?> sunBeanClass;try {sunBeanClass = Class.forName("com.sun.management.UnixOperatingSystemMXBean");} catch(ClassNotFoundException e) {return -1L;}try {Method fhLimitMethod = sunBeanClass.getMethod("getMaxFileDescriptorCount");Object result = fhLimitMethod.invoke(ManagementFactory.getOperatingSystemMXBean());return (Long) result;} catch(Throwable t) {LOG.warn("Unexpected error when accessing file handle limit", t);return -1L;}}


http://www.ppmy.cn/news/1072662.html

相关文章

各个微服务模块之间互相依赖调用的问题

首先是模块之间不能够循环引用&#xff0c;否则会报循环依赖引入的错误。 没有了模块之间的相互依赖&#xff0c;在项目中这两个模块是相互调用的&#xff0c;分别各自定义相应的Feign接口&#xff0c;如下&#xff1a; 最开始写的运行报错的代码如下&#xff1a; FeignCli…

idea --Git Commit Template插件

Git Commit Template是一款免费的IntelliJ IDEA插件&#xff0c;用于提供Git提交模板。该插件可以帮助开发者编写规范的Git提交信息&#xff0c;提高代码管理效率。 首先安装插件&#xff1a; 使用Git Commit Template插件: 注&#xff1a;long description和Breaking changes…

(三)行为模式:6、备忘录模式(Memento Pattern)(C++示例)

目录 1、备忘录模式&#xff08;Memento Pattern&#xff09;含义 2、备忘录模式的UML图学习 3、备忘录模式的应用场景 4、备忘录模式的优缺点 &#xff08;1&#xff09;优点&#xff1a; &#xff08;2&#xff09;缺点 5、C实现备忘录模式的实例 1、备忘录模式&#…

渗透测试漏洞原理之---【任意文件上传漏洞】

文章目录 1、任意文件上传概述1.1、漏洞成因1.2、漏洞危害 2、WebShell解析2.1、Shell2.2、WebShell2.2.1、大马2.2.2、小马2.2.3、GetShell 3、任意文件上传攻防3.1、毫无检测3.1.1、源代码3.1.2、代码审计3.1.3、靶场试炼 3.2、黑白名单策略3.2.1、文件检测3.2.2、后缀名黑名…

无涯教程-Android - Linear Layout函数

Android LinearLayout是一个视图组&#xff0c;该视图组将垂直或水平的所有子级对齐。 Linear Layout - 属性 以下是LinearLayout特有的重要属性- Sr.NoAttribute & 描述1 android:id 这是唯一标识布局的ID。 2 android:baselineAligned 此值必须是布尔值&#xff0c;为…

Localsolver求解器性能大提升,问题标杆研究

LocalSolver性能大提升&#xff0c;12.0发布&#xff01; 车辆路由问题 在1分钟的运行时间内&#xff0c;1,000次交货的车辆路径优化问题得到了近乎最优的解决。下面提到的“差距”是LocalSolver 12.0在标准服务器(Intel Xeon E3-1230处理器&#xff0c;4核&#xff0c;3.6 G…

Python random常见函数

Python 的 random 模块提供了很多功能来产生随机数和随机选择。以下是该模块中的一些常见函数&#xff1a; random(): 返回一个在 [0.0, 1.0) 之间的浮点数。 import random print(random.random())randint(a, b): 返回在 [a, b] 之间的随机整数&#xff0c;包括两端的值。 pri…

聊聊架构师的能力模型

要想从一名普通程序员发展成为优秀的架构师&#xff0c;“个人特性”与“技术技能”缺一不可&#xff1b;而“技术专业能力”、“人际关系能力”和“业务能力”更是优秀架构师重要的三种能力。引子究竟是什么让你在同一个位置上——例如程序员或技术负责人——工作了三年、五年…