modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/QueryCacheDiscovery.java
| 76 ++++++++++
modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml
| 7
2 files changed, 79 insertions(+), 4 deletions(-)
New commits:
commit 583c119780e0d69727de6c2a7bd6aaca33b22b69
Author: Thomas Segismont <tsegismo(a)redhat.com>
Date: Thu Nov 28 15:18:06 2013 +0100
Bug 1033130 - [AS7] Exception during discovery of Query Cache resources of RHQ Server
resource
Query Cache management nodes have a very long name. So the default discovery class was
creating a too long resource key and name.
Now there is a dedicated discovery class for Query Cache resources and the resource
key and name are just the hash of the query-name attribute.
diff --git
a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/QueryCacheDiscovery.java
b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/QueryCacheDiscovery.java
new file mode 100644
index 0000000..48a972f
--- /dev/null
+++
b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/QueryCacheDiscovery.java
@@ -0,0 +1,76 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2013 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+package org.rhq.modules.plugins.jbossas7;
+
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.pluginapi.inventory.DiscoveredResourceDetails;
+import org.rhq.core.pluginapi.inventory.InvalidPluginConfigurationException;
+import org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent;
+import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext;
+import org.rhq.core.util.MessageDigestGenerator;
+import org.rhq.modules.plugins.jbossas7.json.Address;
+import org.rhq.modules.plugins.jbossas7.json.ReadChildrenNames;
+import org.rhq.modules.plugins.jbossas7.json.Result;
+
+/**
+ * @author Thomas Segismont
+ */
+public class QueryCacheDiscovery implements
ResourceDiscoveryComponent<BaseComponent<?>> {
+ private static final String QUERY_CACHE_TYPE_NAME = "query-cache";
+ private static final String RESOURCE_NAME_PREFIX = "Query Cache ";
+
+ @Override
+ public Set<DiscoveredResourceDetails>
discoverResources(ResourceDiscoveryContext<BaseComponent<?>> context)
+ throws InvalidPluginConfigurationException {
+
+ BaseComponent parentComponent = context.getParentResourceComponent();
+ String parentComponentPath = parentComponent.getPath();
+ Address parentAddress = new Address(parentComponentPath);
+
+ Result readChildrenNamesResult = parentComponent.getASConnection().execute(
+ new ReadChildrenNames(parentAddress, QUERY_CACHE_TYPE_NAME));
+
+ if (readChildrenNamesResult.isSuccess()) {
+ Set<DiscoveredResourceDetails> details = new
HashSet<DiscoveredResourceDetails>();
+ List<String> childrenNames = (List<String>)
readChildrenNamesResult.getResult();
+ for (String childName : childrenNames) {
+ Configuration pluginConfiguration =
context.getDefaultPluginConfiguration();
+ pluginConfiguration.setSimpleValue("path", parentComponentPath
+ "," + QUERY_CACHE_TYPE_NAME + "="
+ + childName);
+ String resourceKey = MessageDigestGenerator.getDigestString(childName);
+ details.add( //
+ new DiscoveredResourceDetails( //
+ context.getResourceType(), // DataType
+ resourceKey, // Key
+ RESOURCE_NAME_PREFIX + resourceKey, // Name
+ null, // Version
+ context.getResourceType().getDescription(), //
subsystem.description
+ pluginConfiguration, null));
+ }
+ return details;
+ }
+ return Collections.emptySet();
+ }
+}
diff --git a/modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml
b/modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml
index 39aa818..4e0bf38 100644
--- a/modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml
+++ b/modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml
@@ -10131,12 +10131,11 @@
<service name="Query Cache"
class="BaseComponent"
- discovery="SubsystemDiscovery"
- description="Statistics for individual queries."
- singleton="true">
+ discovery="QueryCacheDiscovery"
+ description="Statistics for individual queries.">
<plugin-configuration>
- <c:simple-property name="path" default="query-cache"
readOnly="true"/>
+ <c:simple-property name="path" readOnly="true"/>
</plugin-configuration>
<metric property="query-cache-hit-count"
displayType="summary" measurementType="trendsup" description="Get
the number of times query was retrieved from cache."/>
Show replies by date