@VisibleForTesting
static HostAndPort getRunningAgentAddress(Integer registryPort, Integer serverPort)
{
JMXConnectorServer jmxServer;
RemoteObject registry;
int actualRegistryPort;
try {
jmxServer = getField(Agent.class, JMXConnectorServer.class, "jmxServer");
registry = getField(ConnectorBootstrap.class, RemoteObject.class, "registry");
if (jmxServer == null || registry == null) {
log.warn("Cannot determine if JMX agent is already running (not an Oracle JVM?). Will try to start it manually.");
return null;
}
actualRegistryPort = ((UnicastRef) registry.getRef()).getLiveRef().getPort();
}
catch (Exception e) {
log.warn(e, "Cannot determine if JMX agent is already running. Will try to start it manually.");
return null;
}