[rhq] modules/common
by mazz
modules/common/ant-bundle/src/main/scripts/assembly.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
New commits:
commit c58abc18d85bf56f89bd01043c26216ad56fa66a
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Fri Oct 29 10:32:59 2010 -0400
looks like mvn requires a non-empty <id> field now.
diff --git a/modules/common/ant-bundle/src/main/scripts/assembly.xml b/modules/common/ant-bundle/src/main/scripts/assembly.xml
index cc7871a..d7c9af7 100644
--- a/modules/common/ant-bundle/src/main/scripts/assembly.xml
+++ b/modules/common/ant-bundle/src/main/scripts/assembly.xml
@@ -4,7 +4,7 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">
- <id></id>
+ <id>ant bundle</id>
<formats>
<format>zip</format>
</formats>
13 years, 6 months
[rhq] 2 commits - pom.xml
by ips
pom.xml | 38 +++++++++++++++++++-------------------
1 file changed, 19 insertions(+), 19 deletions(-)
New commits:
commit 5001f4690dab865ff9f796064000770b7015798f
Author: Ian Springer <ian.springer(a)redhat.com>
Date: Fri Oct 29 00:20:03 2010 -0400
upgrade all Maven plugins to latest versions
diff --git a/pom.xml b/pom.xml
index 7538bae..5270296 100644
--- a/pom.xml
+++ b/pom.xml
@@ -74,7 +74,7 @@
<commons-logging.version>1.1.0.jboss</commons-logging.version>
<concurrent.version>1.3.4-jboss-update1</concurrent.version> <!-- oswego-concurrent compatible with 4.2.3.GA -->
- <findbugs.version>2.3</findbugs.version>
+ <findbugs.version>2.3.1</findbugs.version>
<getopt.version>1.0.13</getopt.version>
<hibernate3.version>3.2.r14201-2</hibernate3.version>
<hibernate-annotations.version>3.2.1.GA</hibernate-annotations.version>
@@ -478,7 +478,7 @@
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
- <version>2.2-beta-5</version>
+ <version>2.2</version>
</plugin>
<plugin>
<artifactId>maven-clean-plugin</artifactId>
@@ -486,7 +486,7 @@
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
- <version>2.3.1</version>
+ <version>2.3.2</version>
</plugin>
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
@@ -498,7 +498,7 @@
</plugin>
<plugin>
<artifactId>maven-ear-plugin</artifactId>
- <version>2.4</version>
+ <version>2.4.2</version>
</plugin>
<plugin>
<artifactId>maven-enforcer-plugin</artifactId>
@@ -506,7 +506,7 @@
</plugin>
<plugin>
<artifactId>maven-ejb-plugin</artifactId>
- <version>2.2</version>
+ <version>2.3</version>
</plugin>
<plugin>
<artifactId>maven-idea-plugin</artifactId>
@@ -514,19 +514,19 @@
</plugin>
<plugin>
<artifactId>maven-install-plugin</artifactId>
- <version>2.3</version>
+ <version>2.3.1</version>
</plugin>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
- <version>2.3</version>
+ <version>2.3.1</version>
</plugin>
<plugin>
<artifactId>maven-javadoc-plugin</artifactId>
- <version>2.6.1</version>
+ <version>2.7</version>
</plugin>
<plugin>
<artifactId>maven-plugin-plugin</artifactId>
- <version>2.5.1</version>
+ <version>2.6</version>
</plugin>
<plugin>
<artifactId>maven-rar-plugin</artifactId>
@@ -534,39 +534,39 @@
</plugin>
<plugin>
<artifactId>maven-release-plugin</artifactId>
- <version>2.0</version>
+ <version>2.1</version>
</plugin>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
- <version>2.4.2</version>
+ <version>2.4.3</version>
</plugin>
<plugin>
<artifactId>maven-scm-plugin</artifactId>
- <version>1.3</version>
+ <version>1.4</version>
</plugin>
<plugin>
<artifactId>maven-site-plugin</artifactId>
- <version>2.0.1</version>
+ <version>2.1.1</version>
</plugin>
<plugin>
<artifactId>maven-source-plugin</artifactId>
- <version>2.1.1</version>
+ <version>2.1.2</version>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
- <version>2.5</version>
+ <version>2.6</version>
<configuration>
<argLine>-Xms16M -Xmx256M</argLine>
</configuration>
</plugin>
<plugin>
<artifactId>maven-war-plugin</artifactId>
- <version>2.1-beta-1</version>
+ <version>2.1</version>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
- <version>1.4</version>
+ <version>1.5</version>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
@@ -576,7 +576,7 @@
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
- <version>1.1</version>
+ <version>1.2</version>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
commit 88a5f718f5e677e83e2c640d89d40fbac83b5f75
Author: Ian Springer <ian.springer(a)redhat.com>
Date: Fri Oct 29 00:10:08 2010 -0400
change initial heap size from 128M to 64M for compiler plugin
diff --git a/pom.xml b/pom.xml
index f95c754..7538bae 100644
--- a/pom.xml
+++ b/pom.xml
@@ -629,7 +629,7 @@
<configuration>
<!-- invocation options -->
<fork>true</fork>
- <meminitial>128M</meminitial>
+ <meminitial>64M</meminitial>
<maxmem>512M</maxmem>
<!-- compiler options -->
13 years, 6 months
[rhq] modules/plugins
by ips
modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/ApplicationServerDiscoveryComponent.java | 7 +------
1 file changed, 1 insertion(+), 6 deletions(-)
New commits:
commit f637fd4e1ad7bd66228164727b8666f602317bd0
Author: Ian Springer <ian.springer(a)redhat.com>
Date: Thu Oct 28 23:18:27 2010 -0400
add JBOSS_HOME/lib/jboss-reflect.jar to list of client jars added to instance/connection classloader, since it's needed by some Profile Service calls (used by MetaValueFactorys to unwrap certain managed property values)
diff --git a/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/ApplicationServerDiscoveryComponent.java b/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/ApplicationServerDiscoveryComponent.java
index 1eb9df6..3bf3b09 100644
--- a/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/ApplicationServerDiscoveryComponent.java
+++ b/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/ApplicationServerDiscoveryComponent.java
@@ -109,6 +109,7 @@ public class ApplicationServerDiscoveryComponent implements ResourceDiscoveryCom
"%libUrl%/jboss-managed.jar", //
"%libUrl%/jboss-metatype.jar", //
"%libUrl%/jboss-dependency.jar", //
+ "%libUrl%/jboss-reflect.jar", //
// AS 6.0 M1 and later
"%libUrl%/jboss-classpool.jar", //
"%libUrl%/jboss-classpool-scoped.jar", //
@@ -136,9 +137,6 @@ public class ApplicationServerDiscoveryComponent implements ResourceDiscoveryCom
public DiscoveredResourceDetails discoverResource(Configuration pluginConfig,
ResourceDiscoveryContext discoveryContext) throws InvalidPluginConfigurationException {
- // Set default values on any props that are not set.
- //setPluginConfigurationDefaults(pluginConfiguration);
-
ProcessInfo processInfo = null;
String jbossHomeDir = pluginConfig.getSimple(ApplicationServerPluginConfigurationProperties.HOME_DIR)
.getStringValue();
@@ -296,9 +294,6 @@ public class ApplicationServerDiscoveryComponent implements ResourceDiscoveryCom
initLogEventSourcesConfigProp(configDir, pluginConfiguration);
- // TODO: Init props that have static defaults.
- //setPluginConfigurationDefaults(pluginConfiguration);
-
DiscoveredResourceDetails resourceDetails = createResourceDetails(discoveryContext, pluginConfiguration,
processInfo, installInfo);
resources.add(resourceDetails);
13 years, 6 months
[rhq] modules/enterprise
by ips
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/templates/ResourceTypeTreeView.java | 11
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/templates/TemplateSchedulesDataSource.java | 160 ++++++++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/templates/TemplateSchedulesView.java | 46 ++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/MeasurementDataGWTService.java | 6
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/AbstractMeasurementScheduleCompositeDataSource.java | 33 -
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/monitoring/schedules/SchedulesDataSource.java | 12
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/schedules/SchedulesDataSource.java | 12
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/MeasurementDataGWTServiceImpl.java | 24 +
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/MeasurementScheduleManagerBean.java | 186 +++++-----
9 files changed, 359 insertions(+), 131 deletions(-)
New commits:
commit 73bff1bdd0a1ea3c5efca7af2f6b886c235d53a9
Author: Ian Springer <ian.springer(a)redhat.com>
Date: Thu Oct 28 18:58:38 2010 -0400
implement Metric Templates view and hook into the new Resource Types view; still need to add the "Update Existing Resources" checkbox
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/templates/ResourceTypeTreeView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/templates/ResourceTypeTreeView.java
index d7c2180..43d51a2 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/templates/ResourceTypeTreeView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/templates/ResourceTypeTreeView.java
@@ -47,7 +47,6 @@ import org.rhq.enterprise.gui.coregui.client.LinkManager;
import org.rhq.enterprise.gui.coregui.client.ViewId;
import org.rhq.enterprise.gui.coregui.client.ViewPath;
import org.rhq.enterprise.gui.coregui.client.alert.definitions.TemplateAlertDefinitionsView;
-import org.rhq.enterprise.gui.coregui.client.components.FullHTMLPane;
import org.rhq.enterprise.gui.coregui.client.components.buttons.BackButton;
import org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTypeRepository;
import org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTypeRepository.TypesLoadedCallback;
@@ -221,13 +220,11 @@ public class ResourceTypeTreeView extends LocatableVLayout implements Bookmarkab
});
}
- private void editMetricTemplate(int resourceTypeId) {
- // TODO: convert this to GWT
+ private void editMetricTemplate(int resourceTypeId) {
Layout metricCanvas = getMetricTemplateCanvas();
- FullHTMLPane jspPage = new FullHTMLPane(extendLocatorId("MetricTemplate"),
- "/admin/platform/monitor/Config.do?nomenu=true&mode=configure&id="
- + resourceTypeId + "&type=" + resourceTypeId);
- prepareSubCanvas(metricCanvas, jspPage, true);
+ TemplateSchedulesView templateSchedulesView = new TemplateSchedulesView(extendLocatorId("MetricTemplate"),
+ resourceTypeId);
+ prepareSubCanvas(metricCanvas, templateSchedulesView, true);
switchToCanvas(ResourceTypeTreeView.this, metricCanvas);
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/templates/TemplateSchedulesDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/templates/TemplateSchedulesDataSource.java
new file mode 100644
index 0000000..bad1853
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/templates/TemplateSchedulesDataSource.java
@@ -0,0 +1,160 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2010 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.enterprise.gui.coregui.client.admin.templates;
+
+import java.util.List;
+
+import com.google.gwt.user.client.rpc.AsyncCallback;
+import com.smartgwt.client.data.Criteria;
+import com.smartgwt.client.data.DSRequest;
+import com.smartgwt.client.data.DSResponse;
+import com.smartgwt.client.data.DataSourceField;
+import com.smartgwt.client.data.fields.DataSourceIntegerField;
+import com.smartgwt.client.widgets.grid.ListGridRecord;
+
+import org.rhq.core.domain.common.EntityContext;
+import org.rhq.core.domain.criteria.MeasurementScheduleCriteria;
+import org.rhq.core.domain.measurement.composite.MeasurementScheduleComposite;
+import org.rhq.enterprise.gui.coregui.client.CoreGUI;
+import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
+import org.rhq.enterprise.gui.coregui.client.gwt.MeasurementDataGWTServiceAsync;
+import org.rhq.enterprise.gui.coregui.client.inventory.common.AbstractMeasurementScheduleCompositeDataSource;
+import org.rhq.enterprise.gui.coregui.client.inventory.common.AbstractMeasurementScheduleListView;
+import org.rhq.enterprise.gui.coregui.client.util.message.Message;
+
+/**
+ * A DataSource for reading and updating the default metric schedules for a particular ResourceType.
+ *
+ * @author Ian Springer
+ */
+public class TemplateSchedulesDataSource extends AbstractMeasurementScheduleCompositeDataSource {
+ private MeasurementDataGWTServiceAsync measurementService = GWTServiceLookup.getMeasurementDataService();
+ private int resourceTypeId;
+
+ public TemplateSchedulesDataSource(int resourceTypeId) {
+ this.resourceTypeId = resourceTypeId;
+ }
+
+ @Override
+ protected List<DataSourceField> addDataSourceFields() {
+ List<DataSourceField> fields = super.addDataSourceFields();
+
+ DataSourceField resourceGroupIdField = new DataSourceIntegerField(
+ MeasurementScheduleCriteria.FILTER_FIELD_RESOURCE_TYPE_ID, "Resource Type Id");
+ resourceGroupIdField.setHidden(true);
+ fields.add(resourceGroupIdField);
+
+ return fields;
+ }
+
+ @Override
+ protected void executeFetch(DSRequest request, DSResponse response) {
+ super.executeFetch(request, response);
+
+ }
+
+ @Override
+ protected EntityContext getEntityContext(DSRequest request) {
+ Criteria requestCriteria = request.getCriteria();
+ Integer typeId = requestCriteria.getAttributeAsInt(MeasurementScheduleCriteria.FILTER_FIELD_RESOURCE_TYPE_ID);
+ return EntityContext.forTemplate(typeId);
+ }
+
+ @Override
+ public ListGridRecord copyValues(MeasurementScheduleComposite from) {
+ ListGridRecord record = super.copyValues(from);
+ record.setAttribute(MeasurementScheduleCriteria.FILTER_FIELD_RESOURCE_TYPE_ID, this.resourceTypeId);
+ return record;
+ }
+
+ @Override
+ protected void enableSchedules(final AbstractMeasurementScheduleListView measurementScheduleListView,
+ final int[] measurementDefinitionIds, final List<String> measurementDefinitionDisplayNames) {
+ final String s = (measurementDefinitionIds.length > 1) ? "s" : "";
+ this.measurementService.enableMeasurementTemplates(measurementDefinitionIds,
+ new AsyncCallback<Void>() {
+ @Override
+ public void onFailure(Throwable throwable) {
+ CoreGUI.getErrorHandler().handleError(
+ "Failed to enable collection of metric" + s + " " + measurementDefinitionDisplayNames
+ + " by default for ResourceType with id [" + resourceTypeId + "].", throwable);
+ }
+
+ @Override
+ public void onSuccess(Void aVoid) {
+ CoreGUI.getMessageCenter().notify(
+ new Message("Enabled collection of selected metric" + s + ".", "Enabled collection of metric"
+ + s + " " + measurementDefinitionDisplayNames + " by default for ResourceType with id ["
+ + resourceTypeId + "].", Message.Severity.Info));
+ measurementScheduleListView.refresh();
+ }
+ });
+ }
+
+ @Override
+ protected void disableSchedules(final AbstractMeasurementScheduleListView measurementScheduleListView,
+ int[] measurementDefinitionIds, final List<String> measurementDefinitionDisplayNames) {
+ final String s = (measurementDefinitionIds.length > 1) ? "s" : "";
+ this.measurementService.disableSchedulesForCompatibleGroup(this.resourceTypeId, measurementDefinitionIds,
+ new AsyncCallback<Void>() {
+ @Override
+ public void onFailure(Throwable throwable) {
+ CoreGUI.getErrorHandler().handleError(
+ "Failed to disable collection of metric" + s + " " + measurementDefinitionDisplayNames
+ + " by default for ResourceType with id [" + resourceTypeId + "].", throwable);
+ }
+
+ @Override
+ public void onSuccess(Void aVoid) {
+ CoreGUI.getMessageCenter().notify(
+ new Message("Disabled collection of selected metric" + s + ".", "Disabled collection of metric"
+ + s + " " + measurementDefinitionDisplayNames + " by default for ResourceType with id ["
+ + resourceTypeId + "].", Message.Severity.Info));
+ measurementScheduleListView.refresh();
+ }
+ });
+ }
+
+ @Override
+ protected void updateSchedules(final AbstractMeasurementScheduleListView measurementScheduleListView,
+ int[] measurementDefinitionIds, final List<String> measurementDefinitionDisplayNames,
+ final long collectionInterval) {
+ final String s = (measurementDefinitionIds.length > 1) ? "s" : "";
+ this.measurementService.updateMeasurementTemplates(measurementDefinitionIds, collectionInterval,
+ new AsyncCallback<Void>() {
+ @Override
+ public void onFailure(Throwable throwable) {
+ CoreGUI.getErrorHandler().handleError(
+ "Failed to set collection interval to " + (collectionInterval / 1000) + " seconds for metric"
+ + s + " " + measurementDefinitionDisplayNames + " by default for ResourceType with id ["
+ + resourceTypeId + "].", throwable);
+ }
+
+ @Override
+ public void onSuccess(Void aVoid) {
+ CoreGUI.getMessageCenter().notify(
+ new Message("Updated collection intervals of selected metric" + s + ".",
+ "Collection interval for metric" + s + " " + measurementDefinitionDisplayNames
+ + " by default for ResourceType with id [" + resourceTypeId + "] set to "
+ + (collectionInterval / 1000) + " seconds.", Message.Severity.Info));
+ measurementScheduleListView.refresh();
+ }
+ });
+ }
+}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/templates/TemplateSchedulesView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/templates/TemplateSchedulesView.java
new file mode 100644
index 0000000..648ae40
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/templates/TemplateSchedulesView.java
@@ -0,0 +1,46 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2010 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.enterprise.gui.coregui.client.admin.templates;
+
+import com.smartgwt.client.data.Criteria;
+
+import org.rhq.core.domain.criteria.MeasurementScheduleCriteria;
+import org.rhq.enterprise.gui.coregui.client.inventory.common.AbstractMeasurementScheduleListView;
+
+/**
+ * A view for viewing and updating the default metric schedules ("metric templates") for a particular ResourceType.
+ *
+ * @author Ian Springer
+ */
+public class TemplateSchedulesView extends AbstractMeasurementScheduleListView {
+ private static final String TITLE = "Template Metric Collection Schedules";
+
+ private static final String[] EXCLUDED_FIELD_NAMES = new String[] { MeasurementScheduleCriteria.FILTER_FIELD_RESOURCE_TYPE_ID };
+
+ public TemplateSchedulesView(String locatorId, int resourceTypeId) {
+ super(locatorId, TITLE, new TemplateSchedulesDataSource(resourceTypeId), createCriteria(resourceTypeId),
+ EXCLUDED_FIELD_NAMES);
+ }
+
+ private static Criteria createCriteria(int resourceTypeId) {
+ Criteria criteria = new Criteria();
+ criteria.addCriteria(MeasurementScheduleCriteria.FILTER_FIELD_RESOURCE_TYPE_ID, resourceTypeId);
+ return criteria;
+ }
+}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/MeasurementDataGWTService.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/MeasurementDataGWTService.java
index c6c44d8..ea64488 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/MeasurementDataGWTService.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/MeasurementDataGWTService.java
@@ -80,6 +80,12 @@ public interface MeasurementDataGWTService extends RemoteService {
void updateSchedulesForCompatibleGroup(int resourceGroupId, int[] measurementDefinitionIds, long collectionInterval);
+ void enableMeasurementTemplates(int[] measurementDefinitionIds);
+
+ void disableMeasurementTemplates(int[] measurementDefinitionIds);
+
+ void updateMeasurementTemplates(int[] measurementDefinitionIds, long collectionInterval);
+
PageList<MeasurementDataTrait> findTraitsByCriteria(MeasurementDataTraitCriteria criteria);
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/AbstractMeasurementScheduleCompositeDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/AbstractMeasurementScheduleCompositeDataSource.java
index 1f7da77..cac8051 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/AbstractMeasurementScheduleCompositeDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/AbstractMeasurementScheduleCompositeDataSource.java
@@ -20,10 +20,8 @@ package org.rhq.enterprise.gui.coregui.client.inventory.common;
import java.util.ArrayList;
import java.util.List;
-import java.util.Map;
import com.google.gwt.user.client.rpc.AsyncCallback;
-import com.smartgwt.client.data.Criteria;
import com.smartgwt.client.data.DSRequest;
import com.smartgwt.client.data.DSResponse;
import com.smartgwt.client.data.DataSourceField;
@@ -116,31 +114,7 @@ public abstract class AbstractMeasurementScheduleCompositeDataSource extends
});
}
- protected EntityContext getEntityContext(DSRequest request) {
- EntityContext entityContext = null;
-
- Criteria requestCriteria = request.getCriteria();
- if (requestCriteria != null) {
- Map values = requestCriteria.getValues();
- for (Object key : values.keySet()) {
- String fieldName = (String) key;
- if (fieldName.equals(MeasurementScheduleCriteria.FILTER_FIELD_RESOURCE_ID)) {
- Integer resourceId = (Integer) values.get(fieldName);
- entityContext = EntityContext.forResource(resourceId);
- } else if (fieldName.equals(MeasurementScheduleCriteria.FILTER_FIELD_RESOURCE_GROUP_ID)) {
- Integer groupId = (Integer) values.get(fieldName);
- entityContext = EntityContext.forGroup(groupId);
- }
- // TODO: Add support for other fields we need to filter by (e.g. resourceTypeId for metric templates).
- }
- }
-
- if (entityContext == null) {
- throw new IllegalStateException("No support criteria fields were found.");
- }
-
- return entityContext;
- }
+ protected abstract EntityContext getEntityContext(DSRequest request);
@Override
public MeasurementScheduleComposite copyValues(ListGridRecord from) {
@@ -161,8 +135,6 @@ public abstract class AbstractMeasurementScheduleCompositeDataSource extends
record.setAttribute(MeasurementScheduleCriteria.SORT_FIELD_ENABLED, from.getCollectionEnabled());
record.setAttribute(MeasurementScheduleCriteria.SORT_FIELD_INTERVAL, from.getCollectionInterval());
- // TODO: resourceId and resourceGroupId (in subclasses)
-
return record;
}
@@ -170,7 +142,6 @@ public abstract class AbstractMeasurementScheduleCompositeDataSource extends
int[] ids = getMeasurementDefinitionIds(measurementScheduleListView);
List<String> displayNames = getMeasurementDefinitionDisplayNames(measurementScheduleListView);
enableSchedules(measurementScheduleListView, ids, displayNames);
- measurementScheduleListView.refresh();
}
protected abstract void enableSchedules(AbstractMeasurementScheduleListView measurementScheduleListView,
@@ -180,7 +151,6 @@ public abstract class AbstractMeasurementScheduleCompositeDataSource extends
int[] ids = getMeasurementDefinitionIds(measurementScheduleListView);
List<String> displayNames = getMeasurementDefinitionDisplayNames(measurementScheduleListView);
disableSchedules(measurementScheduleListView, ids, displayNames);
- measurementScheduleListView.refresh();
}
protected abstract void disableSchedules(AbstractMeasurementScheduleListView measurementScheduleListView,
@@ -190,7 +160,6 @@ public abstract class AbstractMeasurementScheduleCompositeDataSource extends
int[] ids = getMeasurementDefinitionIds(measurementScheduleListView);
List<String> displayNames = getMeasurementDefinitionDisplayNames(measurementScheduleListView);
updateSchedules(measurementScheduleListView, ids, displayNames, interval);
- measurementScheduleListView.refresh();
}
private int[] getMeasurementDefinitionIds(AbstractMeasurementScheduleListView measurementScheduleListView) {
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/monitoring/schedules/SchedulesDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/monitoring/schedules/SchedulesDataSource.java
index 79a9b2a..0ba35d0 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/monitoring/schedules/SchedulesDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/monitoring/schedules/SchedulesDataSource.java
@@ -84,7 +84,7 @@ public class SchedulesDataSource extends AbstractMeasurementScheduleCompositeDat
}
@Override
- protected void enableSchedules(AbstractMeasurementScheduleListView measurementScheduleListView,
+ protected void enableSchedules(final AbstractMeasurementScheduleListView measurementScheduleListView,
final int[] measurementDefinitionIds, final List<String> measurementDefinitionDisplayNames) {
final String s = (measurementDefinitionIds.length > 1) ? "s" : "";
this.measurementService.enableSchedulesForCompatibleGroup(this.resourceGroupId, measurementDefinitionIds,
@@ -102,13 +102,13 @@ public class SchedulesDataSource extends AbstractMeasurementScheduleCompositeDat
new Message("Enabled collection of selected metric" + s + ".", "Enabled collection of metric"
+ s + " " + measurementDefinitionDisplayNames + " for Resource group with id ["
+ resourceGroupId + "].", Message.Severity.Info));
-
+ measurementScheduleListView.refresh();
}
});
}
@Override
- protected void disableSchedules(AbstractMeasurementScheduleListView measurementScheduleListView,
+ protected void disableSchedules(final AbstractMeasurementScheduleListView measurementScheduleListView,
int[] measurementDefinitionIds, final List<String> measurementDefinitionDisplayNames) {
final String s = (measurementDefinitionIds.length > 1) ? "s" : "";
this.measurementService.disableSchedulesForCompatibleGroup(this.resourceGroupId, measurementDefinitionIds,
@@ -126,13 +126,13 @@ public class SchedulesDataSource extends AbstractMeasurementScheduleCompositeDat
new Message("Disabled collection of selected metric" + s + ".", "Disabled collection of metric"
+ s + " " + measurementDefinitionDisplayNames + " for Resource group with id ["
+ resourceGroupId + "].", Message.Severity.Info));
-
+ measurementScheduleListView.refresh();
}
});
}
@Override
- protected void updateSchedules(AbstractMeasurementScheduleListView measurementScheduleListView,
+ protected void updateSchedules(final AbstractMeasurementScheduleListView measurementScheduleListView,
int[] measurementDefinitionIds, final List<String> measurementDefinitionDisplayNames,
final long collectionInterval) {
final String s = (measurementDefinitionIds.length > 1) ? "s" : "";
@@ -153,7 +153,7 @@ public class SchedulesDataSource extends AbstractMeasurementScheduleCompositeDat
"Collection interval for metric" + s + " " + measurementDefinitionDisplayNames
+ " for Resource group with id [" + resourceGroupId + "] set to "
+ (collectionInterval / 1000) + " seconds.", Message.Severity.Info));
-
+ measurementScheduleListView.refresh();
}
});
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/schedules/SchedulesDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/schedules/SchedulesDataSource.java
index ac7c8dd..7d631ba 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/schedules/SchedulesDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/schedules/SchedulesDataSource.java
@@ -77,7 +77,7 @@ public class SchedulesDataSource extends AbstractMeasurementScheduleCompositeDat
}
@Override
- protected void enableSchedules(AbstractMeasurementScheduleListView measurementScheduleListView,
+ protected void enableSchedules(final AbstractMeasurementScheduleListView measurementScheduleListView,
int[] measurementDefinitionIds, final List<String> measurementDefinitionDisplayNames) {
this.measurementService.enableSchedulesForResource(this.resourceId, measurementDefinitionIds,
new AsyncCallback<Void>() {
@@ -93,13 +93,13 @@ public class SchedulesDataSource extends AbstractMeasurementScheduleCompositeDat
CoreGUI.getMessageCenter().notify(
new Message("Enabled collection of metrics " + measurementDefinitionDisplayNames
+ " for Resource with id [" + resourceId + "].", Message.Severity.Info));
-
+ measurementScheduleListView.refresh();
}
});
}
@Override
- protected void disableSchedules(AbstractMeasurementScheduleListView measurementScheduleListView,
+ protected void disableSchedules(final AbstractMeasurementScheduleListView measurementScheduleListView,
int[] measurementDefinitionIds, final List<String> measurementDefinitionDisplayNames) {
this.measurementService.disableSchedulesForResource(this.resourceId, measurementDefinitionIds,
new AsyncCallback<Void>() {
@@ -115,13 +115,13 @@ public class SchedulesDataSource extends AbstractMeasurementScheduleCompositeDat
CoreGUI.getMessageCenter().notify(
new Message("Disabled collection of metrics " + measurementDefinitionDisplayNames
+ " for Resource with id [" + resourceId + "].", Message.Severity.Info));
-
+ measurementScheduleListView.refresh();
}
});
}
@Override
- protected void updateSchedules(AbstractMeasurementScheduleListView measurementScheduleListView,
+ protected void updateSchedules(final AbstractMeasurementScheduleListView measurementScheduleListView,
int[] measurementDefinitionIds, final List<String> measurementDefinitionDisplayNames,
final long collectionInterval) {
this.measurementService.updateSchedulesForResource(this.resourceId, measurementDefinitionIds,
@@ -140,7 +140,7 @@ public class SchedulesDataSource extends AbstractMeasurementScheduleCompositeDat
new Message("Collection interval for metrics " + measurementDefinitionDisplayNames
+ " for Resource with id [" + resourceId + "] set to " + (collectionInterval / 1000)
+ " seconds.", Message.Severity.Info));
-
+ measurementScheduleListView.refresh();
}
});
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/MeasurementDataGWTServiceImpl.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/MeasurementDataGWTServiceImpl.java
index 8f5c9be..9073af2 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/MeasurementDataGWTServiceImpl.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/MeasurementDataGWTServiceImpl.java
@@ -199,6 +199,30 @@ public class MeasurementDataGWTServiceImpl extends AbstractGWTServiceImpl implem
}
}
+ public void enableMeasurementTemplates(int[] measurementDefinitionIds) {
+ try {
+ scheduleManager.enableMeasurementTemplates(getSessionSubject(), measurementDefinitionIds);
+ } catch (RuntimeException e) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ }
+ }
+
+ public void disableMeasurementTemplates(int[] measurementDefinitionIds) {
+ try {
+ scheduleManager.disableMeasurementTemplates(getSessionSubject(), measurementDefinitionIds);
+ } catch (RuntimeException e) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ }
+ }
+
+ public void updateMeasurementTemplates(int[] measurementDefinitionIds, long collectionInterval) {
+ try {
+ scheduleManager.updateMeasurementTemplates(getSessionSubject(), measurementDefinitionIds, collectionInterval);
+ } catch (RuntimeException e) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ }
+ }
+
public PageList<MeasurementDataTrait> findTraitsByCriteria(MeasurementDataTraitCriteria criteria) {
try {
return SerialUtility.prepare(dataManager.findTraitsByCriteria(getSessionSubject(), criteria),
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/MeasurementScheduleManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/MeasurementScheduleManagerBean.java
index 4053a25..ccd65bc 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/MeasurementScheduleManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/MeasurementScheduleManagerBean.java
@@ -1,6 +1,6 @@
/*
* RHQ Management Platform
- * Copyright (C) 2005-2008 Red Hat, Inc.
+ * Copyright (C) 2005-2010 Red Hat, Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
@@ -53,6 +53,7 @@ import org.rhq.core.db.SQLServerDatabaseType;
import org.rhq.core.domain.auth.Subject;
import org.rhq.core.domain.authz.Permission;
import org.rhq.core.domain.common.EntityContext;
+import org.rhq.core.domain.criteria.MeasurementDefinitionCriteria;
import org.rhq.core.domain.criteria.MeasurementScheduleCriteria;
import org.rhq.core.domain.criteria.ResourceCriteria;
import org.rhq.core.domain.measurement.DataType;
@@ -173,7 +174,7 @@ public class MeasurementScheduleManagerBean implements MeasurementScheduleManage
/**
* Return a list of MeasurementSchedules for the given ids
*
- * @param ids PrimaryKeys of the schedules searched
+ * @param scheduleIds PrimaryKeys of the schedules searched
*
* @return a list of Schedules
*/
@@ -1179,92 +1180,117 @@ public class MeasurementScheduleManagerBean implements MeasurementScheduleManage
pc.addDefaultOrderingField("definition.displayName");
// check authorization up front, so that criteria-based queries can run without authz checks
- if (context.type == EntityContext.Type.Resource) {
- if (authorizationManager.canViewResource(subject, context.resourceId) == false) {
- throw new PermissionException("User [" + subject.getName()
- + "] does not have permission to view measurement schedules for resource[id=" + context.resourceId
- + "]");
- }
- } else if (context.type == EntityContext.Type.ResourceGroup) {
- if (authorizationManager.canViewGroup(subject, context.groupId) == false) {
- throw new PermissionException("User [" + subject.getName()
- + "] does not have permission to view measurement schedules for resourceGroup[id="
- + context.groupId + "]");
- }
- } else if (context.type == EntityContext.Type.AutoGroup) {
- if (authorizationManager.canViewAutoGroup(subject, context.parentResourceId, context.resourceTypeId) == false) {
- throw new PermissionException("User [" + subject.getName()
- + "] does not have permission to view measurement schedules for autoGroup[parentResourceId="
- + context.parentResourceId + ", resourceTypeId=" + context.resourceTypeId + "]");
- }
- }
-
- // general criteria setup
- MeasurementScheduleCriteria criteria = new MeasurementScheduleCriteria();
- //criteria.addFilterDefinitionIds(measurementDefinitionIds);
- if (context.type == EntityContext.Type.Resource) {
- criteria.addFilterResourceId(context.resourceId);
- } else if (context.type == EntityContext.Type.ResourceGroup) {
- criteria.addFilterResourceGroupId(context.groupId);
- } else if (context.type == EntityContext.Type.AutoGroup) {
- criteria.addFilterAutoGroupParentResourceId(context.parentResourceId);
- criteria.addFilterAutoGroupResourceTypeId(context.resourceTypeId);
+ switch (context.type) {
+ case Resource:
+ if (authorizationManager.canViewResource(subject, context.resourceId) == false) {
+ throw new PermissionException("User [" + subject.getName()
+ + "] does not have permission to view measurement schedules for resource[id=" +
+ context.resourceId
+ + "]");
+ }
+ break;
+ case ResourceGroup:
+ if (authorizationManager.canViewGroup(subject, context.groupId) == false) {
+ throw new PermissionException("User [" + subject.getName()
+ + "] does not have permission to view measurement schedules for resourceGroup[id="
+ + context.groupId + "]");
+ }
+ break;
+ case AutoGroup:
+ if (authorizationManager.canViewAutoGroup(subject, context.parentResourceId, context.resourceTypeId) ==
+ false) {
+ throw new PermissionException("User [" + subject.getName()
+ + "] does not have permission to view measurement schedules for autoGroup[parentResourceId="
+ + context.parentResourceId + ", resourceTypeId=" + context.resourceTypeId + "]");
+ }
+ break;
}
- criteria.setPageControl(pc); // for primary return list, use passed PageControl
- // get the core definitions
- CriteriaQueryGenerator generator = new CriteriaQueryGenerator(subject, criteria);
- ;
- generator.alterProjection(" distinct measurementschedule.definition ");
- CriteriaQueryRunner<MeasurementDefinition> queryRunner = new CriteriaQueryRunner(criteria, generator,
- entityManager);
- PageList<MeasurementDefinition> definitions = queryRunner.execute();
-
- // reset paging -- remove ordering, add group by
- criteria.setPageControl(PageControl.getUnlimitedInstance());
- generator.setGroupByClause(" measurementschedule.definition.id ");
-
- // get the interval results
- generator.alterProjection("" //
- + " measurementschedule.definition.id, " //
- + " min(measurementschedule.interval), " //
- + " max(measurementschedule.interval) ");
- Query query = generator.getQuery(entityManager);
- List<Object[]> definitionIntervalResults = query.getResultList();
-
- // get the enabled results
- criteria.addFilterEnabled(true);
- generator.alterProjection(" measurementschedule.definition.id, count(measurementschedule.id) ");
- query = generator.getQuery(entityManager);
- List<Object[]> definitionEnabledResults = query.getResultList();
-
- // generate intermediate maps
+ PageList<MeasurementDefinition> definitions;
Map<Integer, Long> definitionIntervalMap = new HashMap<Integer, Long>();
- for (Object[] nextInterval : definitionIntervalResults) {
- int definitionId = (Integer) nextInterval[0];
- long minInterval = (Long) nextInterval[1];
- long maxInterval = (Long) nextInterval[2];
-
- long interval = (minInterval != maxInterval) ? 0 : minInterval;
- definitionIntervalMap.put(definitionId, interval);
- }
- int size = getResourceCount(context);
Map<Integer, Boolean> definitionEnabledMap = new HashMap<Integer, Boolean>();
- for (Object[] nextEnabled : definitionEnabledResults) {
- int definitionId = (Integer) nextEnabled[0];
- long enabledCount = (Long) nextEnabled[1];
-
- Boolean enabled = null;
- if (enabledCount == size) {
- enabled = true;
- } else if (enabledCount == 0) {
- enabled = false;
+ if (context.type == EntityContext.Type.ResourceTemplate) {
+ MeasurementDefinitionCriteria criteria = new MeasurementDefinitionCriteria();
+ criteria.addFilterResourceTypeId(context.resourceTypeId);
+
+ CriteriaQueryGenerator generator = new CriteriaQueryGenerator(subject, criteria);
+ CriteriaQueryRunner<MeasurementDefinition> queryRunner = new CriteriaQueryRunner(criteria, generator,
+ entityManager);
+ definitions = queryRunner.execute();
+ for (MeasurementDefinition definition : definitions) {
+ definitionIntervalMap.put(definition.getId(), definition.getDefaultInterval());
+ definitionEnabledMap.put(definition.getId(), definition.isDefaultOn());
}
+ } else {
+ // Do general criteria setup.
+ MeasurementScheduleCriteria criteria = new MeasurementScheduleCriteria();
+ //criteria.addFilterDefinitionIds(measurementDefinitionIds);
+ switch (context.type) {
+ case Resource:
+ criteria.addFilterResourceId(context.resourceId);
+ break;
+ case ResourceGroup:
+ criteria.addFilterResourceGroupId(context.groupId);
+ break;
+ case AutoGroup:
+ criteria.addFilterAutoGroupParentResourceId(context.parentResourceId);
+ criteria.addFilterAutoGroupResourceTypeId(context.resourceTypeId);
+ break;
+ }
+ criteria.setPageControl(pc); // for primary return list, use passed PageControl
+
+ // Get the core definitions.
+ CriteriaQueryGenerator generator = new CriteriaQueryGenerator(subject, criteria);
+
+ generator.alterProjection(" distinct measurementschedule.definition ");
+ CriteriaQueryRunner<MeasurementDefinition> queryRunner = new CriteriaQueryRunner(criteria, generator,
+ entityManager);
+ definitions = queryRunner.execute();
+
+ // Reset paging -- remove ordering, add group by.
+ criteria.setPageControl(PageControl.getUnlimitedInstance());
+ generator.setGroupByClause(" measurementschedule.definition.id ");
+
+ // Get the interval results.
+ generator.alterProjection("" //
+ + " measurementschedule.definition.id, " //
+ + " min(measurementschedule.interval), " //
+ + " max(measurementschedule.interval) ");
+ Query query = generator.getQuery(entityManager);
+ List<Object[]> definitionIntervalResults = query.getResultList();
+
+ // Get the enabled results.
+ criteria.addFilterEnabled(true);
+ generator.alterProjection(" measurementschedule.definition.id, count(measurementschedule.id) ");
+ query = generator.getQuery(entityManager);
+ List<Object[]> definitionEnabledResults = query.getResultList();
+
+ // Generate intermediate maps for intervals and enabled values.
+ for (Object[] nextInterval : definitionIntervalResults) {
+ int definitionId = (Integer) nextInterval[0];
+ long minInterval = (Long) nextInterval[1];
+ long maxInterval = (Long) nextInterval[2];
+
+ long interval = (minInterval != maxInterval) ? 0 : minInterval;
+ definitionIntervalMap.put(definitionId, interval);
+ }
+ int size = getResourceCount(context);
+ for (Object[] nextEnabled : definitionEnabledResults) {
+ int definitionId = (Integer) nextEnabled[0];
+ long enabledCount = (Long) nextEnabled[1];
+
+ Boolean enabled = null;
+ if (enabledCount == size) {
+ enabled = true;
+ } else if (enabledCount == 0) {
+ enabled = false;
+ }
- definitionEnabledMap.put(definitionId, enabled);
+ definitionEnabledMap.put(definitionId, enabled);
+ }
}
- // finally merge everything together
+ // Finally, merge everything together.
List<MeasurementScheduleComposite> composites = new ArrayList<MeasurementScheduleComposite>();
for (MeasurementDefinition next : definitions) {
int definitionId = next.getId();
13 years, 6 months
[rhq] Branch 'release-3.0.0' - .classpath
by Jay Shaughnessy
.classpath | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
New commits:
commit b54488164ee92ab49b4588070d12f305a62822bb
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Thu Oct 28 15:05:36 2010 -0400
remove explicit path from dep lib
diff --git a/.classpath b/.classpath
index 36e5832..381d93e 100644
--- a/.classpath
+++ b/.classpath
@@ -251,6 +251,6 @@
<classpathentry exported="true" kind="var" path="M2_REPO/com/smartgwt/smartgwt/2.2/smartgwt-2.2.jar"/>
<classpathentry exported="true" kind="var" path="M2_REPO/ca/nanometrics/gflot/1.0.0/gflot-1.0.0.jar"/>
<classpathentry exported="true" kind="var" path="M2_REPO/com/jcraft/jsch/0.1.29/jsch-0.1.29.jar"/>
- <classpathentry exported="true" kind="lib" path="C:/workspace/rhq/modules/enterprise/remoting/webservices/target/rhq-remoting-webservices-3.0.1-SNAPSHOT"/>
+ <classpathentry exported="true" kind="lib" path="modules/enterprise/remoting/webservices/target/rhq-remoting-webservices-3.0.1-SNAPSHOT/wsconsume-output"/>
<classpathentry kind="output" path="eclipse-classes"/>
</classpath>
13 years, 6 months
[rhq] modules/plugins
by Jay Shaughnessy
modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/AbstractManagedDeploymentComponent.java | 10
modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/ApplicationServerComponent.java | 100 +++---
modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/Ejb2BeanComponent.java | 14
modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/ManagedComponentComponent.java | 153 ++++++----
modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/TxConnectionFactoryComponent.java | 42 +-
modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/util/ManagedComponentUtils.java | 99 ++----
6 files changed, 231 insertions(+), 187 deletions(-)
New commits:
commit f8f501532d2658d814048ecf3879685ddfdff984
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Thu Oct 28 13:07:04 2010 -0500
Perf Work on the AS-5 Plugin to try and reduce avail and metric gathering
times. In general trying to reduce interaction with Profile Service.
1) Cache ManagedComponent in ManagedComponentComponent
This is the base class for resources managed by a profile service
ManagedComponent. It seems that for "runtime" properties gettingthe prop
value returns the live value, so we dont have to get the re-fetch the
ManagedComponent object from the ManagementView. This greatly helps avail checking
Since RunState is a runtime value. It also helps metric collection if all
of the requested metrics are runtime values.
2) Cache whether metrics are runtime or not runtime
Instead of figuring out every time whether requested metrics are runtime
properties, cache this info to save time. This is a static cache so all
instances of the type can share the info.
3) Remove use of ManagedComponentUtils.getManagedComponent()
The PS API added ManagementView.getComponent(name, type), which is more
efficient.
4) Avoid load() when checking avail for ManagedDeployment components (EAR/WAR)
Although it is necessary to re-fetch the ManagedDeployment to get an
updated deployment state, a load of the management view is not necessary.
Conflicts:
modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/ApplicationServerComponent.java
modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/ManagedComponentComponent.java
diff --git a/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/AbstractManagedDeploymentComponent.java b/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/AbstractManagedDeploymentComponent.java
index bd78958..e925148 100644
--- a/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/AbstractManagedDeploymentComponent.java
+++ b/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/AbstractManagedDeploymentComponent.java
@@ -106,7 +106,7 @@ public abstract class AbstractManagedDeploymentComponent extends AbstractManaged
public AvailabilityType getAvailability() {
DeploymentState deploymentState = null;
try {
- deploymentState = getManagedDeployment().getDeploymentState();
+ deploymentState = getManagedDeployment(false).getDeploymentState();
} catch (NoSuchDeploymentException e) {
log.warn(this.deploymentType + " deployment '" + this.deploymentName + "' not found. Cause: "
+ e.getLocalizedMessage());
@@ -186,8 +186,14 @@ public abstract class AbstractManagedDeploymentComponent extends AbstractManaged
}
protected ManagedDeployment getManagedDeployment() throws NoSuchDeploymentException {
+ return getManagedDeployment(true);
+ }
+
+ protected ManagedDeployment getManagedDeployment(boolean forceLoad) throws NoSuchDeploymentException {
ManagementView managementView = getConnection().getManagementView();
- managementView.load();
+ if (forceLoad) {
+ managementView.load();
+ }
return managementView.getDeployment(this.deploymentName);
}
diff --git a/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/ApplicationServerComponent.java b/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/ApplicationServerComponent.java
index 855791a..5bacccb 100644
--- a/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/ApplicationServerComponent.java
+++ b/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/ApplicationServerComponent.java
@@ -35,9 +35,15 @@ import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
+import com.jboss.jbossnetwork.product.jbpm.handlers.ControlActionFacade;
+
+import org.apache.commons.lang.exception.ExceptionUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.apache.commons.lang.exception.ExceptionUtils;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+import org.mc4j.ems.connection.EmsConnection;
+import org.mc4j.ems.connection.support.metadata.InternalVMTypeDescriptor;
import org.jboss.deployers.spi.management.ManagementView;
import org.jboss.deployers.spi.management.deploy.ProgressEvent;
@@ -49,17 +55,12 @@ import org.jboss.on.common.jbossas.JBPMWorkflowManager;
import org.jboss.on.common.jbossas.JBossASPaths;
import org.jboss.on.common.jbossas.JmxConnectionHelper;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
-import org.mc4j.ems.connection.EmsConnection;
-import org.mc4j.ems.connection.support.metadata.InternalVMTypeDescriptor;
-
-import org.rhq.core.domain.content.transfer.DeployPackagesResponse;
-import org.rhq.core.domain.content.transfer.RemovePackagesResponse;
import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.configuration.PropertySimple;
import org.rhq.core.domain.content.PackageType;
import org.rhq.core.domain.content.transfer.DeployPackageStep;
+import org.rhq.core.domain.content.transfer.DeployPackagesResponse;
+import org.rhq.core.domain.content.transfer.RemovePackagesResponse;
import org.rhq.core.domain.content.transfer.ResourcePackageDetails;
import org.rhq.core.domain.measurement.AvailabilityType;
import org.rhq.core.domain.measurement.DataType;
@@ -88,12 +89,10 @@ import org.rhq.plugins.jbossas5.connection.ProfileServiceConnection;
import org.rhq.plugins.jbossas5.connection.ProfileServiceConnectionProvider;
import org.rhq.plugins.jbossas5.connection.RemoteProfileServiceConnectionProvider;
import org.rhq.plugins.jbossas5.helper.CreateChildResourceFacetDelegate;
-import org.rhq.plugins.jbossas5.helper.JBossAS5ConnectionTypeDescriptor;
import org.rhq.plugins.jbossas5.helper.InPluginControlActionFacade;
+import org.rhq.plugins.jbossas5.helper.JBossAS5ConnectionTypeDescriptor;
import org.rhq.plugins.jbossas5.util.ManagedComponentUtils;
-import com.jboss.jbossnetwork.product.jbpm.handlers.ControlActionFacade;
-
/**
* ResourceComponent for a JBoss AS, 5.1.0.CR1 or later, Server.
*
@@ -144,25 +143,26 @@ public class ApplicationServerComponent implements ResourceComponent, ProfileSer
try {
ManagementView managementView = this.connection.getManagementView();
managementView.load();
-
+
//let's see if the connection corresponds to the server
//this component represents. This is to prevent 2 servers
//with the same JNP URL to be reported as UP when just one
//of them can be up at a time.
- ManagedComponent serverConfig = managementView.getComponentsForType(new ComponentType("MCBean", "ServerConfig")).iterator().next();
-
- String reportedServerHomeDirPath = (String)((SimpleValue)serverConfig.getProperty("serverHomeDir").getValue()).getValue();
-
- String configuredServerHomeDirPath = resourceContext.getPluginConfiguration()
- .getSimpleValue(ApplicationServerPluginConfigurationProperties.SERVER_HOME_DIR, null);
-
+ ManagedComponent serverConfig = managementView.getComponentsForType(
+ new ComponentType("MCBean", "ServerConfig")).iterator().next();
+
+ String reportedServerHomeDirPath = (String) ((SimpleValue) serverConfig.getProperty("serverHomeDir")
+ .getValue()).getValue();
+
+ String configuredServerHomeDirPath = resourceContext.getPluginConfiguration().getSimpleValue(
+ ApplicationServerPluginConfigurationProperties.SERVER_HOME_DIR, null);
+
//the paths might be symlinked
File reportedServerHomeDir = new File(reportedServerHomeDirPath);
File configuredServerHomeDir = new File(configuredServerHomeDirPath);
-
- availability = reportedServerHomeDir.getCanonicalPath().equals(configuredServerHomeDir.getCanonicalPath())
- ? AvailabilityType.UP
- : AvailabilityType.DOWN;
+
+ availability = reportedServerHomeDir.getCanonicalPath().equals(
+ configuredServerHomeDir.getCanonicalPath()) ? AvailabilityType.UP : AvailabilityType.DOWN;
} catch (Exception e) {
availability = AvailabilityType.DOWN;
}
@@ -193,7 +193,8 @@ public class ApplicationServerComponent implements ResourceComponent, ProfileSer
// prepare to perform async avail checking
Configuration pc = resourceContext.getPluginConfiguration();
- String availCheckPeriodProp = pc.getSimpleValue(ApplicationServerPluginConfigurationProperties.AVAIL_CHECK_PERIOD_CONFIG_PROP, null);
+ String availCheckPeriodProp = pc.getSimpleValue(
+ ApplicationServerPluginConfigurationProperties.AVAIL_CHECK_PERIOD_CONFIG_PROP, null);
if (availCheckPeriodProp != null) {
try {
long availCheckMillis = Integer.parseInt(availCheckPeriodProp) * 1000L;
@@ -260,7 +261,7 @@ public class ApplicationServerComponent implements ResourceComponent, ProfileSer
propertyNames.add(ALTERNATE_METRIC_NAMES.get(requestName));
}
throw new IllegalStateException("A property was not found with any of the following names: "
- + propertyNames);
+ + propertyNames);
}
if (value != null) {
@@ -350,10 +351,13 @@ public class ApplicationServerComponent implements ResourceComponent, ProfileSer
connectionProvider = new LocalProfileServiceConnectionProvider();
} else {
Configuration pluginConfig = this.resourceContext.getPluginConfiguration();
- String namingURL = pluginConfig.getSimpleValue(ApplicationServerPluginConfigurationProperties.NAMING_URL, null);
+ String namingURL = pluginConfig.getSimpleValue(ApplicationServerPluginConfigurationProperties.NAMING_URL,
+ null);
validateNamingURL(namingURL);
- String principal = pluginConfig.getSimpleValue(ApplicationServerPluginConfigurationProperties.PRINCIPAL, null);
- String credentials = pluginConfig.getSimpleValue(ApplicationServerPluginConfigurationProperties.CREDENTIALS, null);
+ String principal = pluginConfig.getSimpleValue(ApplicationServerPluginConfigurationProperties.PRINCIPAL,
+ null);
+ String credentials = pluginConfig.getSimpleValue(
+ ApplicationServerPluginConfigurationProperties.CREDENTIALS, null);
connectionProvider = new RemoteProfileServiceConnectionProvider(namingURL, principal, credentials);
}
if (Thread.interrupted()) {
@@ -373,7 +377,7 @@ public class ApplicationServerComponent implements ResourceComponent, ProfileSer
log.warn("Failed to connect to Profile Service - cause: " + rootCause);
}
throw new InvalidPluginConfigurationException(
- "Values of 'principal' and/or 'credentials' connection properties are invalid.", rootCause);
+ "Values of 'principal' and/or 'credentials' connection properties are invalid.", rootCause);
}
log.debug("Failed to connect to Profile Service.", e);
}
@@ -395,15 +399,18 @@ public class ApplicationServerComponent implements ResourceComponent, ProfileSer
private JBossASPaths getJBossASPaths() {
Configuration pluginConfiguration = this.resourceContext.getPluginConfiguration();
- String homeDir = pluginConfiguration.getSimpleValue(ApplicationServerPluginConfigurationProperties.HOME_DIR, null);
- String serverHomeDir = pluginConfiguration.getSimpleValue(ApplicationServerPluginConfigurationProperties.SERVER_HOME_DIR, null);
+ String homeDir = pluginConfiguration.getSimpleValue(ApplicationServerPluginConfigurationProperties.HOME_DIR,
+ null);
+ String serverHomeDir = pluginConfiguration.getSimpleValue(
+ ApplicationServerPluginConfigurationProperties.SERVER_HOME_DIR, null);
return new JBossASPaths(homeDir, serverHomeDir);
}
private boolean runningEmbedded() {
Configuration pluginConfiguration = this.resourceContext.getPluginConfiguration();
- String namingUrl = pluginConfiguration.getSimpleValue(ApplicationServerPluginConfigurationProperties.NAMING_URL, null);
+ String namingUrl = pluginConfiguration.getSimpleValue(
+ ApplicationServerPluginConfigurationProperties.NAMING_URL, null);
return namingUrl == null;
}
@@ -412,7 +419,8 @@ public class ApplicationServerComponent implements ResourceComponent, ProfileSer
File configDir = new File(path);
if (!configDir.isAbsolute()) {
Configuration pluginConfig = this.resourceContext.getPluginConfiguration();
- String homeDir = pluginConfig.getSimple(ApplicationServerPluginConfigurationProperties.HOME_DIR).getStringValue();
+ String homeDir = pluginConfig.getSimple(ApplicationServerPluginConfigurationProperties.HOME_DIR)
+ .getStringValue();
configDir = new File(homeDir, path);
}
return configDir;
@@ -455,7 +463,7 @@ public class ApplicationServerComponent implements ResourceComponent, ProfileSer
public OperationResult invokeOperation(String name, Configuration parameters) throws InterruptedException,
Exception {
-
+
ApplicationServerSupportedOperations operation = Enum.valueOf(ApplicationServerSupportedOperations.class, name
.toUpperCase());
return this.operationDelegate.invoke(operation, parameters);
@@ -466,16 +474,20 @@ public class ApplicationServerComponent implements ResourceComponent, ProfileSer
Configuration jmxConfig = new Configuration();
- String jbossHomeDir = pluginConfiguration.getSimpleValue(ApplicationServerPluginConfigurationProperties.HOME_DIR, null);
+ String jbossHomeDir = pluginConfiguration.getSimpleValue(
+ ApplicationServerPluginConfigurationProperties.HOME_DIR, null);
String connectorDescriptorType;
boolean runningEmbedded = runningEmbedded();
if (runningEmbedded) {
connectorDescriptorType = InternalVMTypeDescriptor.class.getName();
} else {
- String connectorAddress = pluginConfiguration.getSimpleValue(ApplicationServerPluginConfigurationProperties.NAMING_URL, null);
- String connectorPrincipal = pluginConfiguration.getSimpleValue(ApplicationServerPluginConfigurationProperties.PRINCIPAL, null);
- String connectorCredentials = pluginConfiguration.getSimpleValue(ApplicationServerPluginConfigurationProperties.CREDENTIALS, null);
+ String connectorAddress = pluginConfiguration.getSimpleValue(
+ ApplicationServerPluginConfigurationProperties.NAMING_URL, null);
+ String connectorPrincipal = pluginConfiguration.getSimpleValue(
+ ApplicationServerPluginConfigurationProperties.PRINCIPAL, null);
+ String connectorCredentials = pluginConfiguration.getSimpleValue(
+ ApplicationServerPluginConfigurationProperties.CREDENTIALS, null);
connectorDescriptorType = JBossAS5ConnectionTypeDescriptor.class.getName();
@@ -512,7 +524,7 @@ public class ApplicationServerComponent implements ResourceComponent, ProfileSer
private File getConfigurationPath() {
Configuration pluginConfig = this.resourceContext.getPluginConfiguration();
String serverHomeDir = getRequiredPropertyValue(pluginConfig,
- ApplicationServerPluginConfigurationProperties.SERVER_HOME_DIR);
+ ApplicationServerPluginConfigurationProperties.SERVER_HOME_DIR);
File configPath = resolvePathRelativeToHomeDir(serverHomeDir);
if (!configPath.isDirectory()) {
throw new InvalidPluginConfigurationException("Configuration path '" + configPath + "' does not exist.");
@@ -527,7 +539,7 @@ public class ApplicationServerComponent implements ResourceComponent, ProfileSer
Matcher matcher = METRIC_NAME_PATTERN.matcher(metricName);
if (!matcher.matches()) {
throw new IllegalStateException("Metric name '" + metricName + "' does not match pattern '"
- + METRIC_NAME_PATTERN + "'.");
+ + METRIC_NAME_PATTERN + "'.");
}
String componentCategory = matcher.group(1);
String componentSubType = matcher.group(2);
@@ -538,7 +550,13 @@ public class ApplicationServerComponent implements ResourceComponent, ProfileSer
if (componentName.equals("*")) {
component = ManagedComponentUtils.getSingletonManagedComponent(managementView, componentType);
} else {
- component = ManagedComponentUtils.getManagedComponent(managementView, componentType, componentName);
+ //component = ManagedComponentUtils.getManagedComponent(managementView, componentType, componentName);
+ try {
+ component = managementView.getComponent(componentName, componentType);
+ } catch (Exception e) {
+ throw new IllegalStateException("Error fetching component " + componentName + "of type "
+ + componentType);
+ }
}
return ManagedComponentUtils.getSimplePropertyValue(component, propertyName);
diff --git a/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/Ejb2BeanComponent.java b/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/Ejb2BeanComponent.java
index 1eb2219..15ffea3 100644
--- a/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/Ejb2BeanComponent.java
+++ b/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/Ejb2BeanComponent.java
@@ -24,8 +24,9 @@ package org.rhq.plugins.jbossas5;
import java.util.Set;
-import org.jboss.managed.api.ManagedComponent;
+import org.jboss.deployers.spi.management.ManagementView;
import org.jboss.managed.api.ComponentType;
+import org.jboss.managed.api.ManagedComponent;
import org.rhq.plugins.jbossas5.util.Ejb2BeanUtils;
@@ -38,26 +39,27 @@ public class Ejb2BeanComponent extends AbstractEjbBeanComponent {
private static final ComponentType MDB_COMPONENT_TYPE = new ComponentType("EJB", "MDB");
@Override
- protected ManagedComponent getManagedComponent() {
+ protected ManagedComponent getManagedComponent(boolean forceRefresh) {
if (MDB_COMPONENT_TYPE.equals(getComponentType())) {
try {
//we need to reload the management view here, because the MDBs might have changed since
//the last call, because the @object-id is part of their names.
- getConnection().getManagementView().load();
+ ManagementView mv = getConnection().getManagementView();
+ mv.load();
- Set<ManagedComponent> mdbs = getConnection().getManagementView().getComponentsForType(
- MDB_COMPONENT_TYPE);
+ Set<ManagedComponent> mdbs = mv.getComponentsForType(MDB_COMPONENT_TYPE);
for (ManagedComponent mdb : mdbs) {
if (getComponentName().equals(Ejb2BeanUtils.getUniqueBeanIdentificator(mdb))) {
return mdb;
}
}
+
} catch (Exception e) {
throw new IllegalStateException(e);
}
} else {
- return super.getManagedComponent();
+ return super.getManagedComponent(forceRefresh);
}
return null;
diff --git a/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/ManagedComponentComponent.java b/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/ManagedComponentComponent.java
index 7c70bc7..6d564ee 100644
--- a/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/ManagedComponentComponent.java
+++ b/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/ManagedComponentComponent.java
@@ -24,12 +24,16 @@ package org.rhq.plugins.jbossas5;
import java.lang.reflect.Array;
import java.util.ArrayList;
+import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
import org.jboss.deployers.spi.management.ManagementView;
import org.jboss.deployers.spi.management.deploy.DeploymentManager;
import org.jboss.deployers.spi.management.deploy.DeploymentProgress;
@@ -40,20 +44,17 @@ import org.jboss.managed.api.ManagedDeployment;
import org.jboss.managed.api.ManagedOperation;
import org.jboss.managed.api.ManagedProperty;
import org.jboss.managed.api.RunState;
+import org.jboss.managed.api.annotation.ViewUse;
import org.jboss.metatype.api.values.ArrayValue;
import org.jboss.metatype.api.values.CollectionValue;
import org.jboss.metatype.api.values.CompositeValue;
import org.jboss.metatype.api.values.EnumValue;
import org.jboss.metatype.api.values.MetaValue;
import org.jboss.metatype.api.values.SimpleValue;
-import org.jboss.remoting.CannotConnectException;
-
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
import org.rhq.core.domain.configuration.Configuration;
-import org.rhq.core.domain.configuration.PropertySimple;
import org.rhq.core.domain.configuration.ConfigurationUpdateStatus;
+import org.rhq.core.domain.configuration.PropertySimple;
import org.rhq.core.domain.configuration.definition.ConfigurationDefinition;
import org.rhq.core.domain.measurement.AvailabilityType;
import org.rhq.core.domain.measurement.DataType;
@@ -72,11 +73,10 @@ import org.rhq.core.pluginapi.operation.OperationFacet;
import org.rhq.core.pluginapi.operation.OperationResult;
import org.rhq.core.util.exception.ThrowableUtil;
import org.rhq.plugins.jbossas5.util.ConversionUtils;
+import org.rhq.plugins.jbossas5.util.DebugUtils;
import org.rhq.plugins.jbossas5.util.DeploymentUtils;
-import org.rhq.plugins.jbossas5.util.ManagedComponentUtils;
-import org.rhq.plugins.jbossas5.util.ResourceTypeUtils;
import org.rhq.plugins.jbossas5.util.ResourceComponentUtils;
-import org.rhq.plugins.jbossas5.util.DebugUtils;
+import org.rhq.plugins.jbossas5.util.ResourceTypeUtils;
/**
* Service ResourceComponent for all {@link ManagedComponent}s in a Profile.
@@ -93,12 +93,19 @@ public class ManagedComponentComponent extends AbstractManagedComponent implemen
String COMPONENT_NAME = "componentName";
String TEMPLATE_NAME = "templateName";
String COMPONENT_NAME_PROPERTY = "componentNameProperty";
- }
+ }
protected static final char PREFIX_DELIMITER = '|';
+ // Map the managedComponentComponent class name to a map of metricName to "isRuntimeProp". So, for a given
+ // component we can quickly determine whether requested metrics need to refresh the managedComponent, or not.
+ private static final Map<String, Map<String, Boolean>> runtimeMetricMaps = new HashMap<String, Map<String, Boolean>>();
+
private final Log log = LogFactory.getLog(this.getClass());
+ // Cache the ManagedComponent since it can be re-used to request any ViewUse.RUNTIME property values
+ private ManagedComponent managedComponent = null;
+
private String componentName;
private ComponentType componentType;
@@ -109,15 +116,15 @@ public class ManagedComponentComponent extends AbstractManagedComponent implemen
try {
runState = getManagedComponent().getRunState();
} catch (Throwable t) {
- log.debug("Could not get component state for " + this.componentType + " component '"
- + this.componentName + "', cause: ", t);
+ log.debug("Could not get component state for " + this.componentType + " component '" + this.componentName
+ + "', cause: ", t);
return AvailabilityType.DOWN;
}
if (runState == RunState.RUNNING) {
return AvailabilityType.UP;
} else {
- log.debug(this.componentType + " component '" + this.componentName + "' was not running, state" +
- " was: " + runState);
+ log.debug(this.componentType + " component '" + this.componentName + "' was not running, state" + " was: "
+ + runState);
return AvailabilityType.DOWN;
}
}
@@ -132,58 +139,51 @@ public class ManagedComponentComponent extends AbstractManagedComponent implemen
}
public void stop() {
- return;
+ managedComponent = null;
+ super.stop();
}
// ConfigurationComponent Implementation --------------------------------------------
- public Configuration loadResourceConfiguration()
- {
+ public Configuration loadResourceConfiguration() {
Configuration resourceConfig;
- try
- {
+ try {
Map<String, ManagedProperty> managedProperties = getManagedComponent().getProperties();
- Map<String, PropertySimple> customProps =
- ResourceComponentUtils.getCustomProperties(getResourceContext().getPluginConfiguration());
- if (this.log.isDebugEnabled()) this.log.debug("*** AFTER LOAD:\n"
- + DebugUtils.convertPropertiesToString(managedProperties));
- resourceConfig = ConversionUtils.convertManagedObjectToConfiguration(managedProperties,
- customProps, getResourceContext().getResourceType());
- }
- catch (Exception e)
- {
+ Map<String, PropertySimple> customProps = ResourceComponentUtils.getCustomProperties(getResourceContext()
+ .getPluginConfiguration());
+ if (this.log.isDebugEnabled())
+ this.log.debug("*** AFTER LOAD:\n" + DebugUtils.convertPropertiesToString(managedProperties));
+ resourceConfig = ConversionUtils.convertManagedObjectToConfiguration(managedProperties, customProps,
+ getResourceContext().getResourceType());
+ } catch (Exception e) {
RunState runState = getManagedComponent().getRunState();
if (runState == RunState.RUNNING) {
- this.log.error("Failed to load configuration for " + getResourceDescription() + ".", e);
+ this.log.error("Failed to load configuration for " + getResourceDescription() + ".", e);
} else {
- this.log.debug("Failed to load configuration for " + getResourceDescription()
- + ", but managed component is not in the RUNNING state.", e);
+ this.log.debug("Failed to load configuration for " + getResourceDescription()
+ + ", but managed component is not in the RUNNING state.", e);
}
throw new RuntimeException(ThrowableUtil.getAllMessages(e));
}
return resourceConfig;
}
- public void updateResourceConfiguration(ConfigurationUpdateReport configurationUpdateReport)
- {
+ public void updateResourceConfiguration(ConfigurationUpdateReport configurationUpdateReport) {
Configuration resourceConfig = configurationUpdateReport.getConfiguration();
Configuration pluginConfig = getResourceContext().getPluginConfiguration();
- try
- {
+ try {
ManagedComponent managedComponent = getManagedComponent();
Map<String, ManagedProperty> managedProperties = managedComponent.getProperties();
Map<String, PropertySimple> customProps = ResourceComponentUtils.getCustomProperties(pluginConfig);
- if (this.log.isDebugEnabled()) this.log.debug("*** BEFORE UPDATE:\n"
- + DebugUtils.convertPropertiesToString(managedProperties));
+ if (this.log.isDebugEnabled())
+ this.log.debug("*** BEFORE UPDATE:\n" + DebugUtils.convertPropertiesToString(managedProperties));
ConversionUtils.convertConfigurationToManagedProperties(managedProperties, resourceConfig,
- getResourceContext().getResourceType(), customProps);
- if (this.log.isDebugEnabled()) this.log.debug("*** AFTER UPDATE:\n"
- + DebugUtils.convertPropertiesToString(managedProperties));
+ getResourceContext().getResourceType(), customProps);
+ if (this.log.isDebugEnabled())
+ this.log.debug("*** AFTER UPDATE:\n" + DebugUtils.convertPropertiesToString(managedProperties));
updateComponent(managedComponent);
configurationUpdateReport.setStatus(ConfigurationUpdateStatus.SUCCESS);
- }
- catch (Exception e)
- {
+ } catch (Exception e) {
this.log.error("Failed to update configuration for " + getResourceDescription() + ".", e);
configurationUpdateReport.setStatus(ConfigurationUpdateStatus.FAILURE);
configurationUpdateReport.setErrorMessage(ThrowableUtil.getAllMessages(e));
@@ -234,7 +234,36 @@ public class ManagedComponentComponent extends AbstractManagedComponent implemen
// MeasurementFacet Implementation --------------------------------------------
public void getValues(MeasurementReport report, Set<MeasurementScheduleRequest> metrics) throws Exception {
- ManagedComponent managedComponent = getManagedComponent();
+ // this bit could be synchronized but I don't think it really hurts to perhaps go through this logic more
+ // than once, it will settle down near immediately
+ Map<String, Boolean> runtimeMetricMap = runtimeMetricMaps.get(this.getClass().getName());
+ if (null == runtimeMetricMap) {
+ //log.info("\nADDING MAP FOR CLASS=" + this.getClass().getName());
+ runtimeMetricMap = new HashMap<String, Boolean>();
+ runtimeMetricMaps.put(this.getClass().getName(), runtimeMetricMap);
+ }
+
+ // determine whether we can use the cachedComponent or if we need to force a component fetch to
+ // gather the requested metrics.
+ boolean forceRefresh = false;
+ for (MeasurementScheduleRequest request : metrics) {
+ Boolean isRuntimeMetric = runtimeMetricMap.get(request.getName());
+ // if this is the first time we've seen this metric find out if it's a runtime prop
+ if (null == isRuntimeMetric) {
+ //log.info("\nADDING MAP ENTRY FOR METRIC=" + request.getName());
+ ManagedProperty managedProp = getManagedProperty(managedComponent, request);
+ runtimeMetricMap.put(request.getName(), Boolean.valueOf((null == managedProp || managedProp
+ .hasViewUse(ViewUse.RUNTIME))));
+ }
+
+ if (Boolean.FALSE.equals(runtimeMetricMap.get(request.getName()))) {
+ //log.info("\nFORCING COMPONENT REFRESH DUE TO NON-RUNTIME PROP: " + request.getName());
+ forceRefresh = true;
+ break;
+ }
+ }
+
+ ManagedComponent managedComponent = getManagedComponent(forceRefresh);
RunState runState = managedComponent.getRunState();
for (MeasurementScheduleRequest request : metrics) {
try {
@@ -249,7 +278,7 @@ public class ManagedComponentComponent extends AbstractManagedComponent implemen
log.error("Failed to collect metric for " + request, e);
} else {
log.debug("Failed to collect metric for " + request
- + ", but managed component is not in the RUNNING state.", e);
+ + ", but managed component is not in the RUNNING state.", e);
}
}
}
@@ -297,6 +326,29 @@ public class ManagedComponentComponent extends AbstractManagedComponent implemen
return getInnerValue(metaValue);
}
+ /**
+ * The name of the measurement schedule request (i.e. the metric name) can be in one of two forms:
+ * <p/>
+ * [prefix'|']simplePropertyName (e.g. "maxTime" or "ThreadPool|currentThreadCount")
+ * [prefix'|']compositePropertyName'.'key (e.g. "consumerCount" or "messageStatistics.count")
+ *
+ * @param managedComponent a managed component
+ * @param request a measurement schedule request
+ * @return the metric value
+ */
+ @Nullable
+ protected ManagedProperty getManagedProperty(ManagedComponent managedComponent, MeasurementScheduleRequest request) {
+ String metricName = request.getName();
+ int pipeIndex = metricName.indexOf(PREFIX_DELIMITER);
+ // Remove the prefix if there is one (e.g. "ThreadPool|currentThreadCount" -> "currentThreadCount").
+ String compositePropName = (pipeIndex == -1) ? metricName : metricName.substring(pipeIndex + 1);
+ int dotIndex = compositePropName.indexOf('.');
+ String metricPropName = (dotIndex == -1) ? compositePropName : compositePropName.substring(0, dotIndex);
+ ManagedProperty metricProp = managedComponent.getProperty(metricPropName);
+
+ return metricProp;
+ }
+
// TODO: Move this to a utility class.
@Nullable
private static Object getInnerValue(MetaValue metaValue) {
@@ -362,11 +414,18 @@ public class ManagedComponentComponent extends AbstractManagedComponent implemen
}
protected ManagedComponent getManagedComponent() {
- ManagedComponent managedComponent;
+ return getManagedComponent(false);
+ }
+
+ protected ManagedComponent getManagedComponent(boolean forceRefresh) {
+
+ if (!forceRefresh && null != this.managedComponent) {
+ return this.managedComponent;
+ }
+
try {
ManagementView managementView = getConnection().getManagementView();
- managedComponent = ManagedComponentUtils.getManagedComponent(managementView, this.componentType,
- this.componentName);
+ managedComponent = managementView.getComponent(this.componentName, this.componentType);
} catch (Exception e) {
throw new RuntimeException("Failed to load [" + this.componentType + "] ManagedComponent ["
+ this.componentName + "].", e);
diff --git a/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/TxConnectionFactoryComponent.java b/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/TxConnectionFactoryComponent.java
index 07f4462..cdfa98b 100644
--- a/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/TxConnectionFactoryComponent.java
+++ b/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/TxConnectionFactoryComponent.java
@@ -27,47 +27,41 @@ import java.util.Set;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.rhq.core.domain.measurement.MeasurementDataTrait;
-import org.rhq.core.domain.measurement.MeasurementReport;
-import org.rhq.core.domain.measurement.MeasurementScheduleRequest;
+import org.jboss.managed.api.ManagedComponent;
import org.jboss.managed.api.ManagedProperty;
import org.jboss.metatype.api.values.SimpleValue;
+import org.rhq.core.domain.measurement.MeasurementDataTrait;
+import org.rhq.core.domain.measurement.MeasurementReport;
+import org.rhq.core.domain.measurement.MeasurementScheduleRequest;
+
/**
* A Resource component for JBoss AS 5 Tx Connection Factories.
*
* @author Ian Springer
*/
-public class TxConnectionFactoryComponent extends ManagedComponentComponent
-{
+public class TxConnectionFactoryComponent extends ManagedComponentComponent {
private final Log log = LogFactory.getLog(this.getClass());
@Override
- public void getValues(MeasurementReport report, Set<MeasurementScheduleRequest> metrics) throws Exception
- {
- Set<MeasurementScheduleRequest> uncollectedMetrics = new HashSet();
- for (MeasurementScheduleRequest request : metrics)
- {
- try
- {
- if (request.getName().equals("custom.transactionType"))
- {
- ManagedProperty xaTransactionProp = getManagedComponent().getProperty("xa-transaction");
- SimpleValue xaTransactionMetaValue = (SimpleValue)xaTransactionProp.getValue();
- Boolean xaTransactionValue = (xaTransactionMetaValue != null)
- ? (Boolean)xaTransactionMetaValue.getValue() : null;
+ public void getValues(MeasurementReport report, Set<MeasurementScheduleRequest> metrics) throws Exception {
+ ManagedComponent mc = getManagedComponent(true);
+ Set<MeasurementScheduleRequest> uncollectedMetrics = new HashSet<MeasurementScheduleRequest>();
+ for (MeasurementScheduleRequest request : metrics) {
+ try {
+ if (request.getName().equals("custom.transactionType")) {
+ ManagedProperty xaTransactionProp = mc.getProperty("xa-transaction");
+ SimpleValue xaTransactionMetaValue = (SimpleValue) xaTransactionProp.getValue();
+ Boolean xaTransactionValue = (xaTransactionMetaValue != null) ? (Boolean) xaTransactionMetaValue
+ .getValue() : null;
boolean isXa = (xaTransactionValue != null && xaTransactionValue);
String transactionType = (isXa) ? "XA" : "Local";
report.addData(new MeasurementDataTrait(request, transactionType));
- }
- else
- {
+ } else {
uncollectedMetrics.add(request);
}
- }
- catch (Exception e)
- {
+ } catch (Exception e) {
log.error("Failed to collect metric for " + request, e);
}
}
diff --git a/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/util/ManagedComponentUtils.java b/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/util/ManagedComponentUtils.java
index b928584..a08a043 100644
--- a/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/util/ManagedComponentUtils.java
+++ b/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/util/ManagedComponentUtils.java
@@ -23,12 +23,13 @@
package org.rhq.plugins.jbossas5.util;
import java.io.Serializable;
+import java.util.Comparator;
import java.util.EnumSet;
-import java.util.Set;
import java.util.HashSet;
-import java.util.Comparator;
+import java.util.Set;
import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
import org.jboss.deployers.spi.management.ManagementView;
import org.jboss.deployers.spi.management.NameMatcher;
@@ -39,78 +40,53 @@ import org.jboss.managed.api.annotation.ViewUse;
import org.jboss.metatype.api.types.MetaType;
import org.jboss.metatype.api.values.EnumValue;
import org.jboss.metatype.api.values.SimpleValue;
-import org.jetbrains.annotations.Nullable;
/**
* A collection of utility methods for working with Profile Service {@link ManagedComponent}s.
*
* @author Ian Springer
*/
-public class ManagedComponentUtils
-{
+public class ManagedComponentUtils {
private static final Comparator<ComponentType> COMPONENT_TYPE_COMPARATOR = new ComponentTypeComparator();
@Nullable
- public static ManagedComponent getManagedComponent(ManagementView managementView, ComponentType componentType,
- String componentName)
- {
- Set<ManagedComponent> components = getManagedComponents(managementView, componentType);
- for (ManagedComponent component : components)
- {
- if (component.getName().equals(componentName))
- return component;
- }
- return null;
- }
-
- @Nullable
public static ManagedComponent getSingletonManagedComponent(ManagementView managementView,
- ComponentType componentType)
- {
+ ComponentType componentType) {
Set<ManagedComponent> components = getManagedComponents(managementView, componentType);
- if (components.size() > 1)
- {
+ if (components.size() > 1) {
throw new IllegalStateException("Found more than one component of type " + componentType + ": "
- + components);
+ + components);
}
- @SuppressWarnings({"UnnecessaryLocalVariable"})
+ @SuppressWarnings( { "UnnecessaryLocalVariable" })
ManagedComponent component = (components.size() == 1) ? components.iterator().next() : null;
return component;
}
public static Serializable getSimplePropertyValue(ManagedComponent component, String propertyName)
- throws PropertyNotFoundException {
+ throws PropertyNotFoundException {
ManagedProperty property = component.getProperty(propertyName);
- if (property == null)
- {
- throw new PropertyNotFoundException("Property named '" + propertyName + "' not found for ManagedComponent ["
- + component + "].");
+ if (property == null) {
+ throw new PropertyNotFoundException("Property named '" + propertyName
+ + "' not found for ManagedComponent [" + component + "].");
}
MetaType metaType = property.getMetaType();
Serializable value;
- if (metaType.isSimple())
- {
- SimpleValue simpleValue = (SimpleValue)property.getValue();
+ if (metaType.isSimple()) {
+ SimpleValue simpleValue = (SimpleValue) property.getValue();
value = (simpleValue != null) ? simpleValue.getValue() : null;
- }
- else if (metaType.isEnum())
- {
- EnumValue enumValue = (EnumValue)property.getValue();
+ } else if (metaType.isEnum()) {
+ EnumValue enumValue = (EnumValue) property.getValue();
value = (enumValue != null) ? enumValue.getValue() : null;
- }
- else
- {
+ } else {
throw new IllegalStateException("Type of [" + property + "] is not simple or enum.");
}
return value;
}
@NotNull
- public static EnumSet<ViewUse> getViewUses(ManagedProperty managedProperty)
- {
+ public static EnumSet<ViewUse> getViewUses(ManagedProperty managedProperty) {
EnumSet<ViewUse> viewUses = EnumSet.noneOf(ViewUse.class);
- for (ViewUse viewUse : ViewUse.values())
- {
+ for (ViewUse viewUse : ViewUse.values()) {
if (managedProperty.hasViewUse(viewUse))
viewUses.add(viewUse);
}
@@ -120,19 +96,15 @@ public class ManagedComponentUtils
/**
* TODO
*/
- public static boolean isManagedComponent(ManagementView managementView, String name, ComponentType componentType)
- {
+ public static boolean isManagedComponent(ManagementView managementView, String name, ComponentType componentType) {
boolean isDeployed = false;
- if (name != null)
- {
- try
- {
- ManagedComponent component = getManagedComponent(managementView, componentType, name);
+ if (name != null) {
+ try {
+ //ManagedComponent component = getManagedComponent(managementView, componentType, name);
+ ManagedComponent component = managementView.getComponent(name, componentType);
if (component != null)
isDeployed = true;
- }
- catch (Exception e)
- {
+ } catch (Exception e) {
// Setting it to true to be safe than sorry, since there might be a component
// already deployed in the AS. TODO (ips): I don't think I like this.
isDeployed = true;
@@ -142,9 +114,8 @@ public class ManagedComponentUtils
}
@NotNull
- public static Set<ManagedComponent> getManagedComponents(ManagementView managementView, ComponentType componentType,
- String name, NameMatcher<ManagedComponent> nameMatcher)
- {
+ public static Set<ManagedComponent> getManagedComponents(ManagementView managementView,
+ ComponentType componentType, String name, NameMatcher<ManagedComponent> nameMatcher) {
Set<ManagedComponent> matchingComponents = new HashSet<ManagedComponent>();
Set<ManagedComponent> allComponents = getManagedComponents(managementView, componentType);
for (ManagedComponent component : allComponents) {
@@ -160,24 +131,18 @@ public class ManagedComponentUtils
}
@NotNull
- private static Set<ManagedComponent> getManagedComponents(ManagementView managementView, ComponentType componentType)
- {
+ private static Set<ManagedComponent> getManagedComponents(ManagementView managementView, ComponentType componentType) {
Set<ManagedComponent> components;
- try
- {
+ try {
components = managementView.getComponentsForType(componentType);
- }
- catch (Exception e)
- {
+ } catch (Exception e) {
throw new IllegalStateException(e);
}
return components;
}
- private static class ComponentTypeComparator implements Comparator<ComponentType>
- {
- public int compare(ComponentType type1, ComponentType type2)
- {
+ private static class ComponentTypeComparator implements Comparator<ComponentType> {
+ public int compare(ComponentType type1, ComponentType type2) {
int value = type1.getType().compareTo(type2.getType());
// If the categories (e.g. JMSDestination) were equal, do a secondary sort by subtype (e.g. Queue).
return (value != 0) ? value : type1.getSubtype().compareTo(type2.getSubtype());
13 years, 6 months
[rhq] Branch 'delete-agent-plugin' - modules/enterprise
by John Sanda
modules/enterprise/server/jar/src/test/groovy/org/rhq/enterprise/server/resource/metadata/ResourceMetadataManagerBeanTest.groovy | 85 +++++++++-
1 file changed, 77 insertions(+), 8 deletions(-)
New commits:
commit c815a908dfd4c982c0f63d9a05d9244c7dea6dba
Author: John Sanda <jsanda(a)redhat.com>
Date: Thu Oct 28 15:07:18 2010 -0400
Test that resources of removed types get deleted
diff --git a/modules/enterprise/server/jar/src/test/groovy/org/rhq/enterprise/server/resource/metadata/ResourceMetadataManagerBeanTest.groovy b/modules/enterprise/server/jar/src/test/groovy/org/rhq/enterprise/server/resource/metadata/ResourceMetadataManagerBeanTest.groovy
index 3500b87..584683c 100644
--- a/modules/enterprise/server/jar/src/test/groovy/org/rhq/enterprise/server/resource/metadata/ResourceMetadataManagerBeanTest.groovy
+++ b/modules/enterprise/server/jar/src/test/groovy/org/rhq/enterprise/server/resource/metadata/ResourceMetadataManagerBeanTest.groovy
@@ -16,6 +16,9 @@ import org.rhq.core.domain.criteria.ResourceTypeCriteria
import org.rhq.core.domain.criteria.OperationDefinitionCriteria
import org.testng.annotations.AfterClass
import org.hibernate.Session
+import org.rhq.core.domain.shared.ResourceBuilder
+import org.rhq.core.domain.criteria.ResourceCriteria
+import org.rhq.core.domain.resource.InventoryStatus
class ResourceMetadataManagerBeanTest extends AbstractEJB3Test {
@@ -23,14 +26,14 @@ class ResourceMetadataManagerBeanTest extends AbstractEJB3Test {
@AfterClass
void removePluginsFromDB() {
- transactionManager.begin()
- // using direct hibernate query here because JPA 1.0 lacks support for the IN clause
- // where you can directly specify a collection for the parameter value used in an IN
- // clause
- Session session = entityManager.getDelegate()
- session.createQuery("delete from Plugin p where p.name in (:plugins)").setParameterList("plugins", plugins)
- .executeUpdate()
- transactionManager.commit()
+ transaction {
+ // using direct hibernate query here because JPA 1.0 lacks support for the IN clause
+ // where you can directly specify a collection for the parameter value used in an IN
+ // clause
+ Session session = entityManager.getDelegate()
+ session.createQuery("delete from Plugin p where p.name in (:plugins)").setParameterList("plugins", plugins)
+ .executeUpdate()
+ }
}
@Test(groups = ['NewPlugin'])
@@ -308,6 +311,8 @@ class ResourceMetadataManagerBeanTest extends AbstractEJB3Test {
createPlugin 'remove-types-plugin', '1.0', originalDescriptor
+ createResources(3, 'RemoveTypesPlugin', 'ServerC')
+
def updatedDescriptor = """
<plugin name="RemoveTypesPlugin" displayName="Remove Types Plugin" package="org.rhq.plugins.test"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
@@ -322,6 +327,31 @@ class ResourceMetadataManagerBeanTest extends AbstractEJB3Test {
createPlugin 'remove-types-plugin', '2.0', updatedDescriptor
}
+ def createResources(Integer count, String pluginName, String resourceTypeName) {
+ def resourceTypeMgr = LookupUtil.resourceTypeManager
+ def resourceType = resourceTypeMgr.getResourceTypeByNameAndPlugin(resourceTypeName, pluginName)
+
+ assertNotNull(
+ "Cannot create resources. Unable to find resource type for [name: $resourceTypeName, plugin: $pluginName]",
+ resourceType
+ )
+
+ def resources = []
+ count.times {
+ resources << new ResourceBuilder()
+ .createServer()
+ .withResourceType(resourceType)
+ .withName("${resourceType.name}-$it")
+ .withUuid("$resourceType.name:")
+ .withRandomResourceKey("${resourceType.name}-$it")
+ .build()
+ }
+
+ transaction {
+ resources.each { resource -> entityManager.persist(resource) }
+ }
+ }
+
@Test(dependsOnMethods = ['upgradePluginWithTypesRemoved'], groups = ['RemoveTypes'])
void deleteOperationDefsForRemovedType() {
def operationMgr = LookupUtil.operationManager
@@ -393,6 +423,45 @@ class ResourceMetadataManagerBeanTest extends AbstractEJB3Test {
assertEquals "The subcategories should have been deleted", 0, subcategories.size()
}
+ @Test(dependsOnMethods = ['upgradePluginWithTypesRemoved'], groups = ['RemoveTypes'])
+ void deleteResources() {
+ def resourceMgr = LookupUtil.resourceManager
+ def subjectMgr = LookupUtil.subjectManager
+
+ def criteria = new ResourceCriteria()
+ criteria.addFilterResourceTypeName 'ServerC'
+ criteria.addFilterPluginName 'RemoveTypesPlugin'
+
+ def resources = resourceMgr.findResourcesByCriteria(subjectMgr.overlord, criteria)
+
+ assertTrue(
+ "Did not expect to find any more that three resources. Database might need to be reset",
+ resources.size() < 4
+ )
+
+ // We won't do anything more rigorous that making sure the resources were marked uninventoried.
+ // Resource deletion is an expensive, time-consuming process; consequently, it is carried out
+ // asynchronously in a scheduled job. The call to initiate the resource deletion returns very
+ // quickly as it is basically just updates the the inventory status to UNINVENTORIED for the
+ // resources to be deleted.
+ resources.each {
+ assertEquals(
+ "The resource should have been marked for deletion",
+ InventoryStatus.UNINVENTORIED == it.inventoryStatus
+ )
+ }
+ }
+
+ def transaction(work) {
+ try {
+ transactionManager.begin()
+ work()
+ transactionManager.commit()
+ } catch (Throwable t) {
+ transactionManager.rollback()
+ }
+ }
+
/**
* This method creates the plugin-related artifacts that are need to call
* ResourceMetadataManager.registerPlugin. It creates the PluginDescriptor object, and
13 years, 6 months
[rhq] modules/enterprise
by ips
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/CoreGUI.java | 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/DemoCanvas.java | 120 ----------
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/DashboardView.java | 4
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/menu/MenuBarView.java | 10
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/TestTopView.java | 28 ++
5 files changed, 38 insertions(+), 126 deletions(-)
New commits:
commit 30ed07c50505da3915d8fdcf17d4a498ca297038
Author: Ian Springer <ian.springer(a)redhat.com>
Date: Thu Oct 28 14:26:36 2010 -0400
merge DemoCanvas (#Demo) into new TestTopView (#Test); use constants for view IDs in MenuBarView
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/CoreGUI.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/CoreGUI.java
index a8bdeba..17b37cb 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/CoreGUI.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/CoreGUI.java
@@ -195,8 +195,6 @@ public class CoreGUI implements EntryPoint, ValueChangeHandler<String> {
if (breadcrumbName.equals(AdministrationView.VIEW_ID)) {
canvas = new AdministrationView();
- } else if (breadcrumbName.equals(DemoCanvas.VIEW_ID)) {
- canvas = new DemoCanvas();
} else if (breadcrumbName.equals(InventoryView.VIEW_ID)) {
canvas = new InventoryView();
} else if (breadcrumbName.equals(ResourceTopView.VIEW_ID)) {
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/DemoCanvas.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/DemoCanvas.java
deleted file mode 100644
index d252fb8..0000000
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/DemoCanvas.java
+++ /dev/null
@@ -1,120 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-2010 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., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-package org.rhq.enterprise.gui.coregui.client;
-
-import com.smartgwt.client.types.Side;
-import com.smartgwt.client.types.TabBarControls;
-import com.smartgwt.client.widgets.Canvas;
-import com.smartgwt.client.widgets.menu.Menu;
-import com.smartgwt.client.widgets.menu.MenuButton;
-import com.smartgwt.client.widgets.menu.MenuItem;
-import com.smartgwt.client.widgets.menu.events.ItemClickEvent;
-import com.smartgwt.client.widgets.menu.events.ItemClickHandler;
-import com.smartgwt.client.widgets.tab.Tab;
-import com.smartgwt.client.widgets.tab.TabSet;
-
-import org.rhq.enterprise.gui.coregui.client.components.configuration.ConfigurationEditor;
-import org.rhq.enterprise.gui.coregui.client.inventory.resource.selection.ResourceSelector;
-import org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTypeTreeView;
-import org.rhq.enterprise.gui.coregui.client.report.tag.TagCloudView;
-
-/**
- * @author Greg Hinkle
- */
-public class DemoCanvas extends Canvas {
- public static final String VIEW_ID = "Demo";
-
- @Override
- protected void onInit() {
-
- setWidth100();
- setHeight100();
-
- final TabSet topTabSet = new TabSet();
- topTabSet.setTabBarPosition(Side.TOP);
- topTabSet.setWidth100();//(1200);
- topTabSet.setHeight100(); //(900);
-
- // topTabSet.setTop(50);
-
- Tab tagTab = new Tab("Tag Cloud");
- Tab selectorTab = new Tab("Selector");
- Tab typeTree = new Tab("Type Tree");
- Tab treeTab = new Tab("Resource Tree");
- final Tab configTab = new Tab("Configuration Editor");
- //Tab alertHistoryTab = new Tab("Alert History");
-
- tagTab.setPane(new TagCloudView("TagTabTagCloud"));
-
- selectorTab.setPane(new ResourceSelector("Demo Resource Selector"));
-
- // Agent: resource (10005) type (10060)
- // Raw: 10003 / 10023
- // both: 10002 / 10022
-
- //configTab.setPane(new ConfigurationEditor(10005, 10060, ConfigurationEditor.ConfigType.plugin));
- //treeTab.setPane(new ResourceTreeView(new Resource(10001)));
- typeTree.setPane(new ResourceTypeTreeView("DemoTypeTree"));
- //alertHistoryTab.setPane(new AbstractAlertsView());
-
- topTabSet.addTab(tagTab);
- topTabSet.addTab(selectorTab);
- topTabSet.addTab(typeTree);
- topTabSet.addTab(configTab);
- topTabSet.addTab(treeTab);
- //topTabSet.addTab(alertHistoryTab);
- //topTabSet.selectSubTabByTitle(alertHistoryTab);
-
- final Menu configSelectMenu = new Menu();
- configSelectMenu.addItem(new MenuItem("Agent"));
- configSelectMenu.addItem(new MenuItem("Raw Only"));
- configSelectMenu.addItem(new MenuItem("Structured and Raw"));
- configSelectMenu.addItem(new MenuItem("List Of Maps"));
- configSelectMenu.addItemClickHandler(new ItemClickHandler() {
- public void onItemClick(ItemClickEvent itemClickEvent) {
- int x = configSelectMenu.getItemNum(itemClickEvent.getItem());
- com.allen_sauer.gwt.log.client.Log.info("Loading: " + x);
- topTabSet.removeTab(configTab);
- switch (x) {
- case 0:
- configTab.setPane(new ConfigurationEditor("Case0", 10005, 10060));
- break;
- case 1:
- configTab.setPane(new ConfigurationEditor("Case1", 10003, 10023));
- break;
- case 2:
- configTab.setPane(new ConfigurationEditor("Case2", 10002, 10022));
- break;
- case 3:
- configTab.setPane(new ConfigurationEditor("Case3", 10149, 10134));
- break;
- }
- topTabSet.addTab(configTab, 0);
- topTabSet.selectTab(0);
- topTabSet.redraw();
-
- }
- });
-
- topTabSet.setTabBarControls(TabBarControls.TAB_SCROLLER, TabBarControls.TAB_PICKER, new MenuButton(
- "Config Resource", configSelectMenu));
-
- addChild(topTabSet);
- }
-}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/DashboardView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/DashboardView.java
index ca5a929..ddf9c4c 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/DashboardView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/DashboardView.java
@@ -19,6 +19,7 @@
package org.rhq.enterprise.gui.coregui.client.dashboard;
import java.util.HashSet;
+import java.util.Set;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.types.Overflow;
@@ -53,7 +54,6 @@ import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
* @author Greg Hinkle
*/
public class DashboardView extends LocatableVLayout {
-
private DashboardsView dashboardsView;
private Dashboard storedDashboard;
@@ -63,7 +63,7 @@ public class DashboardView extends LocatableVLayout {
DynamicForm editForm;
IMenuButton addPortlet;
- HashSet<PortletWindow> portlets = new HashSet<PortletWindow>();
+ Set<PortletWindow> portlets = new HashSet<PortletWindow>();
public DashboardView(String locatorId, DashboardsView dashboardsView, Dashboard storedDashboard) {
super(locatorId);
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/menu/MenuBarView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/menu/MenuBarView.java
index 2aa22ce..453d231 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/menu/MenuBarView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/menu/MenuBarView.java
@@ -31,7 +31,12 @@ import com.smartgwt.client.widgets.events.ClickHandler;
import com.smartgwt.client.widgets.layout.HLayout;
import com.smartgwt.client.widgets.toolbar.ToolStrip;
+import org.rhq.enterprise.gui.coregui.client.admin.AdministrationView;
+import org.rhq.enterprise.gui.coregui.client.bundle.BundleTopView;
import org.rhq.enterprise.gui.coregui.client.components.AboutModalWindow;
+import org.rhq.enterprise.gui.coregui.client.dashboard.DashboardsView;
+import org.rhq.enterprise.gui.coregui.client.inventory.InventoryView;
+import org.rhq.enterprise.gui.coregui.client.report.ReportTopView;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableImg;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
import org.rhq.enterprise.gui.coregui.client.util.selenium.SeleniumUtility;
@@ -42,9 +47,10 @@ import org.rhq.enterprise.gui.coregui.client.util.selenium.SeleniumUtility;
*/
public class MenuBarView extends LocatableVLayout {
- public static final String[] SECTIONS = { "Dashboard", "Inventory", "Reports", "Bundles", "Administration" };
+ public static final String[] SECTIONS = {DashboardsView.VIEW_ID, InventoryView.VIEW_ID, ReportTopView.VIEW_ID,
+ BundleTopView.VIEW_ID, AdministrationView.VIEW_ID};
- private String currentlySelectedSection = "Dashboard";
+ private String currentlySelectedSection = DashboardsView.VIEW_ID;
public MenuBarView(String locatorId) {
super(locatorId);
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/TestTopView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/TestTopView.java
index fa345bf..3714034 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/TestTopView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/TestTopView.java
@@ -28,6 +28,8 @@ import org.rhq.enterprise.gui.coregui.client.components.view.AbstractSectionedLe
import org.rhq.enterprise.gui.coregui.client.components.view.NavigationItem;
import org.rhq.enterprise.gui.coregui.client.components.view.NavigationSection;
import org.rhq.enterprise.gui.coregui.client.components.view.ViewFactory;
+import org.rhq.enterprise.gui.coregui.client.inventory.resource.selection.ResourceSelector;
+import org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTypeTreeView;
import org.rhq.enterprise.gui.coregui.client.test.configuration.TestConfigurationView;
import org.rhq.enterprise.gui.coregui.client.test.configuration.TestGroupConfigurationView;
@@ -40,6 +42,12 @@ import org.rhq.enterprise.gui.coregui.client.test.configuration.TestGroupConfigu
public class TestTopView extends AbstractSectionedLeftNavigationView {
public static final String VIEW_ID = "Test";
+ // view IDs for Inventory section
+ private static final String INVENTORY_SECTION_VIEW_ID = "Inventory";
+
+ private static final String PAGE_RESOURCE_SELECTOR = "ResourceSelector";
+ private static final String PAGE_TYPE_TREE = "TypeTree";
+
// view IDs for Configuration section
private static final String CONFIGURATION_SECTION_VIEW_ID = "Configuration";
@@ -63,12 +71,32 @@ public class TestTopView extends AbstractSectionedLeftNavigationView {
protected List<NavigationSection> getNavigationSections() {
List<NavigationSection> sections = new ArrayList<NavigationSection>();
+ NavigationSection inventorySection = buildInventorySection();
+ sections.add(inventorySection);
+
NavigationSection configurationSection = buildConfigurationSection();
sections.add(configurationSection);
return sections;
}
+ private NavigationSection buildInventorySection() {
+ NavigationItem resourceSelectorItem = new NavigationItem(PAGE_RESOURCE_SELECTOR, null,
+ new ViewFactory() {
+ public Canvas createView() {
+ return new ResourceSelector(extendLocatorId(PAGE_RESOURCE_SELECTOR));
+ }
+ });
+
+ NavigationItem typeTreeItem = new NavigationItem(PAGE_TYPE_TREE, null,
+ new ViewFactory() {
+ public Canvas createView() {
+ return new ResourceTypeTreeView(extendLocatorId(PAGE_TYPE_TREE));
+ }
+ });
+
+ return new NavigationSection(INVENTORY_SECTION_VIEW_ID, resourceSelectorItem, typeTreeItem);
+ }
private NavigationSection buildConfigurationSection() {
NavigationItem configEditorItem = new NavigationItem(PAGE_CONFIG_EDITOR, null,
13 years, 6 months
[rhq] Branch 'release-3.0.0' - 2 commits - .classpath modules/plugins
by Jay Shaughnessy
.classpath | 2
modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/AbstractManagedDeploymentComponent.java | 10
modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/ApplicationServerComponent.java | 109 ++++++----
modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/Ejb2BeanComponent.java | 14 -
modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/ManagedComponentComponent.java | 80 ++++++-
modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/TxConnectionFactoryComponent.java | 42 +--
modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/util/ManagedComponentUtils.java | 99 ++-------
7 files changed, 207 insertions(+), 149 deletions(-)
New commits:
commit f37daa3cc6c920c5b335f0eea7beeb2d0ff64fe2
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Thu Oct 28 14:07:21 2010 -0400
Fix dependency
diff --git a/.classpath b/.classpath
index a3d9d09..36e5832 100644
--- a/.classpath
+++ b/.classpath
@@ -242,7 +242,6 @@
<classpathentry exported="true" kind="var" path="M2_REPO/org/hamcrest/hamcrest-core/1.1/hamcrest-core-1.1.jar"/>
<classpathentry exported="true" kind="var" path="M2_REPO/org/hamcrest/hamcrest-library/1.1/hamcrest-library-1.1.jar"/>
<classpathentry exported="true" kind="var" path="M2_REPO/org/antlr/antlr-runtime/3.2/antlr-runtime-3.2.jar"/>
- <classpathentry exported="true" kind="lib" path="modules/enterprise/remoting/webservices/target/rhq-remoting-webservices-3.0.0-SNAPSHOT/wsconsume-output"/>
<classpathentry exported="true" kind="var" path="M2_REPO/jboss/web/jbossweb/2.0.1.GA/jbossweb-2.0.1.GA.jar"/>
<classpathentry exported="true" kind="var" path="M2_REPO/org/libvirt/libvirt/0.4.1/libvirt-0.4.1.jar"/>
<classpathentry exported="true" kind="var" path="M2_REPO/org/jboss/byteman/byteman/1.2.1/byteman-1.2.1.jar"/>
@@ -252,5 +251,6 @@
<classpathentry exported="true" kind="var" path="M2_REPO/com/smartgwt/smartgwt/2.2/smartgwt-2.2.jar"/>
<classpathentry exported="true" kind="var" path="M2_REPO/ca/nanometrics/gflot/1.0.0/gflot-1.0.0.jar"/>
<classpathentry exported="true" kind="var" path="M2_REPO/com/jcraft/jsch/0.1.29/jsch-0.1.29.jar"/>
+ <classpathentry exported="true" kind="lib" path="C:/workspace/rhq/modules/enterprise/remoting/webservices/target/rhq-remoting-webservices-3.0.1-SNAPSHOT"/>
<classpathentry kind="output" path="eclipse-classes"/>
</classpath>
commit dd93629fc547401147fa6fbfe98da60cf00a92cd
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Thu Oct 28 14:07:04 2010 -0400
Perf Work on the AS-5 Plugin to try and reduce avail and metric gathering
times. In general trying to reduce interaction with Profile Service.
1) Cache ManagedComponent in ManagedComponentComponent
This is the base class for resources managed by a profile service
ManagedComponent. It seems that for "runtime" properties gettingthe prop
value returns the live value, so we dont have to get the re-fetch the
ManagedComponent object from the ManagementView. This greatly helps avail checking
Since RunState is a runtime value. It also helps metric collection if all
of the requested metrics are runtime values.
2) Cache whether metrics are runtime or not runtime
Instead of figuring out every time whether requested metrics are runtime
properties, cache this info to save time. This is a static cache so all
instances of the type can share the info.
3) Remove use of ManagedComponentUtils.getManagedComponent()
The PS API added ManagementView.getComponent(name, type), which is more
efficient.
4) Avoid load() when checking avail for ManagedDeployment components (EAR/WAR)
Although it is necessary to re-fetch the ManagedDeployment to get an
updated deployment state, a load of the management view is not necessary.
diff --git a/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/AbstractManagedDeploymentComponent.java b/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/AbstractManagedDeploymentComponent.java
index e7a1194..a01aa2d 100644
--- a/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/AbstractManagedDeploymentComponent.java
+++ b/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/AbstractManagedDeploymentComponent.java
@@ -106,7 +106,7 @@ public abstract class AbstractManagedDeploymentComponent extends AbstractManaged
public AvailabilityType getAvailability() {
DeploymentState deploymentState = null;
try {
- deploymentState = getManagedDeployment().getDeploymentState();
+ deploymentState = getManagedDeployment(false).getDeploymentState();
} catch (NoSuchDeploymentException e) {
log.warn(this.deploymentType + " deployment '" + this.deploymentName + "' not found. Cause: "
+ e.getLocalizedMessage());
@@ -184,8 +184,14 @@ public abstract class AbstractManagedDeploymentComponent extends AbstractManaged
}
protected ManagedDeployment getManagedDeployment() throws NoSuchDeploymentException {
+ return getManagedDeployment(true);
+ }
+
+ protected ManagedDeployment getManagedDeployment(boolean forceLoad) throws NoSuchDeploymentException {
ManagementView managementView = getConnection().getManagementView();
- managementView.load();
+ if (forceLoad) {
+ managementView.load();
+ }
return managementView.getDeployment(this.deploymentName);
}
diff --git a/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/ApplicationServerComponent.java b/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/ApplicationServerComponent.java
index 6949ff7..63a7571 100644
--- a/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/ApplicationServerComponent.java
+++ b/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/ApplicationServerComponent.java
@@ -35,11 +35,17 @@ import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
+import com.jboss.jbossnetwork.product.jbpm.handlers.ControlActionFacade;
+
+import org.apache.commons.lang.exception.ExceptionUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.apache.commons.lang.exception.ExceptionUtils;
-
import org.hibernate.PropertyNotFoundException;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+import org.mc4j.ems.connection.EmsConnection;
+import org.mc4j.ems.connection.support.metadata.InternalVMTypeDescriptor;
+
import org.jboss.deployers.spi.management.ManagementView;
import org.jboss.deployers.spi.management.deploy.ProgressEvent;
import org.jboss.deployers.spi.management.deploy.ProgressListener;
@@ -49,17 +55,12 @@ import org.jboss.metatype.api.values.SimpleValue;
import org.jboss.on.common.jbossas.JBPMWorkflowManager;
import org.jboss.on.common.jbossas.JBossASPaths;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
-import org.mc4j.ems.connection.EmsConnection;
-import org.mc4j.ems.connection.support.metadata.InternalVMTypeDescriptor;
-
-import org.rhq.core.domain.content.transfer.DeployPackagesResponse;
-import org.rhq.core.domain.content.transfer.RemovePackagesResponse;
import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.configuration.PropertySimple;
import org.rhq.core.domain.content.PackageType;
import org.rhq.core.domain.content.transfer.DeployPackageStep;
+import org.rhq.core.domain.content.transfer.DeployPackagesResponse;
+import org.rhq.core.domain.content.transfer.RemovePackagesResponse;
import org.rhq.core.domain.content.transfer.ResourcePackageDetails;
import org.rhq.core.domain.measurement.AvailabilityType;
import org.rhq.core.domain.measurement.DataType;
@@ -88,13 +89,11 @@ import org.rhq.plugins.jbossas5.connection.ProfileServiceConnection;
import org.rhq.plugins.jbossas5.connection.ProfileServiceConnectionProvider;
import org.rhq.plugins.jbossas5.connection.RemoteProfileServiceConnectionProvider;
import org.rhq.plugins.jbossas5.helper.CreateChildResourceFacetDelegate;
+import org.rhq.plugins.jbossas5.helper.InPluginControlActionFacade;
import org.rhq.plugins.jbossas5.helper.JBossAS5ConnectionTypeDescriptor;
import org.rhq.plugins.jbossas5.helper.JmxConnectionHelper;
-import org.rhq.plugins.jbossas5.helper.InPluginControlActionFacade;
import org.rhq.plugins.jbossas5.util.ManagedComponentUtils;
-import com.jboss.jbossnetwork.product.jbpm.handlers.ControlActionFacade;
-
/**
* ResourceComponent for a JBoss AS, 5.1.0.CR1 or later, Server.
*
@@ -145,25 +144,26 @@ public class ApplicationServerComponent implements ResourceComponent, ProfileSer
try {
ManagementView managementView = this.connection.getManagementView();
managementView.load();
-
+
//let's see if the connection corresponds to the server
//this component represents. This is to prevent 2 servers
//with the same JNP URL to be reported as UP when just one
//of them can be up at a time.
- ManagedComponent serverConfig = managementView.getComponentsForType(new ComponentType("MCBean", "ServerConfig")).iterator().next();
-
- String reportedServerHomeDirPath = (String)((SimpleValue)serverConfig.getProperty("serverHomeDir").getValue()).getValue();
-
- String configuredServerHomeDirPath = resourceContext.getPluginConfiguration()
- .getSimpleValue(ApplicationServerPluginConfigurationProperties.SERVER_HOME_DIR, null);
-
+ ManagedComponent serverConfig = managementView.getComponentsForType(
+ new ComponentType("MCBean", "ServerConfig")).iterator().next();
+
+ String reportedServerHomeDirPath = (String) ((SimpleValue) serverConfig.getProperty("serverHomeDir")
+ .getValue()).getValue();
+
+ String configuredServerHomeDirPath = resourceContext.getPluginConfiguration().getSimpleValue(
+ ApplicationServerPluginConfigurationProperties.SERVER_HOME_DIR, null);
+
//the paths might be symlinked
File reportedServerHomeDir = new File(reportedServerHomeDirPath);
File configuredServerHomeDir = new File(configuredServerHomeDirPath);
-
- availability = reportedServerHomeDir.getCanonicalPath().equals(configuredServerHomeDir.getCanonicalPath())
- ? AvailabilityType.UP
- : AvailabilityType.DOWN;
+
+ availability = reportedServerHomeDir.getCanonicalPath().equals(
+ configuredServerHomeDir.getCanonicalPath()) ? AvailabilityType.UP : AvailabilityType.DOWN;
} catch (Exception e) {
availability = AvailabilityType.DOWN;
}
@@ -194,7 +194,8 @@ public class ApplicationServerComponent implements ResourceComponent, ProfileSer
// prepare to perform async avail checking
Configuration pc = resourceContext.getPluginConfiguration();
- String availCheckPeriodProp = pc.getSimpleValue(ApplicationServerPluginConfigurationProperties.AVAIL_CHECK_PERIOD_CONFIG_PROP, null);
+ String availCheckPeriodProp = pc.getSimpleValue(
+ ApplicationServerPluginConfigurationProperties.AVAIL_CHECK_PERIOD_CONFIG_PROP, null);
if (availCheckPeriodProp != null) {
try {
long availCheckMillis = Integer.parseInt(availCheckPeriodProp) * 1000L;
@@ -267,7 +268,7 @@ public class ApplicationServerComponent implements ResourceComponent, ProfileSer
propertyNames.add(ALTERNATE_METRIC_NAMES.get(requestName));
}
throw new IllegalStateException("A property was not found with any of the following names: "
- + propertyNames);
+ + propertyNames);
}
if (value == null) {
@@ -354,10 +355,13 @@ public class ApplicationServerComponent implements ResourceComponent, ProfileSer
connectionProvider = new LocalProfileServiceConnectionProvider();
} else {
Configuration pluginConfig = this.resourceContext.getPluginConfiguration();
- String namingURL = pluginConfig.getSimpleValue(ApplicationServerPluginConfigurationProperties.NAMING_URL, null);
+ String namingURL = pluginConfig.getSimpleValue(ApplicationServerPluginConfigurationProperties.NAMING_URL,
+ null);
validateNamingURL(namingURL);
- String principal = pluginConfig.getSimpleValue(ApplicationServerPluginConfigurationProperties.PRINCIPAL, null);
- String credentials = pluginConfig.getSimpleValue(ApplicationServerPluginConfigurationProperties.CREDENTIALS, null);
+ String principal = pluginConfig.getSimpleValue(ApplicationServerPluginConfigurationProperties.PRINCIPAL,
+ null);
+ String credentials = pluginConfig.getSimpleValue(
+ ApplicationServerPluginConfigurationProperties.CREDENTIALS, null);
connectionProvider = new RemoteProfileServiceConnectionProvider(namingURL, principal, credentials);
}
if (Thread.interrupted()) {
@@ -377,7 +381,7 @@ public class ApplicationServerComponent implements ResourceComponent, ProfileSer
log.warn("Failed to connect to Profile Service - cause: " + rootCause);
}
throw new InvalidPluginConfigurationException(
- "Values of 'principal' and/or 'credentials' connection properties are invalid.", rootCause);
+ "Values of 'principal' and/or 'credentials' connection properties are invalid.", rootCause);
}
log.debug("Failed to connect to Profile Service.", e);
}
@@ -399,15 +403,18 @@ public class ApplicationServerComponent implements ResourceComponent, ProfileSer
private JBossASPaths getJBossASPaths() {
Configuration pluginConfiguration = this.resourceContext.getPluginConfiguration();
- String homeDir = pluginConfiguration.getSimpleValue(ApplicationServerPluginConfigurationProperties.HOME_DIR, null);
- String serverHomeDir = pluginConfiguration.getSimpleValue(ApplicationServerPluginConfigurationProperties.SERVER_HOME_DIR, null);
+ String homeDir = pluginConfiguration.getSimpleValue(ApplicationServerPluginConfigurationProperties.HOME_DIR,
+ null);
+ String serverHomeDir = pluginConfiguration.getSimpleValue(
+ ApplicationServerPluginConfigurationProperties.SERVER_HOME_DIR, null);
return new JBossASPaths(homeDir, serverHomeDir);
}
private boolean runningEmbedded() {
Configuration pluginConfiguration = this.resourceContext.getPluginConfiguration();
- String namingUrl = pluginConfiguration.getSimpleValue(ApplicationServerPluginConfigurationProperties.NAMING_URL, null);
+ String namingUrl = pluginConfiguration.getSimpleValue(
+ ApplicationServerPluginConfigurationProperties.NAMING_URL, null);
return namingUrl == null;
}
@@ -416,7 +423,8 @@ public class ApplicationServerComponent implements ResourceComponent, ProfileSer
File configDir = new File(path);
if (!configDir.isAbsolute()) {
Configuration pluginConfig = this.resourceContext.getPluginConfiguration();
- String homeDir = pluginConfig.getSimple(ApplicationServerPluginConfigurationProperties.HOME_DIR).getStringValue();
+ String homeDir = pluginConfig.getSimple(ApplicationServerPluginConfigurationProperties.HOME_DIR)
+ .getStringValue();
configDir = new File(homeDir, path);
}
return configDir;
@@ -459,7 +467,7 @@ public class ApplicationServerComponent implements ResourceComponent, ProfileSer
public OperationResult invokeOperation(String name, Configuration parameters) throws InterruptedException,
Exception {
-
+
ApplicationServerSupportedOperations operation = Enum.valueOf(ApplicationServerSupportedOperations.class, name
.toUpperCase());
return this.operationDelegate.invoke(operation, parameters);
@@ -470,16 +478,20 @@ public class ApplicationServerComponent implements ResourceComponent, ProfileSer
Configuration jmxConfig = new Configuration();
- String jbossHomeDir = pluginConfiguration.getSimpleValue(ApplicationServerPluginConfigurationProperties.HOME_DIR, null);
+ String jbossHomeDir = pluginConfiguration.getSimpleValue(
+ ApplicationServerPluginConfigurationProperties.HOME_DIR, null);
String connectorDescriptorType;
boolean runningEmbedded = runningEmbedded();
if (runningEmbedded) {
connectorDescriptorType = InternalVMTypeDescriptor.class.getName();
} else {
- String connectorAddress = pluginConfiguration.getSimpleValue(ApplicationServerPluginConfigurationProperties.NAMING_URL, null);
- String connectorPrincipal = pluginConfiguration.getSimpleValue(ApplicationServerPluginConfigurationProperties.PRINCIPAL, null);
- String connectorCredentials = pluginConfiguration.getSimpleValue(ApplicationServerPluginConfigurationProperties.CREDENTIALS, null);
+ String connectorAddress = pluginConfiguration.getSimpleValue(
+ ApplicationServerPluginConfigurationProperties.NAMING_URL, null);
+ String connectorPrincipal = pluginConfiguration.getSimpleValue(
+ ApplicationServerPluginConfigurationProperties.PRINCIPAL, null);
+ String connectorCredentials = pluginConfiguration.getSimpleValue(
+ ApplicationServerPluginConfigurationProperties.CREDENTIALS, null);
connectorDescriptorType = JBossAS5ConnectionTypeDescriptor.class.getName();
@@ -516,7 +528,7 @@ public class ApplicationServerComponent implements ResourceComponent, ProfileSer
private File getConfigurationPath() {
Configuration pluginConfig = this.resourceContext.getPluginConfiguration();
String serverHomeDir = getRequiredPropertyValue(pluginConfig,
- ApplicationServerPluginConfigurationProperties.SERVER_HOME_DIR);
+ ApplicationServerPluginConfigurationProperties.SERVER_HOME_DIR);
File configPath = resolvePathRelativeToHomeDir(serverHomeDir);
if (!configPath.isDirectory()) {
throw new InvalidPluginConfigurationException("Configuration path '" + configPath + "' does not exist.");
@@ -525,13 +537,13 @@ public class ApplicationServerComponent implements ResourceComponent, ProfileSer
}
private Serializable getMetric(ManagementView managementView, String metricName)
- throws ManagedComponentUtils.PropertyNotFoundException, ComponentNotFoundException {
+ throws ManagedComponentUtils.PropertyNotFoundException, ComponentNotFoundException {
// All metric names are expected to have the following syntax:
// "<componentType>|<componentSubType>|<componentName>|<propertyName>"
Matcher matcher = METRIC_NAME_PATTERN.matcher(metricName);
if (!matcher.matches()) {
throw new IllegalStateException("Metric name '" + metricName + "' does not match pattern '"
- + METRIC_NAME_PATTERN + "'.");
+ + METRIC_NAME_PATTERN + "'.");
}
String componentCategory = matcher.group(1);
String componentSubType = matcher.group(2);
@@ -542,7 +554,13 @@ public class ApplicationServerComponent implements ResourceComponent, ProfileSer
if (componentName.equals("*")) {
component = ManagedComponentUtils.getSingletonManagedComponent(managementView, componentType);
} else {
- component = ManagedComponentUtils.getManagedComponent(managementView, componentType, componentName);
+ //component = ManagedComponentUtils.getManagedComponent(managementView, componentType, componentName);
+ try {
+ component = managementView.getComponent(componentName, componentType);
+ } catch (Exception e) {
+ throw new IllegalStateException("Error fetching component " + componentName + "of type "
+ + componentType);
+ }
}
if (component == null) {
throw new ComponentNotFoundException("No managed components of type " + componentType + " were found.");
@@ -551,6 +569,11 @@ public class ApplicationServerComponent implements ResourceComponent, ProfileSer
}
private class ComponentNotFoundException extends Exception {
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+
private ComponentNotFoundException(String message) {
super(message);
}
diff --git a/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/Ejb2BeanComponent.java b/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/Ejb2BeanComponent.java
index 1eb2219..15ffea3 100644
--- a/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/Ejb2BeanComponent.java
+++ b/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/Ejb2BeanComponent.java
@@ -24,8 +24,9 @@ package org.rhq.plugins.jbossas5;
import java.util.Set;
-import org.jboss.managed.api.ManagedComponent;
+import org.jboss.deployers.spi.management.ManagementView;
import org.jboss.managed.api.ComponentType;
+import org.jboss.managed.api.ManagedComponent;
import org.rhq.plugins.jbossas5.util.Ejb2BeanUtils;
@@ -38,26 +39,27 @@ public class Ejb2BeanComponent extends AbstractEjbBeanComponent {
private static final ComponentType MDB_COMPONENT_TYPE = new ComponentType("EJB", "MDB");
@Override
- protected ManagedComponent getManagedComponent() {
+ protected ManagedComponent getManagedComponent(boolean forceRefresh) {
if (MDB_COMPONENT_TYPE.equals(getComponentType())) {
try {
//we need to reload the management view here, because the MDBs might have changed since
//the last call, because the @object-id is part of their names.
- getConnection().getManagementView().load();
+ ManagementView mv = getConnection().getManagementView();
+ mv.load();
- Set<ManagedComponent> mdbs = getConnection().getManagementView().getComponentsForType(
- MDB_COMPONENT_TYPE);
+ Set<ManagedComponent> mdbs = mv.getComponentsForType(MDB_COMPONENT_TYPE);
for (ManagedComponent mdb : mdbs) {
if (getComponentName().equals(Ejb2BeanUtils.getUniqueBeanIdentificator(mdb))) {
return mdb;
}
}
+
} catch (Exception e) {
throw new IllegalStateException(e);
}
} else {
- return super.getManagedComponent();
+ return super.getManagedComponent(forceRefresh);
}
return null;
diff --git a/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/ManagedComponentComponent.java b/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/ManagedComponentComponent.java
index fb292ee..11c82db 100644
--- a/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/ManagedComponentComponent.java
+++ b/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/ManagedComponentComponent.java
@@ -24,6 +24,7 @@ package org.rhq.plugins.jbossas5;
import java.lang.reflect.Array;
import java.util.ArrayList;
+import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -43,6 +44,7 @@ import org.jboss.managed.api.ManagedDeployment;
import org.jboss.managed.api.ManagedOperation;
import org.jboss.managed.api.ManagedProperty;
import org.jboss.managed.api.RunState;
+import org.jboss.managed.api.annotation.ViewUse;
import org.jboss.metatype.api.values.ArrayValue;
import org.jboss.metatype.api.values.CollectionValue;
import org.jboss.metatype.api.values.CompositeValue;
@@ -73,7 +75,6 @@ import org.rhq.core.util.exception.ThrowableUtil;
import org.rhq.plugins.jbossas5.util.ConversionUtils;
import org.rhq.plugins.jbossas5.util.DebugUtils;
import org.rhq.plugins.jbossas5.util.DeploymentUtils;
-import org.rhq.plugins.jbossas5.util.ManagedComponentUtils;
import org.rhq.plugins.jbossas5.util.ResourceComponentUtils;
import org.rhq.plugins.jbossas5.util.ResourceTypeUtils;
@@ -96,8 +97,15 @@ public class ManagedComponentComponent extends AbstractManagedComponent implemen
protected static final char PREFIX_DELIMITER = '|';
+ // Map the managedComponentComponent class name to a map of metricName to "isRuntimeProp". So, for a given
+ // component we can quickly determine whether requested metrics need to refresh the managedComponent, or not.
+ private static final Map<String, Map<String, Boolean>> runtimeMetricMaps = new HashMap<String, Map<String, Boolean>>();
+
private final Log log = LogFactory.getLog(this.getClass());
+ // Cache the ManagedComponent since it can be re-used to request any ViewUse.RUNTIME property values
+ private ManagedComponent managedComponent = null;
+
private String componentName;
private ComponentType componentType;
@@ -130,7 +138,8 @@ public class ManagedComponentComponent extends AbstractManagedComponent implemen
}
public void stop() {
- return;
+ managedComponent = null;
+ super.stop();
}
// ConfigurationComponent Implementation --------------------------------------------
@@ -224,7 +233,36 @@ public class ManagedComponentComponent extends AbstractManagedComponent implemen
// MeasurementFacet Implementation --------------------------------------------
public void getValues(MeasurementReport report, Set<MeasurementScheduleRequest> metrics) throws Exception {
- ManagedComponent managedComponent = getManagedComponent();
+ // this bit could be synchronized but I don't think it really hurts to perhaps go through this logic more
+ // than once, it will settle down near immediately
+ Map<String, Boolean> runtimeMetricMap = runtimeMetricMaps.get(this.getClass().getName());
+ if (null == runtimeMetricMap) {
+ //log.info("\nADDING MAP FOR CLASS=" + this.getClass().getName());
+ runtimeMetricMap = new HashMap<String, Boolean>();
+ runtimeMetricMaps.put(this.getClass().getName(), runtimeMetricMap);
+ }
+
+ // determine whether we can use the cachedComponent or if we need to force a component fetch to
+ // gather the requested metrics.
+ boolean forceRefresh = false;
+ for (MeasurementScheduleRequest request : metrics) {
+ Boolean isRuntimeMetric = runtimeMetricMap.get(request.getName());
+ // if this is the first time we've seen this metric find out if it's a runtime prop
+ if (null == isRuntimeMetric) {
+ //log.info("\nADDING MAP ENTRY FOR METRIC=" + request.getName());
+ ManagedProperty managedProp = getManagedProperty(managedComponent, request);
+ runtimeMetricMap.put(request.getName(), Boolean.valueOf((null == managedProp || managedProp
+ .hasViewUse(ViewUse.RUNTIME))));
+ }
+
+ if (Boolean.FALSE.equals(runtimeMetricMap.get(request.getName()))) {
+ //log.info("\nFORCING COMPONENT REFRESH DUE TO NON-RUNTIME PROP: " + request.getName());
+ forceRefresh = true;
+ break;
+ }
+ }
+
+ ManagedComponent managedComponent = getManagedComponent(forceRefresh);
RunState runState = managedComponent.getRunState();
for (MeasurementScheduleRequest request : metrics) {
try {
@@ -287,6 +325,29 @@ public class ManagedComponentComponent extends AbstractManagedComponent implemen
return getInnerValue(metaValue);
}
+ /**
+ * The name of the measurement schedule request (i.e. the metric name) can be in one of two forms:
+ * <p/>
+ * [prefix'|']simplePropertyName (e.g. "maxTime" or "ThreadPool|currentThreadCount")
+ * [prefix'|']compositePropertyName'.'key (e.g. "consumerCount" or "messageStatistics.count")
+ *
+ * @param managedComponent a managed component
+ * @param request a measurement schedule request
+ * @return the metric value
+ */
+ @Nullable
+ protected ManagedProperty getManagedProperty(ManagedComponent managedComponent, MeasurementScheduleRequest request) {
+ String metricName = request.getName();
+ int pipeIndex = metricName.indexOf(PREFIX_DELIMITER);
+ // Remove the prefix if there is one (e.g. "ThreadPool|currentThreadCount" -> "currentThreadCount").
+ String compositePropName = (pipeIndex == -1) ? metricName : metricName.substring(pipeIndex + 1);
+ int dotIndex = compositePropName.indexOf('.');
+ String metricPropName = (dotIndex == -1) ? compositePropName : compositePropName.substring(0, dotIndex);
+ ManagedProperty metricProp = managedComponent.getProperty(metricPropName);
+
+ return metricProp;
+ }
+
// TODO: Move this to a utility class.
@Nullable
private static Object getInnerValue(MetaValue metaValue) {
@@ -352,11 +413,18 @@ public class ManagedComponentComponent extends AbstractManagedComponent implemen
}
protected ManagedComponent getManagedComponent() {
- ManagedComponent managedComponent;
+ return getManagedComponent(false);
+ }
+
+ protected ManagedComponent getManagedComponent(boolean forceRefresh) {
+
+ if (!forceRefresh && null != this.managedComponent) {
+ return this.managedComponent;
+ }
+
try {
ManagementView managementView = getConnection().getManagementView();
- managedComponent = ManagedComponentUtils.getManagedComponent(managementView, this.componentType,
- this.componentName);
+ managedComponent = managementView.getComponent(this.componentName, this.componentType);
} catch (Exception e) {
throw new RuntimeException("Failed to load [" + this.componentType + "] ManagedComponent ["
+ this.componentName + "].", e);
diff --git a/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/TxConnectionFactoryComponent.java b/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/TxConnectionFactoryComponent.java
index 07f4462..cdfa98b 100644
--- a/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/TxConnectionFactoryComponent.java
+++ b/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/TxConnectionFactoryComponent.java
@@ -27,47 +27,41 @@ import java.util.Set;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.rhq.core.domain.measurement.MeasurementDataTrait;
-import org.rhq.core.domain.measurement.MeasurementReport;
-import org.rhq.core.domain.measurement.MeasurementScheduleRequest;
+import org.jboss.managed.api.ManagedComponent;
import org.jboss.managed.api.ManagedProperty;
import org.jboss.metatype.api.values.SimpleValue;
+import org.rhq.core.domain.measurement.MeasurementDataTrait;
+import org.rhq.core.domain.measurement.MeasurementReport;
+import org.rhq.core.domain.measurement.MeasurementScheduleRequest;
+
/**
* A Resource component for JBoss AS 5 Tx Connection Factories.
*
* @author Ian Springer
*/
-public class TxConnectionFactoryComponent extends ManagedComponentComponent
-{
+public class TxConnectionFactoryComponent extends ManagedComponentComponent {
private final Log log = LogFactory.getLog(this.getClass());
@Override
- public void getValues(MeasurementReport report, Set<MeasurementScheduleRequest> metrics) throws Exception
- {
- Set<MeasurementScheduleRequest> uncollectedMetrics = new HashSet();
- for (MeasurementScheduleRequest request : metrics)
- {
- try
- {
- if (request.getName().equals("custom.transactionType"))
- {
- ManagedProperty xaTransactionProp = getManagedComponent().getProperty("xa-transaction");
- SimpleValue xaTransactionMetaValue = (SimpleValue)xaTransactionProp.getValue();
- Boolean xaTransactionValue = (xaTransactionMetaValue != null)
- ? (Boolean)xaTransactionMetaValue.getValue() : null;
+ public void getValues(MeasurementReport report, Set<MeasurementScheduleRequest> metrics) throws Exception {
+ ManagedComponent mc = getManagedComponent(true);
+ Set<MeasurementScheduleRequest> uncollectedMetrics = new HashSet<MeasurementScheduleRequest>();
+ for (MeasurementScheduleRequest request : metrics) {
+ try {
+ if (request.getName().equals("custom.transactionType")) {
+ ManagedProperty xaTransactionProp = mc.getProperty("xa-transaction");
+ SimpleValue xaTransactionMetaValue = (SimpleValue) xaTransactionProp.getValue();
+ Boolean xaTransactionValue = (xaTransactionMetaValue != null) ? (Boolean) xaTransactionMetaValue
+ .getValue() : null;
boolean isXa = (xaTransactionValue != null && xaTransactionValue);
String transactionType = (isXa) ? "XA" : "Local";
report.addData(new MeasurementDataTrait(request, transactionType));
- }
- else
- {
+ } else {
uncollectedMetrics.add(request);
}
- }
- catch (Exception e)
- {
+ } catch (Exception e) {
log.error("Failed to collect metric for " + request, e);
}
}
diff --git a/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/util/ManagedComponentUtils.java b/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/util/ManagedComponentUtils.java
index b928584..a08a043 100644
--- a/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/util/ManagedComponentUtils.java
+++ b/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/util/ManagedComponentUtils.java
@@ -23,12 +23,13 @@
package org.rhq.plugins.jbossas5.util;
import java.io.Serializable;
+import java.util.Comparator;
import java.util.EnumSet;
-import java.util.Set;
import java.util.HashSet;
-import java.util.Comparator;
+import java.util.Set;
import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
import org.jboss.deployers.spi.management.ManagementView;
import org.jboss.deployers.spi.management.NameMatcher;
@@ -39,78 +40,53 @@ import org.jboss.managed.api.annotation.ViewUse;
import org.jboss.metatype.api.types.MetaType;
import org.jboss.metatype.api.values.EnumValue;
import org.jboss.metatype.api.values.SimpleValue;
-import org.jetbrains.annotations.Nullable;
/**
* A collection of utility methods for working with Profile Service {@link ManagedComponent}s.
*
* @author Ian Springer
*/
-public class ManagedComponentUtils
-{
+public class ManagedComponentUtils {
private static final Comparator<ComponentType> COMPONENT_TYPE_COMPARATOR = new ComponentTypeComparator();
@Nullable
- public static ManagedComponent getManagedComponent(ManagementView managementView, ComponentType componentType,
- String componentName)
- {
- Set<ManagedComponent> components = getManagedComponents(managementView, componentType);
- for (ManagedComponent component : components)
- {
- if (component.getName().equals(componentName))
- return component;
- }
- return null;
- }
-
- @Nullable
public static ManagedComponent getSingletonManagedComponent(ManagementView managementView,
- ComponentType componentType)
- {
+ ComponentType componentType) {
Set<ManagedComponent> components = getManagedComponents(managementView, componentType);
- if (components.size() > 1)
- {
+ if (components.size() > 1) {
throw new IllegalStateException("Found more than one component of type " + componentType + ": "
- + components);
+ + components);
}
- @SuppressWarnings({"UnnecessaryLocalVariable"})
+ @SuppressWarnings( { "UnnecessaryLocalVariable" })
ManagedComponent component = (components.size() == 1) ? components.iterator().next() : null;
return component;
}
public static Serializable getSimplePropertyValue(ManagedComponent component, String propertyName)
- throws PropertyNotFoundException {
+ throws PropertyNotFoundException {
ManagedProperty property = component.getProperty(propertyName);
- if (property == null)
- {
- throw new PropertyNotFoundException("Property named '" + propertyName + "' not found for ManagedComponent ["
- + component + "].");
+ if (property == null) {
+ throw new PropertyNotFoundException("Property named '" + propertyName
+ + "' not found for ManagedComponent [" + component + "].");
}
MetaType metaType = property.getMetaType();
Serializable value;
- if (metaType.isSimple())
- {
- SimpleValue simpleValue = (SimpleValue)property.getValue();
+ if (metaType.isSimple()) {
+ SimpleValue simpleValue = (SimpleValue) property.getValue();
value = (simpleValue != null) ? simpleValue.getValue() : null;
- }
- else if (metaType.isEnum())
- {
- EnumValue enumValue = (EnumValue)property.getValue();
+ } else if (metaType.isEnum()) {
+ EnumValue enumValue = (EnumValue) property.getValue();
value = (enumValue != null) ? enumValue.getValue() : null;
- }
- else
- {
+ } else {
throw new IllegalStateException("Type of [" + property + "] is not simple or enum.");
}
return value;
}
@NotNull
- public static EnumSet<ViewUse> getViewUses(ManagedProperty managedProperty)
- {
+ public static EnumSet<ViewUse> getViewUses(ManagedProperty managedProperty) {
EnumSet<ViewUse> viewUses = EnumSet.noneOf(ViewUse.class);
- for (ViewUse viewUse : ViewUse.values())
- {
+ for (ViewUse viewUse : ViewUse.values()) {
if (managedProperty.hasViewUse(viewUse))
viewUses.add(viewUse);
}
@@ -120,19 +96,15 @@ public class ManagedComponentUtils
/**
* TODO
*/
- public static boolean isManagedComponent(ManagementView managementView, String name, ComponentType componentType)
- {
+ public static boolean isManagedComponent(ManagementView managementView, String name, ComponentType componentType) {
boolean isDeployed = false;
- if (name != null)
- {
- try
- {
- ManagedComponent component = getManagedComponent(managementView, componentType, name);
+ if (name != null) {
+ try {
+ //ManagedComponent component = getManagedComponent(managementView, componentType, name);
+ ManagedComponent component = managementView.getComponent(name, componentType);
if (component != null)
isDeployed = true;
- }
- catch (Exception e)
- {
+ } catch (Exception e) {
// Setting it to true to be safe than sorry, since there might be a component
// already deployed in the AS. TODO (ips): I don't think I like this.
isDeployed = true;
@@ -142,9 +114,8 @@ public class ManagedComponentUtils
}
@NotNull
- public static Set<ManagedComponent> getManagedComponents(ManagementView managementView, ComponentType componentType,
- String name, NameMatcher<ManagedComponent> nameMatcher)
- {
+ public static Set<ManagedComponent> getManagedComponents(ManagementView managementView,
+ ComponentType componentType, String name, NameMatcher<ManagedComponent> nameMatcher) {
Set<ManagedComponent> matchingComponents = new HashSet<ManagedComponent>();
Set<ManagedComponent> allComponents = getManagedComponents(managementView, componentType);
for (ManagedComponent component : allComponents) {
@@ -160,24 +131,18 @@ public class ManagedComponentUtils
}
@NotNull
- private static Set<ManagedComponent> getManagedComponents(ManagementView managementView, ComponentType componentType)
- {
+ private static Set<ManagedComponent> getManagedComponents(ManagementView managementView, ComponentType componentType) {
Set<ManagedComponent> components;
- try
- {
+ try {
components = managementView.getComponentsForType(componentType);
- }
- catch (Exception e)
- {
+ } catch (Exception e) {
throw new IllegalStateException(e);
}
return components;
}
- private static class ComponentTypeComparator implements Comparator<ComponentType>
- {
- public int compare(ComponentType type1, ComponentType type2)
- {
+ private static class ComponentTypeComparator implements Comparator<ComponentType> {
+ public int compare(ComponentType type1, ComponentType type2) {
int value = type1.getType().compareTo(type2.getType());
// If the categories (e.g. JMSDestination) were equal, do a secondary sort by subtype (e.g. Queue).
return (value != 0) ? value : type1.getSubtype().compareTo(type2.getSubtype());
13 years, 6 months
[rhq] modules/enterprise
by ips
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/summary/InventorySummaryView.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
New commits:
commit 4579fa892ccb4d8c57f55cae84714ae7a009e764
Author: Ian Springer <ian.springer(a)redhat.com>
Date: Thu Oct 28 14:00:47 2010 -0400
fix Inventory Summary portlet (counts were not displaying)
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/summary/InventorySummaryView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/summary/InventorySummaryView.java
index 90c8bc1..e012146 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/summary/InventorySummaryView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/summary/InventorySummaryView.java
@@ -122,7 +122,7 @@ public class InventorySummaryView extends LocatableVLayout implements Portlet {
}
item.setTitle(label);
- item.setValue(value);
+ item.setDefaultValue(value);
return item;
}
13 years, 6 months