Skip to content
This repository has been archived by the owner on Jul 11, 2022. It is now read-only.

Commit

Permalink
[BZ 1109818] partial cherry-pick of bbb18b7 for JMXServerComponent c…
Browse files Browse the repository at this point in the history
…hanges only.
  • Loading branch information
Simeon Pinder committed Jun 23, 2014
1 parent d3a926b commit a9a9afb
Showing 1 changed file with 16 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,15 @@ public void start(ResourceContext context) throws Exception {
} catch (Exception e) {
if (e.getCause() instanceof SecurityException) {
throw new InvalidPluginConfigurationException("Failed to authenticate to managed JVM - "
+ "principal and/or credentials connection properties are not set correctly.");
+ "principal and/or credentials connection properties are not set correctly.");
}
// don't litter agent log with a stack trace unless we're in debug
if (log.isDebugEnabled()) {
log.warn("Failed to connect to " + context.getResourceType() + "[" + context.getResourceKey() + "].", e);
} else {
log.warn("Failed to connect to " + context.getResourceType() + "[" + context.getResourceKey() + "]: "
+ e.getMessage());
}
log.warn("Failed to connect to " + context.getResourceType() + "[" + context.getResourceKey() + "].", e);
}
}

Expand All @@ -82,13 +88,19 @@ protected void internalStart() throws Exception {
String connectionTypeDescriptorClassName = pluginConfig.getSimple(JMXDiscoveryComponent.CONNECTION_TYPE)
.getStringValue();
if (JMXDiscoveryComponent.PARENT_TYPE.equals(connectionTypeDescriptorClassName)) {
// Our parent is itself a JMX component, so just reuse its connection.
// Our parent is itself a JMX component, so just reuse its connection, if it has one.
this.connection = ((JMXComponent) context.getParentResourceComponent()).getEmsConnection();
if (null == this.connection) {
throw new IllegalStateException("Could not access parent connection, parent may be down");
}
this.connectionProvider = this.connection.getConnectionProvider();
} else {
this.connectionProvider = ConnectionProviderFactory.createConnectionProvider(pluginConfig,
this.context.getNativeProcess(), this.context.getTemporaryDirectory());
this.connection = this.connectionProvider.connect();
if (null == this.connection) {
throw new IllegalStateException("Failed to create connection, resource may be down");
}
this.connection.loadSynchronous(false);
}
}
Expand Down Expand Up @@ -149,4 +161,4 @@ private synchronized void reconnectIfDisconnected() {
}
}
}
}
}

0 comments on commit a9a9afb

Please sign in to comment.