For example, maybe we can add new plugin configuration settings to tell
the JMX plugin to ignore certain filters. This allows the user to ignore
certain things while allowing other users not to. Maybe I want to see my
tomcat VMs as JMX Servers - but as of now, you have not given me that
choice.
John Mazzitelli wrote:
IMO, we should not do this kind of thing.
We basically are hardcoding knowledge about a Jopr plugin into a core
RHQ plugin. This is bad practice. An RHQ plugin should not care about
or know anything about a Jopr plugin. In fact, the general practice is
one plugin should not know anything about another plugin.
Pretty soon, we could potentially have bunches of these little
"nuggets" all over the place and then we get into how the old JON 1.x
plugin system worked - dependencies all over the place without any
compartmentalization.
Let's think this through and come up with another solution that
doesn't dirty up the RHQ JMX plugin with Jopr-plugin-specific knowledge.
-------- Original Message --------
Subject: [Rhq-commits] [
rhq-project.org rhq] [2749] Jopr-55 Filter
out standalone Tomcat processes from the JMX plugin discovery.
Date: 26 Jan 2009 17:45:00 -0000
From: jshaughn(a)rhq-project.org
To: rhq-commits(a)lists.sourceforge.net
Revision
2749
Author
jshaughn
Date
2009-01-26 11:45:00 -0600 (Mon, 26 Jan 2009)
Log Message
Jopr-55 Filter out standalone Tomcat processes from the JMX plugin
discovery. To manage standalone Tomcat the Jopr Tomcat plugin should
be installed.
Modified Paths
*
rhq/trunk/modules/plugins/jmx/src/main/java/org/rhq/plugins/jmx/JMXDiscoveryComponent.java
<#rhqtrunkmodulespluginsjmxsrcmainjavaorgrhqpluginsjmxJMXDiscoveryComponentjava>
Diff
Modified:
rhq/trunk/modules/plugins/jmx/src/main/java/org/rhq/plugins/jmx/JMXDiscoveryComponent.java
(2748 => 2749)
---
rhq/trunk/modules/plugins/jmx/src/main/java/org/rhq/plugins/jmx/JMXDiscoveryComponent.java
2009-01-26 15:31:31 UTC (rev 2748)
+++
rhq/trunk/modules/plugins/jmx/src/main/java/org/rhq/plugins/jmx/JMXDiscoveryComponent.java
2009-01-26 17:45:00 UTC (rev 2749)
@@ -59,11 +59,16 @@
public static final String ADDITIONAL_CLASSPATH_ENTRIES =
"additionalClassPathEntries";
+ /* Ignore certain processes that are managed by their own plugin.
For example The Tomcat plugin will
+ * handle tomcat processes configured for JMX management.
+ */
+ private static final String[] PROCESS_FILTERS = {
"catalina.startup.Bootstrap" };
+
public Set<DiscoveredResourceDetails>
discoverResources(ResourceDiscoveryContext context) {
Set<DiscoveredResourceDetails> found = new
HashSet<DiscoveredResourceDetails>();
- // This model of discovery is of questionable usefullness
since if you restart your process you'll get a new resource
+ // This model of discovery is of questionable usefulness
since if you restart your process you'll get a new resource
// Works only on JDK6 and maybe some 64 bit JDK5 See JBNADM-3332.
//
// Map<Integer, LocalVirtualMachine> vms;
@@ -114,7 +119,16 @@
for (ProcessInfo process : processes) {
DiscoveredResourceDetails details =
discoverProcess(context, process);
if (details != null) {
- found.add(details);
+ boolean isFiltered = false;
+ for (String filter : PROCESS_FILTERS) {
+ if
(details.getResourceName().contains(filter)) {
+ isFiltered = true;
+ break;
+ }
+ }
+ if (!isFiltered) {
+ found.add(details);
+ }
}
}
} catch (Exception e) {
@@ -128,8 +142,7 @@
String resourceKey =
c.getSimpleValue(CONNECTOR_ADDRESS_CONFIG_PROPERTY, null);
String connectionType = c.getSimpleValue(CONNECTION_TYPE,
null);
- DiscoveredResourceDetails s = new
DiscoveredResourceDetails(context.getResourceType(), resourceKey,
- "Java VM", "?", connectionType + " [" +
resourceKey +
"]", null, null);
+ DiscoveredResourceDetails s = new
DiscoveredResourceDetails(context.getResourceType(), resourceKey,
"Java VM", "?", connectionType + " [" + resourceKey +
"]", null, null);
s.setPluginConfiguration(c);
@@ -175,14 +188,11 @@
name += " (" + port + ")";
Configuration config =
context.getDefaultPluginConfiguration();
- config.put(new PropertySimple(CONNECTION_TYPE,
-
"org.mc4j.ems.connection.support.metadata.J2SE5ConnectionTypeDescriptor"));
- config.put(new
PropertySimple(CONNECTOR_ADDRESS_CONFIG_PROPERTY,
"service:jmx:rmi:///jndi/rmi://localhost:"
- + port + "/jmxrmi"));
+ config.put(new PropertySimple(CONNECTION_TYPE,
"org.mc4j.ems.connection.support.metadata.J2SE5ConnectionTypeDescriptor"));
+ config.put(new
PropertySimple(CONNECTOR_ADDRESS_CONFIG_PROPERTY,
"service:jmx:rmi:///jndi/rmi://localhost:" + port + "/jmxrmi"));
// config.put(new PropertySimple(INSTALL_URI,
process.getCurrentWorkingDirectory()));
- details = new
DiscoveredResourceDetails(context.getResourceType(), port, name, null,
- "Standalone JVM Process", config, null);
+ details = new
DiscoveredResourceDetails(context.getResourceType(), port, name, null,
"Standalone JVM Process", config, null);
}
return details;