8234484: Add ability to configure third port for remote JMX
Reviewed-by: dfuchs
This commit is contained in:
parent
529587547c
commit
f129cc4328
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2004, 2013, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2004, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -55,6 +55,8 @@ public class AgentConfigurationError extends Error {
|
|||||||
"agent.err.invalid.jmxremote.port";
|
"agent.err.invalid.jmxremote.port";
|
||||||
public static final String INVALID_JMXREMOTE_RMI_PORT =
|
public static final String INVALID_JMXREMOTE_RMI_PORT =
|
||||||
"agent.err.invalid.jmxremote.rmi.port";
|
"agent.err.invalid.jmxremote.rmi.port";
|
||||||
|
public static final String INVALID_JMXREMOTE_LOCAL_PORT =
|
||||||
|
"agent.err.invalid.jmxremote.local.port";
|
||||||
public static final String PASSWORD_FILE_NOT_SET =
|
public static final String PASSWORD_FILE_NOT_SET =
|
||||||
"agent.err.password.file.notset";
|
"agent.err.password.file.notset";
|
||||||
public static final String PASSWORD_FILE_NOT_READABLE =
|
public static final String PASSWORD_FILE_NOT_READABLE =
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -116,6 +116,8 @@ public final class ConnectorBootstrap {
|
|||||||
"com.sun.management.jmxremote.host";
|
"com.sun.management.jmxremote.host";
|
||||||
public static final String RMI_PORT =
|
public static final String RMI_PORT =
|
||||||
"com.sun.management.jmxremote.rmi.port";
|
"com.sun.management.jmxremote.rmi.port";
|
||||||
|
public static final String LOCAL_PORT =
|
||||||
|
"com.sun.management.jmxremote.local.port";
|
||||||
public static final String CONFIG_FILE_NAME =
|
public static final String CONFIG_FILE_NAME =
|
||||||
"com.sun.management.config.file";
|
"com.sun.management.config.file";
|
||||||
public static final String USE_LOCAL_ONLY =
|
public static final String USE_LOCAL_ONLY =
|
||||||
@ -540,13 +542,35 @@ public final class ConnectorBootstrap {
|
|||||||
}
|
}
|
||||||
|
|
||||||
MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
|
MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
|
||||||
|
|
||||||
|
Properties props = null;
|
||||||
try {
|
try {
|
||||||
JMXServiceURL url = new JMXServiceURL("rmi", localhost, 0);
|
props = Agent.getManagementProperties();
|
||||||
// Do we accept connections from local interfaces only?
|
if (props == null) {
|
||||||
Properties props = Agent.getManagementProperties();
|
|
||||||
if (props == null) {
|
|
||||||
props = new Properties();
|
props = new Properties();
|
||||||
}
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new AgentConfigurationError(AGENT_EXCEPTION, e, e.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
// User can specify a port to be used to start local connector server.
|
||||||
|
// Random one will be allocated if port is not specified.
|
||||||
|
int localPort = 0;
|
||||||
|
String localPortStr = props.getProperty(PropertyNames.LOCAL_PORT);
|
||||||
|
try {
|
||||||
|
if (localPortStr != null) {
|
||||||
|
localPort = Integer.parseInt(localPortStr);
|
||||||
|
}
|
||||||
|
} catch (NumberFormatException x) {
|
||||||
|
throw new AgentConfigurationError(INVALID_JMXREMOTE_LOCAL_PORT, x, localPortStr);
|
||||||
|
}
|
||||||
|
if (localPort < 0) {
|
||||||
|
throw new AgentConfigurationError(INVALID_JMXREMOTE_LOCAL_PORT, localPortStr);
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
JMXServiceURL url = new JMXServiceURL("rmi", localhost, localPort);
|
||||||
|
// Do we accept connections from local interfaces only?
|
||||||
String useLocalOnlyStr = props.getProperty(
|
String useLocalOnlyStr = props.getProperty(
|
||||||
PropertyNames.USE_LOCAL_ONLY, DefaultValues.USE_LOCAL_ONLY);
|
PropertyNames.USE_LOCAL_ONLY, DefaultValues.USE_LOCAL_ONLY);
|
||||||
boolean useLocalOnly = Boolean.valueOf(useLocalOnlyStr).booleanValue();
|
boolean useLocalOnly = Boolean.valueOf(useLocalOnlyStr).booleanValue();
|
||||||
|
@ -25,6 +25,8 @@
|
|||||||
# For setting the JMX RMI agent port use the following line
|
# For setting the JMX RMI agent port use the following line
|
||||||
# com.sun.management.jmxremote.port=<port-number>
|
# com.sun.management.jmxremote.port=<port-number>
|
||||||
#
|
#
|
||||||
|
# For setting the JMX local server port use the following line
|
||||||
|
# com.sun.management.jmxremote.local.port=<port-number>
|
||||||
|
|
||||||
#####################################################################
|
#####################################################################
|
||||||
# Optional Instrumentation
|
# Optional Instrumentation
|
||||||
|
Loading…
Reference in New Issue
Block a user