From: <do...@hy...> - 2008-09-02 22:12:43
|
Author: dougm Date: 2008-09-02 15:12:41 -0700 (Tue, 02 Sep 2008) New Revision: 10949 URL: http://svn.hyperic.org/?view=rev&root=Hyperic+HQ&revision=10949 Modified: trunk/plugins/websphere/src/org/hyperic/hq/plugin/websphere/ConnectionPoolCollector.java trunk/plugins/websphere/src/org/hyperic/hq/plugin/websphere/jmx/JDBCProviderQuery.java trunk/plugins/websphere/src/org/hyperic/hq/plugin/websphere/jmx/WebSphereQuery.java trunk/plugins/websphere/src/org/hyperic/hq/plugin/websphere/jmx/WebsphereRuntimeDiscoverer.java Log: [HHQ-2353] Fix Connection Pool queries for multi-server nodes (merged from branches/HQ_3_2) Modified: trunk/plugins/websphere/src/org/hyperic/hq/plugin/websphere/ConnectionPoolCollector.java =================================================================== --- trunk/plugins/websphere/src/org/hyperic/hq/plugin/websphere/ConnectionPoolCollector.java 2008-09-02 22:10:01 UTC (rev 10948) +++ trunk/plugins/websphere/src/org/hyperic/hq/plugin/websphere/ConnectionPoolCollector.java 2008-09-02 22:12:41 UTC (rev 10949) @@ -25,6 +25,7 @@ package org.hyperic.hq.plugin.websphere; +import java.util.Iterator; import java.util.Set; import javax.management.ObjectName; @@ -63,7 +64,7 @@ throw new PluginException(msg, e); } - if ((beans.size() == 0) || (beans.size() > 2)) { + if (beans.size() == 0) { String msg = name + " query returned " + beans.size() + " results"; @@ -76,19 +77,21 @@ return fullName; } else { - //XXX seen in samples, two beans where all attributes are equal - //with the exception of mbeanIdentifier - String id = fullName.getKeyProperty("mbeanIdentifier"); - if (id != null) { - if (id.indexOf(getServerName()) != -1) { - return fullName; + for (Iterator it=beans.iterator(); it.hasNext();) { + //XXX seen in samples, two beans where all attributes are equal + //with the exception of mbeanIdentifier + String id = fullName.getKeyProperty("mbeanIdentifier"); + if (id != null) { + if (id.indexOf(getServerName()) != -1) { + return fullName; + } } - else { - return (ObjectName)beans.iterator().next(); - } } + String msg = + name + " query returned " + + beans.size() + " results"; + throw new PluginException(msg); } - throw new PluginException("Failed to resolve: " + name); } protected void init(AdminClient mServer) throws PluginException { Modified: trunk/plugins/websphere/src/org/hyperic/hq/plugin/websphere/jmx/JDBCProviderQuery.java =================================================================== --- trunk/plugins/websphere/src/org/hyperic/hq/plugin/websphere/jmx/JDBCProviderQuery.java 2008-09-02 22:10:01 UTC (rev 10948) +++ trunk/plugins/websphere/src/org/hyperic/hq/plugin/websphere/jmx/JDBCProviderQuery.java 2008-09-02 22:12:41 UTC (rev 10949) @@ -25,6 +25,8 @@ package org.hyperic.hq.plugin.websphere.jmx; +import javax.management.ObjectName; + import org.hyperic.hq.plugin.websphere.WebsphereProductPlugin; public class JDBCProviderQuery extends WebSphereQuery { @@ -48,4 +50,16 @@ "implementationClassName" }; } + + //see comments in ConnectionPoolCollector + public boolean apply(ObjectName name) { + String server = name.getKeyProperty("Server"); + String id = name.getKeyProperty("mbeanIdentifier"); + if ((server == null) || (id == null)) { + return super.apply(name); + } + else { + return id.indexOf(server) != -1; + } + } } Modified: trunk/plugins/websphere/src/org/hyperic/hq/plugin/websphere/jmx/WebSphereQuery.java =================================================================== --- trunk/plugins/websphere/src/org/hyperic/hq/plugin/websphere/jmx/WebSphereQuery.java 2008-09-02 22:10:01 UTC (rev 10948) +++ trunk/plugins/websphere/src/org/hyperic/hq/plugin/websphere/jmx/WebSphereQuery.java 2008-09-02 22:12:41 UTC (rev 10949) @@ -74,6 +74,10 @@ return query; } + public boolean apply(ObjectName name) { + return true; + } + public String getResourceType() { return null; } Modified: trunk/plugins/websphere/src/org/hyperic/hq/plugin/websphere/jmx/WebsphereRuntimeDiscoverer.java =================================================================== --- trunk/plugins/websphere/src/org/hyperic/hq/plugin/websphere/jmx/WebsphereRuntimeDiscoverer.java 2008-09-02 22:10:01 UTC (rev 10948) +++ trunk/plugins/websphere/src/org/hyperic/hq/plugin/websphere/jmx/WebsphereRuntimeDiscoverer.java 2008-09-02 22:12:41 UTC (rev 10949) @@ -103,6 +103,9 @@ it.hasNext();) { ObjectName obj = (ObjectName)it.next(); + if (!query.apply(obj)) { + continue; + } WebSphereQuery type = query.cloneInstance(); type.setName(obj.getKeyProperty("name")); type.setObjectName(obj); |