Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GEODE-3: remove dependency on management-agent.jar which is not inclu… #2478

Merged
merged 1 commit into from
Sep 18, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import static org.apache.commons.lang.Validate.isTrue;
import static org.apache.commons.lang.Validate.notNull;

import java.io.File;
import java.io.IOException;
import java.util.Properties;
import java.util.Set;
Expand All @@ -33,8 +32,6 @@
import javax.management.remote.JMXConnectorFactory;
import javax.management.remote.JMXServiceURL;

import com.sun.tools.attach.AgentInitializationException;
import com.sun.tools.attach.AgentLoadException;
import com.sun.tools.attach.AttachNotSupportedException;
import com.sun.tools.attach.VirtualMachine;

Expand Down Expand Up @@ -233,32 +230,9 @@ private JMXServiceURL getJMXServiceURL() throws AttachNotSupportedException, IOE
connectorAddress = agentProps.getProperty(PROPERTY_LOCAL_CONNECTOR_ADDRESS);

if (connectorAddress == null) {
// need to load the management-agent and get the address

String javaHome = vm.getSystemProperties().getProperty("java.home");

// assume java.home is JDK and look in JRE for agent
String managementAgentPath = javaHome + File.separator + "jre" + File.separator + "lib"
+ File.separator + "management-agent.jar";
File managementAgent = new File(managementAgentPath);
if (!managementAgent.exists()) {
// assume java.home is JRE and look in lib for agent
managementAgentPath =
javaHome + File.separator + "lib" + File.separator + "management-agent.jar";
managementAgent = new File(managementAgentPath);
if (!managementAgent.exists()) {
throw new IOException("JDK management agent not found");
}
}

// attempt to load the management agent
managementAgentPath = managementAgent.getCanonicalPath();
try {
vm.loadAgent(managementAgentPath, "com.sun.management.jmxremote");
} catch (AgentLoadException | AgentInitializationException e) {
throw new IOException(e);
}

// make sure the local management agent is started and this will ensure
// localConnectorAddress is present in the agent properties.
vm.startLocalManagementAgent();
// get the connector address
agentProps = vm.getAgentProperties();
connectorAddress = agentProps.getProperty(PROPERTY_LOCAL_CONNECTOR_ADDRESS);
Expand Down