提交 ea16bc62 编写于 作者: A asaha

Merge

......@@ -34,7 +34,6 @@ import java.lang.management.ManagementFactory;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.net.InetAddress;
import java.net.Socket;
import java.net.UnknownHostException;
import java.text.MessageFormat;
import java.util.MissingResourceException;
......@@ -88,7 +87,7 @@ public class Agent {
// return empty property set
private static Properties parseString(String args) {
Properties argProps = new Properties();
if (args != null) {
if (args != null && !args.trim().equals("")) {
for (String option : args.split(",")) {
String s[] = option.split("=", 2);
String name = s[0].trim();
......@@ -160,53 +159,59 @@ public class Agent {
throw new RuntimeException(getText(INVALID_STATE, "Agent already started"));
}
Properties argProps = parseString(args);
Properties configProps = new Properties();
try {
Properties argProps = parseString(args);
Properties configProps = new Properties();
// Load the management properties from the config file
// if config file is not specified readConfiguration implicitly
// reads <java.home>/lib/management/management.properties
// Load the management properties from the config file
// if config file is not specified readConfiguration implicitly
// reads <java.home>/lib/management/management.properties
String fname = System.getProperty(CONFIG_FILE);
readConfiguration(fname, configProps);
String fname = System.getProperty(CONFIG_FILE);
readConfiguration(fname, configProps);
// management properties can be overridden by system properties
// which take precedence
Properties sysProps = System.getProperties();
synchronized (sysProps) {
configProps.putAll(sysProps);
}
// management properties can be overridden by system properties
// which take precedence
Properties sysProps = System.getProperties();
synchronized (sysProps) {
configProps.putAll(sysProps);
}
// if user specifies config file into command line for either
// jcmd utilities or attach command it overrides properties set in
// command line at the time of VM start
String fnameUser = argProps.getProperty(CONFIG_FILE);
if (fnameUser != null) {
readConfiguration(fnameUser, configProps);
}
// if user specifies config file into command line for either
// jcmd utilities or attach command it overrides properties set in
// command line at the time of VM start
String fnameUser = argProps.getProperty(CONFIG_FILE);
if (fnameUser != null) {
readConfiguration(fnameUser, configProps);
}
// arguments specified in command line of jcmd utilities
// override both system properties and one set by config file
// specified in jcmd command line
configProps.putAll(argProps);
// arguments specified in command line of jcmd utilities
// override both system properties and one set by config file
// specified in jcmd command line
configProps.putAll(argProps);
// jcmd doesn't allow to change ThreadContentionMonitoring, but user
// can specify this property inside config file, so enable optional
// monitoring functionality if this property is set
final String enableThreadContentionMonitoring =
configProps.getProperty(ENABLE_THREAD_CONTENTION_MONITORING);
// jcmd doesn't allow to change ThreadContentionMonitoring, but user
// can specify this property inside config file, so enable optional
// monitoring functionality if this property is set
final String enableThreadContentionMonitoring =
configProps.getProperty(ENABLE_THREAD_CONTENTION_MONITORING);
if (enableThreadContentionMonitoring != null) {
ManagementFactory.getThreadMXBean().
setThreadContentionMonitoringEnabled(true);
}
if (enableThreadContentionMonitoring != null) {
ManagementFactory.getThreadMXBean().
setThreadContentionMonitoringEnabled(true);
}
String jmxremotePort = configProps.getProperty(JMXREMOTE_PORT);
if (jmxremotePort != null) {
jmxServer = ConnectorBootstrap.
startRemoteConnectorServer(jmxremotePort, configProps);
String jmxremotePort = configProps.getProperty(JMXREMOTE_PORT);
if (jmxremotePort != null) {
jmxServer = ConnectorBootstrap.
startRemoteConnectorServer(jmxremotePort, configProps);
startDiscoveryService(configProps);
startDiscoveryService(configProps);
} else {
throw new AgentConfigurationError(INVALID_JMXREMOTE_PORT, "No port specified");
}
} catch (AgentConfigurationError err) {
error(err.getError(), err.getParams());
}
}
......@@ -507,7 +512,7 @@ public class Agent {
String keyText = getText(key);
System.err.print(getText("agent.err.error") + ": " + keyText);
System.err.println(": " + message);
throw new RuntimeException(keyText);
throw new RuntimeException(keyText + ": " + message);
}
public static void error(Exception e) {
......
......@@ -43,7 +43,7 @@ agent.err.agentclass.failed = Management agent class failed
agent.err.premain.notfound = premain(String) does not exist in agent class
agent.err.agentclass.access.denied = Access to premain(String) is denied
agent.err.invalid.agentclass = Invalid com.sun.management.agent.class property value
agent.err.invalid.state = Invalid agent state
agent.err.invalid.state = Invalid agent state: {0}
agent.err.invalid.jmxremote.port = Invalid com.sun.management.jmxremote.port number
agent.err.invalid.jmxremote.rmi.port = Invalid com.sun.management.jmxremote.rmi.port number
......
......@@ -93,7 +93,7 @@ public class StartManagementAgent {
} catch(AttachOperationFailedException ex) {
// We expect parsing of "apa" above to fail, but if the file path
// can't be read we get a different exception message
if (!ex.getMessage().contains("java.lang.NumberFormatException")) {
if (!ex.getMessage().contains("Invalid com.sun.management.jmxremote.port number")) {
throw ex;
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册