modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/MemoryPoolComponent.java
| 88 ++++++++++
modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml
| 6
2 files changed, 91 insertions(+), 3 deletions(-)
New commits:
commit 4ecca884ee72ed4698804f6b6df5fc5da9671734
Author: Thomas Segismont <tsegismo(a)redhat.com>
Date: Tue Dec 10 16:02:27 2013 +0100
Bug 991202 - Excessive warnings of invalid metric calls
Fixed "*-exceeded" metrics dataType
Created new MemoryPoolComponent
Now gathering "usage-threshold-*" and
"collection-usage-threshold-*" metrics only if enabled
diff --git
a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/MemoryPoolComponent.java
b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/MemoryPoolComponent.java
new file mode 100644
index 0000000..36939a5
--- /dev/null
+++
b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/MemoryPoolComponent.java
@@ -0,0 +1,88 @@
+/*
+ * 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.HashSet;
+import java.util.Set;
+
+import org.rhq.core.domain.measurement.MeasurementDataTrait;
+import org.rhq.core.domain.measurement.MeasurementReport;
+import org.rhq.core.domain.measurement.MeasurementScheduleRequest;
+import org.rhq.core.pluginapi.inventory.ResourceContext;
+
+/**
+ * @author Thomas Segismont
+ */
+public class MemoryPoolComponent extends BaseComponent<BaseComponent<?>> {
+
+ private static final String USAGE_THRESHOLD_PREFIX = "usage-threshold-";
+ private static final String USAGE_THRESHOLD_SUPPORTED_ATTRIBUTE =
USAGE_THRESHOLD_PREFIX + "supported";
+ private static final String COLLECTION_USAGE_THRESHOLD_PREFIX =
"collection-" + USAGE_THRESHOLD_PREFIX;
+ private static final String COLLECTION_USAGE_THRESHOLD_SUPPORTED_ATTRIBUTE =
COLLECTION_USAGE_THRESHOLD_PREFIX
+ + "supported";
+
+ private Boolean usageThresholdSupported;
+ private Boolean collectionUsageThresholdSupported;
+
+ @Override
+ public void start(ResourceContext<BaseComponent<?>> context) throws
Exception {
+ super.start(context);
+ usageThresholdSupported = readAttribute(getAddress(),
USAGE_THRESHOLD_SUPPORTED_ATTRIBUTE, Boolean.class);
+ collectionUsageThresholdSupported = readAttribute(getAddress(),
COLLECTION_USAGE_THRESHOLD_SUPPORTED_ATTRIBUTE,
+ Boolean.class);
+ }
+
+ @Override
+ public void stop() {
+ super.stop();
+ usageThresholdSupported = null;
+ collectionUsageThresholdSupported = null;
+ }
+
+ @Override
+ public void getValues(MeasurementReport report, Set<MeasurementScheduleRequest>
metrics) throws Exception {
+ Set<MeasurementScheduleRequest> filteredMetrics = new
HashSet<MeasurementScheduleRequest>();
+ for (MeasurementScheduleRequest request : metrics) {
+ String requestName = request.getName();
+ if (USAGE_THRESHOLD_SUPPORTED_ATTRIBUTE.equals(requestName)) {
+ report.addData(new MeasurementDataTrait(request,
usageThresholdSupported.toString()));
+ continue;
+ }
+ if (requestName.startsWith(USAGE_THRESHOLD_PREFIX)) {
+ if (usageThresholdSupported) {
+ filteredMetrics.add(request);
+ }
+ continue;
+ }
+ if (COLLECTION_USAGE_THRESHOLD_SUPPORTED_ATTRIBUTE.equals(requestName)) {
+ report.addData(new MeasurementDataTrait(request,
collectionUsageThresholdSupported.toString()));
+ continue;
+ }
+ if (requestName.startsWith(COLLECTION_USAGE_THRESHOLD_PREFIX)) {
+ if (collectionUsageThresholdSupported) {
+ filteredMetrics.add(request);
+ }
+ continue;
+ }
+ filteredMetrics.add(request);
+ }
+ super.getValues(report, filteredMetrics);
+ }
+}
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 2dcf2bd..972e31f 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
@@ -7280,7 +7280,7 @@
<service name="Memory Pool Resource"
discovery="SubsystemDiscovery"
- class="BaseComponent"
+ class="MemoryPoolComponent"
description="The management interface for a memory pool. A memory
pool represents the memory resource managed by the Java virtual machine and is managed by
one or more memory managers.">
<plugin-configuration>
@@ -7299,7 +7299,7 @@
<metric property="collection-usage:committed"
displayName="Collection Usage - Committed" description="The amount of
memory in bytes that is committed for the Java virtual machine to use."/>
<metric property="collection-usage:max" displayName="Collection
Usage - Max" description="The maximum amount of memory in bytes that can be used
for memory management."/>
<metric property="collection-usage-threshold-count"
description="The number of times that the Java virtual machine has detected that the
memory usage has reached or exceeded the collection usage threshold. A memory pool may not
support a collection usage threshold. If
'collection-usage-threshold-supported', is
'false' trying to read this attribute via the
'read-attribute' operation will result in failure, and the value
of this attribute in the result of a 'read-resource' operation
will be 'undefined'."/>
- <metric property="collection-usage-threshold-exceeded"
description="Whether the memory usage of this memory pool after the most recent
collection on which the Java virtual machine has expended effort has reached or exceeded
its collection usage threshold. A memory pool may not support a collection usage
threshold. If
'collection-usage-threshold-supported', is
'false' trying to read this attribute via the
'read-attribute' operation will result in failure, and the value
of this attribute in the result of a 'read-resource' operation
will be 'undefined'."/>
+ <metric property="collection-usage-threshold-exceeded"
dataType="trait" description="Whether the memory usage of this memory pool
after the most recent collection on which the Java virtual machine has expended effort has
reached or exceeded its collection usage threshold. A memory pool may not support a
collection usage threshold. If
'collection-usage-threshold-supported', is
'false' trying to read this attribute via the
'read-attribute' operation will result in failure, and the value
of this attribute in the result of a 'read-resource' operation
will be 'undefined'."/>
<metric property="collection-usage-threshold-supported"
dataType="trait" description="Whether this memory pool supports a
collection usage threshold."/>
<metric property="name" dataType="trait"
description="The name representing this memory pool."/>
<metric property="peak-usage:init" displayName="Peak Usage -
Init" description="The amount of memory in bytes that the Java virtual machine
initially requests from the operating system for memory management."/>
@@ -7312,7 +7312,7 @@
<metric property="usage:committed" displayName="Usage -
Committed" description="The amount of memory in bytes that is committed for the
Java virtual machine to use."/>
<metric property="usage:max" displayName="Usage - Max"
description="The maximum amount of memory in bytes that can be used for memory
management."/>
<metric property="usage-threshold-count" description="The
number of times that the memory usage has crossed the usage threshold. A memory pool may
not support a usage threshold. If
'usage-threshold-supported', is
'false' trying to read this attribute via the
'read-attribute' operation will result in failure, and the value
of this attribute in the result of a 'read-resource' operation
will be 'undefined'."/>
- <metric property="usage-threshold-exceeded"
description="Whether the memory usage of this memory pool reaches or exceeds its
usage threshold value. A memory pool may not support a usage threshold. If
'usage-threshold-supported', is
'false' trying to read this attribute via the
'read-attribute' operation will result in failure, and the value
of this attribute in the result of a 'read-resource' operation
will be 'undefined'."/>
+ <metric property="usage-threshold-exceeded"
dataType="trait" description="Whether the memory usage of this memory pool
reaches or exceeds its usage threshold value. A memory pool may not support a usage
threshold. If 'usage-threshold-supported', is
'false' trying to read this attribute via the
'read-attribute' operation will result in failure, and the value
of this attribute in the result of a 'read-resource' operation
will be 'undefined'."/>
<metric property="usage-threshold-supported"
dataType="trait" description="Whether this memory pool supports usage
threshold."/>
<metric property="valid" dataType="trait"
description="Whether this memory pool is valid in the Java virtual machine. A memory
pool becomes invalid once the Java virtual machine removes it from the memory
system."/>
Show replies by date