1 Star 0 Fork 65

ridedolphin/openjdk-11

forked from src-openEuler/openjdk-11 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
Add-ability-to-configure-third-port-for-remote-JMX.patch 3.36 KB
一键复制 编辑 原始数据 按行查看 历史
Noah 提交于 2020-04-26 19:46 . Initial build from OpenJDK 11.0.6
From b2ff55a515ffbead944a6cc64c77af0fb5bb9116 Mon Sep 17 00:00:00 2001
Date: Mon, 6 Jan 2020 16:25:39 +0000
Subject: [PATCH] Add ability to configure third port for remote JMX
Summary: <jmx>:<Add ability to configure third port for remote JMX>
LLT: NA
Bug url: NA
---
.../jdk/internal/agent/AgentConfigurationError.java | 2 ++
.../sun/management/jmxremote/ConnectorBootstrap.java | 19 ++++++++++++++++++-
2 files changed, 20 insertions(+), 1 deletion(-)
diff --git a/src/jdk.management.agent/share/classes/jdk/internal/agent/AgentConfigurationError.java b/src/jdk.management.agent/share/classes/jdk/internal/agent/AgentConfigurationError.java
index fb00b9f79..5f5e1672f 100644
--- a/src/jdk.management.agent/share/classes/jdk/internal/agent/AgentConfigurationError.java
+++ b/src/jdk.management.agent/share/classes/jdk/internal/agent/AgentConfigurationError.java
@@ -55,6 +55,8 @@ public class AgentConfigurationError extends Error {
"agent.err.invalid.jmxremote.port";
public static final String INVALID_JMXREMOTE_RMI_PORT =
"agent.err.invalid.jmxremote.rmi.port";
+ public static final String INVALID_JMXLOCAL_PORT =
+ "agent.err.invalid.jmxlocal.port";
public static final String PASSWORD_FILE_NOT_SET =
"agent.err.password.file.notset";
public static final String PASSWORD_FILE_NOT_READABLE =
diff --git a/src/jdk.management.agent/share/classes/sun/management/jmxremote/ConnectorBootstrap.java b/src/jdk.management.agent/share/classes/sun/management/jmxremote/ConnectorBootstrap.java
index 8d2031f88..12848cbeb 100644
--- a/src/jdk.management.agent/share/classes/sun/management/jmxremote/ConnectorBootstrap.java
+++ b/src/jdk.management.agent/share/classes/sun/management/jmxremote/ConnectorBootstrap.java
@@ -116,6 +116,8 @@ public final class ConnectorBootstrap {
"com.sun.management.jmxremote.host";
public static final String RMI_PORT =
"com.sun.management.jmxremote.rmi.port";
+ public static final String LOCAL_PORT =
+ "com.sun.management.jmxlocal.port";
public static final String CONFIG_FILE_NAME =
"com.sun.management.config.file";
public static final String USE_LOCAL_ONLY =
@@ -539,9 +541,24 @@ public final class ConnectorBootstrap {
localhost = "127.0.0.1";
}
+ // User can specify a port to be used to start Local Connector Server,
+ // if port is not specified random one will be allocated.
+ int localPort = 0;
+ String localPortStr = System.getProperty(PropertyNames.LOCAL_PORT);
+ try {
+ if (localPortStr != null) {
+ localPort = Integer.parseInt(localPortStr);
+ }
+ } catch (NumberFormatException x) {
+ throw new AgentConfigurationError(INVALID_JMXLOCAL_PORT, x, localPortStr);
+ }
+ if (localPort < 0) {
+ throw new AgentConfigurationError(INVALID_JMXLOCAL_PORT, localPortStr);
+ }
+
MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
try {
- JMXServiceURL url = new JMXServiceURL("rmi", localhost, 0);
+ JMXServiceURL url = new JMXServiceURL("rmi", localhost, localPort);
// Do we accept connections from local interfaces only?
Properties props = Agent.getManagementProperties();
if (props == null) {
--
2.12.3
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C++
1
https://gitee.com/ridedolphin/openjdk-11.git
[email protected]:ridedolphin/openjdk-11.git
ridedolphin
openjdk-11
openjdk-11
master

搜索帮助