Mercurial > hg > release > thermostat-1.0
changeset 1414:2c1c1a161396
Debug message for management agent
Reviewed-by: vanaltj
Review-thread: http://icedtea.classpath.org/pipermail/thermostat/2014-August/010516.html
PR1941
author | Omair Majid <omajid@redhat.com> |
---|---|
date | Thu, 21 Aug 2014 15:21:57 -0400 |
parents | ff297a6f60ef |
children | adb678c592f5 |
files | agent/proxy/server/src/main/java/com/redhat/thermostat/agent/proxy/server/AgentProxyControlImpl.java |
diffstat | 1 files changed, 21 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/agent/proxy/server/src/main/java/com/redhat/thermostat/agent/proxy/server/AgentProxyControlImpl.java Tue Jun 03 11:57:38 2014 -0600 +++ b/agent/proxy/server/src/main/java/com/redhat/thermostat/agent/proxy/server/AgentProxyControlImpl.java Thu Aug 21 15:21:57 2014 -0400 @@ -41,6 +41,7 @@ import java.rmi.RemoteException; import java.util.Properties; import java.util.Set; +import java.util.logging.Logger; import javax.security.auth.Subject; @@ -49,8 +50,12 @@ import com.sun.tools.attach.AttachNotSupportedException; import com.sun.tools.attach.VirtualMachine; +import com.redhat.thermostat.common.utils.LoggingUtils; + class AgentProxyControlImpl { + private static final Logger logger = LoggingUtils.getLogger(AgentProxyControlImpl.class); + private static final String CONNECTOR_ADDRESS_PROPERTY = "com.sun.management.jmxremote.localConnectorAddress"; private final int pid; @@ -78,16 +83,23 @@ Properties props = vm.getAgentProperties(); connectorAddress = props.getProperty(CONNECTOR_ADDRESS_PROPERTY); if (connectorAddress == null) { - props = vm.getSystemProperties(); - String home = props.getProperty("java.home"); - String agent = home + File.separator + "lib" + File.separator + "management-agent.jar"; - vm.loadAgent(agent); - - props = vm.getAgentProperties(); - connectorAddress = props.getProperty(CONNECTOR_ADDRESS_PROPERTY); + String home = null; + String agent = null; + try { + props = vm.getSystemProperties(); + home = props.getProperty("java.home"); + agent = home + File.separator + "lib" + File.separator + "management-agent.jar"; + logger.fine("Loading '" + agent + "' into VM (pid: " + pid + ")"); + vm.loadAgent(agent); + + props = vm.getAgentProperties(); + connectorAddress = props.getProperty(CONNECTOR_ADDRESS_PROPERTY); + } catch (IOException | AgentLoadException | AgentInitializationException e) { + throw new RemoteException("Failed to load agent ('" + agent + "', from home '" + home + "') into VM (pid: " + pid + ")", e); + } } - } catch (AttachNotSupportedException | IOException | AgentLoadException | AgentInitializationException e) { - throw new RemoteException("Failed to attach to VM", e); + } catch (AttachNotSupportedException | IOException e) { + throw new RemoteException("Failed to attach to VM (pid: " + pid + ")", e); } }