.classpath | 2 etc/m2/settings.xml | 1 modules/common/drift/src/main/java/org/rhq/common/drift/ChangeSetReaderImpl.java | 9 modules/common/drift/src/main/java/org/rhq/common/drift/ChangeSetWriter.java | 1 modules/common/drift/src/main/java/org/rhq/common/drift/ChangeSetWriterImpl.java | 1 modules/common/drift/src/main/java/org/rhq/common/drift/Headers.java | 16 modules/common/drift/src/test/java/org/rhq/common/drift/ChangeSetReaderImplTest.java | 13 modules/common/drift/src/test/java/org/rhq/common/drift/ChangeSetWriterImplTest.java | 27 modules/core/dbutils/src/main/scripts/dbsetup/content-schema.xml | 3 modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml | 4 modules/core/domain/src/main/java/org/rhq/core/domain/drift/DriftConfiguration.java | 2 modules/core/domain/src/main/java/org/rhq/core/domain/drift/DriftSnapshot.java | 10 modules/core/domain/src/test/java/org/rhq/core/domain/drift/DriftSnapshotTest.java | 403 ++++++++ modules/core/domain/src/test/java/org/rhq/core/domain/drift/SnapshotTest.java | 403 -------- modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/event/log/LogFileEventResourceComponentHelper.java | 24 modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/inventory/ClassLoaderFacet.java | 2 modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/inventory/ManualAddFacet.java | 2 modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/inventory/ResourceComponent.java | 2 modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/inventory/ResourceContext.java | 14 modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/inventory/ResourceDiscoveryComponent.java | 2 modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/inventory/ResourceDiscoveryContext.java | 13 modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/upgrade/ResourceUpgradeContext.java | 27 modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/upgrade/ResourceUpgradeFacet.java | 2 modules/core/plugin-container/mvn.out | 96 + modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/DriftDetector.java | 22 modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/DriftManager.java | 31 modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/ScheduleQueueImpl.java | 28 modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/InventoryManager.java | 237 ++-- modules/core/plugin-container/src/main/java/org/rhq/core/pc/plugin/PluginComponentFactory.java | 24 modules/core/plugin-container/src/main/java/org/rhq/core/pc/upgrade/ResourceUpgradeDelegate.java | 28 modules/core/plugin-container/src/main/java/org/rhq/core/pc/util/DiscoveryComponentProxyFactory.java | 25 modules/core/plugin-container/src/test/java/org/rhq/core/pc/inventory/ResourceContainerTest.java | 4 modules/core/plugin-container/src/test/java/org/rhq/core/pc/upgrade/plugins/failing/DiscComponent.java | 14 modules/core/plugin-container/src/test/java/org/rhq/core/pc/upgrade/plugins/failing/ResComponent.java | 14 modules/core/plugin-container/src/test/java/org/rhq/core/pc/upgrade/plugins/multi/base/BaseDiscoveryComponent.java | 2 modules/core/plugin-container/src/test/java/org/rhq/core/pc/upgrade/plugins/multi/base/BaseResourceComponent.java | 54 - modules/core/plugin-container/src/test/java/org/rhq/core/pc/upgrade/plugins/multi/base/BaseUpgradingDiscoveryComponent.java | 10 modules/core/plugin-container/src/test/java/org/rhq/core/pc/upgrade/plugins/multi/base/NothingDiscoveringDiscoveryComponent.java | 3 modules/core/plugin-container/src/test/java/org/rhq/core/pc/upgrade/plugins/v1/DiscComponent.java | 4 modules/core/plugin-container/src/test/java/org/rhq/core/pc/upgrade/plugins/v1/ResComponent.java | 4 modules/core/plugin-container/src/test/java/org/rhq/core/pc/upgrade/plugins/v2/DiscComponent.java | 8 modules/core/plugin-container/src/test/java/org/rhq/core/pc/upgrade/plugins/v2/ResComponent.java | 4 modules/core/plugindoc/pom.xml | 2 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertFormatUtility.java | 141 -- modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionsAlertDefinitionForm.java | 43 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionsEditor.java | 41 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NewConditionEditor.java | 492 ++++++---- modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deployment/BundleDeploymentView.java | 1 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/version/file/FileListView.java | 1 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/form/NumberWithUnitsValidator.java | 112 ++ modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/TestNumberFormatView.java | 78 + modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/TestTopView.java | 9 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/MeasurementConverterClient.java | 1 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/measurement/GwtMeasurementConverter.java | 4 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/measurement/MeasurementParser.java | 121 ++ modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties | 2 modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_de.properties | 2 modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ja.properties | 2 modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_pt.properties | 2 modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_zh.properties | 2 modules/enterprise/server/jar/pom.xml | 11 modules/integration-tests/mod_cluster-plugin-test/pom.xml | 15 modules/plugins/augeas/src/main/java/org/rhq/plugins/augeas/AugeasConfigurationComponent.java | 24 modules/plugins/augeas/src/main/java/org/rhq/plugins/augeas/AugeasConfigurationDiscoveryComponent.java | 10 modules/plugins/database/src/main/java/org/rhq/plugins/database/AbstractDatabaseComponent.java | 3 modules/plugins/database/src/main/java/org/rhq/plugins/database/CustomTableComponent.java | 25 modules/plugins/database/src/main/java/org/rhq/plugins/database/CustomTableDiscoveryComponent.java | 6 modules/plugins/database/src/main/java/org/rhq/plugins/database/CustomTableRowDiscoveryComponent.java | 4 modules/plugins/database/src/main/java/org/rhq/plugins/database/DatabaseComponent.java | 3 modules/plugins/hibernate/src/main/java/org/rhq/plugins/hibernate/EntityComponent.java | 48 modules/plugins/hibernate/src/main/java/org/rhq/plugins/hibernate/EntityDiscoveryComponent.java | 50 - modules/plugins/hibernate/src/main/java/org/rhq/plugins/hibernate/StatisticsComponent.java | 60 - modules/plugins/hudson/src/main/java/org/rhq/plugins/hudson/HudsonServerComponent.java | 14 modules/plugins/iis/src/main/java/org/rhq/plugins/iis/IISServerComponent.java | 3 modules/plugins/iis/src/main/java/org/rhq/plugins/iis/IISVHostComponent.java | 10 modules/plugins/iis/src/main/java/org/rhq/plugins/iis/IISVHostDiscoveryComponent.java | 4 modules/plugins/irc/src/main/java/org/rhq/plugins/irc/IRCServerComponent.java | 2 modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/AbstractManagedComponent.java | 26 modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/AbstractManagedDeploymentComponent.java | 17 modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/AbstractManagedDeploymentDiscoveryComponent.java | 75 - modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/ApplicationServerComponent.java | 17 modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/JBossMessagingComponent.java | 10 modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/JBossMessagingDiscoveryComponent.java | 4 modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/JBossWebComponent.java | 22 modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/JBossWebDiscoveryComponent.java | 4 modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/JmsDestinationDiscoveryComponent.java | 2 modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/ManagedComponentComponent.java | 58 - modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/ManagedComponentDiscoveryComponent.java | 13 modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/ManagedDeploymentDiscoveryComponent.java | 4 modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/PlatformComponent.java | 397 +++----- modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/PlatformDiscoveryComponent.java | 128 +- modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/ProfileServiceComponent.java | 2 modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/WebApplicationContextComponent.java | 217 ++-- modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/helper/JBossInstanceInfo.java | 9 modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/script/ScriptComponent.java | 64 - modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/script/ScriptDiscoveryComponent.java | 23 modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/util/JBossConfigurationUtility.java | 2 modules/plugins/jboss-as-5/src/main/resources/META-INF/rhq-plugin.xml | 7 modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/AbstractBaseDiscovery.java | 2 modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseComponent.java | 2 modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/SubsystemDiscovery.java | 82 - modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml | 8 modules/plugins/jboss-as-7/src/test/resources/test-plugin.xml | 2 modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/AbstractMessagingComponent.java | 58 - modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/AbstractMessagingDiscoveryComponent.java | 4 modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/ApplicationComponent.java | 2 modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/ApplicationDiscoveryComponent.java | 16 modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/ConnectionFactoryComponent.java | 4 modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/DatasourceComponent.java | 4 modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/EJB2BeanComponent.java | 2 modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/EJB3BeanComponent.java | 2 modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/EmbeddedWarDiscoveryComponent.java | 19 modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/JBMDestinationDiscoveryComponent.java | 4 modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/JBossASServerComponent.java | 20 modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/JBossASTomcatConnectorDiscoveryComponent.java | 24 modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/JBossASTomcatDiscoveryComponent.java | 54 - modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/JBossASTomcatServerComponent.java | 8 modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/JBossASTomcatVHostDiscoveryService.java | 4 modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/JBossASTomcatVHostService.java | 46 modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/JBossMQDiscoveryComponent.java | 2 modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/JBossMessagingComponent.java | 49 modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/JBossMessagingDiscoveryComponent.java | 2 modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/JMSComponent.java | 53 - modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/WarDiscoveryComponent.java | 2 modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/helper/JBossInstanceInfo.java | 9 modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/script/ScriptComponent.java | 7 modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/script/ScriptDiscoveryComponent.java | 75 - modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/util/JBossConfigurationUtility.java | 2 modules/plugins/jboss-cache-v3/src/main/java/org/rhq/plugins/jbosscache3/JBossCacheComponent.java | 60 - modules/plugins/jboss-cache-v3/src/main/java/org/rhq/plugins/jbosscache3/JBossCacheDetailComponent.java | 8 modules/plugins/jboss-cache-v3/src/main/java/org/rhq/plugins/jbosscache3/JBossCacheDetailDiscoveryComponent.java | 4 modules/plugins/jboss-cache-v3/src/main/java/org/rhq/plugins/jbosscache3/JBossCacheDiscoveryComponent.java | 4 modules/plugins/jboss-cache/src/main/java/org/rhq/plugins/jbosscache/JBossCacheComponent.java | 8 modules/plugins/jboss-cache/src/main/java/org/rhq/plugins/jbosscache/JBossCacheDiscoveryComponent.java | 6 modules/plugins/jboss-cache/src/main/java/org/rhq/plugins/jbosscache/JBossCacheSubsystemComponent.java | 2 modules/plugins/jboss-cache/src/main/java/org/rhq/plugins/jbosscache/JBossCacheSubsystemDiscovery.java | 4 modules/plugins/jmx/src/main/java/org/rhq/plugins/jmx/EmbeddedJMXServerDiscoveryComponent.java | 16 modules/plugins/jmx/src/main/java/org/rhq/plugins/jmx/InternalJMXServerDiscoveryComponent.java | 4 modules/plugins/jmx/src/main/java/org/rhq/plugins/jmx/JMXComponent.java | 2 modules/plugins/jmx/src/main/java/org/rhq/plugins/jmx/JMXServerComponent.java | 3 modules/plugins/jmx/src/main/java/org/rhq/plugins/jmx/MBeanResourceComponent.java | 2 modules/plugins/jmx/src/main/java/org/rhq/plugins/jmx/MBeanResourceDiscoveryComponent.java | 12 modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ClassNameMBeanComponent.java | 4 modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ClassNameMBeanDiscoveryComponent.java | 3 modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/LoadMetricDiscoveryComponent.java | 7 modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/WebappContextComponent.java | 4 modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/WebappContextDiscoveryComponent.java | 7 modules/plugins/mysql/src/main/java/org/rhq/plugins/mysql/MySqlComponent.java | 3 modules/plugins/platform/src/main/java/org/rhq/plugins/platform/FileSystemDiscoveryComponent.java | 64 - modules/plugins/platform/src/main/java/org/rhq/plugins/platform/PlatformComponent.java | 7 modules/plugins/postfix/src/main/java/org/rhq/plugins/postfix/PostfixAccessDiscoveryComponent.java | 5 modules/plugins/postgres/src/main/java/org/rhq/plugins/postgres/PostgresDatabaseComponent.java | 6 modules/plugins/postgres/src/main/java/org/rhq/plugins/postgres/PostgresDatabaseDiscoveryComponent.java | 8 modules/plugins/postgres/src/main/java/org/rhq/plugins/postgres/PostgresServerComponent.java | 3 modules/plugins/postgres/src/main/java/org/rhq/plugins/postgres/PostgresUserComponent.java | 6 modules/plugins/postgres/src/main/java/org/rhq/plugins/postgres/PostgresUserDiscoveryComponent.java | 6 modules/plugins/rhq-agent/src/main/java/org/rhq/plugins/agent/AgentEnvironmentScriptComponent.java | 4 modules/plugins/rhq-agent/src/main/java/org/rhq/plugins/agent/AgentEnvironmentScriptDiscoveryComponent.java | 8 modules/plugins/rhq-agent/src/main/java/org/rhq/plugins/agent/AgentJavaServiceWrapperComponent.java | 8 modules/plugins/rhq-agent/src/main/java/org/rhq/plugins/agent/AgentJavaServiceWrapperDiscoveryComponent.java | 8 modules/plugins/rhq-agent/src/main/java/org/rhq/plugins/agent/AgentLauncherScriptComponent.java | 6 modules/plugins/rhq-agent/src/main/java/org/rhq/plugins/agent/AgentLauncherScriptDiscoveryComponent.java | 8 modules/plugins/rhq-agent/src/main/java/org/rhq/plugins/agent/AgentServerComponent.java | 5 modules/plugins/samba/src/main/java/org/rhq/plugins/samba/SambaServerComponent.java | 39 modules/plugins/snmptrapd/src/main/java/org/rhq/plugins/snmptrapd/SnmpTrapdComponent.java | 2 modules/plugins/tomcat/src/main/java/org/jboss/on/plugins/tomcat/TomcatConnectorComponent.java | 6 modules/plugins/tomcat/src/main/java/org/jboss/on/plugins/tomcat/TomcatConnectorDiscoveryComponent.java | 5 modules/plugins/tomcat/src/main/java/org/jboss/on/plugins/tomcat/TomcatServerComponent.java | 16 modules/plugins/tomcat/src/main/java/org/jboss/on/plugins/tomcat/TomcatUserDatabaseComponent.java | 4 modules/plugins/tomcat/src/main/java/org/jboss/on/plugins/tomcat/TomcatVHostComponent.java | 7 modules/plugins/tomcat/src/main/java/org/jboss/on/plugins/tomcat/TomcatVHostDiscoveryComponent.java | 11 modules/plugins/twitter/src/main/java/org/rhq/plugins/twitter/TwitterComponent.java | 2 modules/plugins/virt/src/main/java/org/rhq/plugins/virt/VirtualizationHostComponent.java | 2 pom.xml | 86 + 174 files changed, 2906 insertions(+), 2201 deletions(-)
New commits: commit e3b846ef72ff03ce0366c01752e06e3e873c3d2b Merge: bd9c503 1a66725 Author: Heiko W. Rupp hwr@redhat.com Date: Thu Sep 15 10:14:40 2011 +0200
Merge branch 'master' into heiko-rest
commit 1a667256e025ccfc134528613dae82625d0cc1a9 Author: John Mazzitelli mazz@redhat.com Date: Thu Sep 15 01:19:51 2011 -0400
[BZ 698600] do some null checks, because i am paranoid
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertFormatUtility.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertFormatUtility.java index 154336b..4e15bd9 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertFormatUtility.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertFormatUtility.java @@ -78,8 +78,10 @@ public class AlertFormatUtility { // this is a calltime threshold condition str.append(MSG.view_alert_common_tab_conditions_type_metric_calltime_threshold()); str.append(" ["); - str.append(condition.getMeasurementDefinition().getDisplayName()); - str.append(" "); + if (condition.getMeasurementDefinition() != null) { + str.append(condition.getMeasurementDefinition().getDisplayName()); + str.append(" "); + } str.append(condition.getOption()); // MIN, MAX, AVG (never null) str.append(" "); str.append(condition.getComparator()); // <, >, = @@ -124,8 +126,10 @@ public class AlertFormatUtility { // this is a calltime change condition str.append(MSG.view_alert_common_tab_conditions_type_metric_calltime_change()); str.append(" ["); - str.append(condition.getMeasurementDefinition().getDisplayName()); - str.append(" "); + if (condition.getMeasurementDefinition() != null) { + str.append(condition.getMeasurementDefinition().getDisplayName()); + str.append(" "); + } str.append(condition.getOption()); // MIN, MAX, AVG (never null) str.append(" "); str.append(getCalltimeChangeComparator(condition.getComparator())); // LO, HI, CH
commit a4122c29a8788b93f85f5a97e8f3895bb89aa028 Author: John Mazzitelli mazz@redhat.com Date: Thu Sep 15 01:19:05 2011 -0400
[BZ 698600] fix UI so users can enter units and see units in alert condition UI
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertFormatUtility.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertFormatUtility.java index 6c41e21..154336b 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertFormatUtility.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertFormatUtility.java @@ -76,16 +76,15 @@ public class AlertFormatUtility { str.append("]"); } else { // this is a calltime threshold condition - // the name of the metric is only obtainable by querying for the name from the meas def ID - // but since most times (all the time?) there is only one calltime metric per resource, - // not showing the metric name probably isn't detrimental str.append(MSG.view_alert_common_tab_conditions_type_metric_calltime_threshold()); str.append(" ["); + str.append(condition.getMeasurementDefinition().getDisplayName()); + str.append(" "); str.append(condition.getOption()); // MIN, MAX, AVG (never null) str.append(" "); str.append(condition.getComparator()); // <, >, = str.append(" "); - str.append(condition.getThreshold()); + str.append(formatted); str.append("]"); if (condition.getName() != null && condition.getName().length() > 0) { str.append(" "); @@ -123,11 +122,10 @@ public class AlertFormatUtility { str.append("]"); } else { // this is a calltime change condition - // the name of the metric is only obtainable by querying for the name from the meas def ID - // but since most times (all the time?) there is only one calltime metric per resource, - // not showing the metric name probably isn't detrimental str.append(MSG.view_alert_common_tab_conditions_type_metric_calltime_change()); str.append(" ["); + str.append(condition.getMeasurementDefinition().getDisplayName()); + str.append(" "); str.append(condition.getOption()); // MIN, MAX, AVG (never null) str.append(" "); str.append(getCalltimeChangeComparator(condition.getComparator())); // LO, HI, CH @@ -276,129 +274,4 @@ public class AlertFormatUtility { } return recoveryInfo; } - /* THIS IS THE OLD CODE - IT HAS LOTS OF TODOs AND DIDN'T FULLY WORK - - public static String formatAlertConditionForDisplay(AlertCondition condition) { - AlertConditionCategory category = condition.getCategory(); - - StringBuilder textValue = new StringBuilder(); - - // first format the LHS of the operator - if (category == AlertConditionCategory.CONTROL) { - try { - String operationName = condition.getName(); - //Integer resourceTypeId = condition.getAlertDefinition().getResource().getResourceType().getId(); - //OperationManagerLocal operationManager = LookupUtil.getOperationManager(); - //OperationDefinition definition = operationManager.getOperationDefinitionByResourceTypeAndName( - // resourceTypeId, operationName, false); - //String operationDisplayName = definition.getDisplayName(); - textValue.append(operationName).append(' '); - } catch (Exception e) { - textValue.append(condition.getName()).append(' '); - } - } else if (category == AlertConditionCategory.RESOURCE_CONFIG) { - textValue.append("Resource Configuration").append(' '); - } else { - textValue.append(condition.getName()).append(' '); - } - - // next format the RHS - if (category == AlertConditionCategory.CONTROL) { - textValue.append(condition.getOption()); - } else if ((category == AlertConditionCategory.THRESHOLD) || (category == AlertConditionCategory.BASELINE)) { - textValue.append(condition.getComparator()); - textValue.append(' '); - - MeasurementSchedule schedule = null; - - MeasurementUnits units; - double value = condition.getThreshold(); - if (category == AlertConditionCategory.THRESHOLD) { - units = condition.getMeasurementDefinition().getUnits(); - } else // ( category == AlertConditionCategory.BASELINE ) - { - units = MeasurementUnits.PERCENTAGE; - } - - String formatted = MeasurementConverterClient.format(value, units, true); - textValue.append(formatted); - - if (category == AlertConditionCategory.BASELINE) { - textValue.append(" of "); - textValue.append(getBaselineText(condition.getOption(), schedule)); - } - } else if (category == AlertConditionCategory.RESOURCE_CONFIG || category == AlertConditionCategory.CHANGE - || category == AlertConditionCategory.TRAIT) { - textValue.append("Value Changed"); - } else if (category == AlertConditionCategory.EVENT) { - String msgKey = "alert.config.props.CB.EventSeverity"; - List<String> args = new ArrayList<String>(2); - - args.add(condition.getName()); - if ((condition.getOption() != null) && (condition.getOption().length() > 0)) { - msgKey += ".RegexMatch"; - args.add(condition.getOption()); - } - // TODO - textValue.append("TODO ").append(args); - } else if (category == AlertConditionCategory.AVAILABILITY) { - // TODO - textValue.append("Availability ").append(condition.getOption()); - } else { - // do nothing - } - - return textValue.toString(); - } - - private static String getBaselineText(String baselineOption, MeasurementSchedule schedule) { - final String BASELINE_OPT_MEAN = "mean"; - final String BASELINE_OPT_MIN = "min"; - final String BASELINE_OPT_MAX = "max"; - - final String MEASUREMENT_BASELINE_MIN_TEXT = "Min Value"; - final String MEASUREMENT_BASELINE_MEAN_TEXT = "Baseline Value"; - final String MEASUREMENT_BASELINE_MAX_TEXT = "Max Value"; - - if ((null != schedule) && (null != schedule.getBaseline())) { - MeasurementBaseline baseline = schedule.getBaseline(); - - String lookupText = null; - Double value = null; - - if (baselineOption.equals(BASELINE_OPT_MIN)) { - lookupText = MEASUREMENT_BASELINE_MIN_TEXT; - value = baseline.getMin(); - } else if (baselineOption.equals(BASELINE_OPT_MEAN)) { - lookupText = MEASUREMENT_BASELINE_MEAN_TEXT; - value = baseline.getMean(); - } else if (baselineOption.equals(BASELINE_OPT_MAX)) { - lookupText = MEASUREMENT_BASELINE_MAX_TEXT; - value = baseline.getMax(); - } - - if (value != null) { - try { - String formatted = MeasurementConverterClient.scaleAndFormat(value, schedule, true); - return formatted + " (" + lookupText + ")"; - } catch (MeasurementConversionException mce) { - return lookupText; - } - } - - // will need a fall-through here because the value was null; this can happen when the user requests to view - // the formatted baseline before the first time it has been calculated - } - - // here is the fall-through - if (BASELINE_OPT_MIN.equals(baselineOption)) { - return MEASUREMENT_BASELINE_MIN_TEXT; - } else if (BASELINE_OPT_MAX.equals(baselineOption)) { - return MEASUREMENT_BASELINE_MAX_TEXT; - } else { - return MEASUREMENT_BASELINE_MEAN_TEXT; - } - } - - */ } diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NewConditionEditor.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NewConditionEditor.java index 2ee65a3..81ba472 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NewConditionEditor.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NewConditionEditor.java @@ -44,7 +44,6 @@ import com.smartgwt.client.widgets.form.fields.StaticTextItem; import com.smartgwt.client.widgets.form.fields.TextItem; import com.smartgwt.client.widgets.form.fields.events.ClickEvent; import com.smartgwt.client.widgets.form.fields.events.ClickHandler; -import com.smartgwt.client.widgets.form.validator.IsFloatValidator;
import org.rhq.core.domain.alert.AlertCondition; import org.rhq.core.domain.alert.AlertConditionCategory; @@ -53,11 +52,14 @@ import org.rhq.core.domain.event.EventSeverity; import org.rhq.core.domain.measurement.AvailabilityType; import org.rhq.core.domain.measurement.DataType; import org.rhq.core.domain.measurement.MeasurementDefinition; +import org.rhq.core.domain.measurement.MeasurementUnits; import org.rhq.core.domain.measurement.NumericType; import org.rhq.core.domain.operation.OperationDefinition; import org.rhq.core.domain.operation.OperationRequestStatus; import org.rhq.core.domain.resource.ResourceType; import org.rhq.enterprise.gui.coregui.client.CoreGUI; +import org.rhq.enterprise.gui.coregui.client.components.form.NumberWithUnitsValidator; +import org.rhq.enterprise.gui.coregui.client.util.measurement.MeasurementParser; import org.rhq.enterprise.gui.coregui.client.util.message.Message; import org.rhq.enterprise.gui.coregui.client.util.message.Message.Severity; import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm; @@ -286,169 +288,187 @@ public class NewConditionEditor extends LocatableDynamicForm {
private boolean saveNewCondition() {
- // Find out if this is using the ALL conjunction - if it is, we can't have more than one conditional use the same metric. - // If we do, immediately abort and warn the user. See BZ 737565 - if ((BooleanExpression.ALL.name().equals(this.conditionExpression.getValue().toString())) - && (supportsMetrics && this.resourceType.getMetricDefinitions() != null)) { - - Map<Integer, String> metricIdsUsed = new HashMap<Integer, String>(); - for (AlertCondition condition : this.conditions) { - if (condition.getMeasurementDefinition() != null) { - Integer id = Integer.valueOf(condition.getMeasurementDefinition().getId()); - if (metricIdsUsed.containsKey(id)) { - String msg = MSG.view_alert_definition_condition_editor_metricswarning(metricIdsUsed.get(id)); - Message warning = new Message(msg, Severity.Warning, EnumSet.of(Message.Option.Transient)); - CoreGUI.getMessageCenter().notify(warning); - return false; // multiple conditions used the same metric with ALL conjunction, this doesn't work - abort (BZ 737565) + try { + // Find out if this is using the ALL conjunction - if it is, we can't have more than one conditional use the same metric. + // If we do, immediately abort and warn the user. See BZ 737565 + if ((BooleanExpression.ALL.name().equals(this.conditionExpression.getValue().toString())) + && (supportsMetrics && this.resourceType.getMetricDefinitions() != null)) { + + Map<Integer, String> metricIdsUsed = new HashMap<Integer, String>(); + for (AlertCondition condition : this.conditions) { + if (condition.getMeasurementDefinition() != null) { + Integer id = Integer.valueOf(condition.getMeasurementDefinition().getId()); + if (metricIdsUsed.containsKey(id)) { + String msg = MSG.view_alert_definition_condition_editor_metricswarning(metricIdsUsed + .get(id)); + Message warning = new Message(msg, Severity.Warning, EnumSet.of(Message.Option.Transient)); + CoreGUI.getMessageCenter().notify(warning); + return false; // multiple conditions used the same metric with ALL conjunction, this doesn't work - abort (BZ 737565) + } + metricIdsUsed.put(id, condition.getMeasurementDefinition().getDisplayName()); } - metricIdsUsed.put(id, condition.getMeasurementDefinition().getDisplayName()); } } - }
- final boolean calltimeCategory; - final AlertConditionCategory category; + final boolean calltimeCategory; + final AlertConditionCategory category;
- String selectedCategory = conditionTypeSelectItem.getValue().toString(); - if (selectedCategory.equals(ALERT_CONDITION_CATEGORY_CALLTIME_THRESHOLD)) { - calltimeCategory = true; - category = AlertConditionCategory.THRESHOLD; - } else if (selectedCategory.equals(ALERT_CONDITION_CATEGORY_CALLTIME_CHANGE)) { - calltimeCategory = true; - category = AlertConditionCategory.CHANGE; - } else { - calltimeCategory = false; - category = AlertConditionCategory.valueOf(selectedCategory); - } + String selectedCategory = conditionTypeSelectItem.getValue().toString(); + if (selectedCategory.equals(ALERT_CONDITION_CATEGORY_CALLTIME_THRESHOLD)) { + calltimeCategory = true; + category = AlertConditionCategory.THRESHOLD; + } else if (selectedCategory.equals(ALERT_CONDITION_CATEGORY_CALLTIME_CHANGE)) { + calltimeCategory = true; + category = AlertConditionCategory.CHANGE; + } else { + calltimeCategory = false; + category = AlertConditionCategory.valueOf(selectedCategory); + }
- AlertCondition newCondition = new AlertCondition(); - newCondition.setCategory(category); - - switch (category) { - case AVAILABILITY: { - newCondition.setName(null); - newCondition.setComparator(null); - newCondition.setThreshold(null); - newCondition.setOption(getValueAsString(AVAILABILITY_ITEMNAME)); - newCondition.setMeasurementDefinition(null); - break; - } + AlertCondition newCondition = new AlertCondition(); + newCondition.setCategory(category);
- case THRESHOLD: { - if (!calltimeCategory) { - MeasurementDefinition measDef = getMeasurementDefinition(getValueAsString(THRESHOLD_METRIC_ITEMNAME)); + switch (category) { + case AVAILABILITY: { + newCondition.setName(null); + newCondition.setComparator(null); + newCondition.setThreshold(null); + newCondition.setOption(getValueAsString(AVAILABILITY_ITEMNAME)); + newCondition.setMeasurementDefinition(null); + break; + } + + case THRESHOLD: { + if (!calltimeCategory) { + MeasurementDefinition measDef = getMeasurementDefinition(getValueAsString(THRESHOLD_METRIC_ITEMNAME)); + newCondition.setName(measDef.getDisplayName()); + newCondition.setThreshold(getMeasurementValue(measDef, + getValueAsString(THRESHOLD_ABSVALUE_ITEMNAME))); + newCondition.setComparator(getValueAsString(THRESHOLD_COMPARATOR_ITEMNAME)); + newCondition.setOption(null); + newCondition.setMeasurementDefinition(measDef); + } else { + MeasurementDefinition measDef = getMeasurementDefinition(getValueAsString(CALLTIME_THRESHOLD_METRIC_ITEMNAME)); + newCondition.setName(getValueAsString(CALLTIME_THRESHOLD_REGEX_ITEMNAME)); + newCondition.setThreshold(getMeasurementValue(measDef, + getValueAsString(CALLTIME_THRESHOLD_ABSVALUE_ITEMNAME))); + newCondition.setComparator(getValueAsString(CALLTIME_THRESHOLD_COMPARATOR_ITEMNAME)); + newCondition.setOption(getValueAsString(CALLTIME_THRESHOLD_MINMAXAVG_ITEMNAME)); + newCondition.setMeasurementDefinition(measDef); + } + break; + } + + case BASELINE: { + MeasurementDefinition measDef = getMeasurementDefinition(getValueAsString(BASELINE_METRIC_ITEMNAME)); newCondition.setName(measDef.getDisplayName()); - newCondition.setThreshold(Double.valueOf(getValueAsString(THRESHOLD_ABSVALUE_ITEMNAME))); - newCondition.setComparator(getValueAsString(THRESHOLD_COMPARATOR_ITEMNAME)); - newCondition.setOption(null); - newCondition.setMeasurementDefinition(measDef); - } else { - MeasurementDefinition measDef = getMeasurementDefinition(getValueAsString(CALLTIME_THRESHOLD_METRIC_ITEMNAME)); - newCondition.setName(getValueAsString(CALLTIME_THRESHOLD_REGEX_ITEMNAME)); - newCondition.setThreshold(Double.valueOf(getValueAsString(CALLTIME_THRESHOLD_ABSVALUE_ITEMNAME))); - newCondition.setComparator(getValueAsString(CALLTIME_THRESHOLD_COMPARATOR_ITEMNAME)); - newCondition.setOption(getValueAsString(CALLTIME_THRESHOLD_MINMAXAVG_ITEMNAME)); + newCondition.setThreshold(getMeasurementValueByUnits(MeasurementUnits.PERCENTAGE, + getValueAsString(BASELINE_PERCENTAGE_ITEMNAME))); + newCondition.setComparator(getValueAsString(BASELINE_COMPARATOR_ITEMNAME)); + newCondition.setOption(getValueAsString(BASELINE_SELECTION_ITEMNAME)); newCondition.setMeasurementDefinition(measDef); + break; } - break; - }
- case BASELINE: { - MeasurementDefinition measDef = getMeasurementDefinition(getValueAsString(BASELINE_METRIC_ITEMNAME)); - newCondition.setName(measDef.getDisplayName()); - newCondition.setThreshold(Double.valueOf(getValueAsString(BASELINE_PERCENTAGE_ITEMNAME)) / 100.0); - newCondition.setComparator(getValueAsString(BASELINE_COMPARATOR_ITEMNAME)); - newCondition.setOption(getValueAsString(BASELINE_SELECTION_ITEMNAME)); - newCondition.setMeasurementDefinition(measDef); - break; - } + case CHANGE: { + if (!calltimeCategory) { + MeasurementDefinition measDef = getMeasurementDefinition(getValueAsString(CHANGE_METRIC_ITEMNAME)); + newCondition.setName(measDef.getDisplayName()); + newCondition.setComparator(null); + newCondition.setThreshold(null); + newCondition.setOption(null); + newCondition.setMeasurementDefinition(measDef); + } else { + MeasurementDefinition measDef = getMeasurementDefinition(getValueAsString(CALLTIME_CHANGE_METRIC_ITEMNAME)); + newCondition.setName(getValueAsString(CALLTIME_CHANGE_REGEX_ITEMNAME)); + newCondition.setThreshold(getMeasurementValueByUnits(MeasurementUnits.PERCENTAGE, + getValueAsString(CALLTIME_CHANGE_PERCENTAGE_ITEMNAME))); + newCondition.setComparator(getValueAsString(CALLTIME_CHANGE_COMPARATOR_ITEMNAME)); + newCondition.setOption(getValueAsString(CALLTIME_CHANGE_MINMAXAVG_ITEMNAME)); + newCondition.setMeasurementDefinition(measDef); + } + break; + }
- case CHANGE: { - if (!calltimeCategory) { - MeasurementDefinition measDef = getMeasurementDefinition(getValueAsString(CHANGE_METRIC_ITEMNAME)); + case TRAIT: { + MeasurementDefinition measDef = getMeasurementDefinition(getValueAsString(TRAIT_METRIC_ITEMNAME)); newCondition.setName(measDef.getDisplayName()); newCondition.setComparator(null); newCondition.setThreshold(null); newCondition.setOption(null); newCondition.setMeasurementDefinition(measDef); - } else { - MeasurementDefinition measDef = getMeasurementDefinition(getValueAsString(CALLTIME_CHANGE_METRIC_ITEMNAME)); - newCondition.setName(getValueAsString(CALLTIME_CHANGE_REGEX_ITEMNAME)); - newCondition - .setThreshold(Double.valueOf(getValueAsString(CALLTIME_CHANGE_PERCENTAGE_ITEMNAME)) / 100.0); - newCondition.setComparator(getValueAsString(CALLTIME_CHANGE_COMPARATOR_ITEMNAME)); - newCondition.setOption(getValueAsString(CALLTIME_CHANGE_MINMAXAVG_ITEMNAME)); - newCondition.setMeasurementDefinition(measDef); + break; } - break; - }
- case TRAIT: { - MeasurementDefinition measDef = getMeasurementDefinition(getValueAsString(TRAIT_METRIC_ITEMNAME)); - newCondition.setName(measDef.getDisplayName()); - newCondition.setComparator(null); - newCondition.setThreshold(null); - newCondition.setOption(null); - newCondition.setMeasurementDefinition(measDef); - break; - } + case CONTROL: { + newCondition.setName(getValueAsString(OPERATION_NAME_ITEMNAME)); + newCondition.setComparator(null); + newCondition.setThreshold(null); + newCondition.setOption(getValueAsString(OPERATION_RESULTS_ITEMNAME)); + newCondition.setMeasurementDefinition(null); + break; + }
- case CONTROL: { - newCondition.setName(getValueAsString(OPERATION_NAME_ITEMNAME)); - newCondition.setComparator(null); - newCondition.setThreshold(null); - newCondition.setOption(getValueAsString(OPERATION_RESULTS_ITEMNAME)); - newCondition.setMeasurementDefinition(null); - break; - } + case EVENT: { + newCondition.setName(getValueAsString(EVENT_SEVERITY_ITEMNAME)); + newCondition.setComparator(null); + newCondition.setThreshold(null); + newCondition.setOption(getValueAsString(EVENT_REGEX_ITEMNAME)); + newCondition.setMeasurementDefinition(null); + break; + }
- case EVENT: { - newCondition.setName(getValueAsString(EVENT_SEVERITY_ITEMNAME)); - newCondition.setComparator(null); - newCondition.setThreshold(null); - newCondition.setOption(getValueAsString(EVENT_REGEX_ITEMNAME)); - newCondition.setMeasurementDefinition(null); - break; - } + case RESOURCE_CONFIG: { + newCondition.setName(null); + newCondition.setComparator(null); + newCondition.setThreshold(null); + newCondition.setOption(null); + newCondition.setMeasurementDefinition(null); + break; + }
- case RESOURCE_CONFIG: { - newCondition.setName(null); - newCondition.setComparator(null); - newCondition.setThreshold(null); - newCondition.setOption(null); - newCondition.setMeasurementDefinition(null); - break; - } + case DRIFT: { + newCondition.setName(getValueAsString(DRIFT_CONFIGNAME_REGEX_ITEMNAME)); + newCondition.setComparator(null); + newCondition.setThreshold(null); + newCondition.setOption(getValueAsString(DRIFT_PATHNAME_REGEX_ITEMNAME)); + newCondition.setMeasurementDefinition(null); + break; + }
- case DRIFT: { - newCondition.setName(getValueAsString(DRIFT_CONFIGNAME_REGEX_ITEMNAME)); - newCondition.setComparator(null); - newCondition.setThreshold(null); - newCondition.setOption(getValueAsString(DRIFT_PATHNAME_REGEX_ITEMNAME)); - newCondition.setMeasurementDefinition(null); - break; - } + case RANGE: { + MeasurementDefinition measDef = getMeasurementDefinition(getValueAsString(RANGE_METRIC_ITEMNAME)); + newCondition.setName(measDef.getDisplayName()); + newCondition.setThreshold(getMeasurementValue(measDef, getValueAsString(RANGE_LO_ABSVALUE_ITEMNAME))); + newCondition.setComparator(getValueAsString(RANGE_COMPARATOR_ITEMNAME)); + newCondition.setOption(getMeasurementValue(measDef, getValueAsString(RANGE_HI_ABSVALUE_ITEMNAME)) + .toString()); + newCondition.setMeasurementDefinition(measDef); + break; + }
- case RANGE: { - MeasurementDefinition measDef = getMeasurementDefinition(getValueAsString(RANGE_METRIC_ITEMNAME)); - newCondition.setName(measDef.getDisplayName()); - newCondition.setThreshold(Double.valueOf(getValueAsString(RANGE_LO_ABSVALUE_ITEMNAME))); - newCondition.setComparator(getValueAsString(RANGE_COMPARATOR_ITEMNAME)); - newCondition.setOption(Double.valueOf(getValueAsString(RANGE_HI_ABSVALUE_ITEMNAME)).toString()); - newCondition.setMeasurementDefinition(measDef); - break; - } + default: { + CoreGUI.getErrorHandler().handleError( + MSG.view_alert_common_tab_invalid_condition_category(category.name())); // should never happen + break; + } + }
- default: { - CoreGUI.getErrorHandler() - .handleError(MSG.view_alert_common_tab_invalid_condition_category(category.name())); // should never happen - break; - } + this.conditions.add(newCondition); + + return true; + } catch (Exception e) { + CoreGUI.getErrorHandler().handleError("Problem creating condition", e); + return false; } + }
- this.conditions.add(newCondition); + private Double getMeasurementValue(MeasurementDefinition measDef, String userEnteredValue) { + return getMeasurementValueByUnits(measDef.getUnits(), userEnteredValue); + }
- return true; + private Double getMeasurementValueByUnits(MeasurementUnits units, String userEnteredValue) { + return MeasurementParser.parse(userEnteredValue, units).getValue(); }
private ArrayList<FormItem> buildMetricThresholdFormItems() { @@ -471,7 +491,8 @@ public class NewConditionEditor extends LocatableDynamicForm { absoluteValue.setTooltip(MSG.view_alert_definition_condition_editor_metric_threshold_value_tooltip()); absoluteValue.setHoverWidth(200); absoluteValue.setValidateOnChange(true); - absoluteValue.setValidators(new IsFloatValidator()); + absoluteValue.setValidators(new NumberWithUnitsValidator(this.resourceType.getMetricDefinitions(), + metricDropDownMenu)); absoluteValue.setShowIfCondition(ifFunc); formItems.add(absoluteValue); } else { @@ -503,7 +524,8 @@ public class NewConditionEditor extends LocatableDynamicForm { absoluteLowValue.setTooltip(MSG.view_alert_definition_condition_editor_metric_range_lovalue_tooltip()); absoluteLowValue.setHoverWidth(200); absoluteLowValue.setValidateOnChange(true); - absoluteLowValue.setValidators(new IsFloatValidator()); + absoluteLowValue.setValidators(new NumberWithUnitsValidator(this.resourceType.getMetricDefinitions(), + metricDropDownMenu)); absoluteLowValue.setShowIfCondition(ifFunc); formItems.add(absoluteLowValue);
@@ -514,7 +536,8 @@ public class NewConditionEditor extends LocatableDynamicForm { absoluteHighValue.setTooltip(MSG.view_alert_definition_condition_editor_metric_range_hivalue_tooltip()); absoluteHighValue.setHoverWidth(200); absoluteHighValue.setValidateOnChange(true); - absoluteHighValue.setValidators(new IsFloatValidator()); + absoluteHighValue.setValidators(new NumberWithUnitsValidator(this.resourceType.getMetricDefinitions(), + metricDropDownMenu)); absoluteHighValue.setShowIfCondition(ifFunc); formItems.add(absoluteHighValue); } else { @@ -550,7 +573,7 @@ public class NewConditionEditor extends LocatableDynamicForm { baselinePercentage.setHoverWidth(200); baselinePercentage.setShowIfCondition(ifFunc); baselinePercentage.setValidateOnChange(true); - baselinePercentage.setValidators(new IsFloatValidator()); + baselinePercentage.setValidators(new NumberWithUnitsValidator(MeasurementUnits.PERCENTAGE)); formItems.add(baselinePercentage);
SelectItem baselineSelection = new SelectItem(BASELINE_SELECTION_ITEMNAME, MSG @@ -605,7 +628,8 @@ public class NewConditionEditor extends LocatableDynamicForm { StaticTextItem helpItem = buildHelpTextItem("calltimeThresholdHelp", helpStr, ifFunc); formItems.add(helpItem);
- formItems.add(buildCalltimeMetricDropDownMenu(CALLTIME_THRESHOLD_METRIC_ITEMNAME, ifFunc)); + SelectItem metricDropDownMenu = buildCalltimeMetricDropDownMenu(CALLTIME_THRESHOLD_METRIC_ITEMNAME, ifFunc); + formItems.add(metricDropDownMenu);
SelectItem minMaxAvgSelection = new SelectItem(CALLTIME_THRESHOLD_MINMAXAVG_ITEMNAME, MSG .view_alert_definition_condition_editor_metric_calltime_common_limit()); @@ -633,7 +657,8 @@ public class NewConditionEditor extends LocatableDynamicForm { absoluteValue.setHoverWidth(200); absoluteValue.setShowIfCondition(ifFunc); absoluteValue.setValidateOnChange(true); - absoluteValue.setValidators(new IsFloatValidator()); + absoluteValue.setValidators(new NumberWithUnitsValidator(this.resourceType.getMetricDefinitions(), + metricDropDownMenu)); formItems.add(absoluteValue);
TextItem regex = new TextItem(CALLTIME_THRESHOLD_REGEX_ITEMNAME, MSG @@ -686,7 +711,7 @@ public class NewConditionEditor extends LocatableDynamicForm { percentage.setHoverWidth(200); percentage.setShowIfCondition(ifFunc); percentage.setValidateOnChange(true); - percentage.setValidators(new IsFloatValidator()); + percentage.setValidators(new NumberWithUnitsValidator(MeasurementUnits.PERCENTAGE)); formItems.add(percentage);
TextItem regex = new TextItem(CALLTIME_CHANGE_REGEX_ITEMNAME, MSG diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/form/NumberWithUnitsValidator.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/form/NumberWithUnitsValidator.java new file mode 100644 index 0000000..37e5589 --- /dev/null +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/form/NumberWithUnitsValidator.java @@ -0,0 +1,112 @@ +/* + * RHQ Management Platform + * Copyright (C) 2005-2009 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.components.form; + +import java.util.Set; + +import com.smartgwt.client.widgets.form.fields.SelectItem; +import com.smartgwt.client.widgets.form.validator.CustomValidator; + +import org.rhq.core.domain.measurement.MeasurementDefinition; +import org.rhq.core.domain.measurement.MeasurementUnits; +import org.rhq.enterprise.gui.coregui.client.util.measurement.MeasurementParser; + +/** + * Validates user entered numbers with units. This validator can be given + * the units directly or it can derive the units based on a selection component + * whose keys are measurement definition IDs - the measurement definitions must be + * given so the ID can be looked up. + * + * @author John Mazzitelli + */ +public class NumberWithUnitsValidator extends CustomValidator { + + private final MeasurementUnits units; + private final Set<MeasurementDefinition> metricDefs; + private final SelectItem metricDropDownMenu; + + public NumberWithUnitsValidator(Set<MeasurementDefinition> metricDefs, SelectItem metricDropDownMenu) { + if (metricDefs == null) { + throw new NullPointerException("metricDefs == null"); + } + if (metricDropDownMenu == null) { + throw new NullPointerException("metricDropDownMenu == null"); + } + this.metricDefs = metricDefs; + this.metricDropDownMenu = metricDropDownMenu; + this.units = null; + } + + public NumberWithUnitsValidator(MeasurementUnits units) { + if (units == null) { + throw new NullPointerException("units == null"); + } + this.metricDefs = null; + this.metricDropDownMenu = null; + this.units = units; + } + + @Override + protected boolean condition(Object value) { + // don't know if this is the right thing to do, but assume the value was optional. + // if there is no value or its empty, assume that is OK and will be considered a 0 + if (value == null || value.toString().trim().length() == 0) { + return true; + } + + MeasurementUnits unitsToUse = this.units; + + if (unitsToUse == null) { + // units weren't directly given to us, find it from the selected metric definition + try { + String idString = metricDropDownMenu.getValueAsString(); + Integer id = Integer.parseInt(idString); + for (MeasurementDefinition metricDef : this.metricDefs) { + if (metricDef.getId() == id.intValue()) { + unitsToUse = metricDef.getUnits(); + break; + } + } + } catch (Exception e) { + unitsToUse = null; + } + } + + if (unitsToUse != null) { + try { + if (MeasurementParser.parse(value.toString(), unitsToUse) != null) { + return true; + } else { + return false; + } + } catch (Exception e) { + return false; + } + } else { + // no units? just see if its a valid floating point number + try { + Double.parseDouble(value.toString()); + return true; + } catch (Exception e) { + return false; + } + } + } +} diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/TestNumberFormatView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/TestNumberFormatView.java new file mode 100644 index 0000000..30b11d4 --- /dev/null +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/TestNumberFormatView.java @@ -0,0 +1,78 @@ +/* + * RHQ Management Platform + * Copyright (C) 2005-2011 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.test; + +import java.util.EnumSet; +import java.util.LinkedHashMap; + +import com.smartgwt.client.widgets.form.fields.ButtonItem; +import com.smartgwt.client.widgets.form.fields.SelectItem; +import com.smartgwt.client.widgets.form.fields.StaticTextItem; +import com.smartgwt.client.widgets.form.fields.TextItem; +import com.smartgwt.client.widgets.form.fields.events.ClickEvent; +import com.smartgwt.client.widgets.form.fields.events.ClickHandler; + +import org.rhq.core.domain.measurement.MeasurementUnits; +import org.rhq.core.domain.measurement.composite.MeasurementNumericValueAndUnits; +import org.rhq.enterprise.gui.coregui.client.util.measurement.MeasurementParser; +import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm; +import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout; + +public class TestNumberFormatView extends LocatableVLayout { + + public TestNumberFormatView(String locatorId) { + super(locatorId); + } + + @Override + protected void onDraw() { + super.onDraw(); + + LinkedHashMap<String, String> unitsChoices = new LinkedHashMap<String, String>(); + for (MeasurementUnits unit : EnumSet.allOf(MeasurementUnits.class)) { + unitsChoices.put(unit.name(), unit.name()); + } + + final SelectItem unitsMenu = new SelectItem("unitsItem", "Units"); + unitsMenu.setValueMap(unitsChoices); + unitsMenu.setDefaultValue(MeasurementUnits.BYTES.name()); + + final TextItem textItem = new TextItem("valueItem", "Value"); + + final StaticTextItem resultsValueItem = new StaticTextItem("resultsValue", "Results Value"); + final StaticTextItem resultsUnitItem = new StaticTextItem("resultsUnits", "Results Units"); + + ButtonItem button = new ButtonItem("convertItem", "Convert"); + button.addClickHandler(new ClickHandler() { + public void onClick(ClickEvent event) { + MeasurementUnits units = MeasurementUnits.valueOf(unitsMenu.getValueAsString()); + String value = textItem.getValueAsString(); + MeasurementNumericValueAndUnits vu = MeasurementParser.parse(value, units); + resultsValueItem.setValue(vu.getValue().toString()); + resultsUnitItem.setValue(vu.getUnits().name()); + } + }); + + LocatableDynamicForm form = new LocatableDynamicForm(extendLocatorId("form")); + form.setItems(unitsMenu, textItem, button, resultsValueItem, resultsUnitItem); + + addMember(form); + } +} 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 a9e131b..94bdd1e 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 @@ -78,6 +78,7 @@ public class TestTopView extends AbstractSectionedLeftNavigationView { // view IDs for Misc section private static final ViewName MISC_SECTION_VIEW_ID = new ViewName("Misc"); private static final ViewName PAGE_PLURALIZATION_TEST = new ViewName("PluralizationTest"); + private static final ViewName PAGE_NUMBER_FORMAT_TEST = new ViewName("NumberFormatTest"); private static final ViewName PAGE_ASYNC = new ViewName("Async"); private static final ViewName PAGE_RPC = new ViewName("Rpc");
@@ -224,6 +225,12 @@ public class TestTopView extends AbstractSectionedLeftNavigationView { }
private NavigationSection buildMiscSection() { + NavigationItem numberFormatItem = new NavigationItem(PAGE_NUMBER_FORMAT_TEST, null, new ViewFactory() { + public Canvas createView() { + return new TestNumberFormatView(extendLocatorId(PAGE_NUMBER_FORMAT_TEST.getName())); + } + }); + NavigationItem pluralizationItem = new NavigationItem(PAGE_PLURALIZATION_TEST, null, new ViewFactory() { public Canvas createView() { return new TestPluralizationView(extendLocatorId(PAGE_PLURALIZATION_TEST.getName())); @@ -242,7 +249,7 @@ public class TestTopView extends AbstractSectionedLeftNavigationView { } });
- return new NavigationSection(MISC_SECTION_VIEW_ID, pluralizationItem, asyncItem, rpcItem); + return new NavigationSection(MISC_SECTION_VIEW_ID, numberFormatItem, pluralizationItem, asyncItem, rpcItem); }
} diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/measurement/MeasurementParser.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/measurement/MeasurementParser.java new file mode 100644 index 0000000..8ce0777 --- /dev/null +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/measurement/MeasurementParser.java @@ -0,0 +1,121 @@ +/* + * RHQ Management Platform + * Copyright (C) 2005-2011 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.util.measurement; + +import com.google.gwt.i18n.client.NumberFormat; + +import org.rhq.core.domain.measurement.MeasurementUnits; +import org.rhq.core.domain.measurement.composite.MeasurementNumericValueAndUnits; +import org.rhq.core.domain.measurement.util.MeasurementConversionException; +import org.rhq.enterprise.gui.coregui.client.util.MeasurementConverterClient; + +/** + * Parses measurement strings given in the typical form of "[sign] magnitude [units]" such as: + * + * -1.0 + * +1.0s + * 200MB + * + * This is purposefully written without java.text and java.util.regex classes so GWT 2.0 + * can use this class. + * + * @author Greg Hinkle + * @author John Mazzitelli + */ +public class MeasurementParser { + + public static MeasurementNumericValueAndUnits parse(String input, MeasurementUnits targetUnits) + throws MeasurementConversionException { + + if (input == null) { + return new MeasurementNumericValueAndUnits(Double.valueOf(0.0), targetUnits); + } + + input = input.trim(); + + if (input.length() == 0) { + return new MeasurementNumericValueAndUnits(Double.valueOf(0.0), targetUnits); + } + + int i = 0; + + // skip over the sign, we'll deal with that later + if (input.startsWith("+") || input.startsWith("-")) { + i = 1; + } + + // find the end of the magnitude (i.e. the number itself) + // note we allow for decimals - and we allow for either "." or "," as the decimal point for i18n purposes + for (; i < input.length(); i++) { + char ch = input.charAt(i); + if (!(Character.isDigit(ch) || ch == '.' || ch == ',')) { + break; + } + } + + String magnitude = input.substring(0, i); + String units = ""; + + if (i <= input.length()) { + // gobble everything after the magnitude and consider it the units + units = input.substring(i); + units = units.trim(); + } + + MeasurementUnits fromUnits; + if (units.equals("")) { + /* + * no units is valid, and we assume the passed targetUnits; however, we will + * still need to check that the number is well-formed, so continue processing. + */ + fromUnits = targetUnits; + } else { + fromUnits = MeasurementUnits.getUsingDisplayUnits(units, targetUnits.getFamily()); + + if ((fromUnits == null) || (!fromUnits.isComparableTo(targetUnits))) { + throw new MeasurementConversionException("The units in '" + input + "' were not valid, " + "expected '" + + targetUnits.getFamily() + "' units, received '" + units + "' units"); + } + } + + try { + if (magnitude.startsWith("+")) { + magnitude = magnitude.substring(1); + } + + Number convertedMagnitude = NumberFormat.getDecimalFormat().parse(magnitude); + Double scaledMagnitude; + + // apply relative scale if applicable, otherwise perform standard scaling + if (MeasurementUnits.Family.RELATIVE == targetUnits.getFamily()) { + scaledMagnitude = MeasurementUnits.scaleDown(convertedMagnitude.doubleValue(), targetUnits); + } else { + MeasurementNumericValueAndUnits valueAndUnits = new MeasurementNumericValueAndUnits(convertedMagnitude + .doubleValue(), fromUnits); + scaledMagnitude = MeasurementConverterClient.scale(valueAndUnits, targetUnits); + } + + return new MeasurementNumericValueAndUnits(scaledMagnitude, targetUnits); + } catch (Exception e) { + throw new MeasurementConversionException("The magnitude in '" + input + "' did not parse correctly " + + "as a valid, localized, stringified number "); + } + + } +}
commit 99a931748c2a9017880fb8b82cf19102743ae11a Author: John Mazzitelli mazz@redhat.com Date: Thu Sep 15 01:09:17 2011 -0400
trivial - clean up imports, add TODO to mark a possible duplicate class
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/MeasurementConverterClient.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/MeasurementConverterClient.java index c538e2b..5842729 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/MeasurementConverterClient.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/MeasurementConverterClient.java @@ -29,7 +29,6 @@ import com.google.gwt.i18n.client.NumberFormat;
import org.rhq.core.domain.measurement.MeasurementSchedule; import org.rhq.core.domain.measurement.MeasurementUnits; -import org.rhq.core.domain.measurement.MeasurementUnits.Family; import org.rhq.core.domain.measurement.composite.MeasurementNumericValueAndUnits; import org.rhq.core.domain.measurement.util.MeasurementConversionException; import org.rhq.enterprise.gui.coregui.client.CoreGUI; diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/measurement/GwtMeasurementConverter.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/measurement/GwtMeasurementConverter.java index a8577e3..6833d07 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/measurement/GwtMeasurementConverter.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/measurement/GwtMeasurementConverter.java @@ -5,7 +5,6 @@ import java.util.HashSet; import java.util.Set;
import com.google.gwt.i18n.client.NumberFormat; -import com.google.gwt.i18n.client.TimeZone;
import org.rhq.core.domain.measurement.MeasurementSchedule; import org.rhq.core.domain.measurement.MeasurementUnits; @@ -17,10 +16,9 @@ import org.rhq.core.domain.measurement.util.MeasurementConversionException; * * @author Simeon Pinder */ +// TODO: what is different here vs. MeasurementConverterClient? we should combine the two public class GwtMeasurementConverter {
- public static TimeZone tz = null; - private static final int MAX_PRECISION_DIGITS = 4; private static final String NULL_OR_NAN_FORMATTED_VALUE = "--no data available--";
commit de2e667b239e40f261e9de116c5149889f217e64 Author: Stefan Negrea snegrea@redhat.com Date: Wed Sep 14 21:26:23 2011 -0500
More wildcard updates propagated upwards from the agent api.
diff --git a/modules/plugins/augeas/src/main/java/org/rhq/plugins/augeas/AugeasConfigurationComponent.java b/modules/plugins/augeas/src/main/java/org/rhq/plugins/augeas/AugeasConfigurationComponent.java index ec0dee8..03dcec0 100644 --- a/modules/plugins/augeas/src/main/java/org/rhq/plugins/augeas/AugeasConfigurationComponent.java +++ b/modules/plugins/augeas/src/main/java/org/rhq/plugins/augeas/AugeasConfigurationComponent.java @@ -24,7 +24,6 @@ import java.util.Arrays; import java.util.Collection; import java.util.Date; import java.util.HashSet; -import java.util.LinkedHashMap; import java.util.List; import java.util.Set;
@@ -68,7 +67,7 @@ import org.rhq.plugins.augeas.helper.AugeasNode; * @author Ian Springer * @author Lukas Krejci */ -public class AugeasConfigurationComponent<T extends ResourceComponent> implements ResourceComponent<T>, +public class AugeasConfigurationComponent<T extends ResourceComponent<?>> implements ResourceComponent<T>, ConfigurationFacet, CreateChildResourceFacet, DeleteResourceFacet { /* Plugin config prop names */ public static final String INCLUDE_GLOBS_PROP = "configurationFilesInclusionPatterns"; @@ -78,7 +77,7 @@ public class AugeasConfigurationComponent<T extends ResourceComponent> implement public static final String AUGEAS_ROOT_PATH_PROP = "augeasRootPath";
private static final boolean IS_WINDOWS = (File.separatorChar == '\'); - public static final String DEFAULT_AUGEAS_ROOT_PATH = (IS_WINDOWS) ? "C:/" : "/"; + public static final String DEFAULT_AUGEAS_ROOT_PATH = (IS_WINDOWS) ? "C:/" : "/";
private final Log log = LogFactory.getLog(this.getClass());
@@ -90,7 +89,7 @@ public class AugeasConfigurationComponent<T extends ResourceComponent> implement private AugeasNode resourceConfigRootNode; private String augeasRootPath; private String augeasLoadPath; - + protected String getAugeasRootPath() { return augeasRootPath; } @@ -102,7 +101,7 @@ public class AugeasConfigurationComponent<T extends ResourceComponent> implement protected String getAugeasLoadPath() { return augeasLoadPath; } - + public void start(ResourceContext<T> resourceContext) throws InvalidPluginConfigurationException, Exception { this.resourceContext = resourceContext; this.resourceDescription = this.resourceContext.getResourceType() + " Resource with key [" @@ -112,9 +111,10 @@ public class AugeasConfigurationComponent<T extends ResourceComponent> implement Configuration pluginConfig = this.resourceContext.getPluginConfiguration(); this.augeasRootPath = pluginConfig.getSimpleValue(AUGEAS_ROOT_PATH_PROP, DEFAULT_AUGEAS_ROOT_PATH); log.debug("Augeas Root Path = "" + this.augeasRootPath + """); - - augeasLoadPath = resourceContext.getDataDirectory().getAbsolutePath() + File.separator + AugeasPluginLifecycleListener.LENSES_SUBDIRECTORY_NAME; - + + augeasLoadPath = resourceContext.getDataDirectory().getAbsolutePath() + File.separator + + AugeasPluginLifecycleListener.LENSES_SUBDIRECTORY_NAME; + if (isAugeasAvailable()) { initAugeas(); } else { @@ -755,16 +755,16 @@ public class AugeasConfigurationComponent<T extends ResourceComponent> implement } } } - + private void checkModuleErrors(Augeas augeas) { List<String> errors = augeas.match("/augeas/load//error"); if (errors != null && errors.size() > 0) { StringBuilder errorMessage = new StringBuilder(); - for(String nodePath : errors) { + for (String nodePath : errors) { AugeasNode node = new AugeasNode(nodePath); String moduleName = node.getParent().getName(); String errorText = augeas.get(nodePath); - + errorMessage.append("Module '").append(moduleName).append("' failed with the following errors:\n"); errorMessage.append(errorText); errorMessage.append("\n\n"); @@ -772,7 +772,7 @@ public class AugeasConfigurationComponent<T extends ResourceComponent> implement throw new IllegalStateException("Augeas modules didn't load cleanly.\n" + errorMessage); } } - + /* (non-Javadoc) * @see java.lang.Object#finalize() */ diff --git a/modules/plugins/augeas/src/main/java/org/rhq/plugins/augeas/AugeasConfigurationDiscoveryComponent.java b/modules/plugins/augeas/src/main/java/org/rhq/plugins/augeas/AugeasConfigurationDiscoveryComponent.java index 292e6df..5bc1d1d 100644 --- a/modules/plugins/augeas/src/main/java/org/rhq/plugins/augeas/AugeasConfigurationDiscoveryComponent.java +++ b/modules/plugins/augeas/src/main/java/org/rhq/plugins/augeas/AugeasConfigurationDiscoveryComponent.java @@ -28,6 +28,7 @@ import java.util.Set; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory;
+import org.rhq.augeas.util.Glob; import org.rhq.core.domain.configuration.Configuration; import org.rhq.core.domain.configuration.PropertySimple; import org.rhq.core.domain.resource.ResourceType; @@ -37,13 +38,12 @@ import org.rhq.core.pluginapi.inventory.ManualAddFacet; import org.rhq.core.pluginapi.inventory.ResourceComponent; import org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent; import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext; -import org.rhq.augeas.util.Glob;
/** * @author Ian Springer * @author Lukas Krejci */ -public class AugeasConfigurationDiscoveryComponent<T extends ResourceComponent> implements +public class AugeasConfigurationDiscoveryComponent<T extends ResourceComponent<?>> implements ResourceDiscoveryComponent<T>, ManualAddFacet<T> { private final Log log = LogFactory.getLog(this.getClass());
@@ -87,8 +87,8 @@ public class AugeasConfigurationDiscoveryComponent<T extends ResourceComponent> Configuration pluginConfig) { ResourceType resourceType = discoveryContext.getResourceType(); String resourceKey = composeResourceKey(pluginConfig); - DiscoveredResourceDetails resource = new DiscoveredResourceDetails(resourceType, resourceKey, resourceType - .getName(), null, resourceType.getDescription(), pluginConfig, null); + DiscoveredResourceDetails resource = new DiscoveredResourceDetails(resourceType, resourceKey, + resourceType.getName(), null, resourceType.getDescription(), pluginConfig, null); return resource; }
@@ -122,7 +122,7 @@ public class AugeasConfigurationDiscoveryComponent<T extends ResourceComponent> .getSimple(AugeasConfigurationComponent.EXCLUDE_GLOBS_PROP);
String augeasRootPath = pluginConfiguration.getSimpleValue(AugeasConfigurationComponent.AUGEAS_ROOT_PATH_PROP, - AugeasConfigurationComponent.DEFAULT_AUGEAS_ROOT_PATH); + AugeasConfigurationComponent.DEFAULT_AUGEAS_ROOT_PATH); File root = new File(augeasRootPath);
List<String> includeGlobs = getGlobList(includeGlobsProp); diff --git a/modules/plugins/database/src/main/java/org/rhq/plugins/database/AbstractDatabaseComponent.java b/modules/plugins/database/src/main/java/org/rhq/plugins/database/AbstractDatabaseComponent.java index 498270a..1170668 100644 --- a/modules/plugins/database/src/main/java/org/rhq/plugins/database/AbstractDatabaseComponent.java +++ b/modules/plugins/database/src/main/java/org/rhq/plugins/database/AbstractDatabaseComponent.java @@ -19,13 +19,14 @@ package org.rhq.plugins.database;
import java.sql.Connection; + import org.rhq.core.pluginapi.inventory.InvalidPluginConfigurationException; import org.rhq.core.pluginapi.inventory.ResourceContext;
/** * @author Greg Hinkle */ -public abstract class AbstractDatabaseComponent<T extends DatabaseComponent> implements DatabaseComponent { +public abstract class AbstractDatabaseComponent<T extends DatabaseComponent<?>> implements DatabaseComponent { protected ResourceContext<T> resourceContext;
public void start(ResourceContext resourceContext) throws InvalidPluginConfigurationException, Exception { diff --git a/modules/plugins/database/src/main/java/org/rhq/plugins/database/CustomTableComponent.java b/modules/plugins/database/src/main/java/org/rhq/plugins/database/CustomTableComponent.java index f8ddcd8..d8906f7 100644 --- a/modules/plugins/database/src/main/java/org/rhq/plugins/database/CustomTableComponent.java +++ b/modules/plugins/database/src/main/java/org/rhq/plugins/database/CustomTableComponent.java @@ -26,6 +26,7 @@ import java.util.Set;
import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; + import org.rhq.core.domain.measurement.AvailabilityType; import org.rhq.core.domain.measurement.MeasurementDataNumeric; import org.rhq.core.domain.measurement.MeasurementReport; @@ -41,13 +42,13 @@ import org.rhq.core.util.jdbc.JDBCUtil; * * @author Greg Hinkle */ -public class CustomTableComponent implements DatabaseComponent<DatabaseComponent>, MeasurementFacet { - private ResourceContext<DatabaseComponent> context; +public class CustomTableComponent implements DatabaseComponent<DatabaseComponent<?>>, MeasurementFacet { + private ResourceContext<DatabaseComponent<?>> context;
private static final Log log = LogFactory.getLog(CustomTableComponent.class); - - public void start(ResourceContext<DatabaseComponent> resourceContext) throws InvalidPluginConfigurationException, - Exception { + + public void start(ResourceContext<DatabaseComponent<?>> resourceContext) + throws InvalidPluginConfigurationException, Exception { this.context = resourceContext; }
@@ -73,16 +74,22 @@ public class CustomTableComponent implements DatabaseComponent<DatabaseComponent
public void getValues(MeasurementReport report, Set<MeasurementScheduleRequest> metrics) throws Exception { String query = this.context.getPluginConfiguration().getSimpleValue("metricQuery", null); - + if (query == null) { ResourceType type = this.context.getResourceType(); String resourceKey = this.context.getResourceKey(); - log.info("Resource " + resourceKey + " (" + type.getName() + ", plugin " + type.getPlugin() + log.info("Resource " + + resourceKey + + " (" + + type.getName() + + ", plugin " + + type.getPlugin() + "): The plugin configuration doesn't specify 'metricQuery' property. Ignoring the measurement request."); return; } - - query = CustomTableRowDiscoveryComponent.formatMessage(query, this.context.getPluginConfiguration().getSimpleValue("key",null)); + + query = CustomTableRowDiscoveryComponent.formatMessage(query, this.context.getPluginConfiguration() + .getSimpleValue("key", null));
Map<String, Double> values = DatabaseQueryUtility.getNumericQueryValues(this, query); for (MeasurementScheduleRequest request : metrics) { diff --git a/modules/plugins/database/src/main/java/org/rhq/plugins/database/CustomTableDiscoveryComponent.java b/modules/plugins/database/src/main/java/org/rhq/plugins/database/CustomTableDiscoveryComponent.java index 633c28c..f25a8b1 100644 --- a/modules/plugins/database/src/main/java/org/rhq/plugins/database/CustomTableDiscoveryComponent.java +++ b/modules/plugins/database/src/main/java/org/rhq/plugins/database/CustomTableDiscoveryComponent.java @@ -39,9 +39,9 @@ import org.rhq.core.util.jdbc.JDBCUtil; * * @author Greg Hinkle */ -public class CustomTableDiscoveryComponent implements ManualAddFacet<DatabaseComponent>, ResourceDiscoveryComponent<DatabaseComponent> { +public class CustomTableDiscoveryComponent implements ManualAddFacet<DatabaseComponent<?>>, ResourceDiscoveryComponent<DatabaseComponent<?>> { public Set<DiscoveredResourceDetails> discoverResources( - ResourceDiscoveryContext<DatabaseComponent> resourceDiscoveryContext) + ResourceDiscoveryContext<DatabaseComponent<?>> resourceDiscoveryContext) throws InvalidPluginConfigurationException, Exception { Statement statement = null; try { @@ -75,7 +75,7 @@ public class CustomTableDiscoveryComponent implements ManualAddFacet<DatabaseCom return Collections.emptySet(); }
- public DiscoveredResourceDetails discoverResource(Configuration pluginConfiguration, ResourceDiscoveryContext<DatabaseComponent> discoveryContext) + public DiscoveredResourceDetails discoverResource(Configuration pluginConfiguration, ResourceDiscoveryContext<DatabaseComponent<?>> discoveryContext) throws InvalidPluginConfigurationException {
Configuration config = pluginConfiguration; diff --git a/modules/plugins/database/src/main/java/org/rhq/plugins/database/CustomTableRowDiscoveryComponent.java b/modules/plugins/database/src/main/java/org/rhq/plugins/database/CustomTableRowDiscoveryComponent.java index 4b40d86..e4d9392 100644 --- a/modules/plugins/database/src/main/java/org/rhq/plugins/database/CustomTableRowDiscoveryComponent.java +++ b/modules/plugins/database/src/main/java/org/rhq/plugins/database/CustomTableRowDiscoveryComponent.java @@ -40,9 +40,9 @@ import org.rhq.core.util.jdbc.JDBCUtil; * * @author Greg Hinkle */ -public class CustomTableRowDiscoveryComponent implements ResourceDiscoveryComponent<DatabaseComponent> { +public class CustomTableRowDiscoveryComponent implements ResourceDiscoveryComponent<DatabaseComponent<?>> { public Set<DiscoveredResourceDetails> discoverResources( - ResourceDiscoveryContext<DatabaseComponent> resourceDiscoveryContext) + ResourceDiscoveryContext<DatabaseComponent<?>> resourceDiscoveryContext) throws InvalidPluginConfigurationException, Exception { Statement statement = null; ResultSet resultSet = null; diff --git a/modules/plugins/database/src/main/java/org/rhq/plugins/database/DatabaseComponent.java b/modules/plugins/database/src/main/java/org/rhq/plugins/database/DatabaseComponent.java index 336554c..5b8ad5f 100644 --- a/modules/plugins/database/src/main/java/org/rhq/plugins/database/DatabaseComponent.java +++ b/modules/plugins/database/src/main/java/org/rhq/plugins/database/DatabaseComponent.java @@ -19,12 +19,13 @@ package org.rhq.plugins.database;
import java.sql.Connection; + import org.rhq.core.pluginapi.inventory.ResourceComponent;
/** * @author Greg Hinkle */ -public interface DatabaseComponent<T extends ResourceComponent> extends ResourceComponent<T> { +public interface DatabaseComponent<T extends ResourceComponent<?>> extends ResourceComponent<T> { Connection getConnection();
void removeConnection(); diff --git a/modules/plugins/hibernate/src/main/java/org/rhq/plugins/hibernate/EntityComponent.java b/modules/plugins/hibernate/src/main/java/org/rhq/plugins/hibernate/EntityComponent.java index 0803ed6..2ed80c8 100644 --- a/modules/plugins/hibernate/src/main/java/org/rhq/plugins/hibernate/EntityComponent.java +++ b/modules/plugins/hibernate/src/main/java/org/rhq/plugins/hibernate/EntityComponent.java @@ -1,25 +1,25 @@ - /* - * Jopr Management Platform - * Copyright (C) 2005-2008 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, version 2, as - * published by the Free Software Foundation, and/or the GNU Lesser - * General Public License, version 2.1, also as published by the Free - * Software Foundation. - * - * 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 and the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU General Public License - * and the GNU Lesser General Public License along with this program; - * if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ +/* + * Jopr Management Platform + * Copyright (C) 2005-2008 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, version 2, as + * published by the Free Software Foundation, and/or the GNU Lesser + * General Public License, version 2.1, also as published by the Free + * Software Foundation. + * + * 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 and the GNU Lesser General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License + * and the GNU Lesser General Public License along with this program; + * if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ package org.rhq.plugins.hibernate;
import java.util.Set; @@ -38,12 +38,12 @@ import org.rhq.plugins.jmx.MBeanResourceComponent; * @author Greg Hinkle * @author John Mazzitelli */ -public class EntityComponent extends MBeanResourceComponent<MBeanResourceComponent> { +public class EntityComponent extends MBeanResourceComponent<MBeanResourceComponent<?>> { @Override protected EmsBean loadBean() { return getResourceContext().getParentResourceComponent().getEmsBean(); } - + @Override public void getValues(MeasurementReport report, Set<MeasurementScheduleRequest> requests) { EmsOperation operation = getEmsBean().getOperation("getEntityStatistics"); diff --git a/modules/plugins/hibernate/src/main/java/org/rhq/plugins/hibernate/EntityDiscoveryComponent.java b/modules/plugins/hibernate/src/main/java/org/rhq/plugins/hibernate/EntityDiscoveryComponent.java index c21cde7..2bc5191 100644 --- a/modules/plugins/hibernate/src/main/java/org/rhq/plugins/hibernate/EntityDiscoveryComponent.java +++ b/modules/plugins/hibernate/src/main/java/org/rhq/plugins/hibernate/EntityDiscoveryComponent.java @@ -1,30 +1,32 @@ - /* - * Jopr Management Platform - * Copyright (C) 2005-2008 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, version 2, as - * published by the Free Software Foundation, and/or the GNU Lesser - * General Public License, version 2.1, also as published by the Free - * Software Foundation. - * - * 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 and the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU General Public License - * and the GNU Lesser General Public License along with this program; - * if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ +/* + * Jopr Management Platform + * Copyright (C) 2005-2008 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, version 2, as + * published by the Free Software Foundation, and/or the GNU Lesser + * General Public License, version 2.1, also as published by the Free + * Software Foundation. + * + * 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 and the GNU Lesser General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License + * and the GNU Lesser General Public License along with this program; + * if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ package org.rhq.plugins.hibernate;
import java.util.HashSet; import java.util.Set; + import org.mc4j.ems.connection.bean.EmsBean; + import org.rhq.core.pluginapi.inventory.DiscoveredResourceDetails; import org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent; import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext; @@ -35,8 +37,8 @@ import org.rhq.plugins.jmx.MBeanResourceComponent; * * @author Greg Hinkle */ -public class EntityDiscoveryComponent implements ResourceDiscoveryComponent<MBeanResourceComponent> { - public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext<MBeanResourceComponent> context) { +public class EntityDiscoveryComponent implements ResourceDiscoveryComponent<MBeanResourceComponent<?>> { + public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext<MBeanResourceComponent<?>> context) { Set<DiscoveredResourceDetails> entities = new HashSet<DiscoveredResourceDetails>();
EmsBean statsBean = context.getParentResourceComponent().getEmsBean(); diff --git a/modules/plugins/hibernate/src/main/java/org/rhq/plugins/hibernate/StatisticsComponent.java b/modules/plugins/hibernate/src/main/java/org/rhq/plugins/hibernate/StatisticsComponent.java index b42c966..bb00686 100644 --- a/modules/plugins/hibernate/src/main/java/org/rhq/plugins/hibernate/StatisticsComponent.java +++ b/modules/plugins/hibernate/src/main/java/org/rhq/plugins/hibernate/StatisticsComponent.java @@ -1,25 +1,25 @@ - /* - * Jopr Management Platform - * Copyright (C) 2005-2008 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, version 2, as - * published by the Free Software Foundation, and/or the GNU Lesser - * General Public License, version 2.1, also as published by the Free - * Software Foundation. - * - * 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 and the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU General Public License - * and the GNU Lesser General Public License along with this program; - * if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ +/* + * Jopr Management Platform + * Copyright (C) 2005-2008 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, version 2, as + * published by the Free Software Foundation, and/or the GNU Lesser + * General Public License, version 2.1, also as published by the Free + * Software Foundation. + * + * 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 and the GNU Lesser General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License + * and the GNU Lesser General Public License along with this program; + * if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ package org.rhq.plugins.hibernate;
import org.rhq.core.domain.configuration.Configuration; @@ -48,16 +48,16 @@ public class StatisticsComponent extends MBeanResourceComponent { Object queryStatistics = getEmsBean().getOperation("getQueryStatistics").invoke( new Object[] { queryString });
- Long executionCount = (Long) queryStatistics.getClass().getMethod("getExecutionCount").invoke( - queryStatistics); + Long executionCount = (Long) queryStatistics.getClass().getMethod("getExecutionCount") + .invoke(queryStatistics); Long executionRowCount = (Long) queryStatistics.getClass().getMethod("getExecutionRowCount") .invoke(queryStatistics); - Long executionMinTime = (Long) queryStatistics.getClass().getMethod("getExecutionMinTime").invoke( - queryStatistics); - Long executionMaxTime = (Long) queryStatistics.getClass().getMethod("getExecutionMaxTime").invoke( - queryStatistics); - Long executionAvgTime = (Long) queryStatistics.getClass().getMethod("getExecutionAvgTime").invoke( - queryStatistics); + Long executionMinTime = (Long) queryStatistics.getClass().getMethod("getExecutionMinTime") + .invoke(queryStatistics); + Long executionMaxTime = (Long) queryStatistics.getClass().getMethod("getExecutionMaxTime") + .invoke(queryStatistics); + Long executionAvgTime = (Long) queryStatistics.getClass().getMethod("getExecutionAvgTime") + .invoke(queryStatistics);
PropertyMap query = new PropertyMap("query", new PropertySimple("query", queryString), new PropertySimple("executionCount", executionCount), new PropertySimple("executionRowCount", diff --git a/modules/plugins/hudson/src/main/java/org/rhq/plugins/hudson/HudsonServerComponent.java b/modules/plugins/hudson/src/main/java/org/rhq/plugins/hudson/HudsonServerComponent.java index 17bcee7..f565052 100644 --- a/modules/plugins/hudson/src/main/java/org/rhq/plugins/hudson/HudsonServerComponent.java +++ b/modules/plugins/hudson/src/main/java/org/rhq/plugins/hudson/HudsonServerComponent.java @@ -18,21 +18,21 @@ */ package org.rhq.plugins.hudson;
+import java.util.HashMap; +import java.util.Map; + import org.json.JSONArray; import org.json.JSONObject; + import org.rhq.core.domain.measurement.AvailabilityType; import org.rhq.core.pluginapi.inventory.InvalidPluginConfigurationException; import org.rhq.core.pluginapi.inventory.ResourceComponent; import org.rhq.core.pluginapi.inventory.ResourceContext;
-import java.util.HashMap; -import java.util.Map; - /** * @author Greg Hinkle */ -public class HudsonServerComponent implements ResourceComponent { - +public class HudsonServerComponent implements ResourceComponent<ResourceComponent<?>> {
private ResourceContext resourceContext; private Map<String, JSONArray> healthMap = new HashMap<String, JSONArray>(); @@ -46,8 +46,8 @@ public class HudsonServerComponent implements ResourceComponent {
public AvailabilityType getAvailability() { try { - JSONObject server = HudsonJSONUtility.getData(this.resourceContext.getPluginConfiguration().getSimple("urlBase").getStringValue(), 1); - + JSONObject server = HudsonJSONUtility.getData( + this.resourceContext.getPluginConfiguration().getSimple("urlBase").getStringValue(), 1);
JSONArray jobs = server.getJSONArray("jobs"); for (int i = 0; i < jobs.length(); i++) { diff --git a/modules/plugins/iis/src/main/java/org/rhq/plugins/iis/IISServerComponent.java b/modules/plugins/iis/src/main/java/org/rhq/plugins/iis/IISServerComponent.java index 67d7621..83495fc 100644 --- a/modules/plugins/iis/src/main/java/org/rhq/plugins/iis/IISServerComponent.java +++ b/modules/plugins/iis/src/main/java/org/rhq/plugins/iis/IISServerComponent.java @@ -46,7 +46,8 @@ import org.rhq.plugins.iis.util.Win32ServiceControlDelegate; * @author Greg Hinkle * @author Joseph Marques */ -public class IISServerComponent implements ResourceComponent, MeasurementFacet, OperationFacet { +public class IISServerComponent<T extends ResourceComponent<?>> implements ResourceComponent<T>, MeasurementFacet, + OperationFacet {
private static final String WINDOWS_SERVICE_NAME = "W3SVC"; private static final long SERVICE_CONTROL_TIMEOUT = 30000L; diff --git a/modules/plugins/iis/src/main/java/org/rhq/plugins/iis/IISVHostComponent.java b/modules/plugins/iis/src/main/java/org/rhq/plugins/iis/IISVHostComponent.java index 9d264b9..8c2b92f 100644 --- a/modules/plugins/iis/src/main/java/org/rhq/plugins/iis/IISVHostComponent.java +++ b/modules/plugins/iis/src/main/java/org/rhq/plugins/iis/IISVHostComponent.java @@ -40,15 +40,15 @@ import org.rhq.core.pluginapi.util.ResponseTimeConfiguration; * @author Greg Hinkle * @author Joseph Marques */ -public class IISVHostComponent implements ResourceComponent<IISServerComponent>, MeasurementFacet { +public class IISVHostComponent implements ResourceComponent<IISServerComponent<?>>, MeasurementFacet {
- private ResourceContext<IISServerComponent> resourceContext; + private ResourceContext<IISServerComponent<?>> resourceContext; private IISResponseTimeDelegate responseTimeDelegate;
private Log log = LogFactory.getLog(IISVHostComponent.class);
- public void start(ResourceContext<IISServerComponent> resourceContext) throws InvalidPluginConfigurationException, - Exception { + public void start(ResourceContext<IISServerComponent<?>> resourceContext) + throws InvalidPluginConfigurationException, Exception { this.resourceContext = resourceContext;
String logDirectory = getLogDirectory(); @@ -59,7 +59,7 @@ public class IISVHostComponent implements ResourceComponent<IISServerComponent>, if (logFormat == null) { throw new InvalidPluginConfigurationException("The 'responseTimeLogFormat' property must be specified."); } - + responseTimeDelegate = new IISResponseTimeDelegate(logDirectory, logFormat, responseTimeConfiguration /*,collectionTZ.equals("true")*/); } diff --git a/modules/plugins/iis/src/main/java/org/rhq/plugins/iis/IISVHostDiscoveryComponent.java b/modules/plugins/iis/src/main/java/org/rhq/plugins/iis/IISVHostDiscoveryComponent.java index 0cd5cd8..be3bd15 100644 --- a/modules/plugins/iis/src/main/java/org/rhq/plugins/iis/IISVHostDiscoveryComponent.java +++ b/modules/plugins/iis/src/main/java/org/rhq/plugins/iis/IISVHostDiscoveryComponent.java @@ -38,13 +38,13 @@ import org.rhq.plugins.iis.util.IISMetaBase; * * @author Greg Hinkle */ -public class IISVHostDiscoveryComponent implements ResourceDiscoveryComponent<IISServerComponent> { +public class IISVHostDiscoveryComponent implements ResourceDiscoveryComponent<IISServerComponent<?>> {
private static final String PDH_WEB_SERVICE = "Web Service"; private static final String PDH_TOTAL = "_Total";
public Set<DiscoveredResourceDetails> discoverResources( - ResourceDiscoveryContext<IISServerComponent> resourceDiscoveryContext) + ResourceDiscoveryContext<IISServerComponent<?>> resourceDiscoveryContext) throws InvalidPluginConfigurationException, Exception {
List<String> vhosts = new ArrayList<String>(); diff --git a/modules/plugins/irc/src/main/java/org/rhq/plugins/irc/IRCServerComponent.java b/modules/plugins/irc/src/main/java/org/rhq/plugins/irc/IRCServerComponent.java index 5f169e8..b29293d 100644 --- a/modules/plugins/irc/src/main/java/org/rhq/plugins/irc/IRCServerComponent.java +++ b/modules/plugins/irc/src/main/java/org/rhq/plugins/irc/IRCServerComponent.java @@ -24,7 +24,7 @@ import org.jibble.pircbot.PircBot; /** * @author Greg Hinkle */ -public class IRCServerComponent implements ResourceComponent, OperationFacet { +public class IRCServerComponent implements ResourceComponent<ResourceComponent<?>>, OperationFacet { private final Log log = LogFactory.getLog(this.getClass());
private Bot bot; diff --git a/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/AbstractManagedComponent.java b/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/AbstractManagedComponent.java index bde5b37..d463007 100644 --- a/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/AbstractManagedComponent.java +++ b/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/AbstractManagedComponent.java @@ -30,35 +30,29 @@ import org.rhq.plugins.jbossas5.connection.ProfileServiceConnection; /** * @author Ian Springer */ -public abstract class AbstractManagedComponent implements ProfileServiceComponent<ProfileServiceComponent> -{ - private ResourceContext<ProfileServiceComponent> resourceContext; +public abstract class AbstractManagedComponent implements ProfileServiceComponent<ProfileServiceComponent<?>> { + private ResourceContext<ProfileServiceComponent<?>> resourceContext; private String resourceDescription;
- public void start(ResourceContext<ProfileServiceComponent> resourceContext) throws Exception - { + public void start(ResourceContext<ProfileServiceComponent<?>> resourceContext) throws Exception { this.resourceContext = resourceContext; - this.resourceDescription = this.resourceContext.getResourceType() - + " Resource with key [" + this.resourceContext.getResourceKey() + "]"; + this.resourceDescription = this.resourceContext.getResourceType() + " Resource with key [" + + this.resourceContext.getResourceKey() + "]"; }
- public void stop() - { + public void stop() { return; - } + }
- public ResourceContext<ProfileServiceComponent> getResourceContext() - { + public ResourceContext<ProfileServiceComponent<?>> getResourceContext() { return this.resourceContext; }
- public ProfileServiceConnection getConnection() - { + public ProfileServiceConnection getConnection() { return this.resourceContext.getParentResourceComponent().getConnection(); }
- protected String getResourceDescription() - { + protected String getResourceDescription() { return this.resourceDescription; }
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 1703036..f554f60 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 @@ -83,7 +83,7 @@ public abstract class AbstractManagedDeploymentComponent extends AbstractManaged
// ----------- ResourceComponent Implementation ------------
- public void start(ResourceContext<ProfileServiceComponent> resourceContext) throws Exception { + public void start(ResourceContext<ProfileServiceComponent<?>> resourceContext) throws Exception { super.start(resourceContext); Configuration pluginConfig = getResourceContext().getPluginConfiguration(); this.deploymentName = pluginConfig.getSimple(DEPLOYMENT_NAME_PROPERTY).getStringValue(); @@ -96,10 +96,9 @@ public abstract class AbstractManagedDeploymentComponent extends AbstractManaged try { getManagedDeployment(); } catch (Exception e) { - log - .warn("The underlying file [" - + this.deploymentFile - + "] no longer exists. It may have been deleted from the filesystem external to RHQ. If you wish to remove this Resource from inventory, you may add &debug=true to the URL for the Browse Resources > Services page and then click the UNINVENTORY button next to this Resource."); + log.warn("The underlying file [" + + this.deploymentFile + + "] no longer exists. It may have been deleted from the filesystem external to RHQ. If you wish to remove this Resource from inventory, you may add &debug=true to the URL for the Browse Resources > Services page and then click the UNINVENTORY button next to this Resource."); } }
@@ -112,16 +111,16 @@ public abstract class AbstractManagedDeploymentComponent extends AbstractManaged + e.getLocalizedMessage()); return AvailabilityType.DOWN; } catch (Throwable t) { - log.debug("Could not get deployment state for " + this.deploymentType + " deployment '" - + this.deploymentName + "', cause: ", t); + log.debug("Could not get deployment state for " + this.deploymentType + " deployment '" + + this.deploymentName + "', cause: ", t); return AvailabilityType.DOWN; }
if (deploymentState == DeploymentState.STARTED) { return AvailabilityType.UP; } else { - log.debug(this.deploymentType + " deployment '" + this.deploymentName + - "' was not running, state was: " + deploymentState); + log.debug(this.deploymentType + " deployment '" + this.deploymentName + "' was not running, state was: " + + deploymentState); return AvailabilityType.DOWN; } } diff --git a/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/AbstractManagedDeploymentDiscoveryComponent.java b/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/AbstractManagedDeploymentDiscoveryComponent.java index 9ab49b7..c3084fb 100644 --- a/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/AbstractManagedDeploymentDiscoveryComponent.java +++ b/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/AbstractManagedDeploymentDiscoveryComponent.java @@ -30,13 +30,19 @@ import java.util.Set;
import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; + +import org.jboss.deployers.spi.management.KnownDeploymentTypes; +import org.jboss.deployers.spi.management.ManagementView; import org.jboss.deployers.spi.management.deploy.DeploymentManager; import org.jboss.deployers.spi.management.deploy.DeploymentProgress; import org.jboss.deployers.spi.management.deploy.DeploymentStatus; import org.jboss.managed.api.DeploymentState; +import org.jboss.managed.api.ManagedDeployment; +import org.jboss.profileservice.spi.NoSuchDeploymentException; import org.jboss.profileservice.spi.Profile; import org.jboss.profileservice.spi.ProfileKey; import org.jboss.profileservice.spi.ProfileService; + import org.rhq.core.domain.configuration.PropertySimple; import org.rhq.core.domain.resource.ResourceType; import org.rhq.core.domain.resource.ResourceUpgradeReport; @@ -47,64 +53,54 @@ import org.rhq.core.pluginapi.upgrade.ResourceUpgradeContext; import org.rhq.core.pluginapi.upgrade.ResourceUpgradeFacet; import org.rhq.plugins.jbossas5.util.ConversionUtils;
-import org.jboss.deployers.spi.management.KnownDeploymentTypes; -import org.jboss.deployers.spi.management.ManagementView; -import org.jboss.managed.api.ManagedDeployment; -import org.jboss.profileservice.spi.NoSuchDeploymentException; - /** * Discovery component for discovering JBAS 5.x/6.x deployments (EARs, WARs, EJB-JARs, etc.). * * @author Mark Spritzler * @author Ian Springer */ -public abstract class AbstractManagedDeploymentDiscoveryComponent - implements ResourceDiscoveryComponent<ProfileServiceComponent>, ResourceUpgradeFacet<ProfileServiceComponent> -{ +public abstract class AbstractManagedDeploymentDiscoveryComponent implements + ResourceDiscoveryComponent<ProfileServiceComponent<?>>, ResourceUpgradeFacet<ProfileServiceComponent<?>> {
private final Log log = LogFactory.getLog(this.getClass());
public Set<DiscoveredResourceDetails> discoverResources( - ResourceDiscoveryContext<ProfileServiceComponent> discoveryContext) - { + ResourceDiscoveryContext<ProfileServiceComponent<?>> discoveryContext) { ResourceType resourceType = discoveryContext.getResourceType(); log.trace("Discovering " + resourceType.getName() + " Resources..."); KnownDeploymentTypes deploymentType = ConversionUtils.getDeploymentType(resourceType); String deploymentTypeString = deploymentType.getType();
- ManagementView managementView = discoveryContext.getParentResourceComponent().getConnection().getManagementView(); + ManagementView managementView = discoveryContext.getParentResourceComponent().getConnection() + .getManagementView(); // TODO (ips): Only refresh the ManagementView *once* per runtime discovery scan, rather than every time this // method is called. Do this by providing a runtime scan id in the ResourceDiscoveryContext. managementView.load();
Set<String> deploymentNames = null; - try - { + try { deploymentNames = managementView.getDeploymentNamesForType(deploymentTypeString); - } - catch (Exception e) - { + } catch (Exception e) { log.error("Unable to get deployment names for type " + deploymentTypeString, e); }
- Set<DiscoveredResourceDetails> discoveredResources = new HashSet<DiscoveredResourceDetails>(deploymentNames.size()); + Set<DiscoveredResourceDetails> discoveredResources = new HashSet<DiscoveredResourceDetails>( + deploymentNames.size());
- ProfileService profileService = discoveryContext.getParentResourceComponent().getConnection().getProfileService(); + ProfileService profileService = discoveryContext.getParentResourceComponent().getConnection() + .getProfileService();
// Create a resource details for each managed deployment found. - for (String deploymentName : deploymentNames) - { + for (String deploymentName : deploymentNames) { // example of a deployment name: vfszip:/C:/opt/jboss-6.0.0.Final/server/default/deploy/http-invoker.sar/invoker.war/ - try - { + try { ManagedDeployment managedDeployment = managementView.getDeployment(deploymentName); if (!accept(managedDeployment)) { continue; } String resourceName = managedDeployment.getSimpleName(); // @TODO remove this when AS5 actually implements this for sars, and some other DeploymentTypes that haven't implemented getSimpleName() - if (resourceName.equals("%Generated%")) - { + if (resourceName.equals("%Generated%")) { resourceName = getResourceName(deploymentName); }
@@ -113,26 +109,17 @@ public abstract class AbstractManagedDeploymentDiscoveryComponent
managedDeployment.getSimpleName(); String version = null; // TODO (ManagedDeployment "version" property?) - DiscoveredResourceDetails resource = - new DiscoveredResourceDetails(resourceType, - resourceKey, - resourceName, - version, - resourceType.getDescription(), - discoveryContext.getDefaultPluginConfiguration(), - null); + DiscoveredResourceDetails resource = new DiscoveredResourceDetails(resourceType, resourceKey, + resourceName, version, resourceType.getDescription(), + discoveryContext.getDefaultPluginConfiguration(), null); resource.getPluginConfiguration().put( - new PropertySimple(AbstractManagedDeploymentComponent.DEPLOYMENT_NAME_PROPERTY, deploymentName)); + new PropertySimple(AbstractManagedDeploymentComponent.DEPLOYMENT_NAME_PROPERTY, deploymentName)); discoveredResources.add(resource); - } - catch (NoSuchDeploymentException e) - { + } catch (NoSuchDeploymentException e) { // This is a bug in the profile service that occurs often, so don't log the stack trace. log.error("ManagementView.getDeploymentNamesForType() returned [" + deploymentName - + "] as a deployment name, but calling getDeployment() with that name failed."); - } - catch (Exception e) - { + + "] as a deployment name, but calling getDeployment() with that name failed."); + } catch (Exception e) { log.error("An error occurred while discovering " + resourceType + " Resources.", e); } } @@ -142,7 +129,7 @@ public abstract class AbstractManagedDeploymentDiscoveryComponent }
@Override - public ResourceUpgradeReport upgrade(ResourceUpgradeContext<ProfileServiceComponent> upgradeContext) { + public ResourceUpgradeReport upgrade(ResourceUpgradeContext<ProfileServiceComponent<?>> upgradeContext) { String inventoriedResourceKey = upgradeContext.getResourceKey();
// check if the inventoried resource already has the new resource key format. @@ -182,8 +169,7 @@ public abstract class AbstractManagedDeploymentDiscoveryComponent deploymentAncestrySimpleNames.add(0, parentDeployment.getSimpleName()); } while ((parentDeployment = parentDeployment.getParent()) != null);
- for (int i = 0, deploymentAncestrySimpleNamesSize = deploymentAncestrySimpleNames.size(); - i < deploymentAncestrySimpleNamesSize; i++) { + for (int i = 0, deploymentAncestrySimpleNamesSize = deploymentAncestrySimpleNames.size(); i < deploymentAncestrySimpleNamesSize; i++) { String deploymentSimpleName = deploymentAncestrySimpleNames.get(i); resourceKey.append(deploymentSimpleName); if (i != (deploymentAncestrySimpleNamesSize - 1)) { @@ -234,8 +220,7 @@ public abstract class AbstractManagedDeploymentDiscoveryComponent
protected abstract boolean accept(ManagedDeployment managedDeployment);
- private static String getResourceName(String fullPath) - { + private static String getResourceName(String fullPath) { int lastSlashIndex = fullPath.lastIndexOf("/"); return fullPath.substring(lastSlashIndex + 1); } 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 5bacccb..299bdcd 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 @@ -100,8 +100,9 @@ import org.rhq.plugins.jbossas5.util.ManagedComponentUtils; * @author Mark Spritzler * @author Ian Springer */ -public class ApplicationServerComponent implements ResourceComponent, ProfileServiceComponent, - CreateChildResourceFacet, MeasurementFacet, ConfigurationFacet, ProgressListener, ContentFacet, OperationFacet { +public class ApplicationServerComponent<T extends ResourceComponent<?>> implements ResourceComponent<T>, + ProfileServiceComponent<T>, CreateChildResourceFacet, MeasurementFacet, ConfigurationFacet, ProgressListener, + ContentFacet, OperationFacet {
private static final Pattern METRIC_NAME_PATTERN = Pattern.compile("(.*)\|(.*)\|(.*)\|(.*)");
@@ -148,8 +149,8 @@ public class ApplicationServerComponent implements ResourceComponent, ProfileSer //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(); + ManagedComponent serverConfig = managementView + .getComponentsForType(new ComponentType("MCBean", "ServerConfig")).iterator().next();
String reportedServerHomeDirPath = (String) ((SimpleValue) serverConfig.getProperty("serverHomeDir") .getValue()).getValue(); @@ -464,8 +465,8 @@ public class ApplicationServerComponent implements ResourceComponent, ProfileSer public OperationResult invokeOperation(String name, Configuration parameters) throws InterruptedException, Exception {
- ApplicationServerSupportedOperations operation = Enum.valueOf(ApplicationServerSupportedOperations.class, name - .toUpperCase()); + ApplicationServerSupportedOperations operation = Enum.valueOf(ApplicationServerSupportedOperations.class, + name.toUpperCase()); return this.operationDelegate.invoke(operation, parameters); }
@@ -509,8 +510,8 @@ public class ApplicationServerComponent implements ResourceComponent, ProfileSer private JBPMWorkflowManager createJbpmWorkflowManager(ResourceContext resourceContext) { ContentContext contentContext = resourceContext.getContentContext(); ControlActionFacade controlActionFacade = initControlActionFacade(); - JBPMWorkflowManager workflowManager = new JBPMWorkflowManager(contentContext, controlActionFacade, this - .getJBossASPaths()); + JBPMWorkflowManager workflowManager = new JBPMWorkflowManager(contentContext, controlActionFacade, + this.getJBossASPaths()); return workflowManager; }
diff --git a/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/JBossMessagingComponent.java b/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/JBossMessagingComponent.java index af47587..e864117 100644 --- a/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/JBossMessagingComponent.java +++ b/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/JBossMessagingComponent.java @@ -22,6 +22,8 @@ */ package org.rhq.plugins.jbossas5;
+import java.util.Set; + import org.rhq.core.domain.measurement.AvailabilityType; import org.rhq.core.domain.measurement.MeasurementReport; import org.rhq.core.domain.measurement.MeasurementScheduleRequest; @@ -31,23 +33,21 @@ import org.rhq.core.pluginapi.inventory.ResourceContext; import org.rhq.core.pluginapi.measurement.MeasurementFacet; import org.rhq.plugins.jbossas5.helper.CreateChildResourceFacetDelegate;
-import java.util.Set; - /** * The ResourceComponent for the singleton JBoss Messaging ResourceType, which supports creation of two child * ResourceTypes - Queue and Topic. * * @author Ian Springer */ -public class JBossMessagingComponent extends ManagedComponentComponent - implements CreateChildResourceFacet, MeasurementFacet { +public class JBossMessagingComponent extends ManagedComponentComponent implements CreateChildResourceFacet, + MeasurementFacet { private CreateChildResourceFacetDelegate createChildResourceDelegate;
public AvailabilityType getAvailability() { return super.getAvailability(); }
- public void start(ResourceContext resourceContext) throws Exception { + public void start(ResourceContext<ProfileServiceComponent<?>> resourceContext) throws Exception { super.start(resourceContext); this.createChildResourceDelegate = new CreateChildResourceFacetDelegate(this); } diff --git a/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/JBossMessagingDiscoveryComponent.java b/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/JBossMessagingDiscoveryComponent.java index a88ac44..b953599 100644 --- a/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/JBossMessagingDiscoveryComponent.java +++ b/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/JBossMessagingDiscoveryComponent.java @@ -34,11 +34,11 @@ import java.util.Set; * * @author Ian Springer */ -public class JBossMessagingDiscoveryComponent extends ManagedComponentDiscoveryComponent<ApplicationServerComponent> { +public class JBossMessagingDiscoveryComponent extends ManagedComponentDiscoveryComponent<ApplicationServerComponent<?>> { private static final String DEFAULT_RESOURCE_NAME = "JBoss Messaging";
@Override - public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext<ApplicationServerComponent> discoveryContext) + public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext<ApplicationServerComponent<?>> discoveryContext) throws Exception { return super.discoverResources(discoveryContext); } diff --git a/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/JBossWebComponent.java b/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/JBossWebComponent.java index 9ac7274..2cdce10 100644 --- a/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/JBossWebComponent.java +++ b/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/JBossWebComponent.java @@ -23,42 +23,38 @@ package org.rhq.plugins.jbossas5;
import org.jetbrains.annotations.NotNull; +import org.mc4j.ems.connection.EmsConnection; + import org.rhq.core.domain.measurement.AvailabilityType; import org.rhq.core.pluginapi.inventory.ResourceContext; import org.rhq.plugins.jbossas5.connection.ProfileServiceConnection; -import org.mc4j.ems.connection.EmsConnection;
/** * A ResourceComponent for managing the JBoss Web servlet container within a JBoss AS instance. * * @author Ian Springer */ -public class JBossWebComponent implements ProfileServiceComponent<ProfileServiceComponent> -{ - private ResourceContext<ProfileServiceComponent> resourceContext; +public class JBossWebComponent implements ProfileServiceComponent<ProfileServiceComponent<?>> { + private ResourceContext<ProfileServiceComponent<?>> resourceContext;
- public void start(ResourceContext<ProfileServiceComponent> resourceContext) throws Exception - { + public void start(ResourceContext<ProfileServiceComponent<?>> resourceContext) throws Exception { this.resourceContext = resourceContext; }
- public void stop() - { + public void stop() { return; }
- public AvailabilityType getAvailability() - { + public AvailabilityType getAvailability() { return AvailabilityType.UP; }
@NotNull - public ResourceContext<ProfileServiceComponent> getResourceContext() { + public ResourceContext<ProfileServiceComponent<?>> getResourceContext() { return this.resourceContext; }
- public ProfileServiceConnection getConnection() - { + public ProfileServiceConnection getConnection() { return this.resourceContext.getParentResourceComponent().getConnection(); }
diff --git a/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/JBossWebDiscoveryComponent.java b/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/JBossWebDiscoveryComponent.java index bdabf9d..1e19e4e 100644 --- a/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/JBossWebDiscoveryComponent.java +++ b/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/JBossWebDiscoveryComponent.java @@ -37,12 +37,12 @@ import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext; * * @author Ian Springer */ -public class JBossWebDiscoveryComponent implements ResourceDiscoveryComponent<ProfileServiceComponent> +public class JBossWebDiscoveryComponent implements ResourceDiscoveryComponent<ProfileServiceComponent<?>> { private final Log log = LogFactory.getLog(this.getClass());
public Set<DiscoveredResourceDetails> discoverResources( - ResourceDiscoveryContext<ProfileServiceComponent> discoveryContext) + ResourceDiscoveryContext<ProfileServiceComponent<?>> discoveryContext) { Set<DiscoveredResourceDetails> discoveredResources = new HashSet<DiscoveredResourceDetails>(); ResourceType resourceType = discoveryContext.getResourceType(); diff --git a/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/JmsDestinationDiscoveryComponent.java b/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/JmsDestinationDiscoveryComponent.java index 43a1722..02c5bed 100644 --- a/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/JmsDestinationDiscoveryComponent.java +++ b/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/JmsDestinationDiscoveryComponent.java @@ -31,7 +31,7 @@ import org.rhq.plugins.jbossas5.util.ManagedComponentUtils; * * @author Ian Springer */ -public class JmsDestinationDiscoveryComponent extends ManagedComponentDiscoveryComponent<ApplicationServerComponent> { +public class JmsDestinationDiscoveryComponent extends ManagedComponentDiscoveryComponent<ApplicationServerComponent<?>> { private static final String NAME_MANAGED_PROPERTY = "name";
@Override 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 bca27da..23f8b2d 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 @@ -129,7 +129,7 @@ public class ManagedComponentComponent extends AbstractManagedComponent implemen } }
- public void start(ResourceContext<ProfileServiceComponent> resourceContext) throws Exception { + public void start(ResourceContext<ProfileServiceComponent<?>> resourceContext) throws Exception { super.start(resourceContext); this.componentType = ConversionUtils.getComponentType(getResourceContext().getResourceType()); Configuration pluginConfig = resourceContext.getPluginConfiguration(); @@ -271,8 +271,8 @@ public class ManagedComponentComponent extends AbstractManagedComponent implemen 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)))); + runtimeMetricMap.put(request.getName(), + Boolean.valueOf((null == managedProp || managedProp.hasViewUse(ViewUse.RUNTIME)))); }
if (Boolean.FALSE.equals(runtimeMetricMap.get(request.getName()))) { @@ -284,7 +284,7 @@ public class ManagedComponentComponent extends AbstractManagedComponent implemen
return getManagedComponent(forceRefresh); } - + protected String getMeasurement(ManagedComponent component, String metricName) throws Exception { if ("runState".equals(metricName)) { return component.getRunState().name(); @@ -293,7 +293,7 @@ public class ManagedComponentComponent extends AbstractManagedComponent implemen return value == null ? null : toString(value); } } - + protected void updateComponent(ManagedComponent managedComponent) throws Exception { log.trace("Updating " + getResourceDescription() + " with component " + toString(managedComponent) + "..."); ManagementView managementView = getConnection().getManagementView(); @@ -340,7 +340,7 @@ 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/> diff --git a/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/ManagedComponentDiscoveryComponent.java b/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/ManagedComponentDiscoveryComponent.java index a0a62ea..573f62c 100644 --- a/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/ManagedComponentDiscoveryComponent.java +++ b/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/ManagedComponentDiscoveryComponent.java @@ -27,9 +27,11 @@ import java.util.Set;
import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; + import org.jboss.deployers.spi.management.ManagementView; import org.jboss.managed.api.ComponentType; import org.jboss.managed.api.ManagedComponent; + import org.rhq.core.domain.configuration.PropertySimple; import org.rhq.core.domain.resource.ResourceType; import org.rhq.core.pluginapi.inventory.DiscoveredResourceDetails; @@ -45,7 +47,7 @@ import org.rhq.plugins.jbossas5.util.ConversionUtils; * @author Mark Spritzer * @author Ian Springer */ -public class ManagedComponentDiscoveryComponent<P extends ProfileServiceComponent> implements +public class ManagedComponentDiscoveryComponent<P extends ProfileServiceComponent<?>> implements ResourceDiscoveryComponent<P> { private final Log log = LogFactory.getLog(this.getClass());
@@ -68,9 +70,8 @@ public class ManagedComponentDiscoveryComponent<P extends ProfileServiceComponen throw new IllegalStateException("Failed to get component types for " + resourceType + ".", e); } if (resourceType.isSingleton() && components.size() > 1) { - throw new IllegalStateException("Discovered multiple [" + componentType - + "] managed components during [" + resourceType - + "] discovery, but expected to find no more than one - components were: " + components); + throw new IllegalStateException("Discovered multiple [" + componentType + "] managed components during [" + + resourceType + "] discovery, but expected to find no more than one - components were: " + components); }
Set<DiscoveredResourceDetails> discoveredResources = new HashSet<DiscoveredResourceDetails>(components.size()); @@ -92,8 +93,8 @@ public class ManagedComponentDiscoveryComponent<P extends ProfileServiceComponen String version = getResourceVersion(component);
DiscoveredResourceDetails resource = new DiscoveredResourceDetails(resourceType, resourceKey, - resourceName, version, resourceType.getDescription(), discoveryContext - .getDefaultPluginConfiguration(), null); + resourceName, version, resourceType.getDescription(), + discoveryContext.getDefaultPluginConfiguration(), null);
resource.getPluginConfiguration().put( new PropertySimple(ManagedComponentComponent.Config.COMPONENT_NAME, resourceKey)); diff --git a/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/ManagedDeploymentDiscoveryComponent.java b/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/ManagedDeploymentDiscoveryComponent.java index 946120d..edac239 100644 --- a/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/ManagedDeploymentDiscoveryComponent.java +++ b/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/ManagedDeploymentDiscoveryComponent.java @@ -45,12 +45,12 @@ import org.jboss.profileservice.spi.NoSuchDeploymentException; * @author Mark Spritzler * @author Ian Springer */ -public abstract class ManagedDeploymentDiscoveryComponent implements ResourceDiscoveryComponent<ApplicationServerComponent> +public abstract class ManagedDeploymentDiscoveryComponent implements ResourceDiscoveryComponent<ApplicationServerComponent<?>> { private final Log log = LogFactory.getLog(this.getClass());
public Set<DiscoveredResourceDetails> discoverResources( - ResourceDiscoveryContext<ApplicationServerComponent> discoveryContext) + ResourceDiscoveryContext<ApplicationServerComponent<?>> discoveryContext) { Set<DiscoveredResourceDetails> discoveredResources = new HashSet<DiscoveredResourceDetails>(); ResourceType resourceType = discoveryContext.getResourceType(); diff --git a/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/PlatformComponent.java b/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/PlatformComponent.java index 2c8e6d9..acfdb06 100644 --- a/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/PlatformComponent.java +++ b/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/PlatformComponent.java @@ -7,6 +7,9 @@ import java.util.Set;
import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.jetbrains.annotations.NotNull; +import org.mc4j.ems.connection.EmsConnection; + import org.jboss.deployers.spi.management.ManagementView; import org.jboss.managed.api.ManagedComponent; import org.jboss.managed.api.ManagedDeployment; @@ -16,7 +19,7 @@ import org.jboss.managed.api.ManagedProperty; import org.jboss.metatype.api.types.MetaType; import org.jboss.metatype.api.values.MetaValue; import org.jboss.profileservice.spi.NoSuchDeploymentException; -import org.jetbrains.annotations.NotNull; + import org.rhq.core.domain.configuration.Configuration; import org.rhq.core.domain.measurement.AvailabilityType; import org.rhq.core.domain.measurement.DataType; @@ -40,240 +43,214 @@ import org.rhq.plugins.jbossas5.adapter.impl.measurement.SimpleMetaValueMeasurem import org.rhq.plugins.jbossas5.connection.ProfileServiceConnection; import org.rhq.plugins.jbossas5.util.ConversionUtils; import org.rhq.plugins.jbossas5.util.ResourceTypeUtils; -import org.mc4j.ems.connection.EmsConnection;
-public class PlatformComponent implements - ProfileServiceComponent<ProfileServiceComponent>, MeasurementFacet, - OperationFacet, ConfigurationFacet { - private final Log log = LogFactory.getLog(this.getClass()); - private ResourceContext<ProfileServiceComponent> context; - private String deployName; - private String componentName; +public class PlatformComponent implements ProfileServiceComponent<ProfileServiceComponent<?>>, MeasurementFacet, + OperationFacet, ConfigurationFacet { + private final Log log = LogFactory.getLog(this.getClass()); + private ResourceContext<ProfileServiceComponent<?>> context; + private String deployName; + private String componentName;
- public PlatformComponent() { - } + public PlatformComponent() { + }
- public void start(ResourceContext<ProfileServiceComponent> context) - throws InvalidPluginConfigurationException, Exception { - this.context = context; - } + public void start(ResourceContext<ProfileServiceComponent<?>> context) throws InvalidPluginConfigurationException, + Exception { + this.context = context; + }
- public void stop() { - return; - } + public void stop() { + return; + }
@NotNull - public ResourceContext<ProfileServiceComponent> getResourceContext() { + public ResourceContext<ProfileServiceComponent<?>> getResourceContext() { return this.context; }
public ProfileServiceConnection getConnection() { - ApplicationServerComponent component = (ApplicationServerComponent) context - .getParentResourceComponent(); - return component.getConnection(); + ApplicationServerComponent component = (ApplicationServerComponent) context.getParentResourceComponent(); + return component.getConnection();
- } + }
public EmsConnection getEmsConnection() { return context.getParentResourceComponent().getEmsConnection(); }
public CreateResourceReport createResource(CreateResourceReport report) { - // TODO Auto-generated method stub - return null; - } + // TODO Auto-generated method stub + return null; + } + + // ------------ MeasurementFacet Implementation ------------ + + public void getValues(MeasurementReport report, Set<MeasurementScheduleRequest> requests) { + try { + ManagedComponent component = loadComponent(); + String[] propertyName;
- // ------------ MeasurementFacet Implementation ------------ + for (MeasurementScheduleRequest request : requests) { + String metricName = request.getName();
- public void getValues(MeasurementReport report, - Set<MeasurementScheduleRequest> requests) { - try { - ManagedComponent component = loadComponent(); - String[] propertyName; + propertyName = parsePropertyName(metricName); + if (propertyName.length == 0) + continue;
- for (MeasurementScheduleRequest request : requests) { - String metricName = request.getName(); + ManagedProperty prop = component.getProperties().get(propertyName[0]);
- propertyName = parsePropertyName(metricName); - if (propertyName.length == 0) - continue; + if (prop != null) { + MetaType type = prop.getMetaType(); + MetaValue value = prop.getValue();
- ManagedProperty prop = component.getProperties().get( - propertyName[0]); + if (value != null) { + MeasurementDefinition measurementDefinition = ResourceTypeUtils.getMeasurementDefinition( + context.getResourceType(), metricName);
- if (prop != null) { - MetaType type = prop.getMetaType(); - MetaValue value = prop.getValue(); + if (type.isSimple()) { + MeasurementAdapter measurementAdapter = new SimpleMetaValueMeasurementAdapter(); + if (measurementDefinition != null & measurementAdapter != null) + measurementAdapter.setMeasurementData(report, value, request, measurementDefinition); + } + if (type.isComposite()) {
- if (value != null) { - MeasurementDefinition measurementDefinition = ResourceTypeUtils - .getMeasurementDefinition(context - .getResourceType(), metricName); + ManagedObject obj = prop.getManagedObject(); + Object attachment = obj.getAttachment(); + + for (int i = 0; i < propertyName.length; i++) { + attachment = getObjectProperty(attachment, propertyName[i]); + } + + setMeasurementData(report, attachment, request, measurementDefinition); + + } + + } + } + } + + } catch (NoSuchDeploymentException e) { + log.error("Loaded component does not exist: " + e); + } catch (SecurityException e) { + log.error("Security Exception: " + e); + + } + } + + public Configuration loadResourceConfiguration() throws Exception { + // TODO Auto-generated method stub + return null; + } + + public void updateResourceConfiguration(ConfigurationUpdateReport report) { + // TODO Auto-generated method stub + + }
- if (type.isSimple()) { - MeasurementAdapter measurementAdapter = new SimpleMetaValueMeasurementAdapter(); - if (measurementDefinition != null - & measurementAdapter != null) - measurementAdapter.setMeasurementData(report, - value, request, measurementDefinition); - } - if (type.isComposite()) { + private ManagedComponent loadComponent() throws NoSuchDeploymentException {
- ManagedObject obj = prop.getManagedObject(); - Object attachment = obj.getAttachment(); + deployName = context.getPluginConfiguration().getSimple(PlatformDiscoveryComponent.PLATFORM_DEPLOYMENT_NAME) + .getStringValue();
- for (int i = 0; i < propertyName.length; i++) { - attachment = getObjectProperty(attachment, - propertyName[i]); - } - - setMeasurementData(report, attachment, request, - measurementDefinition); - - } - - } - } - } - - } catch (NoSuchDeploymentException e) { - log.error("Loaded component does not exist: " + e); - } catch (SecurityException e) { - log.error("Security Exception: " + e); - - } - } - - public Configuration loadResourceConfiguration() throws Exception { - // TODO Auto-generated method stub - return null; - } - - public void updateResourceConfiguration(ConfigurationUpdateReport report) { - // TODO Auto-generated method stub - - } - - private ManagedComponent loadComponent() throws NoSuchDeploymentException { - - deployName = context.getPluginConfiguration().getSimple( - PlatformDiscoveryComponent.PLATFORM_DEPLOYMENT_NAME) - .getStringValue(); - - componentName = context.getPluginConfiguration().getSimple( - PlatformDiscoveryComponent.PLATFORM_COMPONENT_NAME) - .getStringValue(); - - ProfileServiceConnection connection = context - .getParentResourceComponent().getConnection(); - - ManagementView managementView = connection.getManagementView(); - - ManagedDeployment deploy = managementView.getDeployment(deployName); - if (deploy != null) { - Map<String, ManagedComponent> components = deploy.getComponents(); - - return components.get(componentName); - } - - return null; - } - - public AvailabilityType getAvailability() { - // TODO Auto-generated method stub - return null; - } - - public String[] parsePropertyName(String name) { - - String[] ps; - - if (name.indexOf('{') == -1) { - ps = new String[1]; - ps[0] = name; - return ps; - } - name = name.substring(name.indexOf('{') + 1, name.indexOf('}')); - ps = name.split("\."); - - return ps; - } - - protected Object getObjectProperty(Object value, String property) { - - try { - PropertyDescriptor[] pds = Introspector.getBeanInfo( - value.getClass()).getPropertyDescriptors(); - for (PropertyDescriptor pd : pds) { - if (pd.getName().equals(property)) { - pd.getReadMethod().setAccessible(true); - value = pd.getReadMethod().invoke(value); - } - } - } catch (Exception e) { - log.error("Object " + value.toString() - + " does not contain property " + property, e); - } - - return value; - } - - public void setMeasurementData(MeasurementReport report, Object value, - MeasurementScheduleRequest request, - MeasurementDefinition measurementDefinition) { - - DataType dataType = measurementDefinition.getDataType(); - switch (dataType) { - case MEASUREMENT: - try { - MeasurementDataNumeric dataNumeric = new MeasurementDataNumeric( - request, new Double(value.toString())); - report.addData(dataNumeric); - } catch (NumberFormatException e) { - log - .warn( - "Measurement request: " - + request.getName() - + " did not return a numeric value from the Profile Service", - e); - } - break; - case TRAIT: - MeasurementDataTrait dataTrait = new MeasurementDataTrait(request, - String.valueOf(value)); - report.addData(dataTrait); - break; - default: - throw new IllegalStateException( - "Unsupported measurement data type: " + dataType); - } - } - - public OperationResult invokeOperation(String name, Configuration parameters) - throws InterruptedException, Exception { - - ResourceType resourceType = context.getResourceType(); - OperationDefinition operationDefinition = ResourceTypeUtils - .getOperationDefinition(resourceType, name); - - ManagedComponent component = loadComponent(); - Set<ManagedOperation> operations = component.getOperations(); - - for (ManagedOperation operation : operations) { - if (operation.getName().equals(name)) { - MetaValue[] params = ConversionUtils - .convertOperationsParametersToMetaValues(operation, - parameters, operationDefinition); - MetaValue operationResult = operation.invoke(params); - - OperationResult result = new OperationResult(); - ConversionUtils.convertManagedOperationResults(operation, - operationResult, result.getComplexResults(), - operationDefinition); - - return result; - } - } - return null; - } + componentName = context.getPluginConfiguration().getSimple(PlatformDiscoveryComponent.PLATFORM_COMPONENT_NAME) + .getStringValue(); + + ProfileServiceConnection connection = context.getParentResourceComponent().getConnection(); + + ManagementView managementView = connection.getManagementView(); + + ManagedDeployment deploy = managementView.getDeployment(deployName); + if (deploy != null) { + Map<String, ManagedComponent> components = deploy.getComponents(); + + return components.get(componentName); + } + + return null; + } + + public AvailabilityType getAvailability() { + // TODO Auto-generated method stub + return null; + } + + public String[] parsePropertyName(String name) { + + String[] ps; + + if (name.indexOf('{') == -1) { + ps = new String[1]; + ps[0] = name; + return ps; + } + name = name.substring(name.indexOf('{') + 1, name.indexOf('}')); + ps = name.split("\."); + + return ps; + } + + protected Object getObjectProperty(Object value, String property) { + + try { + PropertyDescriptor[] pds = Introspector.getBeanInfo(value.getClass()).getPropertyDescriptors(); + for (PropertyDescriptor pd : pds) { + if (pd.getName().equals(property)) { + pd.getReadMethod().setAccessible(true); + value = pd.getReadMethod().invoke(value); + } + } + } catch (Exception e) { + log.error("Object " + value.toString() + " does not contain property " + property, e); + } + + return value; + } + + public void setMeasurementData(MeasurementReport report, Object value, MeasurementScheduleRequest request, + MeasurementDefinition measurementDefinition) { + + DataType dataType = measurementDefinition.getDataType(); + switch (dataType) { + case MEASUREMENT: + try { + MeasurementDataNumeric dataNumeric = new MeasurementDataNumeric(request, new Double(value.toString())); + report.addData(dataNumeric); + } catch (NumberFormatException e) { + log.warn("Measurement request: " + request.getName() + + " did not return a numeric value from the Profile Service", e); + } + break; + case TRAIT: + MeasurementDataTrait dataTrait = new MeasurementDataTrait(request, String.valueOf(value)); + report.addData(dataTrait); + break; + default: + throw new IllegalStateException("Unsupported measurement data type: " + dataType); + } + } + + public OperationResult invokeOperation(String name, Configuration parameters) throws InterruptedException, + Exception { + + ResourceType resourceType = context.getResourceType(); + OperationDefinition operationDefinition = ResourceTypeUtils.getOperationDefinition(resourceType, name); + + ManagedComponent component = loadComponent(); + Set<ManagedOperation> operations = component.getOperations(); + + for (ManagedOperation operation : operations) { + if (operation.getName().equals(name)) { + MetaValue[] params = ConversionUtils.convertOperationsParametersToMetaValues(operation, parameters, + operationDefinition); + MetaValue operationResult = operation.invoke(params); + + OperationResult result = new OperationResult(); + ConversionUtils.convertManagedOperationResults(operation, operationResult, result.getComplexResults(), + operationDefinition); + + return result; + } + } + return null; + } } diff --git a/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/PlatformDiscoveryComponent.java b/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/PlatformDiscoveryComponent.java index eddbd23..d930ebf 100644 --- a/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/PlatformDiscoveryComponent.java +++ b/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/PlatformDiscoveryComponent.java @@ -5,11 +5,13 @@ import java.util.Set;
import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; + import org.jboss.deployers.spi.management.ManagementView; import org.jboss.managed.api.ComponentType; import org.jboss.managed.api.ManagedComponent; import org.jboss.managed.api.ManagedDeployment; import org.jboss.profileservice.spi.NoSuchDeploymentException; + import org.rhq.core.domain.configuration.Configuration; import org.rhq.core.domain.configuration.PropertySimple; import org.rhq.core.domain.resource.ResourceType; @@ -20,98 +22,82 @@ import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext; import org.rhq.plugins.jbossas5.connection.ProfileServiceConnection; import org.rhq.plugins.jbossas5.util.ManagedComponentUtils;
-public class PlatformDiscoveryComponent implements - ResourceDiscoveryComponent<ApplicationServerComponent> { +public class PlatformDiscoveryComponent implements ResourceDiscoveryComponent<ApplicationServerComponent<?>> {
- private final Log log = LogFactory.getLog(this.getClass()); - public static String PLATFORM_DEPLOYMENT_NAME = "deployment"; - public static String PLATFORM_COMPONENT_NAME = "componentName"; + private final Log log = LogFactory.getLog(this.getClass()); + public static String PLATFORM_DEPLOYMENT_NAME = "deployment"; + public static String PLATFORM_COMPONENT_NAME = "componentName";
- public Set discoverResources( - ResourceDiscoveryContext<ApplicationServerComponent> context) - throws InvalidPluginConfigurationException, Exception { + public Set discoverResources(ResourceDiscoveryContext<ApplicationServerComponent<?>> context) + throws InvalidPluginConfigurationException, Exception {
- log.trace("Discovering " + context.getResourceType().getName() - + " Resources..."); + log.trace("Discovering " + context.getResourceType().getName() + " Resources...");
- Set<DiscoveredResourceDetails> resources = new HashSet<DiscoveredResourceDetails>(); - ResourceType resourceType = context.getResourceType(); + Set<DiscoveredResourceDetails> resources = new HashSet<DiscoveredResourceDetails>(); + ResourceType resourceType = context.getResourceType();
- Set<ManagedComponent> components = new HashSet<ManagedComponent>(); + Set<ManagedComponent> components = new HashSet<ManagedComponent>();
- Configuration config = context.getDefaultPluginConfiguration(); + Configuration config = context.getDefaultPluginConfiguration();
- String deployName = config.getSimple( - PlatformDiscoveryComponent.PLATFORM_DEPLOYMENT_NAME) - .getStringValue(); + String deployName = config.getSimple(PlatformDiscoveryComponent.PLATFORM_DEPLOYMENT_NAME).getStringValue();
- String componentName = config.getSimple( - PlatformDiscoveryComponent.PLATFORM_COMPONENT_NAME) - .getStringValue(); + String componentName = config.getSimple(PlatformDiscoveryComponent.PLATFORM_COMPONENT_NAME).getStringValue();
- components.addAll(addManagedDeploymentComponent(deployName, - componentName, context)); + components.addAll(addManagedDeploymentComponent(deployName, componentName, context));
- for (ManagedComponent component : components) { + for (ManagedComponent component : components) {
- ComponentType type = component.getType(); - String displayName; + ComponentType type = component.getType(); + String displayName;
- try { - displayName = (String) ManagedComponentUtils - .getSimplePropertyValue(component, "name"); - } catch (IllegalStateException il) { - displayName = component.getName(); - } + try { + displayName = (String) ManagedComponentUtils.getSimplePropertyValue(component, "name"); + } catch (IllegalStateException il) { + displayName = component.getName(); + }
- try { - String resourceName = (String) component.getName(); + try { + String resourceName = (String) component.getName();
- String resourceKey = component.getType() + "|" - + type.getSubtype() + "|" + resourceName; + String resourceKey = component.getType() + "|" + type.getSubtype() + "|" + resourceName;
- String version = ""; - Configuration pluginConfig = new Configuration(); - pluginConfig.put(new PropertySimple(PLATFORM_DEPLOYMENT_NAME, - deployName)); - pluginConfig.put(new PropertySimple(PLATFORM_COMPONENT_NAME, - resourceName)); + String version = ""; + Configuration pluginConfig = new Configuration(); + pluginConfig.put(new PropertySimple(PLATFORM_DEPLOYMENT_NAME, deployName)); + pluginConfig.put(new PropertySimple(PLATFORM_COMPONENT_NAME, resourceName));
- resources.add(new DiscoveredResourceDetails(context - .getResourceType(), resourceKey, displayName, version, - resourceType.getDescription(), pluginConfig, null)); - } catch (Exception e) { - log.error("failed discovering the platform Mbeans", e); - } - } + resources.add(new DiscoveredResourceDetails(context.getResourceType(), resourceKey, displayName, + version, resourceType.getDescription(), pluginConfig, null)); + } catch (Exception e) { + log.error("failed discovering the platform Mbeans", e); + } + }
- return resources; - } + return resources; + }
- private Set<ManagedComponent> addManagedDeploymentComponent( - String deployName, String componentName, - ResourceDiscoveryContext<ApplicationServerComponent> context) - throws NoSuchDeploymentException { + private Set<ManagedComponent> addManagedDeploymentComponent(String deployName, String componentName, + ResourceDiscoveryContext<ApplicationServerComponent<?>> context) throws NoSuchDeploymentException {
- ProfileServiceConnection connection = context - .getParentResourceComponent().getConnection(); + ProfileServiceConnection connection = context.getParentResourceComponent().getConnection();
- ManagementView managementView = connection.getManagementView(); + ManagementView managementView = connection.getManagementView();
- Set<ManagedComponent> components = new HashSet<ManagedComponent>(); - ManagedDeployment deploy = managementView.getDeployment(deployName); - if (deploy != null) { - if (componentName == null || componentName.equals("*")) - components.addAll(deploy.getComponents().values()); - else { - for (ManagedComponent comp : deploy.getComponents().values()) { - if (comp.getName().equals(componentName)) - components.add(comp); - } - } - } + Set<ManagedComponent> components = new HashSet<ManagedComponent>(); + ManagedDeployment deploy = managementView.getDeployment(deployName); + if (deploy != null) { + if (componentName == null || componentName.equals("*")) + components.addAll(deploy.getComponents().values()); + else { + for (ManagedComponent comp : deploy.getComponents().values()) { + if (comp.getName().equals(componentName)) + components.add(comp); + } + } + }
- return components; - } + return components; + }
} diff --git a/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/ProfileServiceComponent.java b/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/ProfileServiceComponent.java index 4e13a96..afd73a3 100644 --- a/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/ProfileServiceComponent.java +++ b/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/ProfileServiceComponent.java @@ -33,7 +33,7 @@ import org.rhq.plugins.jmx.JMXComponent; /** * @author Ian Springer */ -public interface ProfileServiceComponent<T extends ResourceComponent> extends ResourceComponent<T>, JMXComponent<T> { +public interface ProfileServiceComponent<T extends ResourceComponent<?>> extends ResourceComponent<T>, JMXComponent<T> { @Nullable ProfileServiceConnection getConnection();
diff --git a/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/WebApplicationContextComponent.java b/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/WebApplicationContextComponent.java index 9c5f938..0d96b2b 100644 --- a/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/WebApplicationContextComponent.java +++ b/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/WebApplicationContextComponent.java @@ -23,7 +23,6 @@ package org.rhq.plugins.jbossas5;
import java.io.File; -import java.util.LinkedHashSet; import java.util.Set;
import org.apache.commons.logging.Log; @@ -53,8 +52,7 @@ import org.rhq.plugins.jbossas5.util.ResourceComponentUtils; * * @author Ian Springer */ -public class WebApplicationContextComponent extends ManagedComponentComponent -{ +public class WebApplicationContextComponent extends ManagedComponentComponent { public static final String VIRTUAL_HOST_PROPERTY = "virtualHost"; public static final String CONTEXT_PATH_PROPERTY = "contextPath";
@@ -65,12 +63,10 @@ public class WebApplicationContextComponent extends ManagedComponentComponent
private static final String CLUSTERED_TRAIT = "clustered"; private static final String DISTRIBUTABLE_MANAGED_PROPERTY = "Distributable"; - + // A regex for the names of all MBean:Servlet components for a WAR. - private static final String SERVLET_COMPONENT_NAMES_REGEX_TEMPLATE = - "jboss.web:J2EEApplication=none,J2EEServer=none," - + "WebModule=//%" + VIRTUAL_HOST_PROPERTY + "%" - + "%" + CONTEXT_PATH_PROPERTY + "%,j2eeType=Servlet,name=[^,]+"; + private static final String SERVLET_COMPONENT_NAMES_REGEX_TEMPLATE = "jboss.web:J2EEApplication=none,J2EEServer=none," + + "WebModule=//%" + VIRTUAL_HOST_PROPERTY + "%" + "%" + CONTEXT_PATH_PROPERTY + "%,j2eeType=Servlet,name=[^,]+";
private static final String SERVLET_METRIC_PREFIX = "Servlet.";
@@ -87,15 +83,13 @@ public class WebApplicationContextComponent extends ManagedComponentComponent private ResponseTimeLogParser logParser;
private boolean clustered; - + @Override - public void start(ResourceContext<ProfileServiceComponent> resourceContext) throws Exception - { + public void start(ResourceContext<ProfileServiceComponent<?>> resourceContext) throws Exception { super.start(resourceContext); Configuration pluginConfig = getResourceContext().getPluginConfiguration(); - this.servletComponentNamesRegex = - ResourceComponentUtils.replacePropertyExpressionsInTemplate(SERVLET_COMPONENT_NAMES_REGEX_TEMPLATE, - pluginConfig); + this.servletComponentNamesRegex = ResourceComponentUtils.replacePropertyExpressionsInTemplate( + SERVLET_COMPONENT_NAMES_REGEX_TEMPLATE, pluginConfig); ResponseTimeConfiguration responseTimeConfig = new ResponseTimeConfiguration(pluginConfig); File logFile = responseTimeConfig.getLogFile(); if (logFile != null) { @@ -111,80 +105,67 @@ public class WebApplicationContextComponent extends ManagedComponentComponent clustered = distributable != null && distributable.booleanValue(); } } catch (Exception e) { - log.warn("Failed to determine whether the web app context " + resourceContext.getResourceKey() + " is clustered or not.", e); + log.warn("Failed to determine whether the web app context " + resourceContext.getResourceKey() + + " is clustered or not.", e); } }
@Override - public void getValues(MeasurementReport report, Set<MeasurementScheduleRequest> requests) - throws Exception - { + public void getValues(MeasurementReport report, Set<MeasurementScheduleRequest> requests) throws Exception { ProfileServiceComponent warComponent = getResourceContext().getParentResourceComponent(); ManagementView managementView = warComponent.getConnection().getManagementView(); - + ManagedComponent component = prepareForMetricCollection(requests); - for (MeasurementScheduleRequest request : requests) - { + for (MeasurementScheduleRequest request : requests) { String metricName = request.getName(); - try - { - if (metricName.startsWith(SERVLET_METRIC_PREFIX)) - { + try { + if (metricName.startsWith(SERVLET_METRIC_PREFIX)) { Double value = getServletMetric(managementView, metricName); MeasurementDataNumeric metric = new MeasurementDataNumeric(request, value); report.addData(metric); - } - else if (metricName.equals(VIRTUAL_HOST_TRAIT)) - { + } else if (metricName.equals(VIRTUAL_HOST_TRAIT)) { Configuration pluginConfig = getResourceContext().getPluginConfiguration(); String virtualHost = pluginConfig.getSimple(VIRTUAL_HOST_PROPERTY).getStringValue(); MeasurementDataTrait trait = new MeasurementDataTrait(request, virtualHost); report.addData(trait); - } - else if (metricName.equals(RESPONSE_TIME_METRIC)) { - if (this.logParser != null) { - try { - CallTimeData callTimeData = new CallTimeData(request); - this.logParser.parseLog(callTimeData); - report.addData(callTimeData); - } catch (Exception e) { - log.error("Failed to retrieve HTTP call-time data.", e); - } - } else { - log.error("The '" + RESPONSE_TIME_METRIC + "' metric is enabled for WAR resource '" - + getComponentName() + "', but no value is defined for the '" - + RESPONSE_TIME_LOG_FILE_CONFIG_PROP + "' connection property."); - // TODO: Communicate this error back to the server for display in the GUI. - } - } - else if (metricName.equals(CLUSTERED_TRAIT)) - { + } else if (metricName.equals(RESPONSE_TIME_METRIC)) { + if (this.logParser != null) { + try { + CallTimeData callTimeData = new CallTimeData(request); + this.logParser.parseLog(callTimeData); + report.addData(callTimeData); + } catch (Exception e) { + log.error("Failed to retrieve HTTP call-time data.", e); + } + } else { + log.error("The '" + RESPONSE_TIME_METRIC + "' metric is enabled for WAR resource '" + + getComponentName() + "', but no value is defined for the '" + + RESPONSE_TIME_LOG_FILE_CONFIG_PROP + "' connection property."); + // TODO: Communicate this error back to the server for display in the GUI. + } + } else if (metricName.equals(CLUSTERED_TRAIT)) { MeasurementDataTrait trait = new MeasurementDataTrait(request, Boolean.toString(clustered)); report.addData(trait); - } - else - { + } else { String metricNameToUse = metricName; if (clustered && !"runState".equals(metricName)) { metricNameToUse = toUpperCaseFirstLetter(metricName); } - + String value = getMeasurement(component, metricNameToUse); - + if (clustered && !"runState".equals(metricName) && value == null) { //hmm... so it looks like https://issues.jboss.org/browse/JBPAPP-7172 has been fixed //and we're getting the metric names in lower case even for clustered contexts value = getMeasurement(component, metricName); } - + addValueToMeasurementReport(report, request, value); } - } - catch (Exception e) - { + } catch (Exception e) { // Don't let one bad apple spoil the barrel. log.error("Failed to collect metric '" + metricName + "' for " + getResourceContext().getResourceType() - + " Resource with key " + getResourceContext().getResourceKey() + ".", e); + + " Resource with key " + getResourceContext().getResourceKey() + ".", e); } } } @@ -192,99 +173,78 @@ public class WebApplicationContextComponent extends ManagedComponentComponent public boolean isClustered() { return clustered; } - - private Double getServletMetric(ManagementView managementView, String metricName) throws Exception - { + + private Double getServletMetric(ManagementView managementView, String metricName) throws Exception { ComponentType servletComponentType = MoreKnownComponentTypes.MBean.Servlet.getType(); //Set<ManagedComponent> servletComponents = managementView.getMatchingComponents(this.servletComponentNamesRegex, // servletComponentType, new RegularExpressionNameMatcher()); Set<ManagedComponent> servletComponents = ManagedComponentUtils.getManagedComponents(managementView, - servletComponentType, this.servletComponentNamesRegex, new RegularExpressionNameMatcher()); + servletComponentType, this.servletComponentNamesRegex, new RegularExpressionNameMatcher());
long min = Long.MAX_VALUE; long max = 0; long processingTime = 0; int requestCount = 0; int errorCount = 0; - for (ManagedComponent servletComponent : servletComponents) - { - if (metricName.equals(SERVLET_MINIMUM_RESPONSE_TIME_METRIC)) - { - Long longValue = (Long)ManagedComponentUtils.getSimplePropertyValue(servletComponent, "minTime"); + for (ManagedComponent servletComponent : servletComponents) { + if (metricName.equals(SERVLET_MINIMUM_RESPONSE_TIME_METRIC)) { + Long longValue = (Long) ManagedComponentUtils.getSimplePropertyValue(servletComponent, "minTime"); if (longValue < min) min = longValue; - } - else if (metricName.equals(SERVLET_MAXIMUM_RESPONSE_TIME_METRIC)) - { - Long longValue = (Long)ManagedComponentUtils.getSimplePropertyValue(servletComponent, "maxTime"); + } else if (metricName.equals(SERVLET_MAXIMUM_RESPONSE_TIME_METRIC)) { + Long longValue = (Long) ManagedComponentUtils.getSimplePropertyValue(servletComponent, "maxTime"); if (longValue > max) max = longValue; - } - else if (metricName.equals(SERVLET_AVERAGE_RESPONSE_TIME_METRIC)) - { - Long longValue = (Long)ManagedComponentUtils.getSimplePropertyValue(servletComponent, "processingTime"); + } else if (metricName.equals(SERVLET_AVERAGE_RESPONSE_TIME_METRIC)) { + Long longValue = (Long) ManagedComponentUtils + .getSimplePropertyValue(servletComponent, "processingTime"); processingTime += longValue; - Integer intValue = (Integer)ManagedComponentUtils.getSimplePropertyValue(servletComponent, "requestCount"); + Integer intValue = (Integer) ManagedComponentUtils.getSimplePropertyValue(servletComponent, + "requestCount"); requestCount += intValue; - } - else if (metricName.equals(SERVLET_REQUEST_COUNT_METRIC)) - { - Integer intValue = (Integer)ManagedComponentUtils.getSimplePropertyValue(servletComponent, "requestCount"); + } else if (metricName.equals(SERVLET_REQUEST_COUNT_METRIC)) { + Integer intValue = (Integer) ManagedComponentUtils.getSimplePropertyValue(servletComponent, + "requestCount"); requestCount += intValue; - } - else if (metricName.equals(SERVLET_ERROR_COUNT_METRIC)) - { - Integer intValue = (Integer)ManagedComponentUtils.getSimplePropertyValue(servletComponent, "errorCount"); + } else if (metricName.equals(SERVLET_ERROR_COUNT_METRIC)) { + Integer intValue = (Integer) ManagedComponentUtils.getSimplePropertyValue(servletComponent, + "errorCount"); errorCount += intValue; - } - else if (metricName.equals(SERVLET_TOTAL_RESPONSE_TIME_METRIC)) - { - Long longValue = (Long)ManagedComponentUtils.getSimplePropertyValue(servletComponent, "processingTime"); + } else if (metricName.equals(SERVLET_TOTAL_RESPONSE_TIME_METRIC)) { + Long longValue = (Long) ManagedComponentUtils + .getSimplePropertyValue(servletComponent, "processingTime"); processingTime += longValue; } }
Double result; - if (metricName.equals(SERVLET_AVERAGE_RESPONSE_TIME_METRIC)) - { - result = (requestCount > 0) ? ((double)processingTime / (double)requestCount) : Double.NaN; - } - else if (metricName.equals(SERVLET_MINIMUM_RESPONSE_TIME_METRIC)) - { - result = (min != Long.MAX_VALUE) ? (double)min : Double.NaN; - } - else if (metricName.equals(SERVLET_MAXIMUM_RESPONSE_TIME_METRIC)) - { - result = (max != 0) ? (double)max : Double.NaN; - } - else if (metricName.equals(SERVLET_ERROR_COUNT_METRIC)) - { - result = (double)errorCount; - } - else if (metricName.equals(SERVLET_REQUEST_COUNT_METRIC)) - { - result = (double)requestCount; - } - else if (metricName.equals(SERVLET_TOTAL_RESPONSE_TIME_METRIC)) - { - result = (double)processingTime; - } - else - { + if (metricName.equals(SERVLET_AVERAGE_RESPONSE_TIME_METRIC)) { + result = (requestCount > 0) ? ((double) processingTime / (double) requestCount) : Double.NaN; + } else if (metricName.equals(SERVLET_MINIMUM_RESPONSE_TIME_METRIC)) { + result = (min != Long.MAX_VALUE) ? (double) min : Double.NaN; + } else if (metricName.equals(SERVLET_MAXIMUM_RESPONSE_TIME_METRIC)) { + result = (max != 0) ? (double) max : Double.NaN; + } else if (metricName.equals(SERVLET_ERROR_COUNT_METRIC)) { + result = (double) errorCount; + } else if (metricName.equals(SERVLET_REQUEST_COUNT_METRIC)) { + result = (double) requestCount; + } else if (metricName.equals(SERVLET_TOTAL_RESPONSE_TIME_METRIC)) { + result = (double) processingTime; + } else { // fallback result = Double.NaN; }
return result; } - + private static String toUpperCaseFirstLetter(String name) { if (name == null || name.length() == 0) { return name; } - + char first = name.charAt(0); - + return Character.toUpperCase(first) + name.substring(1); } } \ No newline at end of file diff --git a/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/script/ScriptComponent.java b/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/script/ScriptComponent.java index fd283f5..36682c4 100644 --- a/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/script/ScriptComponent.java +++ b/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/script/ScriptComponent.java @@ -40,6 +40,7 @@ import java.util.regex.Pattern; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.jetbrains.annotations.NotNull; + import org.rhq.core.domain.configuration.Configuration; import org.rhq.core.domain.configuration.PropertySimple; import org.rhq.core.domain.content.PackageDetailsKey; @@ -66,7 +67,6 @@ import org.rhq.core.util.MessageDigestGenerator; import org.rhq.plugins.jbossas5.ApplicationServerComponent; import org.rhq.plugins.jbossas5.ApplicationServerPluginConfigurationProperties; import org.rhq.plugins.jbossas5.connection.ProfileServiceConnection; -import org.rhq.plugins.jbossas5.deploy.Deployer; import org.rhq.plugins.jbossas5.deploy.RemoteDownloader; import org.rhq.plugins.jbossas5.deploy.ScriptDeployer;
@@ -76,13 +76,14 @@ import org.rhq.plugins.jbossas5.deploy.ScriptDeployer; * @author Ian Springer * @author Lukas Krejci */ -public class ScriptComponent implements ResourceComponent<ApplicationServerComponent>, OperationFacet, DeleteResourceFacet, ContentFacet { +public class ScriptComponent implements ResourceComponent<ApplicationServerComponent<?>>, OperationFacet, + DeleteResourceFacet, ContentFacet { public static final String TYPE_NAME = "Script"; public static final String PACKAGE_TYPE = "script"; - + public static final String PATH_CONFIG_PROP = "path"; public static final String ENVIRONMENT_VARIABLES_CONFIG_PROP = "environmentVariables"; - + public static final String EXECUTE_OPERATION = "execute";
public static final String COMMAND_LINE_ARGUMENTS_PARAM_PROP = "commandLineArguments"; @@ -92,12 +93,12 @@ public class ScriptComponent implements ResourceComponent<ApplicationServerCompo
private static final String PACKAGE_VERSION = "none"; private static final String PACKAGE_ARCHITECTURE = "noarch"; - + private final Log log = LogFactory.getLog(this.getClass());
- private ResourceContext<ApplicationServerComponent> resourceContext; + private ResourceContext<ApplicationServerComponent<?>> resourceContext;
- public void start(ResourceContext<ApplicationServerComponent> resourceContext) { + public void start(ResourceContext<ApplicationServerComponent<?>> resourceContext) { this.resourceContext = resourceContext; }
@@ -160,14 +161,14 @@ public class ScriptComponent implements ResourceComponent<ApplicationServerCompo
public void deleteResource() throws Exception { String path = resourceContext.getPluginConfiguration().getSimpleValue(PATH_CONFIG_PROP, null); - + File f = new File(path); - + if (!f.delete()) { throw new IOException("Failed to delete the file on the configured path: " + path); } } - + public List<DeployPackageStep> generateInstallationSteps(ResourcePackageDetails packageDetails) { return null; } @@ -180,24 +181,28 @@ public class ScriptComponent implements ResourceComponent<ApplicationServerCompo response.setOverallRequestErrorMessage("Only one script can be updated at a time."); return response; } - + try { - String jbossHomeDir = resourceContext.getParentResourceComponent().getResourceContext().getPluginConfiguration().getSimpleValue(ApplicationServerPluginConfigurationProperties.HOME_DIR, null); + String jbossHomeDir = resourceContext.getParentResourceComponent().getResourceContext() + .getPluginConfiguration().getSimpleValue(ApplicationServerPluginConfigurationProperties.HOME_DIR, null); SystemInfo systemInfo = resourceContext.getSystemInformation(); - ProfileServiceConnection profileServiceConnection = resourceContext.getParentResourceComponent().getConnection(); - - ScriptDeployer deployer = new ScriptDeployer(jbossHomeDir, systemInfo, new RemoteDownloader(resourceContext, true, profileServiceConnection)); + ProfileServiceConnection profileServiceConnection = resourceContext.getParentResourceComponent() + .getConnection(); + + ScriptDeployer deployer = new ScriptDeployer(jbossHomeDir, systemInfo, new RemoteDownloader( + resourceContext, true, profileServiceConnection)); ResourcePackageDetails packageDetails = packages.iterator().next(); - - DeployIndividualPackageResponse scriptUpdateResult = deployer.update(packageDetails, resourceContext.getResourceType()); - - response.setOverallRequestResult(scriptUpdateResult.getResult()); - response.addPackageResponse(scriptUpdateResult); + + DeployIndividualPackageResponse scriptUpdateResult = deployer.update(packageDetails, + resourceContext.getResourceType()); + + response.setOverallRequestResult(scriptUpdateResult.getResult()); + response.addPackageResponse(scriptUpdateResult); } catch (Exception e) { response.setOverallRequestErrorMessage(e.getMessage()); response.setOverallRequestResult(ContentResponseResult.FAILURE); } - + return response; }
@@ -209,8 +214,9 @@ public class ScriptComponent implements ResourceComponent<ApplicationServerCompo Set<ResourcePackageDetails> results = new HashSet<ResourcePackageDetails>(); if (PACKAGE_TYPE.equals(type.getName())) { File scriptFile = new File(resourceContext.getResourceKey()); - - PackageDetailsKey key = new PackageDetailsKey(scriptFile.getName(), PACKAGE_VERSION, PACKAGE_TYPE, PACKAGE_ARCHITECTURE); + + PackageDetailsKey key = new PackageDetailsKey(scriptFile.getName(), PACKAGE_VERSION, PACKAGE_TYPE, + PACKAGE_ARCHITECTURE); ResourcePackageDetails details = new ResourcePackageDetails(key); details.setDisplayName(scriptFile.getName()); details.setFileName(scriptFile.getAbsolutePath()); @@ -219,24 +225,26 @@ public class ScriptComponent implements ResourceComponent<ApplicationServerCompo details.setFileCreatedDate(scriptFile.lastModified()); details.setInstallationTimestamp(System.currentTimeMillis()); try { - details.setSHA256(new MessageDigestGenerator(MessageDigestGenerator.SHA_256).calcDigestString(scriptFile)); + details.setSHA256(new MessageDigestGenerator(MessageDigestGenerator.SHA_256) + .calcDigestString(scriptFile)); } catch (IOException e) { log.warn("Failed to compute the SHA256 digest of the script: " + scriptFile.getAbsolutePath(), e); } results.add(details); } - + return results; }
public InputStream retrievePackageBits(ResourcePackageDetails packageDetails) { - String jbossHomeDir = resourceContext.getParentResourceComponent().getResourceContext().getPluginConfiguration().getSimpleValue(ApplicationServerPluginConfigurationProperties.HOME_DIR, null); + String jbossHomeDir = resourceContext.getParentResourceComponent().getResourceContext() + .getPluginConfiguration().getSimpleValue(ApplicationServerPluginConfigurationProperties.HOME_DIR, null); File binDir = new File(jbossHomeDir, "bin");
String scriptName = packageDetails.getKey().getName(); - + File script = new File(binDir, scriptName); - + try { return new FileInputStream(script); } catch (FileNotFoundException e) { diff --git a/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/script/ScriptDiscoveryComponent.java b/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/script/ScriptDiscoveryComponent.java index 8010081..a9d6166 100644 --- a/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/script/ScriptDiscoveryComponent.java +++ b/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/script/ScriptDiscoveryComponent.java @@ -31,6 +31,7 @@ import java.util.Set;
import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; + import org.rhq.core.domain.configuration.Configuration; import org.rhq.core.domain.configuration.PropertySimple; import org.rhq.core.domain.resource.ResourceUpgradeReport; @@ -50,18 +51,18 @@ import org.rhq.plugins.jbossas5.ApplicationServerComponent; * * @author Ian Springer */ -public class ScriptDiscoveryComponent implements ResourceDiscoveryComponent<ApplicationServerComponent>, - ManualAddFacet<ApplicationServerComponent>, ResourceUpgradeFacet<ApplicationServerComponent> { +public class ScriptDiscoveryComponent implements ResourceDiscoveryComponent<ApplicationServerComponent<?>>, + ManualAddFacet<ApplicationServerComponent<?>>, ResourceUpgradeFacet<ApplicationServerComponent<?>> {
private final Log log = LogFactory.getLog(this.getClass()); static final String SERVER_HOME_DIR = "homeDir";
public Set<DiscoveredResourceDetails> discoverResources( - ResourceDiscoveryContext<ApplicationServerComponent> discoveryContext) + ResourceDiscoveryContext<ApplicationServerComponent<?>> discoveryContext) throws InvalidPluginConfigurationException { Set<DiscoveredResourceDetails> resources = new HashSet<DiscoveredResourceDetails>();
- ResourceContext parentResourceContext = discoveryContext.getParentResourceContext(); + ResourceContext<?> parentResourceContext = discoveryContext.getParentResourceContext(); File binDir = getServerBinDirectory(parentResourceContext); log.debug("Searching for scripts beneath JBossAS server bin directory (" + binDir + ")..."); ScriptFileFinder scriptFileFinder = new ScriptFileFinder(discoveryContext.getSystemInformation(), binDir); @@ -81,8 +82,8 @@ public class ScriptDiscoveryComponent implements ResourceDiscoveryComponent<Appl }
public DiscoveredResourceDetails discoverResource(Configuration pluginConfig, - ResourceDiscoveryContext<ApplicationServerComponent> discoveryContext) - throws InvalidPluginConfigurationException { + ResourceDiscoveryContext<ApplicationServerComponent<?>> discoveryContext) + throws InvalidPluginConfigurationException {
File path = new File(pluginConfig.getSimple(ScriptComponent.PATH_CONFIG_PROP).getStringValue()); validatePath(path); @@ -90,12 +91,12 @@ public class ScriptDiscoveryComponent implements ResourceDiscoveryComponent<Appl File binDir = getServerBinDirectory(parentResourceContext); DiscoveredResourceDetails resource = createResourceDetails(discoveryContext, pluginConfig, binDir); log.debug("Manually added script service: " + resource); - + return resource; }
@Override - public ResourceUpgradeReport upgrade(ResourceUpgradeContext<ApplicationServerComponent> upgradeContext) { + public ResourceUpgradeReport upgrade(ResourceUpgradeContext<ApplicationServerComponent<?>> upgradeContext) { String inventoriedResourceKey = upgradeContext.getResourceKey();
ResourceContext<?> parentResourceContext = upgradeContext.getParentResourceContext(); @@ -124,8 +125,8 @@ public class ScriptDiscoveryComponent implements ResourceDiscoveryComponent<Appl }
private static String buildResourceKey(String scriptPath, File binDir) { - return (scriptPath.startsWith(binDir.getPath())) ? scriptPath.substring(binDir.getPath().length() + 1) : - scriptPath; + return (scriptPath.startsWith(binDir.getPath())) ? scriptPath.substring(binDir.getPath().length() + 1) + : scriptPath; }
private void validatePath(File path) { @@ -164,7 +165,7 @@ public class ScriptDiscoveryComponent implements ResourceDiscoveryComponent<Appl }
private DiscoveredResourceDetails createResourceDetails( - ResourceDiscoveryContext<ApplicationServerComponent> discoveryContext, Configuration pluginConfig, + ResourceDiscoveryContext<ApplicationServerComponent<?>> discoveryContext, Configuration pluginConfig, File binDir) { String path = pluginConfig.getSimple(ScriptComponent.PATH_CONFIG_PROP).getStringValue(); String key = buildResourceKey(path, binDir); diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/AbstractBaseDiscovery.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/AbstractBaseDiscovery.java index daa0447..49fabef 100644 --- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/AbstractBaseDiscovery.java +++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/AbstractBaseDiscovery.java @@ -40,7 +40,7 @@ import org.rhq.core.system.ProcessInfo; * in the area of processes and host.xml * @author Heiko W. Rupp */ -public abstract class AbstractBaseDiscovery<T extends ResourceComponent> implements ResourceDiscoveryComponent<T> { +public abstract class AbstractBaseDiscovery<T extends ResourceComponent<?>> implements ResourceDiscoveryComponent<T> { static final String DORG_JBOSS_BOOT_LOG_FILE = "-Dorg.jboss.boot.log.file="; private static final String DJBOSS_SERVER_HOME_DIR = "-Djboss.home.dir"; static final int DEFAULT_MGMT_PORT = 9990; diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseComponent.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseComponent.java index 0eb49db..0ad794c 100644 --- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseComponent.java +++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseComponent.java @@ -70,7 +70,7 @@ import java.util.List; import java.util.Map; import java.util.Set;
-public class BaseComponent implements ResourceComponent, MeasurementFacet, ConfigurationFacet, DeleteResourceFacet, +public class BaseComponent<T extends ResourceComponent<?>> implements ResourceComponent<T>, MeasurementFacet, ConfigurationFacet, DeleteResourceFacet, CreateChildResourceFacet, OperationFacet { private static final String INTERNAL = "_internal:"; diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/SubsystemDiscovery.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/SubsystemDiscovery.java index 7584a68..9b3e3a3 100644 --- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/SubsystemDiscovery.java +++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/SubsystemDiscovery.java @@ -18,16 +18,6 @@ */ package org.rhq.modules.plugins.jbossas7;
-import org.rhq.core.domain.configuration.Configuration; -import org.rhq.core.domain.configuration.PropertySimple; -import org.rhq.core.pluginapi.inventory.DiscoveredResourceDetails; -import org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent; -import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext; -import org.rhq.modules.plugins.jbossas7.json.Address; -import org.rhq.modules.plugins.jbossas7.json.ReadChildrenNames; -import org.rhq.modules.plugins.jbossas7.json.ReadResource; -import org.rhq.modules.plugins.jbossas7.json.Result; - import java.util.ArrayList; import java.util.Arrays; import java.util.HashSet; @@ -39,6 +29,16 @@ import org.apache.commons.logging.LogFactory; import org.codehaus.jackson.map.DeserializationConfig; import org.codehaus.jackson.map.ObjectMapper;
+import org.rhq.core.domain.configuration.Configuration; +import org.rhq.core.domain.configuration.PropertySimple; +import org.rhq.core.pluginapi.inventory.DiscoveredResourceDetails; +import org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent; +import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext; +import org.rhq.modules.plugins.jbossas7.json.Address; +import org.rhq.modules.plugins.jbossas7.json.ReadChildrenNames; +import org.rhq.modules.plugins.jbossas7.json.ReadResource; +import org.rhq.modules.plugins.jbossas7.json.Result; + /** * Discover subsystems. We need to distinguish two cases denoted by the path * plugin config: @@ -55,28 +55,26 @@ import org.codehaus.jackson.map.ObjectMapper; * * @author Heiko W. Rupp */ -@SuppressWarnings("unused") -public class SubsystemDiscovery implements ResourceDiscoveryComponent<BaseComponent> { +public class SubsystemDiscovery implements ResourceDiscoveryComponent<BaseComponent<?>> {
private final Log log = LogFactory.getLog(this.getClass());
- public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext<BaseComponent> context) - throws Exception { + public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext<BaseComponent<?>> context) + throws Exception {
Set<DiscoveredResourceDetails> details = new HashSet<DiscoveredResourceDetails>();
ObjectMapper mapper = new ObjectMapper(); - mapper.configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES,false); - mapper.configure(DeserializationConfig.Feature.READ_ENUMS_USING_TO_STRING,true); + mapper.configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES, false); + mapper.configure(DeserializationConfig.Feature.READ_ENUMS_USING_TO_STRING, true);
BaseComponent parentComponent = context.getParentResourceComponent(); ASConnection connection = parentComponent.getASConnection();
- Configuration config = context.getDefaultPluginConfiguration(); String confPath = config.getSimpleValue("path", ""); - if (confPath==null || confPath.isEmpty()) { - log.error("Path plugin config is null for ResourceType [" + context.getResourceType().getName() +"]."); + if (confPath == null || confPath.isEmpty()) { + log.error("Path plugin config is null for ResourceType [" + context.getResourceType().getName() + "]."); return details; }
@@ -89,7 +87,7 @@ public class SubsystemDiscovery implements ResourceDiscoveryComponent<BaseCompon // Construct the full path including the parent String path; String parentPath = parentComponent.getPath(); - if (parentPath==null || parentPath.isEmpty()) + if (parentPath == null || parentPath.isEmpty()) path = ""; else path = parentPath; @@ -97,7 +95,6 @@ public class SubsystemDiscovery implements ResourceDiscoveryComponent<BaseCompon if (Boolean.getBoolean("as7plugin.verbose")) log.info("total path: [" + path + "]");
- if (lookForChildren) { // Looking for multiple resource of type 'childType'
@@ -105,11 +102,9 @@ public class SubsystemDiscovery implements ResourceDiscoveryComponent<BaseCompon List<String> subTypes = new ArrayList<String>(); if (confPath.contains("|")) { subTypes.addAll(Arrays.asList(confPath.split("\|"))); - } - else + } else subTypes.add(confPath);
- for (String cpath : subTypes) {
Address addr = new Address(parentPath); @@ -128,31 +123,28 @@ public class SubsystemDiscovery implements ResourceDiscoveryComponent<BaseCompon
String resKey;
- if (path==null||path.isEmpty()) + if (path == null || path.isEmpty()) resKey = newPath; else { if (path.startsWith(",")) path = path.substring(1); - resKey = path + "," +cpath + "=" + val; + resKey = path + "," + cpath + "=" + val; }
- PropertySimple pathProp = new PropertySimple("path",resKey); + PropertySimple pathProp = new PropertySimple("path", resKey); config2.put(pathProp);
- DiscoveredResourceDetails detail = new DiscoveredResourceDetails( - context.getResourceType(), // DataType - resKey, // Key - val, // Name - null, // Version - context.getResourceType().getDescription(), // subsystem.description - config2, - null); + DiscoveredResourceDetails detail = new DiscoveredResourceDetails(context.getResourceType(), // DataType + resKey, // Key + val, // Name + null, // Version + context.getResourceType().getDescription(), // subsystem.description + config2, null); details.add(detail); } } } - } - else { + } else { // Single subsystem path += "," + confPath; if (path.startsWith(",")) @@ -163,17 +155,15 @@ public class SubsystemDiscovery implements ResourceDiscoveryComponent<BaseCompon String resKey = path; String name = resKey.substring(resKey.lastIndexOf("=") + 1); Configuration config2 = context.getDefaultPluginConfiguration(); - PropertySimple pathProp = new PropertySimple("path",path); + PropertySimple pathProp = new PropertySimple("path", path); config2.put(pathProp);
- DiscoveredResourceDetails detail = new DiscoveredResourceDetails( - context.getResourceType(), // DataType - path, // Key - name, // Name - null, // Version - context.getResourceType().getDescription(), // Description - config2, - null); + DiscoveredResourceDetails detail = new DiscoveredResourceDetails(context.getResourceType(), // DataType + path, // Key + name, // Name + null, // Version + context.getResourceType().getDescription(), // Description + config2, null); details.add(detail); } } diff --git a/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/AbstractMessagingComponent.java b/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/AbstractMessagingComponent.java index 7c48ed4..01077c9 100644 --- a/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/AbstractMessagingComponent.java +++ b/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/AbstractMessagingComponent.java @@ -1,25 +1,25 @@ - /* - * Jopr Management Platform - * Copyright (C) 2005-2008 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, version 2, as - * published by the Free Software Foundation, and/or the GNU Lesser - * General Public License, version 2.1, also as published by the Free - * Software Foundation. - * - * 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 and the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU General Public License - * and the GNU Lesser General Public License along with this program; - * if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ +/* + * Jopr Management Platform + * Copyright (C) 2005-2008 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, version 2, as + * published by the Free Software Foundation, and/or the GNU Lesser + * General Public License, version 2.1, also as published by the Free + * Software Foundation. + * + * 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 and the GNU Lesser General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License + * and the GNU Lesser General Public License along with this program; + * if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */
package org.rhq.plugins.jbossas;
@@ -59,7 +59,7 @@ import org.rhq.plugins.jmx.MBeanResourceComponent; * Common base class for Messaging related stuff * @author Heiko W. Rupp */ -public abstract class AbstractMessagingComponent extends MBeanResourceComponent<JBossASServerComponent> implements +public abstract class AbstractMessagingComponent extends MBeanResourceComponent<JBossASServerComponent<?>> implements CreateChildResourceFacet {
private static final Pattern PROPERTY_PATTERN = Pattern.compile("^(.*:.*):(.*)$"); @@ -73,7 +73,7 @@ public abstract class AbstractMessagingComponent extends MBeanResourceComponent<
protected Log LOG = null;
- public void start(ResourceContext<JBossASServerComponent> resourceContext, XMLConfigurationEditor editor) { + public void start(ResourceContext<JBossASServerComponent<?>> resourceContext, XMLConfigurationEditor editor) { super.start(resourceContext); this.resourceType = resourceContext.getResourceType(); xmlEditor = editor; @@ -126,7 +126,7 @@ public abstract class AbstractMessagingComponent extends MBeanResourceComponent< JBossASServerComponent jasco = getOurJBossASComponent(); File deploymentFile = jasco.getDeploymentFilePath(resourceKey); Configuration loadedConfiguration = xmlEditor.loadConfiguration(deploymentFile, this.name); - if (loadedConfiguration==null) + if (loadedConfiguration == null) return null; String boundJNDIName = DeploymentUtility.getJndiNameBinding(getEmsBean()); loadedConfiguration.put(new PropertySimple("JNDIBinding", boundJNDIName)); @@ -158,9 +158,8 @@ public abstract class AbstractMessagingComponent extends MBeanResourceComponent< String mBeanName = report.getConfiguration().getSimpleValue(MBEAN_NAME_PROP, null); boolean mBeanNameChanged = false; if (!mBeanName.equals(this.name)) { - LOG - .info("The MBEan Name for this Topic/Queue has been changed. This change will appear in the <mbean> tag for" - + "this Topic/Queue."); + LOG.info("The MBEan Name for this Topic/Queue has been changed. This change will appear in the <mbean> tag for" + + "this Topic/Queue.");
// User has changed the name, so update the plugin configuration. PropertySimple nameProp = getResourceContext().getPluginConfiguration().getSimple(PLUGIN_CONFIG_NAME_PROP); @@ -169,8 +168,7 @@ public abstract class AbstractMessagingComponent extends MBeanResourceComponent< }
if ((deploymentFile == null) || !deploymentFile.exists()) { - deploymentFile = new File(jasco.getConfigurationPath(), name - + ".xml"); + deploymentFile = new File(jasco.getConfigurationPath(), name + ".xml"); }
xmlEditor.updateConfiguration(deploymentFile, this.name, report); diff --git a/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/AbstractMessagingDiscoveryComponent.java b/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/AbstractMessagingDiscoveryComponent.java index 6c247aa..4d1d19d 100644 --- a/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/AbstractMessagingDiscoveryComponent.java +++ b/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/AbstractMessagingDiscoveryComponent.java @@ -44,7 +44,7 @@ import org.rhq.plugins.jmx.ObjectNameQueryUtility; * Abstract base class to discover JBossMessaging and JBossMQ related stuff * @author Heiko W. Rupp */ -public abstract class AbstractMessagingDiscoveryComponent extends MBeanResourceDiscoveryComponent<JMXComponent> { +public abstract class AbstractMessagingDiscoveryComponent extends MBeanResourceDiscoveryComponent<JMXComponent<?>> {
/** * Do the real discovery @@ -55,7 +55,7 @@ public abstract class AbstractMessagingDiscoveryComponent extends MBeanResourceD * @param versionSource A string that determines how to obtain the version. See {@link #getVersionFromSource(org.mc4j.ems.connection.EmsConnection, String)} * @return The details of a discovered resource. */ - protected Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext<JMXComponent> context, String objectName, String resourceName, String resourceDescription, String versionSource) { + protected Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext<JMXComponent<?>> context, String objectName, String resourceName, String resourceDescription, String versionSource) {
Set<DiscoveredResourceDetails> result = new HashSet<DiscoveredResourceDetails>();
diff --git a/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/ApplicationComponent.java b/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/ApplicationComponent.java index 0bde101..a7c70db 100644 --- a/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/ApplicationComponent.java +++ b/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/ApplicationComponent.java @@ -64,7 +64,7 @@ import org.rhq.plugins.jmx.MBeanResourceComponent; * * @author Ian Springer */ -public class ApplicationComponent extends MBeanResourceComponent<JBossASServerComponent> implements ContentFacet, +public class ApplicationComponent extends MBeanResourceComponent<JBossASServerComponent<?>> implements ContentFacet, DeleteResourceFacet, OperationFacet { private static final String BACKUP_FILE_EXTENSION = ".rej"; public static final String RHQ_SHA256 = "RHQ-Sha256"; diff --git a/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/ApplicationDiscoveryComponent.java b/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/ApplicationDiscoveryComponent.java index 5f56681..5368d1d 100644 --- a/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/ApplicationDiscoveryComponent.java +++ b/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/ApplicationDiscoveryComponent.java @@ -31,6 +31,7 @@ import java.util.Map; import java.util.Set;
import org.mc4j.ems.connection.EmsConnection; + import org.rhq.core.domain.configuration.Configuration; import org.rhq.core.domain.configuration.PropertySimple; import org.rhq.core.domain.resource.ResourceType; @@ -46,10 +47,10 @@ import org.rhq.plugins.jmx.MBeanResourceDiscoveryComponent; * * @author Jason Dobies */ -public class ApplicationDiscoveryComponent extends MBeanResourceDiscoveryComponent<JMXComponent> { +public class ApplicationDiscoveryComponent extends MBeanResourceDiscoveryComponent<JMXComponent<?>> { // ResourceDiscoveryComponent Implementation --------------------------------------------
- public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext<JMXComponent> context) { + public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext<JMXComponent<?>> context) { // Parent will discover deployed applications through JMX Set<DiscoveredResourceDetails> jmxResources = super.discoverResources(context);
@@ -57,7 +58,8 @@ public class ApplicationDiscoveryComponent extends MBeanResourceDiscoveryCompone JMXComponent parentComponent = context.getParentResourceComponent(); ApplicationServerComponent applicationServerComponent = (ApplicationServerComponent) parentComponent; EmsConnection emsConnection = parentComponent.getEmsConnection(); - String deployDirectoryPath = generateDeployDirectory(applicationServerComponent.getConfigurationPath().getPath()); + String deployDirectoryPath = generateDeployDirectory(applicationServerComponent.getConfigurationPath() + .getPath());
List<String> earNames = new ArrayList<String>(); for (DiscoveredResourceDetails jmxResource : jmxResources) { @@ -95,14 +97,15 @@ public class ApplicationDiscoveryComponent extends MBeanResourceDiscoveryCompone * @return set of all applications discovered on the file system; this should include at least some of the * applications discovered through JMX as well */ - private Set<DiscoveredResourceDetails> discoverFileSystem(ResourceDiscoveryContext<JMXComponent> context) { + private Set<DiscoveredResourceDetails> discoverFileSystem(ResourceDiscoveryContext<JMXComponent<?>> context) { Configuration defaultConfiguration = context.getDefaultPluginConfiguration();
// Find the location of the deploy directory JMXComponent parentComponent = context.getParentResourceComponent(); ApplicationServerComponent applicationServerComponent = (ApplicationServerComponent) parentComponent;
- String deployDirectoryPath = generateDeployDirectory(applicationServerComponent.getConfigurationPath().getPath()); + String deployDirectoryPath = generateDeployDirectory(applicationServerComponent.getConfigurationPath() + .getPath()); File deployDirectory = new File(deployDirectoryPath);
// Set up filter for application type @@ -120,7 +123,8 @@ public class ApplicationDiscoveryComponent extends MBeanResourceDiscoveryCompone String resourceName = file.getName(); String description = defaultConfiguration.getSimple("descriptionTemplate").getStringValue();
- DiscoveredResourceDetails resource = new DiscoveredResourceDetails(resourceType, resourceKey, resourceName, "", description, null, null); + DiscoveredResourceDetails resource = new DiscoveredResourceDetails(resourceType, resourceKey, resourceName, + "", description, null, null); Configuration resourcePluginConfiguration = resource.getPluginConfiguration(); resourcePluginConfiguration.put(new PropertySimple("name", resourceName)); resourcePluginConfiguration.put(new PropertySimple("objectName", objectName)); diff --git a/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/ConnectionFactoryComponent.java b/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/ConnectionFactoryComponent.java index 90473ae..5db0679 100644 --- a/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/ConnectionFactoryComponent.java +++ b/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/ConnectionFactoryComponent.java @@ -42,7 +42,7 @@ import java.util.Set; /** * @author Mark Spritzler */ -public class ConnectionFactoryComponent extends MBeanResourceComponent<JBossASServerComponent> implements ConfigurationFacet, +public class ConnectionFactoryComponent extends MBeanResourceComponent<JBossASServerComponent<?>> implements ConfigurationFacet, DeleteResourceFacet { private static final String CONNECTION_POOL_OBJECT_NAME = "jboss.jca:name=%NAME%,service=ManagedConnectionPool";
@@ -56,7 +56,7 @@ public class ConnectionFactoryComponent extends MBeanResourceComponent<JBossASSe }
@Override - public void start(ResourceContext<JBossASServerComponent> resourceContext) { + public void start(ResourceContext<JBossASServerComponent<?>> resourceContext) { super.start(resourceContext);
this.name = getResourceContext().getPluginConfiguration().getSimpleValue("name", null); diff --git a/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/DatasourceComponent.java b/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/DatasourceComponent.java index 7e1bfd1..f98dce8 100644 --- a/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/DatasourceComponent.java +++ b/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/DatasourceComponent.java @@ -45,7 +45,7 @@ import org.rhq.plugins.jmx.MBeanResourceComponent; /** * @author Greg Hinkle */ -public class DatasourceComponent extends MBeanResourceComponent<JBossASServerComponent> implements ConfigurationFacet, +public class DatasourceComponent extends MBeanResourceComponent<JBossASServerComponent<?>> implements ConfigurationFacet, DeleteResourceFacet, OperationFacet { private static final String CONNECTION_POOL_OBJECT_NAME = "jboss.jca:name=%NAME%,service=ManagedConnectionPool"; @@ -62,7 +62,7 @@ public class DatasourceComponent extends MBeanResourceComponent<JBossASServerCom }
@Override - public void start(ResourceContext<JBossASServerComponent> resourceContext) + public void start(ResourceContext<JBossASServerComponent<?>> resourceContext) { super.start(resourceContext); this.name = getResourceContext().getPluginConfiguration().getSimpleValue("name", null); diff --git a/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/EJB2BeanComponent.java b/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/EJB2BeanComponent.java index 07fa732..2865441 100644 --- a/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/EJB2BeanComponent.java +++ b/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/EJB2BeanComponent.java @@ -48,7 +48,7 @@ import org.rhq.plugins.jmx.MBeanResourceComponent; * @author Ian Springer * @author John Mazzitelli */ -public class EJB2BeanComponent extends MBeanResourceComponent<JBossASServerComponent> { +public class EJB2BeanComponent extends MBeanResourceComponent<JBossASServerComponent<?>> { private final Log log = LogFactory.getLog(EJB2BeanComponent.class);
private Map<Integer, CallTimeData> previousRawCallTimeDatas = new HashMap<Integer, CallTimeData>(); diff --git a/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/EJB3BeanComponent.java b/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/EJB3BeanComponent.java index af96d54..302440a 100644 --- a/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/EJB3BeanComponent.java +++ b/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/EJB3BeanComponent.java @@ -53,7 +53,7 @@ import org.rhq.plugins.jmx.MBeanResourceComponent; * @author Greg Hinkle * @author Ian Springer */ -public class EJB3BeanComponent extends MBeanResourceComponent<JBossASServerComponent> { +public class EJB3BeanComponent extends MBeanResourceComponent<JBossASServerComponent<?>> { private final Log log = LogFactory.getLog(EJB3BeanComponent.class);
private Map<Integer, CallTimeData> previousRawCallTimeDatas = new HashMap<Integer, CallTimeData>(); diff --git a/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/EmbeddedWarDiscoveryComponent.java b/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/EmbeddedWarDiscoveryComponent.java index cbd027d..18a6b38 100644 --- a/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/EmbeddedWarDiscoveryComponent.java +++ b/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/EmbeddedWarDiscoveryComponent.java @@ -39,37 +39,42 @@ import org.rhq.plugins.jmx.MBeanResourceDiscoveryComponent; * @author Jason Dobies * @author Ian Springer */ -public class EmbeddedWarDiscoveryComponent extends MBeanResourceDiscoveryComponent<JMXComponent> { +public class EmbeddedWarDiscoveryComponent extends MBeanResourceDiscoveryComponent<JMXComponent<?>> { // ResourceDiscoveryComponent Implementation --------------------------------------------
@Override - public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext<JMXComponent> context) { + public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext<JMXComponent<?>> context) { // Generate object name based on the parent EAR with the following format. // jboss.management.local:J2EEApplication=rhq.ear,J2EEServer=Local,j2eeType=WebModule,name=on-portal.war
ApplicationComponent parentEarComponent = (ApplicationComponent) context.getParentResourceComponent(); String parentEar = parentEarComponent.getApplicationName();
- String objectName = "jboss.management.local:J2EEApplication=" + parentEar + ",J2EEServer=Local,j2eeType=WebModule,name=%name%"; + String objectName = "jboss.management.local:J2EEApplication=" + parentEar + + ",J2EEServer=Local,j2eeType=WebModule,name=%name%";
// Stuff the object name into the default plugin configuration to look like any other JMX discovery // where the objectName is read from the default plugin configuration Configuration defaultPluginConfiguration = context.getDefaultPluginConfiguration(); - defaultPluginConfiguration.put(new PropertySimple(MBeanResourceDiscoveryComponent.PROPERTY_OBJECT_NAME, objectName)); + defaultPluginConfiguration.put(new PropertySimple(MBeanResourceDiscoveryComponent.PROPERTY_OBJECT_NAME, + objectName));
// Call the base MBean discovery method to perform the actual discovery - Set<DiscoveredResourceDetails> resourceDetails = super.performDiscovery(defaultPluginConfiguration, parentEarComponent, context.getResourceType()); + Set<DiscoveredResourceDetails> resourceDetails = super.performDiscovery(defaultPluginConfiguration, + parentEarComponent, context.getResourceType());
// Once we've finished making sure the plugin configurations have the data we need: // 1) First the stuff generic to all WARs... JBossASServerComponent grandparentJBossASComponent = parentEarComponent.getParentResourceComponent(); - resourceDetails = WarDiscoveryHelper.initPluginConfigurations(grandparentJBossASComponent, resourceDetails,parentEarComponent); + resourceDetails = WarDiscoveryHelper.initPluginConfigurations(grandparentJBossASComponent, resourceDetails, + parentEarComponent);
// 2) Then the stuff specific to embedded WARs... String parentEarFullFileName = parentEarComponent.getFileName() + File.separator; for (DiscoveredResourceDetails resource : resourceDetails) { Configuration pluginConfiguration = resource.getPluginConfiguration(); - pluginConfiguration.put(new PropertySimple(WarComponent.FILE_NAME, parentEarFullFileName + resource.getResourceName())); + pluginConfiguration.put(new PropertySimple(WarComponent.FILE_NAME, parentEarFullFileName + + resource.getResourceName())); }
return resourceDetails; diff --git a/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/JBMDestinationDiscoveryComponent.java b/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/JBMDestinationDiscoveryComponent.java index ba4d76e..7d71e7b 100644 --- a/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/JBMDestinationDiscoveryComponent.java +++ b/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/JBMDestinationDiscoveryComponent.java @@ -35,10 +35,10 @@ import org.rhq.plugins.jmx.MBeanResourceDiscoveryComponent; * @author Heiko W. Rupp * */ -public class JBMDestinationDiscoveryComponent extends MBeanResourceDiscoveryComponent<JMXComponent> { +public class JBMDestinationDiscoveryComponent extends MBeanResourceDiscoveryComponent<JMXComponent<?>> {
@Override - public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext<JMXComponent> context) { + public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext<JMXComponent<?>> context) {
// Discover Queues and Topics via JMX Set<DiscoveredResourceDetails> results = super.discoverResources(context); diff --git a/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/JBossASServerComponent.java b/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/JBossASServerComponent.java index f241200..a8481cc 100644 --- a/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/JBossASServerComponent.java +++ b/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/JBossASServerComponent.java @@ -90,6 +90,7 @@ import org.rhq.core.pluginapi.inventory.ApplicationServerComponent; import org.rhq.core.pluginapi.inventory.CreateChildResourceFacet; import org.rhq.core.pluginapi.inventory.CreateResourceReport; import org.rhq.core.pluginapi.inventory.InvalidPluginConfigurationException; +import org.rhq.core.pluginapi.inventory.ResourceComponent; import org.rhq.core.pluginapi.inventory.ResourceContext; import org.rhq.core.pluginapi.measurement.MeasurementFacet; import org.rhq.core.pluginapi.operation.OperationFacet; @@ -122,8 +123,8 @@ import org.rhq.plugins.jmx.ObjectNameQueryUtility; * @author Jason Dobies * @author Ian Springer */ -public class JBossASServerComponent implements MeasurementFacet, OperationFacet, JMXComponent, - CreateChildResourceFacet, ApplicationServerComponent, ContentFacet, SupportFacet { +public class JBossASServerComponent<T extends ResourceComponent<?>> implements MeasurementFacet, OperationFacet, + JMXComponent<T>, CreateChildResourceFacet, ApplicationServerComponent, ContentFacet, SupportFacet { // Constants --------------------------------------------
private static final String LOCALHOST = "localhost"; @@ -404,8 +405,8 @@ public class JBossASServerComponent implements MeasurementFacet, OperationFacet, // OperationFacet Implementation --------------------------------------------
public OperationResult invokeOperation(String name, Configuration configuration) throws InterruptedException { - JBossASServerSupportedOperations operation = Enum.valueOf(JBossASServerSupportedOperations.class, name - .toUpperCase()); + JBossASServerSupportedOperations operation = Enum.valueOf(JBossASServerSupportedOperations.class, + name.toUpperCase()); return operationsDelegate.invoke(operation, configuration); }
@@ -1149,14 +1150,15 @@ public class JBossASServerComponent implements MeasurementFacet, OperationFacet, // Since the connection is attempted each time it's used, failure to connect could result in log // file spamming. Log it once for every 10 consecutive times it's encountered. if (consecutiveConnectionErrors % 10 == 0) { - log.warn("Could not establish connection to the JBoss AS instance [" - + (consecutiveConnectionErrors + 1) + "] times for resource [" - + resourceContext.getResourceKey() + "]", e); + log.warn( + "Could not establish connection to the JBoss AS instance [" + (consecutiveConnectionErrors + 1) + + "] times for resource [" + resourceContext.getResourceKey() + "]", e); }
if (log.isDebugEnabled()) - log.debug("Could not connect to the JBoss AS instance for resource [" - + resourceContext.getResourceKey() + "]", e); + log.debug( + "Could not connect to the JBoss AS instance for resource [" + resourceContext.getResourceKey() + + "]", e);
consecutiveConnectionErrors++;
diff --git a/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/JBossASTomcatConnectorDiscoveryComponent.java b/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/JBossASTomcatConnectorDiscoveryComponent.java index 1603c37..30068e8 100644 --- a/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/JBossASTomcatConnectorDiscoveryComponent.java +++ b/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/JBossASTomcatConnectorDiscoveryComponent.java @@ -33,6 +33,7 @@ import org.apache.commons.logging.LogFactory; import org.mc4j.ems.connection.EmsConnection; import org.mc4j.ems.connection.bean.EmsBean; import org.mc4j.ems.connection.bean.EmsBeanName; + import org.rhq.core.domain.configuration.Configuration; import org.rhq.core.domain.configuration.PropertySimple; import org.rhq.core.pluginapi.inventory.DiscoveredResourceDetails; @@ -48,13 +49,13 @@ import org.rhq.plugins.jmx.ObjectNameQueryUtility; * @author Jason Dobies * @author Ian Springer */ -public class JBossASTomcatConnectorDiscoveryComponent extends MBeanResourceDiscoveryComponent<JMXComponent> { +public class JBossASTomcatConnectorDiscoveryComponent extends MBeanResourceDiscoveryComponent<JMXComponent<?>> { private final Log log = LogFactory.getLog(this.getClass());
// MBeanResourceDiscoveryComponent Overridden Methods --------------------------------------------
@Override - public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext<JMXComponent> context) { + public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext<JMXComponent<?>> context) { Set<DiscoveredResourceDetails> resourceDetails = super.discoverResources(context);
/* @@ -62,7 +63,8 @@ public class JBossASTomcatConnectorDiscoveryComponent extends MBeanResourceDisco * corresponding jboss.web:type=Connector,* primary connector MBeans. */ EmsConnection connection = context.getParentResourceComponent().getEmsConnection(); - ObjectNameQueryUtility queryUtility = new ObjectNameQueryUtility("jboss.web:type=GlobalRequestProcessor,name=%name%"); + ObjectNameQueryUtility queryUtility = new ObjectNameQueryUtility( + "jboss.web:type=GlobalRequestProcessor,name=%name%"); List<EmsBean> beans = connection.queryBeans(queryUtility.getTranslatedQuery());
// We can't populate the name and scheme in the plugin config if the GlobalRequestProcessor MBeans aren't @@ -104,7 +106,8 @@ public class JBossASTomcatConnectorDiscoveryComponent extends MBeanResourceDisco for (DiscoveredResourceDetails resource : resourceDetails) { Configuration pluginConfiguration = resource.getPluginConfiguration();
- String dirtyAddress = pluginConfiguration.getSimple(JBossASTomcatConnectorComponent.PROPERTY_ADDRESS).getStringValue(); + String dirtyAddress = pluginConfiguration.getSimple(JBossASTomcatConnectorComponent.PROPERTY_ADDRESS) + .getStringValue();
String cleanAddress; if (dirtyAddress.startsWith("%2F")) { @@ -119,21 +122,20 @@ public class JBossASTomcatConnectorDiscoveryComponent extends MBeanResourceDisco }
String port = pluginConfiguration.getSimple(JBossASTomcatConnectorComponent.PROPERTY_PORT).getStringValue(); - + // Add the address to the Resource name (e.g. "Tomcat Connector (127.0.0.1:8080)"). - - String resourceName = resource.getResourceName(); - //resourceName = resourceName.replace("(", "(" + cleanAddress + ":"); - resource.setResourceName(resourceName);
- + String resourceName = resource.getResourceName(); + //resourceName = resourceName.replace("(", "(" + cleanAddress + ":"); + resource.setResourceName(resourceName);
String scheme = schemeMap.get(port); pluginConfiguration.put(new PropertySimple(JBossASTomcatConnectorComponent.PROPERTY_SCHEMA, scheme));
// Update the "address" and "dash" plugin config props, or remove them if not needed. if (addressPresentMap.containsKey(port)) { - pluginConfiguration.put(new PropertySimple(JBossASTomcatConnectorComponent.PROPERTY_ADDRESS, cleanAddress)); + pluginConfiguration.put(new PropertySimple(JBossASTomcatConnectorComponent.PROPERTY_ADDRESS, + cleanAddress)); pluginConfiguration.put(new PropertySimple(JBossASTomcatConnectorComponent.PROPERTY_DASH, "-")); } else { pluginConfiguration.put(new PropertySimple(JBossASTomcatConnectorComponent.PROPERTY_ADDRESS, "")); diff --git a/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/JBossASTomcatDiscoveryComponent.java b/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/JBossASTomcatDiscoveryComponent.java index 4966c49..8283423 100644 --- a/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/JBossASTomcatDiscoveryComponent.java +++ b/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/JBossASTomcatDiscoveryComponent.java @@ -1,25 +1,25 @@ - /* - * Jopr Management Platform - * Copyright (C) 2005-2008 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, version 2, as - * published by the Free Software Foundation, and/or the GNU Lesser - * General Public License, version 2.1, also as published by the Free - * Software Foundation. - * - * 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 and the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU General Public License - * and the GNU Lesser General Public License along with this program; - * if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ +/* + * Jopr Management Platform + * Copyright (C) 2005-2008 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, version 2, as + * published by the Free Software Foundation, and/or the GNU Lesser + * General Public License, version 2.1, also as published by the Free + * Software Foundation. + * + * 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 and the GNU Lesser General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License + * and the GNU Lesser General Public License along with this program; + * if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ package org.rhq.plugins.jbossas;
import java.io.File; @@ -48,14 +48,14 @@ import org.rhq.core.system.ProcessInfo; * @author Greg Hinkle * @author Ian Springer */ -public class JBossASTomcatDiscoveryComponent implements ResourceDiscoveryComponent<JBossASServerComponent> { +public class JBossASTomcatDiscoveryComponent implements ResourceDiscoveryComponent<JBossASServerComponent<?>> { private final Log log = LogFactory.getLog(JBossASTomcatDiscoveryComponent.class);
public static final String EMBEDDED_TOMCAT_PRE42_DIR = "jbossweb-tomcat"; public static final String EMBEDDED_TOMCAT_42_DIR = "jboss-web."; private static final String SERVER_INFO_PROPERTIES_RESOURCE = "org/apache/catalina/util/ServerInfo.properties";
- public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext<JBossASServerComponent> context) + public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext<JBossASServerComponent<?>> context) throws InvalidPluginConfigurationException, Exception { log.debug("Discovering Tomcat servers embedded in JBossAS server...");
@@ -86,8 +86,8 @@ public class JBossASTomcatDiscoveryComponent implements ResourceDiscoveryCompone + File.separator + ")"; Configuration pluginConfig = null; ProcessInfo processInfo = null; - DiscoveredResourceDetails resource = new DiscoveredResourceDetails(context.getResourceType(), key, getResourceName(pre42), - version, description, pluginConfig, processInfo); + DiscoveredResourceDetails resource = new DiscoveredResourceDetails(context.getResourceType(), key, + getResourceName(pre42), version, description, pluginConfig, processInfo); set.add(resource); }
@@ -97,7 +97,7 @@ public class JBossASTomcatDiscoveryComponent implements ResourceDiscoveryCompone private String getResourceName(boolean pre42) { return pre42 ? "Embedded Tomcat Server" : "Embedded JBossWeb Server"; } - + private String getVersion(File jbossWebDir) throws IOException { boolean pre42 = jbossWebDir.getName().startsWith(EMBEDDED_TOMCAT_PRE42_DIR); String jarFileName = (pre42) ? "catalina.jar" : "jbossweb.jar"; diff --git a/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/JBossASTomcatServerComponent.java b/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/JBossASTomcatServerComponent.java index 62b5b31..f240650 100644 --- a/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/JBossASTomcatServerComponent.java +++ b/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/JBossASTomcatServerComponent.java @@ -48,12 +48,12 @@ import org.rhq.plugins.jmx.JMXComponent; * @author John Mazzitelli */ public class JBossASTomcatServerComponent implements MeasurementFacet, OperationFacet, ConfigurationFacet, - JMXComponent<JMXComponent> { + JMXComponent<JMXComponent<?>> { private static Log log = LogFactory.getLog(JBossASTomcatServerComponent.class);
- private ResourceContext<JMXComponent> resourceContext; + private ResourceContext<JMXComponent<?>> resourceContext;
- public void start(ResourceContext<JMXComponent> context) { + public void start(ResourceContext<JMXComponent<?>> context) { resourceContext = context; }
@@ -99,7 +99,7 @@ public class JBossASTomcatServerComponent implements MeasurementFacet, Operation return this.resourceContext.getParentResourceComponent().getEmsConnection(); }
- ResourceContext<JMXComponent> getResourceContext() { + ResourceContext<JMXComponent<?>> getResourceContext() { return resourceContext; } } \ No newline at end of file diff --git a/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/JBossASTomcatVHostDiscoveryService.java b/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/JBossASTomcatVHostDiscoveryService.java index cafe78c..59989b6 100644 --- a/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/JBossASTomcatVHostDiscoveryService.java +++ b/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/JBossASTomcatVHostDiscoveryService.java @@ -37,12 +37,12 @@ import org.rhq.plugins.jmx.MBeanResourceDiscoveryComponent; * @author Heiko W. Rupp * */ -public class JBossASTomcatVHostDiscoveryService extends MBeanResourceDiscoveryComponent<JMXComponent> { +public class JBossASTomcatVHostDiscoveryService extends MBeanResourceDiscoveryComponent<JMXComponent<?>> {
static Pattern pattern = Pattern.compile(".*host=([\w.]+).*");
@Override - public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext<JMXComponent> discoveryContext) { + public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext<JMXComponent<?>> discoveryContext) {
Set<DiscoveredResourceDetails> resources = super.discoverResources(discoveryContext);
diff --git a/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/JBossASTomcatVHostService.java b/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/JBossASTomcatVHostService.java index e17f7a6..35411a5 100644 --- a/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/JBossASTomcatVHostService.java +++ b/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/JBossASTomcatVHostService.java @@ -1,25 +1,25 @@ - /* - * Jopr Management Platform - * Copyright (C) 2005-2008 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, version 2, as - * published by the Free Software Foundation, and/or the GNU Lesser - * General Public License, version 2.1, also as published by the Free - * Software Foundation. - * - * 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 and the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU General Public License - * and the GNU Lesser General Public License along with this program; - * if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ +/* + * Jopr Management Platform + * Copyright (C) 2005-2008 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, version 2, as + * published by the Free Software Foundation, and/or the GNU Lesser + * General Public License, version 2.1, also as published by the Free + * Software Foundation. + * + * 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 and the GNU Lesser General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License + * and the GNU Lesser General Public License along with this program; + * if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */
package org.rhq.plugins.jbossas;
@@ -41,7 +41,7 @@ import org.rhq.plugins.jmx.MBeanResourceComponent; * @author Heiko W. Rupp * */ -public class JBossASTomcatVHostService extends MBeanResourceComponent<JMXComponent> implements MeasurementFacet { +public class JBossASTomcatVHostService extends MBeanResourceComponent<JMXComponent<?>> implements MeasurementFacet {
/* (non-Javadoc) * @see org.rhq.core.pluginapi.inventory.ResourceComponent#getAvailability() diff --git a/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/JBossMQDiscoveryComponent.java b/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/JBossMQDiscoveryComponent.java index 65844b6..7ac105e 100644 --- a/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/JBossMQDiscoveryComponent.java +++ b/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/JBossMQDiscoveryComponent.java @@ -41,7 +41,7 @@ public class JBossMQDiscoveryComponent extends AbstractMessagingDiscoveryCompone private static final String VERSION_SOURCE = "jboss.mq:service=DestinationManager;Interceptor";
@Override - public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext<JMXComponent> context) { + public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext<JMXComponent<?>> context) { String objectNameQueryTemplate = "jboss.mq:service=DestinationManager"; Set<DiscoveredResourceDetails> result = super.discoverResources(context, objectNameQueryTemplate, DEFAULT_RESOURCE_NAME, DEFAULT_RESOURCE_DESCRIPTION, diff --git a/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/JBossMessagingComponent.java b/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/JBossMessagingComponent.java index e06b5cf..bf8d94f 100644 --- a/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/JBossMessagingComponent.java +++ b/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/JBossMessagingComponent.java @@ -1,25 +1,25 @@ - /* - * Jopr Management Platform - * Copyright (C) 2005-2008 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, version 2, as - * published by the Free Software Foundation, and/or the GNU Lesser - * General Public License, version 2.1, also as published by the Free - * Software Foundation. - * - * 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 and the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU General Public License - * and the GNU Lesser General Public License along with this program; - * if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ +/* + * Jopr Management Platform + * Copyright (C) 2005-2008 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, version 2, as + * published by the Free Software Foundation, and/or the GNU Lesser + * General Public License, version 2.1, also as published by the Free + * Software Foundation. + * + * 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 and the GNU Lesser General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License + * and the GNU Lesser General Public License along with this program; + * if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */
package org.rhq.plugins.jbossas;
@@ -67,7 +67,7 @@ public class JBossMessagingComponent extends AbstractMessagingComponent implemen }
@Override - public void start(ResourceContext<JBossASServerComponent> context) { + public void start(ResourceContext<JBossASServerComponent<?>> context) { super.start(context, new JBossMessagingConfigurationEditor(context.getResourceType().getName())); }
@@ -111,8 +111,7 @@ public class JBossMessagingComponent extends AbstractMessagingComponent implemen xmlEditor.updateConfiguration(deploymentFile, name, report); try { parentResourceComponent.deployFile(deploymentFile); - } - catch (Exception e) { + } catch (Exception e) { JBossASServerComponent.setErrorOnCreateResourceReport(report, e.getLocalizedMessage(), e); return report; } diff --git a/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/JBossMessagingDiscoveryComponent.java b/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/JBossMessagingDiscoveryComponent.java index 9feeb42..975d668 100644 --- a/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/JBossMessagingDiscoveryComponent.java +++ b/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/JBossMessagingDiscoveryComponent.java @@ -39,7 +39,7 @@ public class JBossMessagingDiscoveryComponent extends AbstractMessagingDiscovery private static final String DEFAULT_RESOURCE_DESCRIPTION = "JBoss Messaging subsystem";
@Override - public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext<JMXComponent> context) { + public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext<JMXComponent<?>> context) { String objectNameQueryTemplate = "jboss.messaging:service=PostOffice"; Set<DiscoveredResourceDetails> result = super.discoverResources(context, objectNameQueryTemplate, DEFAULT_RESOURCE_NAME, DEFAULT_RESOURCE_DESCRIPTION, diff --git a/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/JMSComponent.java b/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/JMSComponent.java index a4cb1c7..9bdc4ab 100644 --- a/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/JMSComponent.java +++ b/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/JMSComponent.java @@ -1,25 +1,25 @@ - /* - * Jopr Management Platform - * Copyright (C) 2005-2008 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, version 2, as - * published by the Free Software Foundation, and/or the GNU Lesser - * General Public License, version 2.1, also as published by the Free - * Software Foundation. - * - * 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 and the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU General Public License - * and the GNU Lesser General Public License along with this program; - * if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ +/* + * Jopr Management Platform + * Copyright (C) 2005-2008 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, version 2, as + * published by the Free Software Foundation, and/or the GNU Lesser + * General Public License, version 2.1, also as published by the Free + * Software Foundation. + * + * 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 and the GNU Lesser General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License + * and the GNU Lesser General Public License along with this program; + * if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ package org.rhq.plugins.jbossas;
import java.io.File; @@ -72,7 +72,7 @@ public class JMSComponent extends AbstractMessagingComponent implements Configur }
@Override - public void start(ResourceContext<JBossASServerComponent> context) { + public void start(ResourceContext<JBossASServerComponent<?>> context) { super.start(context, new JMSConfigurationEditor(context.getResourceType().getName())); }
@@ -115,8 +115,7 @@ public class JMSComponent extends AbstractMessagingComponent implements Configur xmlEditor.updateConfiguration(deploymentFile, name, report); try { parentResourceComponent.deployFile(deploymentFile); - } - catch (Exception e) { + } catch (Exception e) { JBossASServerComponent.setErrorOnCreateResourceReport(report, e.getLocalizedMessage(), e); return report; } @@ -124,7 +123,7 @@ public class JMSComponent extends AbstractMessagingComponent implements Configur // This key needs to be the same as the object name string used in discovery, defined in the plugin descriptor // jboss.mq.destination:service=<Queue|Topic,name=%name% String serviceString = (isTopic ? "Topic" : "Queue"); - + String objectName = "jboss.mq.destination:name=" + name + ",service=" + serviceString; try { // IMPORTANT: The object name must be canonicalized so it matches the resource key that @@ -136,7 +135,7 @@ public class JMSComponent extends AbstractMessagingComponent implements Configur return report; } report.setResourceName(rName); - + try { Thread.sleep(5000L); } catch (InterruptedException e) { diff --git a/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/WarDiscoveryComponent.java b/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/WarDiscoveryComponent.java index 179859d..059f90e 100644 --- a/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/WarDiscoveryComponent.java +++ b/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/WarDiscoveryComponent.java @@ -36,7 +36,7 @@ import org.rhq.plugins.jmx.JMXComponent; */ public class WarDiscoveryComponent extends ApplicationDiscoveryComponent { @Override - public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext<JMXComponent> discoveryContext) { + public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext<JMXComponent<?>> discoveryContext) { Set<DiscoveredResourceDetails> resources = super.discoverResources(discoveryContext); JBossASServerComponent parentJBossASComponent = (JBossASServerComponent) discoveryContext .getParentResourceComponent(); diff --git a/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/script/ScriptComponent.java b/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/script/ScriptComponent.java index f62b3aa..736f0eb 100644 --- a/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/script/ScriptComponent.java +++ b/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/script/ScriptComponent.java @@ -34,6 +34,7 @@ import java.util.regex.Pattern; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.jetbrains.annotations.NotNull; + import org.rhq.core.domain.configuration.Configuration; import org.rhq.core.domain.configuration.PropertySimple; import org.rhq.core.domain.measurement.AvailabilityType; @@ -52,7 +53,7 @@ import org.rhq.plugins.jbossas.JBossASServerComponent; * * @author Ian Springer */ -public class ScriptComponent implements ResourceComponent<JBossASServerComponent>, OperationFacet { +public class ScriptComponent implements ResourceComponent<JBossASServerComponent<?>>, OperationFacet { public static final String PATH_CONFIG_PROP = "path"; public static final String ENVIRONMENT_VARIABLES_CONFIG_PROP = "environmentVariables";
@@ -65,9 +66,9 @@ public class ScriptComponent implements ResourceComponent<JBossASServerComponent
private final Log log = LogFactory.getLog(this.getClass());
- private ResourceContext<JBossASServerComponent> resourceContext; + private ResourceContext<JBossASServerComponent<?>> resourceContext;
- public void start(ResourceContext<JBossASServerComponent> resourceContext) { + public void start(ResourceContext<JBossASServerComponent<?>> resourceContext) { this.resourceContext = resourceContext; }
diff --git a/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/script/ScriptDiscoveryComponent.java b/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/script/ScriptDiscoveryComponent.java index 667d10f..93a768a 100644 --- a/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/script/ScriptDiscoveryComponent.java +++ b/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/script/ScriptDiscoveryComponent.java @@ -1,25 +1,25 @@ - /* - * Jopr Management Platform - * Copyright (C) 2005-2011 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, version 2, as - * published by the Free Software Foundation, and/or the GNU Lesser - * General Public License, version 2.1, also as published by the Free - * Software Foundation. - * - * 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 and the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU General Public License - * and the GNU Lesser General Public License along with this program; - * if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ +/* + * Jopr Management Platform + * Copyright (C) 2005-2011 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, version 2, as + * published by the Free Software Foundation, and/or the GNU Lesser + * General Public License, version 2.1, also as published by the Free + * Software Foundation. + * + * 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 and the GNU Lesser General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License + * and the GNU Lesser General Public License along with this program; + * if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ package org.rhq.plugins.jbossas.script;
import java.io.File; @@ -28,16 +28,18 @@ import java.util.HashSet; 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.rhq.core.domain.configuration.Configuration; import org.rhq.core.domain.configuration.PropertySimple; import org.rhq.core.domain.resource.ResourceUpgradeReport; import org.rhq.core.pluginapi.inventory.DiscoveredResourceDetails; +import org.rhq.core.pluginapi.inventory.InvalidPluginConfigurationException; import org.rhq.core.pluginapi.inventory.ResourceContext; import org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent; import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext; -import org.rhq.core.pluginapi.inventory.InvalidPluginConfigurationException; import org.rhq.core.pluginapi.upgrade.ResourceUpgradeContext; import org.rhq.core.pluginapi.upgrade.ResourceUpgradeFacet; import org.rhq.core.system.ProcessInfo; @@ -48,14 +50,14 @@ import org.rhq.plugins.jbossas.JBossASServerComponent; * * @author Ian Springer */ -public class ScriptDiscoveryComponent implements ResourceDiscoveryComponent<JBossASServerComponent>, - ResourceUpgradeFacet<JBossASServerComponent> { +public class ScriptDiscoveryComponent implements ResourceDiscoveryComponent<JBossASServerComponent<?>>, + ResourceUpgradeFacet<JBossASServerComponent<?>> {
private final Log log = LogFactory.getLog(this.getClass());
public Set<DiscoveredResourceDetails> discoverResources( - ResourceDiscoveryContext<JBossASServerComponent> discoveryContext) - throws InvalidPluginConfigurationException { + ResourceDiscoveryContext<JBossASServerComponent<?>> discoveryContext) + throws InvalidPluginConfigurationException { Set<DiscoveredResourceDetails> resources = new HashSet<DiscoveredResourceDetails>(); // TODO: Upgrade to new manual discovery API. List<Configuration> pluginConfigs = discoveryContext.getPluginConfigurations(); @@ -68,7 +70,7 @@ public class ScriptDiscoveryComponent implements ResourceDiscoveryComponent<JBos }
@Override - public ResourceUpgradeReport upgrade(ResourceUpgradeContext<JBossASServerComponent> upgradeContext) { + public ResourceUpgradeReport upgrade(ResourceUpgradeContext<JBossASServerComponent<?>> upgradeContext) { String inventoriedResourceKey = upgradeContext.getResourceKey();
ResourceContext parentResourceContext = upgradeContext.getParentResourceContext(); @@ -92,17 +94,18 @@ public class ScriptDiscoveryComponent implements ResourceDiscoveryComponent<JBos
private File getServerBinDirectory(ResourceContext parentResourceContext) { Configuration parentPluginConfig = parentResourceContext.getPluginConfiguration(); - String homeDir = parentPluginConfig.getSimple(JBossASServerComponent.JBOSS_HOME_DIR_CONFIG_PROP).getStringValue(); + String homeDir = parentPluginConfig.getSimple(JBossASServerComponent.JBOSS_HOME_DIR_CONFIG_PROP) + .getStringValue(); return new File(homeDir, "bin"); }
private static String buildResourceKey(String scriptPath, File binDir) { - return (scriptPath.startsWith(binDir.getPath())) ? scriptPath.substring(binDir.getPath().length() + 1) : - scriptPath; + return (scriptPath.startsWith(binDir.getPath())) ? scriptPath.substring(binDir.getPath().length() + 1) + : scriptPath; }
- private void processAutoDiscoveredResources(ResourceDiscoveryContext<JBossASServerComponent> discoveryContext, - Set<DiscoveredResourceDetails> resources) { + private void processAutoDiscoveredResources(ResourceDiscoveryContext<JBossASServerComponent<?>> discoveryContext, + Set<DiscoveredResourceDetails> resources) { ResourceContext parentResourceContext = discoveryContext.getParentResourceContext(); File binDir = getServerBinDirectory(parentResourceContext); log.debug("Searching for scripts beneath JBossAS server bin directory (" + binDir + ")..."); @@ -120,8 +123,8 @@ public class ScriptDiscoveryComponent implements ResourceDiscoveryComponent<JBos } }
- private void processManuallyAddedResources(ResourceDiscoveryContext<JBossASServerComponent> discoveryContext, - Set<DiscoveredResourceDetails> resources, List<Configuration> pluginConfigs) { + private void processManuallyAddedResources(ResourceDiscoveryContext<JBossASServerComponent<?>> discoveryContext, + Set<DiscoveredResourceDetails> resources, List<Configuration> pluginConfigs) { ResourceContext parentResourceContext = discoveryContext.getParentResourceContext(); File binDir = getServerBinDirectory(parentResourceContext); for (Configuration pluginConfig : pluginConfigs) { @@ -167,7 +170,7 @@ public class ScriptDiscoveryComponent implements ResourceDiscoveryComponent<JBos }
private DiscoveredResourceDetails createResourceDetails( - ResourceDiscoveryContext<JBossASServerComponent> discoveryContext, Configuration pluginConfig, File homeDir) { + ResourceDiscoveryContext<JBossASServerComponent<?>> discoveryContext, Configuration pluginConfig, File homeDir) { String path = pluginConfig.getSimple(ScriptComponent.PATH_CONFIG_PROP).getStringValue(); String key = buildResourceKey(path, homeDir); String name = new File(path).getName(); diff --git a/modules/plugins/jboss-cache-v3/src/main/java/org/rhq/plugins/jbosscache3/JBossCacheComponent.java b/modules/plugins/jboss-cache-v3/src/main/java/org/rhq/plugins/jbosscache3/JBossCacheComponent.java index 17a2b1e..883c49d 100644 --- a/modules/plugins/jboss-cache-v3/src/main/java/org/rhq/plugins/jbosscache3/JBossCacheComponent.java +++ b/modules/plugins/jboss-cache-v3/src/main/java/org/rhq/plugins/jbosscache3/JBossCacheComponent.java @@ -27,6 +27,7 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.jetbrains.annotations.NotNull; import org.mc4j.ems.connection.EmsConnection; + import org.rhq.core.domain.configuration.Configuration; import org.rhq.core.domain.measurement.AvailabilityType; import org.rhq.core.pluginapi.inventory.InvalidPluginConfigurationException; @@ -39,54 +40,51 @@ import org.rhq.plugins.jbossas5.connection.ProfileServiceConnection; * @author Filip Drabek * */ -public class JBossCacheComponent implements - ProfileServiceComponent<ProfileServiceComponent> { +public class JBossCacheComponent implements ProfileServiceComponent<ProfileServiceComponent<?>> {
- private final Log log = LogFactory.getLog(this.getClass()); + private final Log log = LogFactory.getLog(this.getClass());
- public static String CACHE_SEARCH_STRING = "searchString"; + public static String CACHE_SEARCH_STRING = "searchString";
- private ProfileServiceComponent parentComp; + private ProfileServiceComponent<?> parentComp;
- private String beanName; + private String beanName;
- private ResourceContext<ProfileServiceComponent> resourceContext; + private ResourceContext<ProfileServiceComponent<?>> resourceContext;
- public void start(ResourceContext<ProfileServiceComponent> context) - throws InvalidPluginConfigurationException, Exception { + public void start(ResourceContext<ProfileServiceComponent<?>> context) throws InvalidPluginConfigurationException, + Exception {
resourceContext = context; - parentComp = context.getParentResourceComponent(); + parentComp = context.getParentResourceComponent();
- Configuration configuration = context.getPluginConfiguration(); + Configuration configuration = context.getPluginConfiguration();
- if (configuration.get(JBossCacheComponent.CACHE_SEARCH_STRING) != null) - beanName = configuration.getSimple( - JBossCacheComponent.CACHE_SEARCH_STRING).getStringValue(); - else - throw new InvalidPluginConfigurationException( - "Invalid plugin configuration in JBossCache component."); + if (configuration.get(JBossCacheComponent.CACHE_SEARCH_STRING) != null) + beanName = configuration.getSimple(JBossCacheComponent.CACHE_SEARCH_STRING).getStringValue(); + else + throw new InvalidPluginConfigurationException("Invalid plugin configuration in JBossCache component.");
- } + }
- public void stop() { - return; - } + public void stop() { + return; + }
- public AvailabilityType getAvailability() { - return parentComp.getAvailability(); - } + public AvailabilityType getAvailability() { + return parentComp.getAvailability(); + }
- public ProfileServiceConnection getConnection() { - return parentComp.getConnection(); - } + public ProfileServiceConnection getConnection() { + return parentComp.getConnection(); + }
- public EmsConnection getEmsConnection() { - return parentComp.getEmsConnection(); - } + public EmsConnection getEmsConnection() { + return parentComp.getEmsConnection(); + }
@NotNull - public ResourceContext<ProfileServiceComponent> getResourceContext() { + public ResourceContext<ProfileServiceComponent<?>> getResourceContext() { return resourceContext; } } diff --git a/modules/plugins/jboss-cache-v3/src/main/java/org/rhq/plugins/jbosscache3/JBossCacheDetailComponent.java b/modules/plugins/jboss-cache-v3/src/main/java/org/rhq/plugins/jbosscache3/JBossCacheDetailComponent.java index 844da14..281ce80 100644 --- a/modules/plugins/jboss-cache-v3/src/main/java/org/rhq/plugins/jbosscache3/JBossCacheDetailComponent.java +++ b/modules/plugins/jboss-cache-v3/src/main/java/org/rhq/plugins/jbosscache3/JBossCacheDetailComponent.java @@ -53,16 +53,16 @@ import org.rhq.plugins.jbossas5.connection.ProfileServiceConnection; * */ public class JBossCacheDetailComponent implements MeasurementFacet, - OperationFacet, ProfileServiceComponent<ProfileServiceComponent> { + OperationFacet, ProfileServiceComponent<ProfileServiceComponent<?>> {
public static String JMX_NAME = "jmx-name"; public static String CACHE_DETAIL_BEAN_NAME = "bean-name"; public ProfileServiceComponent parentComponent; private String beanName; private final Log log = LogFactory.getLog(this.getClass()); - private ResourceContext<ProfileServiceComponent> resourceContext; + private ResourceContext<ProfileServiceComponent<?>> resourceContext;
- public void start(ResourceContext<ProfileServiceComponent> context) + public void start(ResourceContext<ProfileServiceComponent<?>> context) throws InvalidPluginConfigurationException, Exception {
resourceContext = context; @@ -104,7 +104,7 @@ public class JBossCacheDetailComponent implements MeasurementFacet, }
@NotNull - public ResourceContext<ProfileServiceComponent> getResourceContext() { + public ResourceContext<ProfileServiceComponent<?>> getResourceContext() { return resourceContext; }
diff --git a/modules/plugins/jboss-cache-v3/src/main/java/org/rhq/plugins/jbosscache3/JBossCacheDetailDiscoveryComponent.java b/modules/plugins/jboss-cache-v3/src/main/java/org/rhq/plugins/jbosscache3/JBossCacheDetailDiscoveryComponent.java index 764bf64..5d522de 100644 --- a/modules/plugins/jboss-cache-v3/src/main/java/org/rhq/plugins/jbosscache3/JBossCacheDetailDiscoveryComponent.java +++ b/modules/plugins/jboss-cache-v3/src/main/java/org/rhq/plugins/jbosscache3/JBossCacheDetailDiscoveryComponent.java @@ -45,7 +45,7 @@ import org.rhq.plugins.jbossas5.ProfileServiceComponent; * */ public class JBossCacheDetailDiscoveryComponent implements - ResourceDiscoveryComponent<ProfileServiceComponent> { + ResourceDiscoveryComponent<ProfileServiceComponent<?>> { public static String CACHE_JMX_NAME = "jmx-resource";
private final Log log = LogFactory.getLog(this.getClass()); @@ -53,7 +53,7 @@ public class JBossCacheDetailDiscoveryComponent implements private ProfileServiceComponent parentComponent;
public Set<DiscoveredResourceDetails> discoverResources( - ResourceDiscoveryContext<ProfileServiceComponent> context) + ResourceDiscoveryContext<ProfileServiceComponent<?>> context) throws InvalidPluginConfigurationException, Exception {
ResourceType resourceType = context.getResourceType(); diff --git a/modules/plugins/jboss-cache-v3/src/main/java/org/rhq/plugins/jbosscache3/JBossCacheDiscoveryComponent.java b/modules/plugins/jboss-cache-v3/src/main/java/org/rhq/plugins/jbosscache3/JBossCacheDiscoveryComponent.java index 88fd836..86bd02f 100644 --- a/modules/plugins/jboss-cache-v3/src/main/java/org/rhq/plugins/jbosscache3/JBossCacheDiscoveryComponent.java +++ b/modules/plugins/jboss-cache-v3/src/main/java/org/rhq/plugins/jbosscache3/JBossCacheDiscoveryComponent.java @@ -48,13 +48,13 @@ import org.rhq.plugins.jmx.ObjectNameQueryUtility; * */ public class JBossCacheDiscoveryComponent implements - ResourceDiscoveryComponent<ProfileServiceComponent> { + ResourceDiscoveryComponent<ProfileServiceComponent<?>> { private String REGEX = "(,|:)jmx-resource=[^,]*(,|\z)"; private static String[] RESOURCE_NAME_KEY_PROPS = { "cluster", "config" }; private static final String DEFAULT_RESOURCE_DESCRIPTION = "JBoss Cache";
public Set<DiscoveredResourceDetails> discoverResources( - ResourceDiscoveryContext<ProfileServiceComponent> context) + ResourceDiscoveryContext<ProfileServiceComponent<?>> context) throws InvalidPluginConfigurationException, Exception {
ProfileServiceComponent parentComponent = context diff --git a/modules/plugins/jboss-cache/src/main/java/org/rhq/plugins/jbosscache/JBossCacheComponent.java b/modules/plugins/jboss-cache/src/main/java/org/rhq/plugins/jbosscache/JBossCacheComponent.java index daa7cdb..1ee8500 100644 --- a/modules/plugins/jboss-cache/src/main/java/org/rhq/plugins/jbosscache/JBossCacheComponent.java +++ b/modules/plugins/jboss-cache/src/main/java/org/rhq/plugins/jbosscache/JBossCacheComponent.java @@ -69,7 +69,7 @@ import org.rhq.plugins.jmx.ObjectNameQueryUtility; * @author Heiko W. Rupp * */ -public class JBossCacheComponent implements ResourceComponent<JMXComponent>, MeasurementFacet, OperationFacet, +public class JBossCacheComponent implements ResourceComponent<JMXComponent<?>>, MeasurementFacet, OperationFacet, ConfigurationFacet {
private final static Log log = LogFactory.getLog(JBossCacheComponent.class); @@ -86,7 +86,7 @@ public class JBossCacheComponent implements ResourceComponent<JMXComponent>, Mea this.context = context;
PropertySimple tcProp = context.getPluginConfiguration().getSimple("isTreeCache"); - if (tcProp==null || tcProp.getBooleanValue()==null) + if (tcProp == null || tcProp.getBooleanValue() == null) throw new InvalidPluginConfigurationException("Cache flavour not provided"); else isTreeCache = tcProp.getBooleanValue(); @@ -200,7 +200,7 @@ public class JBossCacheComponent implements ResourceComponent<JMXComponent>, Mea public Configuration loadResourceConfiguration() throws Exception {
File file = DeploymentUtility.getDescriptorFile(parentServer.getEmsConnection(), context.getResourceKey()); - if (file==null) { + if (file == null) { log.warn("Can not find the deployment descriptor for this cache "); return null; } @@ -286,7 +286,7 @@ public class JBossCacheComponent implements ResourceComponent<JMXComponent>, Mea report.setErrorMessage("Failed to determine the deployment descriptor file for mbean '" + mbeanName + "'."); return; } - + CacheConfigurationHelper helper = new CacheConfigurationHelper(); try { helper.writeConfig(file, newOne, mbeanName, true); diff --git a/modules/plugins/jboss-cache/src/main/java/org/rhq/plugins/jbosscache/JBossCacheDiscoveryComponent.java b/modules/plugins/jboss-cache/src/main/java/org/rhq/plugins/jbosscache/JBossCacheDiscoveryComponent.java index f37099e..4d1eecf 100644 --- a/modules/plugins/jboss-cache/src/main/java/org/rhq/plugins/jbosscache/JBossCacheDiscoveryComponent.java +++ b/modules/plugins/jboss-cache/src/main/java/org/rhq/plugins/jbosscache/JBossCacheDiscoveryComponent.java @@ -49,7 +49,7 @@ import org.rhq.plugins.jmx.MBeanResourceDiscoveryComponent; * * @author Heiko W. Rupp */ -public class JBossCacheDiscoveryComponent extends MBeanResourceDiscoveryComponent<JMXComponent> { +public class JBossCacheDiscoveryComponent extends MBeanResourceDiscoveryComponent<JMXComponent<?>> {
private static final Log log = LogFactory.getLog(JBossCacheDiscoveryComponent.class);
@@ -57,10 +57,10 @@ public class JBossCacheDiscoveryComponent extends MBeanResourceDiscoveryComponen * @see org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent#discoverResources(org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext) */ @Override - public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext<JMXComponent> context) { + public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext<JMXComponent<?>> context) {
ResourceContext parentCtx = context.getParentResourceContext(); - JMXComponent<JBossASServerComponent> gparentComponent = (JMXComponent<JBossASServerComponent>) parentCtx.getParentResourceComponent(); + JMXComponent<JBossASServerComponent<?>> gparentComponent = (JMXComponent<JBossASServerComponent<?>>) parentCtx.getParentResourceComponent();
Set<DiscoveredResourceDetails> discovered = super.performDiscovery(context.getDefaultPluginConfiguration(), gparentComponent, context.getResourceType(), false);
diff --git a/modules/plugins/jboss-cache/src/main/java/org/rhq/plugins/jbosscache/JBossCacheSubsystemComponent.java b/modules/plugins/jboss-cache/src/main/java/org/rhq/plugins/jbosscache/JBossCacheSubsystemComponent.java index 13acbec..d167d51 100644 --- a/modules/plugins/jboss-cache/src/main/java/org/rhq/plugins/jbosscache/JBossCacheSubsystemComponent.java +++ b/modules/plugins/jboss-cache/src/main/java/org/rhq/plugins/jbosscache/JBossCacheSubsystemComponent.java @@ -47,7 +47,7 @@ import org.rhq.plugins.jmx.JMXComponent; * * @author Heiko W. Rupp */ -public class JBossCacheSubsystemComponent<T extends JMXComponent<JBossASServerComponent>> implements +public class JBossCacheSubsystemComponent<T extends JMXComponent<JBossASServerComponent<?>>> implements ResourceComponent<T>, CreateChildResourceFacet {
private final Log log = LogFactory.getLog(JBossCacheSubsystemComponent.class); diff --git a/modules/plugins/jboss-cache/src/main/java/org/rhq/plugins/jbosscache/JBossCacheSubsystemDiscovery.java b/modules/plugins/jboss-cache/src/main/java/org/rhq/plugins/jbosscache/JBossCacheSubsystemDiscovery.java index 9a0a3ce..514d390 100644 --- a/modules/plugins/jboss-cache/src/main/java/org/rhq/plugins/jbosscache/JBossCacheSubsystemDiscovery.java +++ b/modules/plugins/jboss-cache/src/main/java/org/rhq/plugins/jbosscache/JBossCacheSubsystemDiscovery.java @@ -28,7 +28,7 @@ import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext; * * @author Heiko W. Rupp */ -public class JBossCacheSubsystemDiscovery implements ResourceDiscoveryComponent<JBossCacheSubsystemComponent> +public class JBossCacheSubsystemDiscovery implements ResourceDiscoveryComponent<JBossCacheSubsystemComponent<?>> {
private static final String JBOSS_CACHE_SUBSYSTEM = "JBoss Cache subsystem"; @@ -38,7 +38,7 @@ public class JBossCacheSubsystemDiscovery implements ResourceDiscoveryComponent< * * @see org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent#discoverResources(org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext) */ - public Set<DiscoveredResourceDetails> discoverResources( ResourceDiscoveryContext<JBossCacheSubsystemComponent> context) + public Set<DiscoveredResourceDetails> discoverResources( ResourceDiscoveryContext<JBossCacheSubsystemComponent<?>> context) throws InvalidPluginConfigurationException, Exception {
Set<DiscoveredResourceDetails> subsystem = new HashSet<DiscoveredResourceDetails>(1); diff --git a/modules/plugins/jmx/src/main/java/org/rhq/plugins/jmx/EmbeddedJMXServerDiscoveryComponent.java b/modules/plugins/jmx/src/main/java/org/rhq/plugins/jmx/EmbeddedJMXServerDiscoveryComponent.java index f79daed..4b48067 100644 --- a/modules/plugins/jmx/src/main/java/org/rhq/plugins/jmx/EmbeddedJMXServerDiscoveryComponent.java +++ b/modules/plugins/jmx/src/main/java/org/rhq/plugins/jmx/EmbeddedJMXServerDiscoveryComponent.java @@ -22,9 +22,9 @@ */ package org.rhq.plugins.jmx;
+import java.lang.reflect.Method; import java.util.HashSet; import java.util.Set; -import java.lang.reflect.Method;
import org.mc4j.ems.connection.EmsConnection; import org.mc4j.ems.connection.bean.EmsBean; @@ -47,8 +47,8 @@ import org.rhq.core.system.ProcessInfo; * * @author Greg Hinkle */ -public class EmbeddedJMXServerDiscoveryComponent implements ResourceDiscoveryComponent<JMXComponent> { - public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext<JMXComponent> context) +public class EmbeddedJMXServerDiscoveryComponent implements ResourceDiscoveryComponent<JMXComponent<?>> { + public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext<JMXComponent<?>> context) throws Exception { Set<DiscoveredResourceDetails> discoveredServers = new HashSet<DiscoveredResourceDetails>();
@@ -98,8 +98,8 @@ public class EmbeddedJMXServerDiscoveryComponent implements ResourceDiscoveryCom if (runtimeMBean != null) { String version = getSystemProperty(runtimeMBean, "java.version"); DiscoveredResourceDetails server = new DiscoveredResourceDetails(context.getResourceType(), "JVM", - ParentDefinedJMXServerNamingUtility.getJVMName(context), version, context.getResourceType().getDescription(), - configuration, null); + ParentDefinedJMXServerNamingUtility.getJVMName(context), version, context.getResourceType() + .getDescription(), configuration, null); discoveredServers.add(server); }
@@ -111,11 +111,11 @@ public class EmbeddedJMXServerDiscoveryComponent implements ResourceDiscoveryCom // ClassCastExceptions due to EMS having used a different classloader than us to load them. Object tabularDataObj = runtimeMBean.getAttribute("systemProperties").refresh(); Method getMethod = tabularDataObj.getClass().getMethod("get", - new Class[] { Class.forName("[Ljava.lang.Object;") }); + new Class[] { Class.forName("[Ljava.lang.Object;") }); // varargs don't work out when the arg itself is an array, so specify the parameters explicitly using arrays. - Object compositeDataObj = getMethod.invoke(tabularDataObj, new Object[] { new Object[] { propertyName }}); + Object compositeDataObj = getMethod.invoke(tabularDataObj, new Object[] { new Object[] { propertyName } }); getMethod = compositeDataObj.getClass().getMethod("get", String.class); - String version = (String)getMethod.invoke(compositeDataObj, "value"); + String version = (String) getMethod.invoke(compositeDataObj, "value"); return version; } } \ No newline at end of file diff --git a/modules/plugins/jmx/src/main/java/org/rhq/plugins/jmx/InternalJMXServerDiscoveryComponent.java b/modules/plugins/jmx/src/main/java/org/rhq/plugins/jmx/InternalJMXServerDiscoveryComponent.java index 8973b54..fcd16fc 100644 --- a/modules/plugins/jmx/src/main/java/org/rhq/plugins/jmx/InternalJMXServerDiscoveryComponent.java +++ b/modules/plugins/jmx/src/main/java/org/rhq/plugins/jmx/InternalJMXServerDiscoveryComponent.java @@ -42,8 +42,8 @@ public class InternalJMXServerDiscoveryComponent implements ResourceDiscoveryCom Set<DiscoveredResourceDetails> found = new HashSet<DiscoveredResourceDetails>();
DiscoveredResourceDetails localVM = new DiscoveredResourceDetails(context.getResourceType(), "InternalVM", - ParentDefinedJMXServerNamingUtility.getJVMName(context), System.getProperty("java.version"), "VM of plugin container", null, - null); + ParentDefinedJMXServerNamingUtility.getJVMName(context), System.getProperty("java.version"), + "VM of plugin container", null, null); Configuration configuration = localVM.getPluginConfiguration(); configuration.put(new PropertySimple(JMXDiscoveryComponent.CONNECTOR_ADDRESS_CONFIG_PROPERTY, "Local Connection")); diff --git a/modules/plugins/jmx/src/main/java/org/rhq/plugins/jmx/JMXServerComponent.java b/modules/plugins/jmx/src/main/java/org/rhq/plugins/jmx/JMXServerComponent.java index 29b36e8..1f77f48 100644 --- a/modules/plugins/jmx/src/main/java/org/rhq/plugins/jmx/JMXServerComponent.java +++ b/modules/plugins/jmx/src/main/java/org/rhq/plugins/jmx/JMXServerComponent.java @@ -44,6 +44,7 @@ import org.rhq.core.domain.configuration.PropertySimple; import org.rhq.core.domain.measurement.AvailabilityType; import org.rhq.core.domain.resource.Resource; import org.rhq.core.domain.resource.ResourceType; +import org.rhq.core.pluginapi.inventory.ResourceComponent; import org.rhq.core.pluginapi.inventory.ResourceContext;
/** @@ -59,7 +60,7 @@ import org.rhq.core.pluginapi.inventory.ResourceContext; * @author Greg Hinkle * @author John Mazzitelli */ -public class JMXServerComponent implements JMXComponent { +public class JMXServerComponent<T extends ResourceComponent<?>> implements JMXComponent<T> { private static Log log = LogFactory.getLog(JMXServerComponent.class);
private EmsConnection connection; diff --git a/modules/plugins/jmx/src/main/java/org/rhq/plugins/jmx/MBeanResourceComponent.java b/modules/plugins/jmx/src/main/java/org/rhq/plugins/jmx/MBeanResourceComponent.java index 8da6a2d..f10c150 100644 --- a/modules/plugins/jmx/src/main/java/org/rhq/plugins/jmx/MBeanResourceComponent.java +++ b/modules/plugins/jmx/src/main/java/org/rhq/plugins/jmx/MBeanResourceComponent.java @@ -75,7 +75,7 @@ import org.rhq.core.util.exception.ThrowableUtil; * @author Greg Hinkle * @author John Mazzitelli */ -public class MBeanResourceComponent<T extends JMXComponent> implements MeasurementFacet, OperationFacet, +public class MBeanResourceComponent<T extends JMXComponent<?>> implements MeasurementFacet, OperationFacet, ConfigurationFacet, JMXComponent<T> {
/** diff --git a/modules/plugins/jmx/src/main/java/org/rhq/plugins/jmx/MBeanResourceDiscoveryComponent.java b/modules/plugins/jmx/src/main/java/org/rhq/plugins/jmx/MBeanResourceDiscoveryComponent.java index 94bc89c..c4e1c5d 100644 --- a/modules/plugins/jmx/src/main/java/org/rhq/plugins/jmx/MBeanResourceDiscoveryComponent.java +++ b/modules/plugins/jmx/src/main/java/org/rhq/plugins/jmx/MBeanResourceDiscoveryComponent.java @@ -50,7 +50,7 @@ import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext; * * @author Greg Hinkle */ -public class MBeanResourceDiscoveryComponent<T extends JMXComponent> implements ResourceDiscoveryComponent<T> { +public class MBeanResourceDiscoveryComponent<T extends JMXComponent<?>> implements ResourceDiscoveryComponent<T> { // Constants --------------------------------------------
/** @@ -93,8 +93,8 @@ public class MBeanResourceDiscoveryComponent<T extends JMXComponent> implements public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext<T> context, boolean skipUnknownProps) { this.discoveryContext = context; - return performDiscovery(context.getDefaultPluginConfiguration(), context.getParentResourceComponent(), context - .getResourceType(), skipUnknownProps); + return performDiscovery(context.getDefaultPluginConfiguration(), context.getParentResourceComponent(), + context.getResourceType(), skipUnknownProps); }
/** @@ -161,12 +161,10 @@ public class MBeanResourceDiscoveryComponent<T extends JMXComponent> implements String resourceKey = bean.getBeanName().getCanonicalName(); // The detected object name
String nameTemplate = (pluginConfiguration.getSimple(PROPERTY_NAME_TEMPLATE) != null) ? pluginConfiguration - .getSimple(PROPERTY_NAME_TEMPLATE).getStringValue() - : null; + .getSimple(PROPERTY_NAME_TEMPLATE).getStringValue() : null;
String descriptionTemplate = (pluginConfiguration.getSimple(PROPERTY_DESCRIPTION_TEMPLATE) != null) ? pluginConfiguration - .getSimple(PROPERTY_DESCRIPTION_TEMPLATE).getStringValue() - : null; + .getSimple(PROPERTY_DESCRIPTION_TEMPLATE).getStringValue() : null;
String name = resourceKey; if (nameTemplate != null) { diff --git a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ClassNameMBeanComponent.java b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ClassNameMBeanComponent.java index fc8b818..2d0b55e 100644 --- a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ClassNameMBeanComponent.java +++ b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ClassNameMBeanComponent.java @@ -30,8 +30,8 @@ import org.rhq.plugins.jmx.MBeanResourceComponent; * @author Stefan Negrea * */ -@SuppressWarnings({ "rawtypes", "deprecation" }) -public class ClassNameMBeanComponent extends MBeanResourceComponent<JMXComponent> { +@SuppressWarnings({ "deprecation" }) +public class ClassNameMBeanComponent extends MBeanResourceComponent<JMXComponent<?>> { private static final Log log = LogFactory.getLog(WebappContextComponent.class);
private static final String CLASS_NAME = "className"; diff --git a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ClassNameMBeanDiscoveryComponent.java b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ClassNameMBeanDiscoveryComponent.java index 686642a..8487704 100644 --- a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ClassNameMBeanDiscoveryComponent.java +++ b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ClassNameMBeanDiscoveryComponent.java @@ -35,8 +35,7 @@ import org.rhq.plugins.jmx.MBeanResourceDiscoveryComponent; * * @author Stefan Negrea */ -@SuppressWarnings("rawtypes") -public class ClassNameMBeanDiscoveryComponent<T extends JMXComponent> extends MBeanResourceDiscoveryComponent<T> { +public class ClassNameMBeanDiscoveryComponent<T extends JMXComponent<?>> extends MBeanResourceDiscoveryComponent<T> {
private static final Log log = LogFactory.getLog(FileConfiguredMBeanResourceComponent.class);
diff --git a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/LoadMetricDiscoveryComponent.java b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/LoadMetricDiscoveryComponent.java index 31530d7..1c5f894 100644 --- a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/LoadMetricDiscoveryComponent.java +++ b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/LoadMetricDiscoveryComponent.java @@ -33,11 +33,10 @@ import org.rhq.plugins.jmx.MBeanResourceDiscoveryComponent; * @author Stefan Negrea * */ -@SuppressWarnings("rawtypes") -public class LoadMetricDiscoveryComponent extends MBeanResourceDiscoveryComponent<JMXComponent> { +public class LoadMetricDiscoveryComponent extends MBeanResourceDiscoveryComponent<JMXComponent<?>> {
@Override - public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext<JMXComponent> context, + public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext<JMXComponent<?>> context, boolean skipUnknownProps) {
Set<DiscoveredResourceDetails> results = super.discoverResources(context, skipUnknownProps); @@ -83,7 +82,7 @@ public class LoadMetricDiscoveryComponent extends MBeanResourceDiscoveryComponen * @param objectName * @return */ - private String getBeanConfiguredClassName(ResourceDiscoveryContext<JMXComponent> context, String objectName) { + private String getBeanConfiguredClassName(ResourceDiscoveryContext<JMXComponent<?>> context, String objectName) { EmsConnection connection = context.getParentResourceComponent().getEmsConnection(); EmsBean emsBean = loadBean(connection, objectName);
diff --git a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/WebappContextComponent.java b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/WebappContextComponent.java index 6131578..f7010a0 100644 --- a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/WebappContextComponent.java +++ b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/WebappContextComponent.java @@ -36,8 +36,8 @@ import org.rhq.plugins.modcluster.model.ProxyInfo; * * @author Stefan Negrea */ -@SuppressWarnings({ "rawtypes", "deprecation" }) -public class WebappContextComponent extends MBeanResourceComponent<MBeanResourceComponent> { +@SuppressWarnings({ "deprecation" }) +public class WebappContextComponent extends MBeanResourceComponent<MBeanResourceComponent<?>> {
private static final Log log = LogFactory.getLog(WebappContextComponent.class);
diff --git a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/WebappContextDiscoveryComponent.java b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/WebappContextDiscoveryComponent.java index 559e1b6..faa9795 100644 --- a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/WebappContextDiscoveryComponent.java +++ b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/WebappContextDiscoveryComponent.java @@ -37,8 +37,7 @@ import org.rhq.plugins.modcluster.model.ProxyInfo; * * @author Stefan Negrea */ -@SuppressWarnings("rawtypes") -public class WebappContextDiscoveryComponent implements ResourceDiscoveryComponent<MBeanResourceComponent> { +public class WebappContextDiscoveryComponent implements ResourceDiscoveryComponent<MBeanResourceComponent<?>> {
private static final String JVM_ROUTE_PROPERTY = "jvmRoute"; private static final String ENGINE_OBJECT_NAME = "engineObjectName"; @@ -46,7 +45,7 @@ public class WebappContextDiscoveryComponent implements ResourceDiscoveryCompone /* (non-Javadoc) * @see org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent#discoverResources(org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext) */ - public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext<MBeanResourceComponent> context) { + public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext<MBeanResourceComponent<?>> context) { String jvmRoute = this.getJvmRoute(context);
EmsBean configBean = context.getParentResourceComponent().getEmsBean(); @@ -72,7 +71,7 @@ public class WebappContextDiscoveryComponent implements ResourceDiscoveryCompone * @param context the discovery context * @return node's jvm route */ - private String getJvmRoute(ResourceDiscoveryContext<MBeanResourceComponent> context) { + private String getJvmRoute(ResourceDiscoveryContext<MBeanResourceComponent<?>> context) { Configuration pluginConfig = context.getParentResourceComponent().getResourceContext().getPluginConfiguration(); String engineObjectName = pluginConfig.getSimple(ENGINE_OBJECT_NAME).getStringValue(); EmsBean engineBean = this.loadBean(engineObjectName, context.getParentResourceComponent()); diff --git a/modules/plugins/mysql/src/main/java/org/rhq/plugins/mysql/MySqlComponent.java b/modules/plugins/mysql/src/main/java/org/rhq/plugins/mysql/MySqlComponent.java index 325ed20..f1a16e4 100644 --- a/modules/plugins/mysql/src/main/java/org/rhq/plugins/mysql/MySqlComponent.java +++ b/modules/plugins/mysql/src/main/java/org/rhq/plugins/mysql/MySqlComponent.java @@ -50,7 +50,8 @@ import org.rhq.plugins.database.DatabaseQueryUtility; * @author Greg Hinkle * @author Steve Millidge */ -public class MySqlComponent implements DatabaseComponent, ResourceComponent, MeasurementFacet { +public class MySqlComponent implements DatabaseComponent<ResourceComponent<?>>, + ResourceComponent<ResourceComponent<?>>, MeasurementFacet {
private ResourceContext resourceContext; private AggregateProcessInfo aggregateProcessInfo; diff --git a/modules/plugins/platform/src/main/java/org/rhq/plugins/platform/FileSystemDiscoveryComponent.java b/modules/plugins/platform/src/main/java/org/rhq/plugins/platform/FileSystemDiscoveryComponent.java index b1367b6..b213063 100644 --- a/modules/plugins/platform/src/main/java/org/rhq/plugins/platform/FileSystemDiscoveryComponent.java +++ b/modules/plugins/platform/src/main/java/org/rhq/plugins/platform/FileSystemDiscoveryComponent.java @@ -1,25 +1,25 @@ - /* - * RHQ Management Platform - * Copyright (C) 2005-2011 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, version 2, as - * published by the Free Software Foundation, and/or the GNU Lesser - * General Public License, version 2.1, also as published by the Free - * Software Foundation. - * - * 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 and the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU General Public License - * and the GNU Lesser General Public License along with this program; - * if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ +/* + * RHQ Management Platform + * Copyright (C) 2005-2011 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, version 2, as + * published by the Free Software Foundation, and/or the GNU Lesser + * General Public License, version 2.1, also as published by the Free + * Software Foundation. + * + * 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 and the GNU Lesser General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License + * and the GNU Lesser General Public License along with this program; + * if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ package org.rhq.plugins.platform;
import java.util.LinkedHashSet; @@ -40,7 +40,6 @@ import org.rhq.core.system.SystemInfo; * @author Greg Hinkle * @author Ian Springer */ -@SuppressWarnings({"UnusedDeclaration"}) public class FileSystemDiscoveryComponent implements ResourceDiscoveryComponent<PlatformComponent> {
private static final String SYS_TYPE_NAME_LOFS = "lofs"; @@ -65,21 +64,20 @@ public class FileSystemDiscoveryComponent implements ResourceDiscoveryComponent< int fsType = fs.getType(); // We only support local, network (nfs), lofs, or tmpfs filesystems - skip any other types. switch (fsType) { - case FileSystem.TYPE_LOCAL_DISK: - case FileSystem.TYPE_NETWORK: - break; - default: - String sysTypeName = fs.getSysTypeName(); - if (!(SYS_TYPE_NAME_LOFS.equals(sysTypeName) || SYS_TYPE_NAME_TMPFS.equals(sysTypeName))) { - continue; - } + case FileSystem.TYPE_LOCAL_DISK: + case FileSystem.TYPE_NETWORK: + break; + default: + String sysTypeName = fs.getSysTypeName(); + if (!(SYS_TYPE_NAME_LOFS.equals(sysTypeName) || SYS_TYPE_NAME_TMPFS.equals(sysTypeName))) { + continue; + } }
try { String key = fsInfo.getMountPoint(); String name = fsInfo.getMountPoint(); - String description = fsInfo.getFileSystem().getDevName() + ": " - + fsInfo.getFileSystem().getDirName(); + String description = fsInfo.getFileSystem().getDevName() + ": " + fsInfo.getFileSystem().getDirName(); Configuration pluginConfig = discoveryContext.getDefaultPluginConfiguration(); DiscoveredResourceDetails details = new DiscoveredResourceDetails(discoveryContext.getResourceType(), key, name, null, description, pluginConfig, null); diff --git a/modules/plugins/platform/src/main/java/org/rhq/plugins/platform/PlatformComponent.java b/modules/plugins/platform/src/main/java/org/rhq/plugins/platform/PlatformComponent.java index 4cf56a3..757c812 100644 --- a/modules/plugins/platform/src/main/java/org/rhq/plugins/platform/PlatformComponent.java +++ b/modules/plugins/platform/src/main/java/org/rhq/plugins/platform/PlatformComponent.java @@ -65,7 +65,8 @@ import org.rhq.core.system.SystemInfo; * * @author John Mazzitelli */ -public class PlatformComponent implements ResourceComponent, ConfigurationFacet, MeasurementFacet, OperationFacet { +public class PlatformComponent implements ResourceComponent<PlatformComponent>, ConfigurationFacet, MeasurementFacet, + OperationFacet {
private final Log log = LogFactory.getLog(PlatformComponent.class);
@@ -229,9 +230,7 @@ public class PlatformComponent implements ResourceComponent, ConfigurationFacet, pm.put(new PropertySimple("name", process.getBaseName())); pm.put(new PropertySimple("size", (process.getMemory() != null) ? process.getMemory().getSize() : "0")); pm.put(new PropertySimple("userTime", (process.getTime() != null) ? process.getTime().getUser() : "0")); - pm - .put(new PropertySimple("kernelTime", (process.getTime() != null) ? process.getTime().getSys() - : "0")); + pm.put(new PropertySimple("kernelTime", (process.getTime() != null) ? process.getTime().getSys() : "0")); processList.add(pm); }
diff --git a/modules/plugins/postfix/src/main/java/org/rhq/plugins/postfix/PostfixAccessDiscoveryComponent.java b/modules/plugins/postfix/src/main/java/org/rhq/plugins/postfix/PostfixAccessDiscoveryComponent.java index 0a34baa..8102eb6 100644 --- a/modules/plugins/postfix/src/main/java/org/rhq/plugins/postfix/PostfixAccessDiscoveryComponent.java +++ b/modules/plugins/postfix/src/main/java/org/rhq/plugins/postfix/PostfixAccessDiscoveryComponent.java @@ -26,6 +26,7 @@ import java.util.Set; import org.rhq.core.domain.configuration.Configuration; import org.rhq.core.pluginapi.inventory.DiscoveredResourceDetails; import org.rhq.core.pluginapi.inventory.InvalidPluginConfigurationException; +import org.rhq.core.pluginapi.inventory.ResourceComponent; import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext; import org.rhq.plugins.augeas.AugeasConfigurationDiscoveryComponent;
@@ -33,11 +34,11 @@ import org.rhq.plugins.augeas.AugeasConfigurationDiscoveryComponent; * @author paji * */ -public class PostfixAccessDiscoveryComponent extends AugeasConfigurationDiscoveryComponent<PostfixAccessComponent> { +public class PostfixAccessDiscoveryComponent extends AugeasConfigurationDiscoveryComponent<ResourceComponent<?>> { public static final String RESOURCE_KEY = "Access";
public Set<DiscoveredResourceDetails> discoverResources( - ResourceDiscoveryContext<PostfixAccessComponent> discoveryContext) throws InvalidPluginConfigurationException, + ResourceDiscoveryContext<ResourceComponent<?>> discoveryContext) throws InvalidPluginConfigurationException, Exception {
Set<DiscoveredResourceDetails> details = new HashSet<DiscoveredResourceDetails>(); diff --git a/modules/plugins/postgres/src/main/java/org/rhq/plugins/postgres/PostgresDatabaseComponent.java b/modules/plugins/postgres/src/main/java/org/rhq/plugins/postgres/PostgresDatabaseComponent.java index fec4c0f..d6380b7 100644 --- a/modules/plugins/postgres/src/main/java/org/rhq/plugins/postgres/PostgresDatabaseComponent.java +++ b/modules/plugins/postgres/src/main/java/org/rhq/plugins/postgres/PostgresDatabaseComponent.java @@ -46,11 +46,11 @@ import org.rhq.core.pluginapi.operation.OperationResult; import org.rhq.core.util.jdbc.JDBCUtil; import org.rhq.plugins.database.DatabaseComponent;
-public class PostgresDatabaseComponent implements DatabaseComponent<PostgresServerComponent>, MeasurementFacet, +public class PostgresDatabaseComponent implements DatabaseComponent<PostgresServerComponent<?>>, MeasurementFacet, CreateChildResourceFacet, OperationFacet { private Log log = LogFactory.getLog(PostgresDatabaseComponent.class);
- private ResourceContext<PostgresServerComponent> resourceContext; + private ResourceContext<PostgresServerComponent<?>> resourceContext;
private Connection databaseConnection;
@@ -89,7 +89,7 @@ public class PostgresDatabaseComponent implements DatabaseComponent<PostgresServ this.databaseConnection = null; }
- public void start(ResourceContext<PostgresServerComponent> context) { + public void start(ResourceContext<PostgresServerComponent<?>> context) { this.resourceContext = context; }
diff --git a/modules/plugins/postgres/src/main/java/org/rhq/plugins/postgres/PostgresDatabaseDiscoveryComponent.java b/modules/plugins/postgres/src/main/java/org/rhq/plugins/postgres/PostgresDatabaseDiscoveryComponent.java index 5236fd3..f7f6f56 100644 --- a/modules/plugins/postgres/src/main/java/org/rhq/plugins/postgres/PostgresDatabaseDiscoveryComponent.java +++ b/modules/plugins/postgres/src/main/java/org/rhq/plugins/postgres/PostgresDatabaseDiscoveryComponent.java @@ -22,6 +22,7 @@ import java.sql.ResultSet; import java.sql.Statement; import java.util.HashSet; import java.util.Set; + import org.rhq.core.domain.configuration.PropertySimple; import org.rhq.core.pluginapi.inventory.DiscoveredResourceDetails; import org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent; @@ -31,8 +32,8 @@ import org.rhq.core.util.jdbc.JDBCUtil; /** * @author Greg Hinkle */ -public class PostgresDatabaseDiscoveryComponent implements ResourceDiscoveryComponent<PostgresServerComponent> { - public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext<PostgresServerComponent> context) +public class PostgresDatabaseDiscoveryComponent implements ResourceDiscoveryComponent<PostgresServerComponent<?>> { + public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext<PostgresServerComponent<?>> context) throws Exception { Set<DiscoveredResourceDetails> databases = new HashSet<DiscoveredResourceDetails>();
@@ -45,8 +46,7 @@ public class PostgresDatabaseDiscoveryComponent implements ResourceDiscoveryComp while (resultSet.next()) { String databaseName = resultSet.getString("datname"); DiscoveredResourceDetails database = new DiscoveredResourceDetails(context.getResourceType(), - databaseName, databaseName, null, "The " + databaseName - + " Postgres Database Instance", null, null); + databaseName, databaseName, null, "The " + databaseName + " Postgres Database Instance", null, null); database.getPluginConfiguration().put(new PropertySimple("databaseName", databaseName)); databases.add(database); } diff --git a/modules/plugins/postgres/src/main/java/org/rhq/plugins/postgres/PostgresServerComponent.java b/modules/plugins/postgres/src/main/java/org/rhq/plugins/postgres/PostgresServerComponent.java index 8308a23..f80f288 100644 --- a/modules/plugins/postgres/src/main/java/org/rhq/plugins/postgres/PostgresServerComponent.java +++ b/modules/plugins/postgres/src/main/java/org/rhq/plugins/postgres/PostgresServerComponent.java @@ -55,6 +55,7 @@ import org.rhq.core.pluginapi.configuration.ConfigurationFacet; import org.rhq.core.pluginapi.configuration.ConfigurationUpdateReport; import org.rhq.core.pluginapi.inventory.CreateChildResourceFacet; import org.rhq.core.pluginapi.inventory.CreateResourceReport; +import org.rhq.core.pluginapi.inventory.ResourceComponent; import org.rhq.core.pluginapi.inventory.ResourceContext; import org.rhq.core.pluginapi.measurement.MeasurementFacet; import org.rhq.core.pluginapi.operation.OperationFacet; @@ -70,7 +71,7 @@ import org.rhq.plugins.postgres.util.PostgresqlConfFile; * * @author Greg Hinkle */ -public class PostgresServerComponent implements DatabaseComponent, ConfigurationFacet, MeasurementFacet, +public class PostgresServerComponent<T extends ResourceComponent<?>> implements DatabaseComponent<T>, ConfigurationFacet, MeasurementFacet, OperationFacet, CreateChildResourceFacet { private static Log log = LogFactory.getLog(PostgresServerComponent.class);
diff --git a/modules/plugins/postgres/src/main/java/org/rhq/plugins/postgres/PostgresUserComponent.java b/modules/plugins/postgres/src/main/java/org/rhq/plugins/postgres/PostgresUserComponent.java index 6312c4d..92a5203 100644 --- a/modules/plugins/postgres/src/main/java/org/rhq/plugins/postgres/PostgresUserComponent.java +++ b/modules/plugins/postgres/src/main/java/org/rhq/plugins/postgres/PostgresUserComponent.java @@ -44,11 +44,11 @@ import org.rhq.plugins.database.DatabaseQueryUtility; /** * @author Greg Hinkle */ -public class PostgresUserComponent implements DatabaseComponent<PostgresServerComponent>, MeasurementFacet, +public class PostgresUserComponent implements DatabaseComponent<PostgresServerComponent<?>>, MeasurementFacet, ConfigurationFacet, DeleteResourceFacet { - private ResourceContext<PostgresServerComponent> resourceContext; + private ResourceContext<PostgresServerComponent<?>> resourceContext;
- public void start(ResourceContext<PostgresServerComponent> resourceContext) { + public void start(ResourceContext<PostgresServerComponent<?>> resourceContext) { this.resourceContext = resourceContext; }
diff --git a/modules/plugins/postgres/src/main/java/org/rhq/plugins/postgres/PostgresUserDiscoveryComponent.java b/modules/plugins/postgres/src/main/java/org/rhq/plugins/postgres/PostgresUserDiscoveryComponent.java index c0d0273..4eab143 100644 --- a/modules/plugins/postgres/src/main/java/org/rhq/plugins/postgres/PostgresUserDiscoveryComponent.java +++ b/modules/plugins/postgres/src/main/java/org/rhq/plugins/postgres/PostgresUserDiscoveryComponent.java @@ -23,8 +23,10 @@ import java.sql.ResultSet; import java.sql.Statement; import java.util.HashSet; import java.util.Set; + import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; + import org.rhq.core.domain.configuration.PropertySimple; import org.rhq.core.pluginapi.inventory.DiscoveredResourceDetails; import org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent; @@ -36,12 +38,12 @@ import org.rhq.core.util.jdbc.JDBCUtil; * * @author Greg Hinkle */ -public class PostgresUserDiscoveryComponent implements ResourceDiscoveryComponent<PostgresServerComponent> { +public class PostgresUserDiscoveryComponent implements ResourceDiscoveryComponent<PostgresServerComponent<?>> { private static final Log log = LogFactory.getLog(PostgresTableDiscoveryComponent.class);
public static final String USERS_QUERY = "select * from pg_roles";
- public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext<PostgresServerComponent> context) + public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext<PostgresServerComponent<?>> context) throws Exception { log.info("Discovering postgres users"); Set<DiscoveredResourceDetails> discoveredUsers = new HashSet<DiscoveredResourceDetails>(); diff --git a/modules/plugins/rhq-agent/src/main/java/org/rhq/plugins/agent/AgentEnvironmentScriptComponent.java b/modules/plugins/rhq-agent/src/main/java/org/rhq/plugins/agent/AgentEnvironmentScriptComponent.java index 8b8e1f9..e21a456 100644 --- a/modules/plugins/rhq-agent/src/main/java/org/rhq/plugins/agent/AgentEnvironmentScriptComponent.java +++ b/modules/plugins/rhq-agent/src/main/java/org/rhq/plugins/agent/AgentEnvironmentScriptComponent.java @@ -47,12 +47,12 @@ import org.rhq.enterprise.agent.EnvironmentScriptFileUpdate.NameValuePair; * * @author John Mazzitelli */ -public class AgentEnvironmentScriptComponent implements ResourceComponent<AgentServerComponent>, ConfigurationFacet { +public class AgentEnvironmentScriptComponent implements ResourceComponent<AgentServerComponent<?>>, ConfigurationFacet { private Log log = LogFactory.getLog(AgentEnvironmentScriptComponent.class);
private File script;
- public void start(ResourceContext<AgentServerComponent> resourceContext) throws Exception { + public void start(ResourceContext<AgentServerComponent<?>> resourceContext) throws Exception { Configuration pc = resourceContext.getPluginConfiguration(); PropertySimple pathnameProp = pc.getSimple(AgentEnvironmentScriptDiscoveryComponent.PLUGINCONFIG_PATHNAME); if (pathnameProp == null) { diff --git a/modules/plugins/rhq-agent/src/main/java/org/rhq/plugins/agent/AgentEnvironmentScriptDiscoveryComponent.java b/modules/plugins/rhq-agent/src/main/java/org/rhq/plugins/agent/AgentEnvironmentScriptDiscoveryComponent.java index ff312f8..31523d8 100644 --- a/modules/plugins/rhq-agent/src/main/java/org/rhq/plugins/agent/AgentEnvironmentScriptDiscoveryComponent.java +++ b/modules/plugins/rhq-agent/src/main/java/org/rhq/plugins/agent/AgentEnvironmentScriptDiscoveryComponent.java @@ -39,7 +39,7 @@ import org.rhq.enterprise.agent.Version; * * @author John Mazzitelli */ -public class AgentEnvironmentScriptDiscoveryComponent implements ResourceDiscoveryComponent<AgentServerComponent> { +public class AgentEnvironmentScriptDiscoveryComponent implements ResourceDiscoveryComponent<AgentServerComponent<?>> { private final Log log = LogFactory.getLog(AgentEnvironmentScriptDiscoveryComponent.class);
/** @@ -53,7 +53,7 @@ public class AgentEnvironmentScriptDiscoveryComponent implements ResourceDiscove * * @see ResourceDiscoveryComponent#discoverResources(ResourceDiscoveryContext) */ - public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext<AgentServerComponent> context) { + public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext<AgentServerComponent<?>> context) { log.info("Discovering RHQ Agent's environment setup script...");
HashSet<DiscoveredResourceDetails> set = new HashSet<DiscoveredResourceDetails>(); @@ -90,7 +90,7 @@ public class AgentEnvironmentScriptDiscoveryComponent implements ResourceDiscove * * @return <code>true</code> if this method discovers the script; <code>false</code> if not */ - private boolean findInAgentHome(ResourceDiscoveryContext<AgentServerComponent> context, String version, + private boolean findInAgentHome(ResourceDiscoveryContext<AgentServerComponent<?>> context, String version, String baseName, HashSet<DiscoveredResourceDetails> discoveries) {
try { @@ -111,7 +111,7 @@ public class AgentEnvironmentScriptDiscoveryComponent implements ResourceDiscove } }
- private DiscoveredResourceDetails createDetails(ResourceDiscoveryContext<AgentServerComponent> context, + private DiscoveredResourceDetails createDetails(ResourceDiscoveryContext<AgentServerComponent<?>> context, String version, File discoveredScript) {
String key = "environment-setup-script"; // this is a singleton resource; only ever one of these diff --git a/modules/plugins/rhq-agent/src/main/java/org/rhq/plugins/agent/AgentJavaServiceWrapperComponent.java b/modules/plugins/rhq-agent/src/main/java/org/rhq/plugins/agent/AgentJavaServiceWrapperComponent.java index 2b5b041..cff8181 100644 --- a/modules/plugins/rhq-agent/src/main/java/org/rhq/plugins/agent/AgentJavaServiceWrapperComponent.java +++ b/modules/plugins/rhq-agent/src/main/java/org/rhq/plugins/agent/AgentJavaServiceWrapperComponent.java @@ -54,19 +54,19 @@ import org.rhq.enterprise.agent.EnvironmentScriptFileUpdate.NameValuePair; * * @author John Mazzitelli */ -public class AgentJavaServiceWrapperComponent implements ResourceComponent<AgentServerComponent>, ConfigurationFacet, - OperationFacet { +public class AgentJavaServiceWrapperComponent implements ResourceComponent<AgentServerComponent<?>>, + ConfigurationFacet, OperationFacet {
private Log log = LogFactory.getLog(AgentJavaServiceWrapperComponent.class);
- private ResourceContext<AgentServerComponent> resourceContext; + private ResourceContext<AgentServerComponent<?>> resourceContext;
private File launcherScript; private File configFile; private File environmentFile; private File includeFile;
- public void start(ResourceContext<AgentServerComponent> rc) throws Exception { + public void start(ResourceContext<AgentServerComponent<?>> rc) throws Exception {
this.resourceContext = rc;
diff --git a/modules/plugins/rhq-agent/src/main/java/org/rhq/plugins/agent/AgentJavaServiceWrapperDiscoveryComponent.java b/modules/plugins/rhq-agent/src/main/java/org/rhq/plugins/agent/AgentJavaServiceWrapperDiscoveryComponent.java index fd9c4bc..85fa609 100644 --- a/modules/plugins/rhq-agent/src/main/java/org/rhq/plugins/agent/AgentJavaServiceWrapperDiscoveryComponent.java +++ b/modules/plugins/rhq-agent/src/main/java/org/rhq/plugins/agent/AgentJavaServiceWrapperDiscoveryComponent.java @@ -41,7 +41,7 @@ import org.rhq.enterprise.agent.Version; * * @author John Mazzitelli */ -public class AgentJavaServiceWrapperDiscoveryComponent implements ResourceDiscoveryComponent<AgentServerComponent> { +public class AgentJavaServiceWrapperDiscoveryComponent implements ResourceDiscoveryComponent<AgentServerComponent<?>> { private final Log log = LogFactory.getLog(AgentJavaServiceWrapperDiscoveryComponent.class);
/** @@ -73,7 +73,7 @@ public class AgentJavaServiceWrapperDiscoveryComponent implements ResourceDiscov * * @see ResourceDiscoveryComponent#discoverResources(ResourceDiscoveryContext) */ - public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext<AgentServerComponent> context) { + public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext<AgentServerComponent<?>> context) { log.info("Discovering RHQ Agent's JSW service...");
HashSet<DiscoveredResourceDetails> set = new HashSet<DiscoveredResourceDetails>(); @@ -115,7 +115,7 @@ public class AgentJavaServiceWrapperDiscoveryComponent implements ResourceDiscov * * @return <code>true</code> if this method discovers the JSW; <code>false</code> if not */ - private boolean findInAgentHome(ResourceDiscoveryContext<AgentServerComponent> context, String version, + private boolean findInAgentHome(ResourceDiscoveryContext<AgentServerComponent<?>> context, String version, String baseName, HashSet<DiscoveredResourceDetails> discoveries) {
try { @@ -136,7 +136,7 @@ public class AgentJavaServiceWrapperDiscoveryComponent implements ResourceDiscov } }
- private DiscoveredResourceDetails createDetails(ResourceDiscoveryContext<AgentServerComponent> context, + private DiscoveredResourceDetails createDetails(ResourceDiscoveryContext<AgentServerComponent<?>> context, String version, File discoveredLocation) {
String key = "jsw"; // this is a singleton resource; only ever one of these diff --git a/modules/plugins/rhq-agent/src/main/java/org/rhq/plugins/agent/AgentLauncherScriptComponent.java b/modules/plugins/rhq-agent/src/main/java/org/rhq/plugins/agent/AgentLauncherScriptComponent.java index 6cefec8..f51febf 100644 --- a/modules/plugins/rhq-agent/src/main/java/org/rhq/plugins/agent/AgentLauncherScriptComponent.java +++ b/modules/plugins/rhq-agent/src/main/java/org/rhq/plugins/agent/AgentLauncherScriptComponent.java @@ -42,15 +42,15 @@ import org.rhq.core.system.SystemInfo; * * @author John Mazzitelli */ -public class AgentLauncherScriptComponent implements ResourceComponent<AgentServerComponent>, OperationFacet { +public class AgentLauncherScriptComponent implements ResourceComponent<AgentServerComponent<?>>, OperationFacet {
private Log log = LogFactory.getLog(AgentLauncherScriptComponent.class);
- private ResourceContext<AgentServerComponent> resourceContext; + private ResourceContext<AgentServerComponent<?>> resourceContext;
private File launcherScript;
- public void start(ResourceContext<AgentServerComponent> rc) throws Exception { + public void start(ResourceContext<AgentServerComponent<?>> rc) throws Exception {
this.resourceContext = rc; Configuration pc = this.resourceContext.getPluginConfiguration(); diff --git a/modules/plugins/rhq-agent/src/main/java/org/rhq/plugins/agent/AgentLauncherScriptDiscoveryComponent.java b/modules/plugins/rhq-agent/src/main/java/org/rhq/plugins/agent/AgentLauncherScriptDiscoveryComponent.java index b386f59..ddbdbeb 100644 --- a/modules/plugins/rhq-agent/src/main/java/org/rhq/plugins/agent/AgentLauncherScriptDiscoveryComponent.java +++ b/modules/plugins/rhq-agent/src/main/java/org/rhq/plugins/agent/AgentLauncherScriptDiscoveryComponent.java @@ -43,7 +43,7 @@ import org.rhq.enterprise.agent.Version; * * @author John Mazzitelli */ -public class AgentLauncherScriptDiscoveryComponent implements ResourceDiscoveryComponent<AgentServerComponent> { +public class AgentLauncherScriptDiscoveryComponent implements ResourceDiscoveryComponent<AgentServerComponent<?>> { private final Log log = LogFactory.getLog(AgentLauncherScriptDiscoveryComponent.class);
/** @@ -57,7 +57,7 @@ public class AgentLauncherScriptDiscoveryComponent implements ResourceDiscoveryC * * @see ResourceDiscoveryComponent#discoverResources(ResourceDiscoveryContext) */ - public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext<AgentServerComponent> context) { + public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext<AgentServerComponent<?>> context) { log.info("Discovering RHQ Agent's launcher script service...");
HashSet<DiscoveredResourceDetails> set = new HashSet<DiscoveredResourceDetails>(); @@ -99,7 +99,7 @@ public class AgentLauncherScriptDiscoveryComponent implements ResourceDiscoveryC * * @return <code>true</code> if this method discovers the launcher script; <code>false</code> if not */ - private boolean findInAgentHome(ResourceDiscoveryContext<AgentServerComponent> context, String version, + private boolean findInAgentHome(ResourceDiscoveryContext<AgentServerComponent<?>> context, String version, String baseName, HashSet<DiscoveredResourceDetails> discoveries) {
try { @@ -120,7 +120,7 @@ public class AgentLauncherScriptDiscoveryComponent implements ResourceDiscoveryC } }
- private DiscoveredResourceDetails createDetails(ResourceDiscoveryContext<AgentServerComponent> context, + private DiscoveredResourceDetails createDetails(ResourceDiscoveryContext<AgentServerComponent<?>> context, String version, File discoveredLocation) {
String key = "launcherscript"; // this is a singleton resource; only ever one of these diff --git a/modules/plugins/rhq-agent/src/main/java/org/rhq/plugins/agent/AgentServerComponent.java b/modules/plugins/rhq-agent/src/main/java/org/rhq/plugins/agent/AgentServerComponent.java index d352ae9..82179ab 100644 --- a/modules/plugins/rhq-agent/src/main/java/org/rhq/plugins/agent/AgentServerComponent.java +++ b/modules/plugins/rhq-agent/src/main/java/org/rhq/plugins/agent/AgentServerComponent.java @@ -50,6 +50,7 @@ import org.rhq.core.domain.measurement.MeasurementScheduleRequest; import org.rhq.core.pluginapi.configuration.ConfigurationFacet; import org.rhq.core.pluginapi.configuration.ConfigurationUpdateReport; import org.rhq.core.pluginapi.event.log.LogFileEventResourceComponentHelper; +import org.rhq.core.pluginapi.inventory.ResourceComponent; import org.rhq.core.pluginapi.inventory.ResourceContext; import org.rhq.core.pluginapi.measurement.MeasurementFacet; import org.rhq.core.pluginapi.operation.OperationFacet; @@ -70,8 +71,8 @@ import org.rhq.plugins.jmx.JMXServerComponent; * * @author John Mazzitelli */ -public class AgentServerComponent extends JMXServerComponent implements JMXComponent, MeasurementFacet, OperationFacet, - ConfigurationFacet, SupportFacet { +public class AgentServerComponent<T extends ResourceComponent<?>> extends JMXServerComponent<T> implements + JMXComponent<T>, MeasurementFacet, OperationFacet, ConfigurationFacet, SupportFacet { private static Log log = LogFactory.getLog(AgentServerComponent.class);
/** diff --git a/modules/plugins/samba/src/main/java/org/rhq/plugins/samba/SambaServerComponent.java b/modules/plugins/samba/src/main/java/org/rhq/plugins/samba/SambaServerComponent.java index d50f324..f9f2648 100644 --- a/modules/plugins/samba/src/main/java/org/rhq/plugins/samba/SambaServerComponent.java +++ b/modules/plugins/samba/src/main/java/org/rhq/plugins/samba/SambaServerComponent.java @@ -18,9 +18,13 @@ */ package org.rhq.plugins.samba;
+import java.util.List; +import java.util.Set; + import net.augeas.Augeas;
-import org.rhq.core.domain.configuration.*; +import org.rhq.core.domain.configuration.Configuration; +import org.rhq.core.domain.configuration.PropertySimple; import org.rhq.core.domain.configuration.definition.PropertyDefinitionSimple; import org.rhq.core.domain.measurement.AvailabilityType; import org.rhq.core.domain.measurement.MeasurementDataNumeric; @@ -30,23 +34,25 @@ import org.rhq.core.domain.resource.ResourceType; import org.rhq.core.pluginapi.configuration.ConfigurationUpdateReport; import org.rhq.core.pluginapi.inventory.CreateResourceReport; import org.rhq.core.pluginapi.inventory.InvalidPluginConfigurationException; +import org.rhq.core.pluginapi.inventory.ResourceComponent; import org.rhq.core.pluginapi.inventory.ResourceContext; import org.rhq.core.pluginapi.measurement.MeasurementFacet; import org.rhq.core.pluginapi.operation.OperationFacet; import org.rhq.core.pluginapi.operation.OperationResult; import org.rhq.core.pluginapi.util.ObjectUtil; -import org.rhq.core.system.*; +import org.rhq.core.system.NetworkStats; +import org.rhq.core.system.ProcessExecution; +import org.rhq.core.system.ProcessExecutionResults; +import org.rhq.core.system.ProcessInfo; +import org.rhq.core.system.SystemInfo; import org.rhq.plugins.augeas.AugeasConfigurationComponent; import org.rhq.plugins.augeas.helper.AugeasNode;
-import java.util.List; -import java.util.Set; - - /** * TODO */ -public class SambaServerComponent extends AugeasConfigurationComponent implements OperationFacet, MeasurementFacet { +public class SambaServerComponent extends AugeasConfigurationComponent<ResourceComponent<?>> implements OperationFacet, + MeasurementFacet {
static final String ENABLE_RECYCLING = "enableRecycleBin"; static final String AUTHCONFIG_PATH = "/usr/bin/authconfig"; @@ -57,7 +63,6 @@ public class SambaServerComponent extends AugeasConfigurationComponent implement
private ResourceContext resourceContext;
- public void start(ResourceContext resourceContext) throws Exception { this.resourceContext = resourceContext; super.start(resourceContext); @@ -141,8 +146,8 @@ public class SambaServerComponent extends AugeasConfigurationComponent implement
private void getProcess() {
- List<ProcessInfo> procs = - resourceContext.getSystemInformation().getProcesses("process|basename|match=smbd,process|basename|nomatch|parent=smbd"); + List<ProcessInfo> procs = resourceContext.getSystemInformation().getProcesses( + "process|basename|match=smbd,process|basename|nomatch|parent=smbd");
if (procs.size() == 1) { this.processInfo = procs.get(0).getAggregateProcessTree(); @@ -153,7 +158,7 @@ public class SambaServerComponent extends AugeasConfigurationComponent implement
NetworkStats stats = resourceContext.getSystemInformation().getNetworkStats("localhost", PORT);
- if (processInfo!=null) { + if (processInfo != null) { processInfo.refresh();
for (MeasurementScheduleRequest request : metrics) { @@ -161,7 +166,8 @@ public class SambaServerComponent extends AugeasConfigurationComponent implement int val = stats.getByName(request.getName().substring("NetworkStat.".length())); report.addData(new MeasurementDataNumeric(request, (double) val)); } else if (request.getName().startsWith("Process.")) { - Double value = ObjectUtil.lookupDeepNumericAttributeProperty(processInfo, request.getName().substring("Process.".length())); + Double value = ObjectUtil.lookupDeepNumericAttributeProperty(processInfo, request.getName() + .substring("Process.".length())); report.addData(new MeasurementDataNumeric(request, value)); } } @@ -173,10 +179,9 @@ public class SambaServerComponent extends AugeasConfigurationComponent implement OperationResult result = null;
if (name.equals("join")) { - result = updateSmbAds(params); - } - else if (name.equals("disconnect")) { - result = disconnectSmbAds(params); + result = updateSmbAds(params); + } else if (name.equals("disconnect")) { + result = disconnectSmbAds(params); } return result; } @@ -279,6 +284,6 @@ public class SambaServerComponent extends AugeasConfigurationComponent implement ProcessExecutionResults results = sysInfo.executeProcess(processExecution);
return results; - } + }
} diff --git a/modules/plugins/snmptrapd/src/main/java/org/rhq/plugins/snmptrapd/SnmpTrapdComponent.java b/modules/plugins/snmptrapd/src/main/java/org/rhq/plugins/snmptrapd/SnmpTrapdComponent.java index 9e0de67..7967e15 100644 --- a/modules/plugins/snmptrapd/src/main/java/org/rhq/plugins/snmptrapd/SnmpTrapdComponent.java +++ b/modules/plugins/snmptrapd/src/main/java/org/rhq/plugins/snmptrapd/SnmpTrapdComponent.java @@ -47,7 +47,7 @@ import org.rhq.core.util.exception.ThrowableUtil; * @author Heiko W. Rupp * */ -public class SnmpTrapdComponent implements ResourceComponent, MeasurementFacet { +public class SnmpTrapdComponent implements ResourceComponent<ResourceComponent<?>>, MeasurementFacet {
private final Log log = LogFactory.getLog(SnmpTrapdComponent.class);
diff --git a/modules/plugins/tomcat/src/main/java/org/jboss/on/plugins/tomcat/TomcatConnectorComponent.java b/modules/plugins/tomcat/src/main/java/org/jboss/on/plugins/tomcat/TomcatConnectorComponent.java index 0265123..4f334a4 100644 --- a/modules/plugins/tomcat/src/main/java/org/jboss/on/plugins/tomcat/TomcatConnectorComponent.java +++ b/modules/plugins/tomcat/src/main/java/org/jboss/on/plugins/tomcat/TomcatConnectorComponent.java @@ -54,7 +54,7 @@ import org.rhq.plugins.jmx.ObjectNameQueryUtility; * @author Jay Shaughnessy * @author Jason Dobies */ -public class TomcatConnectorComponent extends MBeanResourceComponent<TomcatServerComponent> { +public class TomcatConnectorComponent extends MBeanResourceComponent<TomcatServerComponent<?>> {
/** * property name for the protocol of the connector @@ -103,7 +103,7 @@ public class TomcatConnectorComponent extends MBeanResourceComponent<TomcatServe }
@Override - public void start(ResourceContext<TomcatServerComponent> context) { + public void start(ResourceContext<TomcatServerComponent<?>> context) { if (UNKNOWN.equals(context.getPluginConfiguration().getSimple(PLUGIN_CONFIG_HANDLER).getStringValue())) { throw new InvalidPluginConfigurationException( "The connector is not listening for requests on the configured port. This is most likely due to the configured port being in use at Tomcat startup. In some cases (AJP connectors) Tomcat will assign an open port. This happens most often when there are multiple Tomcat servers running on the same platform. Check your Tomcat configuration for conflicts: " @@ -206,7 +206,7 @@ public class TomcatConnectorComponent extends MBeanResourceComponent<TomcatServe public void updateResourceConfiguration(ConfigurationUpdateReport report) {
// When starting the component get the connector type specific property keys - ResourceContext<TomcatServerComponent> context = getResourceContext(); + ResourceContext<TomcatServerComponent<?>> context = getResourceContext(); ConfigurationDefinition configDef = context.getResourceType().getResourceConfigurationDefinition(); String protocol = report.getConfiguration().getSimpleValue(CONFIG_PROTOCOL, null); if ((null == protocol) || protocol.toUpperCase().contains("HTTP")) { diff --git a/modules/plugins/tomcat/src/main/java/org/jboss/on/plugins/tomcat/TomcatConnectorDiscoveryComponent.java b/modules/plugins/tomcat/src/main/java/org/jboss/on/plugins/tomcat/TomcatConnectorDiscoveryComponent.java index f6ad696..0940910 100644 --- a/modules/plugins/tomcat/src/main/java/org/jboss/on/plugins/tomcat/TomcatConnectorDiscoveryComponent.java +++ b/modules/plugins/tomcat/src/main/java/org/jboss/on/plugins/tomcat/TomcatConnectorDiscoveryComponent.java @@ -33,6 +33,7 @@ import org.apache.commons.logging.LogFactory; import org.mc4j.ems.connection.EmsConnection; import org.mc4j.ems.connection.bean.EmsBean; import org.mc4j.ems.connection.bean.EmsBeanName; + import org.rhq.core.domain.configuration.Configuration; import org.rhq.core.domain.configuration.PropertySimple; import org.rhq.core.pluginapi.inventory.DiscoveredResourceDetails; @@ -48,13 +49,13 @@ import org.rhq.plugins.jmx.ObjectNameQueryUtility; * @author Jason Dobies * @author Ian Springer */ -public class TomcatConnectorDiscoveryComponent extends MBeanResourceDiscoveryComponent<TomcatServerComponent> { +public class TomcatConnectorDiscoveryComponent extends MBeanResourceDiscoveryComponent<TomcatServerComponent<?>> { private final Log log = LogFactory.getLog(this.getClass());
// MBeanResourceDiscoveryComponent Overridden Methods --------------------------------------------
@Override - public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext<TomcatServerComponent> context) { + public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext<TomcatServerComponent<?>> context) {
// Connector objectNames can have two formats: // Catalina:type=Connector,port=%port% (this is the default for the connector type in the plugin desc) diff --git a/modules/plugins/tomcat/src/main/java/org/jboss/on/plugins/tomcat/TomcatServerComponent.java b/modules/plugins/tomcat/src/main/java/org/jboss/on/plugins/tomcat/TomcatServerComponent.java index d67f072..bc843ef 100644 --- a/modules/plugins/tomcat/src/main/java/org/jboss/on/plugins/tomcat/TomcatServerComponent.java +++ b/modules/plugins/tomcat/src/main/java/org/jboss/on/plugins/tomcat/TomcatServerComponent.java @@ -48,6 +48,7 @@ import org.rhq.core.domain.measurement.MeasurementDataTrait; import org.rhq.core.domain.measurement.MeasurementReport; import org.rhq.core.domain.measurement.MeasurementScheduleRequest; import org.rhq.core.pluginapi.inventory.InvalidPluginConfigurationException; +import org.rhq.core.pluginapi.inventory.ResourceComponent; import org.rhq.core.pluginapi.inventory.ResourceContext; import org.rhq.core.pluginapi.measurement.MeasurementFacet; import org.rhq.core.pluginapi.operation.OperationFacet; @@ -60,8 +61,8 @@ import org.rhq.plugins.jmx.JMXDiscoveryComponent; * * @author Jay Shaughnessy */ -@SuppressWarnings("unchecked") -public class TomcatServerComponent implements JMXComponent, MeasurementFacet, OperationFacet { +public class TomcatServerComponent<T extends ResourceComponent<?>> implements JMXComponent<T>, MeasurementFacet, + OperationFacet {
public enum SupportedOperations { /** @@ -251,14 +252,15 @@ public class TomcatServerComponent implements JMXComponent, MeasurementFacet, Op // Since the connection is attempted each time it's used, failure to connect could result in log // file spamming. Log it once for every 10 consecutive times it's encountered. if (consecutiveConnectionErrors % 10 == 0) { - log.warn("Could not establish connection to the Tomcat instance [" - + (consecutiveConnectionErrors + 1) + "] times for resource [" - + resourceContext.getResourceKey() + "]", e); + log.warn( + "Could not establish connection to the Tomcat instance [" + (consecutiveConnectionErrors + 1) + + "] times for resource [" + resourceContext.getResourceKey() + "]", e); }
if (log.isDebugEnabled()) - log.debug("Could not connect to the Tomcat instance for resource [" - + resourceContext.getResourceKey() + "]", e); + log.debug( + "Could not connect to the Tomcat instance for resource [" + resourceContext.getResourceKey() + + "]", e);
consecutiveConnectionErrors++;
diff --git a/modules/plugins/tomcat/src/main/java/org/jboss/on/plugins/tomcat/TomcatUserDatabaseComponent.java b/modules/plugins/tomcat/src/main/java/org/jboss/on/plugins/tomcat/TomcatUserDatabaseComponent.java index 880ecc5..bb13097 100644 --- a/modules/plugins/tomcat/src/main/java/org/jboss/on/plugins/tomcat/TomcatUserDatabaseComponent.java +++ b/modules/plugins/tomcat/src/main/java/org/jboss/on/plugins/tomcat/TomcatUserDatabaseComponent.java @@ -24,6 +24,7 @@ package org.jboss.on.plugins.tomcat;
import org.jboss.on.plugins.tomcat.helper.CreateResourceHelper; + import org.rhq.core.domain.configuration.Configuration; import org.rhq.core.domain.resource.CreateResourceStatus; import org.rhq.core.pluginapi.inventory.CreateChildResourceFacet; @@ -35,7 +36,8 @@ import org.rhq.plugins.jmx.MBeanResourceComponent; * * @author Jay Shaughnessy */ -public class TomcatUserDatabaseComponent extends MBeanResourceComponent<TomcatServerComponent> implements CreateChildResourceFacet { +public class TomcatUserDatabaseComponent extends MBeanResourceComponent<TomcatServerComponent<?>> implements + CreateChildResourceFacet {
public CreateResourceReport createResource(CreateResourceReport report) { String resourceTypeName = report.getResourceType().getName(); diff --git a/modules/plugins/tomcat/src/main/java/org/jboss/on/plugins/tomcat/TomcatVHostComponent.java b/modules/plugins/tomcat/src/main/java/org/jboss/on/plugins/tomcat/TomcatVHostComponent.java index 2746c5b..7f600a7 100644 --- a/modules/plugins/tomcat/src/main/java/org/jboss/on/plugins/tomcat/TomcatVHostComponent.java +++ b/modules/plugins/tomcat/src/main/java/org/jboss/on/plugins/tomcat/TomcatVHostComponent.java @@ -64,7 +64,7 @@ import org.rhq.plugins.jmx.MBeanResourceComponent; * @author Heiko W. Rupp * */ -public class TomcatVHostComponent extends MBeanResourceComponent<TomcatServerComponent> implements +public class TomcatVHostComponent extends MBeanResourceComponent<TomcatServerComponent<?>> implements ApplicationServerComponent, CreateChildResourceFacet {
public static final String CONFIG_ALIASES = "aliases"; @@ -358,9 +358,8 @@ public class TomcatVHostComponent extends MBeanResourceComponent<TomcatServerCom deployer = new TomcatApplicationDeployer(connection, getName()); } } catch (Throwable e) { - log - .error("Unable to access Deployer MBean required for creation and deletion of managed resources - this should never happen. Cause: " - + e); + log.error("Unable to access Deployer MBean required for creation and deletion of managed resources - this should never happen. Cause: " + + e); }
return deployer; diff --git a/modules/plugins/tomcat/src/main/java/org/jboss/on/plugins/tomcat/TomcatVHostDiscoveryComponent.java b/modules/plugins/tomcat/src/main/java/org/jboss/on/plugins/tomcat/TomcatVHostDiscoveryComponent.java index 7b3f0a1..5cf6143 100644 --- a/modules/plugins/tomcat/src/main/java/org/jboss/on/plugins/tomcat/TomcatVHostDiscoveryComponent.java +++ b/modules/plugins/tomcat/src/main/java/org/jboss/on/plugins/tomcat/TomcatVHostDiscoveryComponent.java @@ -37,16 +37,17 @@ import org.rhq.plugins.jmx.MBeanResourceDiscoveryComponent; * @author Jay Shaughnessy * @author Heiko W. Rupp */ -public class TomcatVHostDiscoveryComponent extends MBeanResourceDiscoveryComponent<TomcatServerComponent> { - - static Pattern pattern = Pattern.compile(".*host=([\w.]+).*"); +public class TomcatVHostDiscoveryComponent extends MBeanResourceDiscoveryComponent<TomcatServerComponent<?>> { + + static Pattern pattern = Pattern.compile(".*host=([\w.]+).*");
@Override - public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext<TomcatServerComponent> discoveryContext) { + public Set<DiscoveredResourceDetails> discoverResources( + ResourceDiscoveryContext<TomcatServerComponent<?>> discoveryContext) {
Set<DiscoveredResourceDetails> resources = super.discoverResources(discoveryContext);
- for (DiscoveredResourceDetails detail : resources) { + for (DiscoveredResourceDetails detail : resources) { String name = detail.getResourceName(); Matcher m = pattern.matcher(name); if (m.matches()) { diff --git a/modules/plugins/twitter/src/main/java/org/rhq/plugins/twitter/TwitterComponent.java b/modules/plugins/twitter/src/main/java/org/rhq/plugins/twitter/TwitterComponent.java index eab4634..f6283ce 100644 --- a/modules/plugins/twitter/src/main/java/org/rhq/plugins/twitter/TwitterComponent.java +++ b/modules/plugins/twitter/src/main/java/org/rhq/plugins/twitter/TwitterComponent.java @@ -54,7 +54,7 @@ import org.rhq.core.pluginapi.operation.OperationResult; * * @author Heiko W. Rupp */ -public class TwitterComponent implements ResourceComponent, OperationFacet, MeasurementFacet +public class TwitterComponent implements ResourceComponent<ResourceComponent<?>>, OperationFacet, MeasurementFacet { private final Log log = LogFactory.getLog(this.getClass());
diff --git a/modules/plugins/virt/src/main/java/org/rhq/plugins/virt/VirtualizationHostComponent.java b/modules/plugins/virt/src/main/java/org/rhq/plugins/virt/VirtualizationHostComponent.java index 0c9b9cd..33f0478 100644 --- a/modules/plugins/virt/src/main/java/org/rhq/plugins/virt/VirtualizationHostComponent.java +++ b/modules/plugins/virt/src/main/java/org/rhq/plugins/virt/VirtualizationHostComponent.java @@ -47,7 +47,7 @@ import org.rhq.plugins.virt.LibVirtConnection.HVInfo; * * @author Greg Hinkle */ -public class VirtualizationHostComponent implements ResourceComponent, MeasurementFacet, ConfigurationFacet, +public class VirtualizationHostComponent implements ResourceComponent<ResourceComponent<?>>, MeasurementFacet, ConfigurationFacet, CreateChildResourceFacet {
private Log log = LogFactory.getLog(VirtualizationDomainComponent.class);
commit 57e2de0e2dffbee8bc6aa7d9777542a700e71a62 Author: Ian Springer ian.springer@redhat.com Date: Wed Sep 14 17:40:54 2011 -0400
add commented out skipTests=true prop in overrides profile
diff --git a/etc/m2/settings.xml b/etc/m2/settings.xml index bf489e0..7c4e855 100644 --- a/etc/m2/settings.xml +++ b/etc/m2/settings.xml @@ -61,6 +61,7 @@ <!--<enforcer.skip>true</enforcer.skip>-->
<!-- *** surefire plugin settings *** --> + <!--<skipTests>true</skipTests>--> <!--<maven.test.skip>true</maven.test.skip>--> <!--<maven.test.failure.ignore>true</maven.test.failure.ignore>--> <!--<maven.test.error.ignore>true</maven.test.error.ignore>-->
commit e83562248e5ec6296afe826417bb5af70c32643e Merge: 63a0592 40bdc06 Author: Ian Springer ian.springer@redhat.com Date: Wed Sep 14 17:38:57 2011 -0400
Merge branch 'master' of ssh://git.fedorahosted.org/git/rhq/rhq
commit 40bdc0627dc468d6e968ce01fb35d216f315ae52 Author: John Sanda jsanda@redhat.com Date: Wed Sep 14 17:10:47 2011 -0400
Filter queue by resource id when checking for deleted configs
When resources are discovered after the agent has already been running, an inventory sync is triggered, and for syncing drift configs this has a different execution path than an inventory sync at start up because DriftManager is already initialized. In this execution path I was detecting deleted configs incorrectly. When comparings the configs from the server against the configs in the schedule queue, we need to filter the queue by resource id.
diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/InventoryManager.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/InventoryManager.java index 414c232..a4f292f 100644 --- a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/InventoryManager.java +++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/InventoryManager.java @@ -2149,7 +2149,7 @@ public class InventoryManager extends AgentService implements ContainerService,
List<DriftConfiguration> deleted = new ArrayList<DriftConfiguration>();
- for (DriftDetectionSchedule schedule : queue.toArray()) { + for (DriftDetectionSchedule schedule : getSchedulesForResource(resourceId, queue.toArray())) { if (!configsFromServerSet.contains(schedule.getDriftConfiguration())) { if (log.isDebugEnabled()) { log.debug("Detected stale drift configuration. Preparing to unschedule " + schedule); @@ -2227,6 +2227,16 @@ public class InventoryManager extends AgentService implements ContainerService, } }
+ private List<DriftDetectionSchedule> getSchedulesForResource(int resourceId, DriftDetectionSchedule[] schedules) { + List<DriftDetectionSchedule> resourceSchedules = new LinkedList<DriftDetectionSchedule>(); + for (DriftDetectionSchedule s : schedules) { + if (s.getResourceId() == resourceId) { + resourceSchedules.add(s); + } + } + return resourceSchedules; + } + /** * Calling this method will immediately perform an availability check on all inventories resources. The availability * checks will be made asynchronously; this method will not block.
commit 50b7ebaa0106ff1995d21ea54b58ef2a49cbd571 Author: Stefan Negrea snegrea@redhat.com Date: Wed Sep 14 14:28:49 2011 -0500
Merge branch 'master' of ssh://git.fedorahosted.org/git/rhq/rhq
Conflicts: modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/InventoryManager.java
diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/InventoryManager.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/InventoryManager.java index 416e90a..414c232 100644 --- a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/InventoryManager.java +++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/InventoryManager.java @@ -23,6 +23,7 @@ package org.rhq.core.pc.inventory;
import static org.rhq.core.domain.drift.DriftConfigurationComparator.CompareMode.BOTH_BASE_INFO_AND_DIRECTORY_SPECIFICATIONS; +import static org.rhq.core.util.file.FileUtil.purge;
import java.io.File; import java.net.URL; @@ -125,9 +126,6 @@ import org.rhq.core.system.SystemInfoFactory; import org.rhq.core.util.exception.ThrowableUtil; import org.rhq.core.util.exception.WrappedRemotingException;
-import static org.rhq.core.domain.drift.DriftConfigurationComparator.CompareMode.BOTH_BASE_INFO_AND_DIRECTORY_SPECIFICATIONS; -import static org.rhq.core.util.file.FileUtil.purge; - /** * Manages the process of both auto-detection of servers and runtime detection of services across all plugins. Manages * their scheduling and result sending as well as the general inventory model. @@ -2178,8 +2176,8 @@ public class InventoryManager extends AgentService implements ContainerService, } } } else { - log.info("DriftManager is not available. Drift configurations will be persisted but detection will not " + - "be scheduled."); + log.info("DriftManager is not available. Drift configurations will be persisted but detection will not " + + "be scheduled.");
// First check for drift configurations that have been deleted log.debug("Checking for stale drift configurations that need to be purged from inventory"); @@ -2220,8 +2218,8 @@ public class InventoryManager extends AgentService implements ContainerService, ResourceContainer container = getResourceContainer(resourceId); for (DriftConfiguration c : configsFromServer.get(resourceId)) { if (log.isDebugEnabled()) { - log.debug("Adding DriftConfiguration[name: " + c.getName() + ", resourceId: " + resourceId + - "]"); + log.debug("Adding DriftConfiguration[name: " + c.getName() + ", resourceId: " + resourceId + + "]"); } container.addDriftConfiguration(c); }
commit 8e8c1d9068d0d7ab3da91b9ef3c2b9e3fdb36adb Author: Stefan Negrea snegrea@redhat.com Date: Wed Sep 14 13:52:10 2011 -0500
First set of wildcard generic updates. The change was mainly done in the plugin-api module but updated all the code directly affected by the change.
diff --git a/modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/event/log/LogFileEventResourceComponentHelper.java b/modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/event/log/LogFileEventResourceComponentHelper.java index 02430c2..962764a 100644 --- a/modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/event/log/LogFileEventResourceComponentHelper.java +++ b/modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/event/log/LogFileEventResourceComponentHelper.java @@ -24,23 +24,23 @@ import java.text.SimpleDateFormat; import java.util.regex.Pattern; import java.util.regex.PatternSyntaxException;
+import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + import org.rhq.core.domain.configuration.Configuration; -import org.rhq.core.domain.configuration.PropertyList; import org.rhq.core.domain.configuration.Property; +import org.rhq.core.domain.configuration.PropertyList; import org.rhq.core.domain.configuration.PropertyMap; import org.rhq.core.domain.event.EventSeverity; +import org.rhq.core.pluginapi.event.EventContext; +import org.rhq.core.pluginapi.event.EventPoller; import org.rhq.core.pluginapi.inventory.InvalidPluginConfigurationException; import org.rhq.core.pluginapi.inventory.ResourceContext; -import org.rhq.core.pluginapi.event.EventPoller; -import org.rhq.core.pluginapi.event.EventContext; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory;
/** * @author Ian Springer */ -public class LogFileEventResourceComponentHelper -{ +public class LogFileEventResourceComponentHelper { public static final String LOG_ENTRY_EVENT_TYPE = "logEntry";
public static final String LOG_EVENT_SOURCES_CONFIG_PROP = "logEventSources"; @@ -56,10 +56,9 @@ public class LogFileEventResourceComponentHelper
private final Log log = LogFactory.getLog(this.getClass());
- private ResourceContext resourceContext; + private ResourceContext<?> resourceContext;
- public LogFileEventResourceComponentHelper(ResourceContext resourceContext) - { + public LogFileEventResourceComponentHelper(ResourceContext<?> resourceContext) { this.resourceContext = resourceContext; }
@@ -71,13 +70,14 @@ public class LogFileEventResourceComponentHelper Boolean enabled = Boolean.valueOf(logEventSource.getSimpleValue(LogEventSourcePropertyNames.ENABLED, null)); if (enabled) { String logFilePathname = logEventSource.getSimpleValue(LogEventSourcePropertyNames.LOG_FILE_PATH, null); - if (logFilePathname==null) { + if (logFilePathname == null) { log.info("LOGFILE: No logfile path given, can not watch this event log."); return; } File logFile = new File(logFilePathname); if (!logFile.exists() || !logFile.canRead()) { - log.error("LOGFILE: Logfile at location " + logFilePathname + " does not exist or is not readable. Can not start watching the event log."); + log.error("LOGFILE: Logfile at location " + logFilePathname + + " does not exist or is not readable. Can not start watching the event log."); return; }
diff --git a/modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/inventory/ClassLoaderFacet.java b/modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/inventory/ClassLoaderFacet.java index c08449e..df7dc31 100644 --- a/modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/inventory/ClassLoaderFacet.java +++ b/modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/inventory/ClassLoaderFacet.java @@ -37,7 +37,7 @@ import java.util.List; * * @author John Mazzitelli */ -public interface ClassLoaderFacet<T extends ResourceComponent> { +public interface ClassLoaderFacet<T extends ResourceComponent<?>> { /** * This method provides the location for additional jars that are needed in the resource's classloader * in order to properly connect and talk to the managed resource. diff --git a/modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/inventory/ManualAddFacet.java b/modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/inventory/ManualAddFacet.java index 62ef20c..476e8d8 100644 --- a/modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/inventory/ManualAddFacet.java +++ b/modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/inventory/ManualAddFacet.java @@ -40,7 +40,7 @@ import org.rhq.core.domain.configuration.Configuration; * * @author Ian Springer */ -public interface ManualAddFacet<T extends ResourceComponent> { +public interface ManualAddFacet<T extends ResourceComponent<?>> { /** * Using the specified plugin configuration, creates a DiscoveredResourceDetails object describing a new Resource * to be added to inventory. diff --git a/modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/inventory/ResourceComponent.java b/modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/inventory/ResourceComponent.java index 6d1147a..aebea7f 100644 --- a/modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/inventory/ResourceComponent.java +++ b/modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/inventory/ResourceComponent.java @@ -54,7 +54,7 @@ import org.rhq.core.pluginapi.support.SupportFacet; * @param <T> the parent resource component type for this component. This means you can nest a hierarchy of resource * components that mimic the resource type hierarchy as defined in a plugin deployment descriptor. */ -public interface ResourceComponent<T extends ResourceComponent> extends AvailabilityFacet { +public interface ResourceComponent<T extends ResourceComponent<?>> extends AvailabilityFacet { /** * Initializes the resource component, possibly connecting to the managed resource itself. The implementation can be * custom to the plugin or resource, but the idea is that a resource component can create a single connection to diff --git a/modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/inventory/ResourceContext.java b/modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/inventory/ResourceContext.java index a86a08d..853345d 100644 --- a/modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/inventory/ResourceContext.java +++ b/modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/inventory/ResourceContext.java @@ -58,14 +58,14 @@ import org.rhq.core.system.pquery.ProcessInfoQuery; * @author John Mazzitelli */ @SuppressWarnings("unchecked") -public class ResourceContext<T extends ResourceComponent> { +public class ResourceContext<T extends ResourceComponent<?>> { private final String resourceKey; private final ResourceType resourceType; private final String version; private final T parentResourceComponent; private final Configuration pluginConfiguration; private final SystemInfo systemInformation; - private final ResourceDiscoveryComponent resourceDiscoveryComponent; + private final ResourceDiscoveryComponent<T> resourceDiscoveryComponent; private final File temporaryDirectory; private final File dataDirectory; private final String pluginContainerName; @@ -105,7 +105,7 @@ public class ResourceContext<T extends ResourceComponent> { * @param pluginContainerDeployment indicates where the plugin container is running */ public ResourceContext(Resource resource, T parentResourceComponent, - ResourceDiscoveryComponent resourceDiscoveryComponent, SystemInfo systemInfo, File temporaryDirectory, + ResourceDiscoveryComponent<T> resourceDiscoveryComponent, SystemInfo systemInfo, File temporaryDirectory, File dataDirectory, String pluginContainerName, EventContext eventContext, OperationContext operationContext, ContentContext contentContext, Executor availCollectorThreadPool, PluginContainerDeployment pluginContainerDeployment) { @@ -221,11 +221,11 @@ public class ResourceContext<T extends ResourceComponent> { if (this.resourceDiscoveryComponent != null) { try { Set<DiscoveredResourceDetails> details; - ResourceDiscoveryContext<ResourceComponent<?>> context; + ResourceDiscoveryContext<T> context;
- context = new ResourceDiscoveryContext<ResourceComponent<?>>(this.resourceType, - this.parentResourceComponent, this, this.systemInformation, getNativeProcessesForType(), - Collections.EMPTY_LIST, getPluginContainerName(), getPluginContainerDeployment()); + context = new ResourceDiscoveryContext<T>(this.resourceType, this.parentResourceComponent, this, + this.systemInformation, getNativeProcessesForType(), Collections.EMPTY_LIST, + getPluginContainerName(), getPluginContainerDeployment());
details = this.resourceDiscoveryComponent.discoverResources(context);
diff --git a/modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/inventory/ResourceDiscoveryComponent.java b/modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/inventory/ResourceDiscoveryComponent.java index e93a38b..b695290 100644 --- a/modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/inventory/ResourceDiscoveryComponent.java +++ b/modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/inventory/ResourceDiscoveryComponent.java @@ -38,7 +38,7 @@ import java.util.Set; * * @see ClassLoaderFacet */ -public interface ResourceDiscoveryComponent<T extends ResourceComponent> { +public interface ResourceDiscoveryComponent<T extends ResourceComponent<?>> { /** * <p>Asks the discovery component to discover all of its resources. The plugin container may or may not have already * {@link ResourceDiscoveryContext#getAutoDiscoveredProcesses() auto-discovered} some resources for this component diff --git a/modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/inventory/ResourceDiscoveryContext.java b/modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/inventory/ResourceDiscoveryContext.java index 3c45e79..b9e9bcd 100644 --- a/modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/inventory/ResourceDiscoveryContext.java +++ b/modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/inventory/ResourceDiscoveryContext.java @@ -53,7 +53,7 @@ import org.rhq.core.system.SystemInfo; * * @author John Mazzitelli */ -public class ResourceDiscoveryContext<T extends ResourceComponent> { +public class ResourceDiscoveryContext<T extends ResourceComponent<?>> { private final ResourceType resourceType; private final T parentComponent; private final PluginContainerDeployment pluginContainerDeployment; @@ -61,7 +61,7 @@ public class ResourceDiscoveryContext<T extends ResourceComponent> { /** * @since 1.0.1 */ - private final ResourceContext parentResourceContext; + private final ResourceContext<?> parentResourceContext; private final SystemInfo systemInformation; private final List<ProcessScanResult> processScanResults; private final List<Configuration> pluginConfigurations; @@ -86,12 +86,11 @@ public class ResourceDiscoveryContext<T extends ResourceComponent> { * can be assured this name is unique across <b>all</b> plugin containers/agents running * @param pluginContainerDeployment indicates where the plugin container is running */ - @SuppressWarnings("unchecked") public ResourceDiscoveryContext(ResourceType resourceType, T parentComponent, - ResourceContext parentResourceContext, SystemInfo systemInfo, List<ProcessScanResult> processScanResults, + ResourceContext<?> parentResourceContext, SystemInfo systemInfo, List<ProcessScanResult> processScanResults, String pluginContainerName, PluginContainerDeployment pluginContainerDeployment) { this(resourceType, parentComponent, parentResourceContext, systemInfo, processScanResults, null, - pluginContainerName, pluginContainerDeployment); + pluginContainerName, pluginContainerDeployment); }
/** @@ -119,7 +118,7 @@ public class ResourceDiscoveryContext<T extends ResourceComponent> { */ @SuppressWarnings("unchecked") public ResourceDiscoveryContext(ResourceType resourceType, T parentComponent, - ResourceContext parentResourceContext, SystemInfo systemInfo, List<ProcessScanResult> processScanResults, + ResourceContext<?> parentResourceContext, SystemInfo systemInfo, List<ProcessScanResult> processScanResults, List<Configuration> pluginConfigurations, String pluginContainerName, PluginContainerDeployment pluginContainerDeployment) { this.resourceType = resourceType; @@ -161,7 +160,7 @@ public class ResourceDiscoveryContext<T extends ResourceComponent> { * @return the resource context for the parent * @since 1.0.1 */ - public ResourceContext getParentResourceContext() { + public ResourceContext<?> getParentResourceContext() { return parentResourceContext; }
diff --git a/modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/upgrade/ResourceUpgradeContext.java b/modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/upgrade/ResourceUpgradeContext.java index c56d280..b4c6192 100644 --- a/modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/upgrade/ResourceUpgradeContext.java +++ b/modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/upgrade/ResourceUpgradeContext.java @@ -44,27 +44,26 @@ import org.rhq.core.system.SystemInfo; * * @author Lukas Krejci */ -@SuppressWarnings("rawtypes") -public class ResourceUpgradeContext<T extends ResourceComponent> extends ResourceContext<T> { +public class ResourceUpgradeContext<T extends ResourceComponent<?>> extends ResourceContext<T> {
private final Configuration resourceConfiguration; private final String name; private final String description; private ResourceContext<?> parentResourceContext; - + /** * @see ResourceContext#ResourceContext(Resource, ResourceComponent, ResourceDiscoveryComponent, SystemInfo, File, File, String, EventContext, OperationContext, ContentContext, Executor, PluginContainerDeployment) */ - public ResourceUpgradeContext(Resource resource, ResourceContext<?> parentResourceContext, T parentResourceComponent, - ResourceDiscoveryComponent resourceDiscoveryComponent, SystemInfo systemInfo, File temporaryDirectory, - File dataDirectory, String pluginContainerName, EventContext eventContext, OperationContext operationContext, - ContentContext contentContext, Executor availCollectorThreadPool, + public ResourceUpgradeContext(Resource resource, ResourceContext<?> parentResourceContext, + T parentResourceComponent, ResourceDiscoveryComponent<T> resourceDiscoveryComponent, SystemInfo systemInfo, + File temporaryDirectory, File dataDirectory, String pluginContainerName, EventContext eventContext, + OperationContext operationContext, ContentContext contentContext, Executor availCollectorThreadPool, PluginContainerDeployment pluginContainerDeployment) { - - super(resource, parentResourceComponent, resourceDiscoveryComponent, systemInfo, temporaryDirectory, dataDirectory, - pluginContainerName, eventContext, operationContext, contentContext, availCollectorThreadPool, - pluginContainerDeployment); - + + super(resource, parentResourceComponent, resourceDiscoveryComponent, systemInfo, temporaryDirectory, + dataDirectory, pluginContainerName, eventContext, operationContext, contentContext, + availCollectorThreadPool, pluginContainerDeployment); + this.parentResourceContext = parentResourceContext; this.resourceConfiguration = resource.getResourceConfiguration(); this.name = resource.getName(); @@ -72,9 +71,9 @@ public class ResourceUpgradeContext<T extends ResourceComponent> extends Resourc }
public ResourceContext<?> getParentResourceContext() { - return parentResourceContext; + return parentResourceContext; } - + public Configuration getResourceConfiguration() { return resourceConfiguration; } diff --git a/modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/upgrade/ResourceUpgradeFacet.java b/modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/upgrade/ResourceUpgradeFacet.java index 915a9e7..13c155a 100644 --- a/modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/upgrade/ResourceUpgradeFacet.java +++ b/modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/upgrade/ResourceUpgradeFacet.java @@ -34,7 +34,7 @@ import org.rhq.core.pluginapi.inventory.ResourceComponent; * * @author Lukas Krejci */ -public interface ResourceUpgradeFacet<T extends ResourceComponent> { +public interface ResourceUpgradeFacet<T extends ResourceComponent<?>> { /** * Specifies what data should change on the provided resource to upgrade it to the current version. * diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/InventoryManager.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/InventoryManager.java index fe15bb5..416e90a 100644 --- a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/InventoryManager.java +++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/InventoryManager.java @@ -22,6 +22,8 @@ */ package org.rhq.core.pc.inventory;
+import static org.rhq.core.domain.drift.DriftConfigurationComparator.CompareMode.BOTH_BASE_INFO_AND_DIRECTORY_SPECIFICATIONS; + import java.io.File; import java.net.URL; import java.util.ArrayList; @@ -251,16 +253,19 @@ public class InventoryManager extends AgentService implements ContainerService, // inside EmbJopr). if (configuration.isInsideAgent()) { // After an initial delay (5s by default), periodically run an availability check (every 1m by default). - availabilityThreadPoolExecutor.scheduleWithFixedDelay(availabilityExecutor, configuration - .getAvailabilityScanInitialDelay(), configuration.getAvailabilityScanPeriod(), TimeUnit.SECONDS); + availabilityThreadPoolExecutor.scheduleWithFixedDelay(availabilityExecutor, + configuration.getAvailabilityScanInitialDelay(), configuration.getAvailabilityScanPeriod(), + TimeUnit.SECONDS);
// After an initial delay (10s by default), periodically run a server discovery scan (every 15m by default). - inventoryThreadPoolExecutor.scheduleWithFixedDelay(serverScanExecutor, configuration - .getServerDiscoveryInitialDelay(), configuration.getServerDiscoveryPeriod(), TimeUnit.SECONDS); + inventoryThreadPoolExecutor.scheduleWithFixedDelay(serverScanExecutor, + configuration.getServerDiscoveryInitialDelay(), configuration.getServerDiscoveryPeriod(), + TimeUnit.SECONDS);
// After an initial delay (20s by default), periodically run a service discovery scan (every 1d by default). - inventoryThreadPoolExecutor.scheduleWithFixedDelay(serviceScanExecutor, configuration - .getServiceDiscoveryInitialDelay(), configuration.getServiceDiscoveryPeriod(), TimeUnit.SECONDS); + inventoryThreadPoolExecutor.scheduleWithFixedDelay(serviceScanExecutor, + configuration.getServiceDiscoveryInitialDelay(), configuration.getServiceDiscoveryPeriod(), + TimeUnit.SECONDS); } } finally { inventoryLock.writeLock().unlock(); @@ -317,8 +322,8 @@ public class InventoryManager extends AgentService implements ContainerService, long timeout = getDiscoveryComponentTimeout(context.getResourceType());
try { - ResourceDiscoveryComponent proxy = this.discoveryComponentProxyFactory.getDiscoveryComponentProxy(context - .getResourceType(), component, timeout, parentResourceContainer); + ResourceDiscoveryComponent proxy = this.discoveryComponentProxyFactory.getDiscoveryComponentProxy( + context.getResourceType(), component, timeout, parentResourceContainer); Set<DiscoveredResourceDetails> results = proxy.discoverResources(context); return results; } catch (TimeoutException te) { @@ -348,13 +353,13 @@ public class InventoryManager extends AgentService implements ContainerService, * @throws Exception if the discovery component threw an exception */ private DiscoveredResourceDetails discoverResource(ResourceDiscoveryComponent component, - Configuration pluginConfig, ResourceDiscoveryContext context, - ResourceContainer parentResourceContainer) throws Exception { + Configuration pluginConfig, ResourceDiscoveryContext context, ResourceContainer parentResourceContainer) + throws Exception { long timeout = getDiscoveryComponentTimeout(context.getResourceType());
try { - ManualAddFacet proxy = this.discoveryComponentProxyFactory.getDiscoveryComponentProxy(context - .getResourceType(), component, timeout, ManualAddFacet.class, parentResourceContainer); + ManualAddFacet proxy = this.discoveryComponentProxyFactory.getDiscoveryComponentProxy( + context.getResourceType(), component, timeout, ManualAddFacet.class, parentResourceContainer); DiscoveredResourceDetails result = proxy.discoverResource(pluginConfig, context); return result; } catch (TimeoutException te) { @@ -393,8 +398,8 @@ public class InventoryManager extends AgentService implements ContainerService, component, timeout, ClassLoaderFacet.class, parentContainer);
ResourceDiscoveryContext discoveryContext = new ResourceDiscoveryContext(resourceType, parentComponent, - parentResourceContext, SystemInfoFactory.createSystemInfo(), null, null, this.configuration - .getContainerName(), this.configuration.getPluginContainerDeployment()); + parentResourceContext, SystemInfoFactory.createSystemInfo(), null, null, + this.configuration.getContainerName(), this.configuration.getPluginContainerDeployment());
// Configurations are not immutable, so clone the plugin config, so the plugin will not be able to change the // actual PC-managed plugin config. @@ -409,9 +414,9 @@ public class InventoryManager extends AgentService implements ContainerService, return results; }
- public <T extends ResourceComponent> ResourceUpgradeReport invokeDiscoveryComponentResourceUpgradeFacet( - ResourceType resourceType, ResourceDiscoveryComponent<T> component, - ResourceUpgradeContext<T> inventoriedResource, ResourceContainer parentResourceContainer) throws Throwable { + public <T extends ResourceComponent<?>> ResourceUpgradeReport invokeDiscoveryComponentResourceUpgradeFacet( + ResourceType resourceType, ResourceDiscoveryComponent<T> component, + ResourceUpgradeContext<T> inventoriedResource, ResourceContainer parentResourceContainer) throws Throwable {
long timeout = getDiscoveryComponentTimeout(resourceType); try { @@ -679,16 +684,16 @@ public class InventoryManager extends AgentService implements ContainerService, DiscoveredResourceDetails discoveredResourceDetails; if (discoveryComponent instanceof ManualAddFacet) { // The plugin is using the new manual add API. - ResourceDiscoveryContext<ResourceComponent> discoveryContext = new ResourceDiscoveryContext<ResourceComponent>( + ResourceDiscoveryContext<ResourceComponent<?>> discoveryContext = new ResourceDiscoveryContext<ResourceComponent<?>>( resourceType, parentResourceComponent, parentResourceContainer.getResourceContext(), SystemInfoFactory.createSystemInfo(), new ArrayList<ProcessScanResult>(0), - new ArrayList<Configuration>(0), this.configuration.getContainerName(), this.configuration - .getPluginContainerDeployment()); + new ArrayList<Configuration>(0), this.configuration.getContainerName(), + this.configuration.getPluginContainerDeployment());
// Ask the plugin's discovery component to find the new resource, throwing exceptions if it cannot be // found at all. discoveredResourceDetails = discoverResource(discoveryComponent, pluginConfiguration, discoveryContext, - parentResourceContainer); + parentResourceContainer); if (discoveredResourceDetails == null) { log.info("Plugin Error: During manual add, discovery component method [" + discoveryComponent.getClass().getName() + ".discoverResource()] returned null " @@ -706,7 +711,7 @@ public class InventoryManager extends AgentService implements ContainerService, + "rather than the new ManualAddFacet interface."); List<Configuration> pluginConfigurations = new ArrayList<Configuration>(1); pluginConfigurations.add(pluginConfiguration); - ResourceDiscoveryContext<ResourceComponent> discoveryContext = new ResourceDiscoveryContext<ResourceComponent>( + ResourceDiscoveryContext<ResourceComponent<?>> discoveryContext = new ResourceDiscoveryContext<ResourceComponent<?>>( resourceType, parentResourceComponent, parentResourceContainer.getResourceContext(), SystemInfoFactory.createSystemInfo(), new ArrayList<ProcessScanResult>(0), pluginConfigurations, this.configuration.getContainerName(), this.configuration.getPluginContainerDeployment()); @@ -885,8 +890,7 @@ public class InventoryManager extends AgentService implements ContainerService, if ((this.platform != null) && (this.platform.getInventoryStatus() == InventoryStatus.NEW) && newPlatformWasDeletedRecently) { // let's make sure we are registered; its probable that our platform was deleted and we need to re-register - log - .info("No committed resources to send in our availability report - the platform/agent was deleted, let's re-register again"); + log.info("No committed resources to send in our availability report - the platform/agent was deleted, let's re-register again"); registerWithServer(); newPlatformWasDeletedRecently = false; // we've tried to recover from our platform being deleted, let's not do it again } @@ -929,8 +933,8 @@ public class InventoryManager extends AgentService implements ContainerService, log.debug("Availability report content: " + report.toString(log.isTraceEnabled())); }
- boolean ok = configuration.getServerServices().getDiscoveryServerService().mergeAvailabilityReport( - report); + boolean ok = configuration.getServerServices().getDiscoveryServerService() + .mergeAvailabilityReport(report); if (!ok) { // I guess I could immediately call executeAvailabilityScanImmediately and pass its results to // mergeAvailabilityReport again right now, but what happens if we've queued up a bunch of @@ -976,9 +980,9 @@ public class InventoryManager extends AgentService implements ContainerService, (System.currentTimeMillis() - startTime))); } } catch (StaleTypeException e) { - log.error("Failed to merge inventory report with server. The report contains one or more resource types " + - "that have been marked for deletion. Notifying the plugin container that a reboot is needed to purge " + - "stale types."); + log.error("Failed to merge inventory report with server. The report contains one or more resource types " + + "that have been marked for deletion. Notifying the plugin container that a reboot is needed to purge " + + "stale types."); PluginContainer.getInstance().notifyRebootRequestListener(); return false; } catch (InvalidInventoryReportException e) { @@ -986,8 +990,7 @@ public class InventoryManager extends AgentService implements ContainerService, if ((this.platform != null) && (this.platform.getInventoryStatus() == InventoryStatus.NEW) && newPlatformWasDeletedRecently) { // let's make sure we are registered; its probable that our platform was deleted and we need to re-register - log - .info("The inventory report was invalid probably because the platform/Agent was deleted; let's re-register..."); + log.info("The inventory report was invalid probably because the platform/Agent was deleted; let's re-register..."); registerWithServer(); newPlatformWasDeletedRecently = false; // we've tried to recover from our platform being deleted, let's not do it again } @@ -1183,8 +1186,8 @@ public class InventoryManager extends AgentService implements ContainerService, parent.removeChildResource(resource); }
- PluginContainer.getInstance().getMeasurementManager().unscheduleCollection( - Collections.singleton(resource.getId())); + PluginContainer.getInstance().getMeasurementManager() + .unscheduleCollection(Collections.singleton(resource.getId()));
if (this.resourceContainers.remove(resource.getUuid()) == null) { if (log.isDebugEnabled()) { @@ -1290,8 +1293,8 @@ public class InventoryManager extends AgentService implements ContainerService, logMessage.append("description, "); }
- logMessage.replace(logMessage.length() - 1, logMessage.length(), "to become [").append( - existingResource.toString()).append("]"); + logMessage.replace(logMessage.length() - 1, logMessage.length(), "to become [") + .append(existingResource.toString()).append("]");
log.info(logMessage.toString()); } else { @@ -1452,22 +1455,24 @@ public class InventoryManager extends AgentService implements ContainerService, * @throws PluginContainerException * @return true the resource has been successfully prepared and can be started. False if the resource should not be started. */ - private boolean prepareResourceForActivation(Resource resource, @NotNull ResourceContainer container, boolean forceReinitialization) throws InvalidPluginConfigurationException, PluginContainerException { + private boolean prepareResourceForActivation(Resource resource, @NotNull ResourceContainer container, + boolean forceReinitialization) throws InvalidPluginConfigurationException, PluginContainerException { if (resourceUpgradeDelegate.hasUpgradeFailed(resource)) { if (log.isTraceEnabled()) { log.trace("Skipping activation of " + resource + " - it has failed to upgrade."); } return false; } - + ResourceComponent component = container.getResourceComponent();
// if the component already exists and is started, and the resource's plugin config has not changed, there is // nothing to do, so return immediately - if ((component != null) && (container.getResourceComponentState() == ResourceComponentState.STARTED - && !forceReinitialization)) { + if ((component != null) + && (container.getResourceComponentState() == ResourceComponentState.STARTED && !forceReinitialization)) { if (log.isTraceEnabled()) { - log.trace("No need to prepare the activation of resource " + resource + " - its component is already started and its plugin " + log.trace("No need to prepare the activation of resource " + resource + + " - its component is already started and its plugin " + "config has not been updated since it was last started."); } return false; @@ -1475,7 +1480,8 @@ public class InventoryManager extends AgentService implements ContainerService,
if (log.isDebugEnabled()) { log.debug("Preparing component for [" + resource + "] for activation, current state=[" - + container.getResourceComponentState() + "], forcing reinitialization=[" + forceReinitialization + "]..."); + + container.getResourceComponentState() + "], forcing reinitialization=[" + forceReinitialization + + "]..."); }
// If the component does not even exist yet, we need to instantiate it and set it on the container. @@ -1494,7 +1500,7 @@ public class InventoryManager extends AgentService implements ContainerService, //this is a transient field, so reinitialize it just in case this is invoked just after //loadFromDisk() container.setResourceComponentState(ResourceComponentState.STOPPED); - + // start the resource, but only if its parent component is running. If the parent is null, that means // the resource is, itself, the root platform and we always activate that. ResourceContainer parentResourceContainer; @@ -1524,8 +1530,8 @@ public class InventoryManager extends AgentService implements ContainerService, log.warn("Cannot give activated resource its discovery component. Cause: " + e); }
- ConfigurationUtility.normalizeConfiguration(resource.getPluginConfiguration(), type - .getPluginConfigurationDefinition()); + ConfigurationUtility.normalizeConfiguration(resource.getPluginConfiguration(), + type.getPluginConfigurationDefinition());
ResourceComponent<?> parentComponent = null; if (resource.getParentResource() != null) { @@ -1539,13 +1545,14 @@ public class InventoryManager extends AgentService implements ContainerService, return true; } else { if (log.isDebugEnabled()) { - log.debug("Resource [" + resource + "] not being prepared for activation; parent isn't started: " + parentResourceContainer); + log.debug("Resource [" + resource + "] not being prepared for activation; parent isn't started: " + + parentResourceContainer); } - + return false; } } - + /** * This will start the resource's plugin component, creating it first if it has not yet been created. If the * component is already created and started, this method is a no-op. @@ -1570,12 +1577,12 @@ public class InventoryManager extends AgentService implements ContainerService, }
if (prepareResourceForActivation(resource, container, updatedPluginConfig)) { - + ResourceContext context = container.getResourceContext(); - + // Wrap the component in a proxy that will provide locking and a timeout for the call to start(). - ResourceComponent component = container.createResourceComponentProxy(ResourceComponent.class, FacetLockType.READ, - COMPONENT_START_TIMEOUT, true, false); + ResourceComponent component = container.createResourceComponentProxy(ResourceComponent.class, + FacetLockType.READ, COMPONENT_START_TIMEOUT, true, false);
try { // One last check to make sure another thread didn't beat us to the punch. @@ -1613,7 +1620,7 @@ public class InventoryManager extends AgentService implements ContainerService, } }
- private <T extends ResourceComponent> ResourceContext<T> createResourceContext(Resource resource, + private <T extends ResourceComponent<?>> ResourceContext<T> createResourceContext(Resource resource, T parentComponent, ResourceDiscoveryComponent<T> discoveryComponent) { File pluginDataDir = new File(this.configuration.getDataDirectory(), resource.getResourceType().getPlugin());
@@ -1631,7 +1638,7 @@ public class InventoryManager extends AgentService implements ContainerService, this.configuration.getPluginContainerDeployment()); // helps components make determinations of what to do }
- public <T extends ResourceComponent> ResourceUpgradeContext<T> createResourceUpgradeContext(Resource resource, + public <T extends ResourceComponent<?>> ResourceUpgradeContext<T> createResourceUpgradeContext(Resource resource, ResourceContext<?> parentResourceContext, T parentComponent, ResourceDiscoveryComponent<T> discoveryComponent) { File pluginDataDir = new File(this.configuration.getDataDirectory(), resource.getResourceType().getPlugin());
@@ -1662,8 +1669,8 @@ public class InventoryManager extends AgentService implements ContainerService, resource.setConnected(false); // invalid plugin configuration infers the resource component is disconnected // Give the server-side an error message describing the connection failure that can be // displayed on the resource's Inventory page. - ResourceError resourceError = new ResourceError(resource, ResourceErrorType.INVALID_PLUGIN_CONFIGURATION, t - .getLocalizedMessage(), ThrowableUtil.getStackAsString(t), System.currentTimeMillis()); + ResourceError resourceError = new ResourceError(resource, ResourceErrorType.INVALID_PLUGIN_CONFIGURATION, + t.getLocalizedMessage(), ThrowableUtil.getStackAsString(t), System.currentTimeMillis()); return sendResourceErrorToServer(resourceError); }
@@ -1922,8 +1929,7 @@ public class InventoryManager extends AgentService implements ContainerService, } } else { // This is very strange - there are no platform types - we should never be missing the built-in platform plugin. - log - .error("Missing platform plugin(s) - falling back to dummy platform impl; this should only occur in tests!"); + log.error("Missing platform plugin(s) - falling back to dummy platform impl; this should only occur in tests!"); // TODO: Set sysprop (e.g. rhq.test.mode=true) in integration tests, // and throw a runtime exception here if that sysprop is not set. return getTestPlatform(); @@ -2133,8 +2139,8 @@ public class InventoryManager extends AgentService implements ContainerService, log.info("Syncing drift configurations from server with local inventory..."); DriftManager driftMgr = PluginContainer.getInstance().getDriftManager(); if (driftMgr != null && driftMgr.isInitialized()) { - DriftConfigurationComparator comparator = - new DriftConfigurationComparator(BOTH_BASE_INFO_AND_DIRECTORY_SPECIFICATIONS); + DriftConfigurationComparator comparator = new DriftConfigurationComparator( + BOTH_BASE_INFO_AND_DIRECTORY_SPECIFICATIONS); ScheduleQueue queue = driftMgr.getSchedulesQueue();
// First check for drift configurations that have been deleted @@ -2164,8 +2170,8 @@ public class InventoryManager extends AgentService implements ContainerService, for (DriftConfiguration c : configsFromServer.get(resourceId)) { if (!queue.contains(resourceId, c, comparator)) { if (log.isDebugEnabled()) { - log.debug("Detected new drift configuration. Creating new schedule for " + - "DriftConfiguration[name: " + c.getName() + ", resourceId: " + resourceId + "]"); + log.debug("Detected new drift configuration. Creating new schedule for " + + "DriftConfiguration[name: " + c.getName() + ", resourceId: " + resourceId + "]"); } driftMgr.scheduleDriftDetection(resourceId, c); } @@ -2190,8 +2196,8 @@ public class InventoryManager extends AgentService implements ContainerService, for (DriftConfiguration c : container.getDriftConfigurations()) { if (!resourceConfigs.contains(c)) { if (log.isDebugEnabled()) { - log.debug("Detected stale drift configuration. Preparing to delete DriftConfiguration[" + - "name: " + c.getName() + ", resourceId: " + resourceId + "]"); + log.debug("Detected stale drift configuration. Preparing to delete DriftConfiguration[" + + "name: " + c.getName() + ", resourceId: " + resourceId + "]"); } deleted.add(c); } @@ -2394,8 +2400,8 @@ public class InventoryManager extends AgentService implements ContainerService, try { ResourceDiscoveryContext context = new ResourceDiscoveryContext(resourceType, parentComponent, parentResourceContext, SystemInfoFactory.createSystemInfo(), processScanResults, - Collections.EMPTY_LIST, this.configuration.getContainerName(), this.configuration - .getPluginContainerDeployment()); + Collections.EMPTY_LIST, this.configuration.getContainerName(), + this.configuration.getPluginContainerDeployment()); newResources = new HashSet<Resource>(); try { Set<DiscoveredResourceDetails> discoveredResources = invokeDiscoveryComponent(parentContainer, @@ -2631,8 +2637,8 @@ public class InventoryManager extends AgentService implements ContainerService, if (log.isDebugEnabled()) { log.debug("Merging [" + modifiedResourceIds.size() + "] modified Resources into local inventory..."); } - Set<Resource> modifiedResources = configuration.getServerServices().getDiscoveryServerService().getResources( - modifiedResourceIds, false); + Set<Resource> modifiedResources = configuration.getServerServices().getDiscoveryServerService() + .getResources(modifiedResourceIds, false); syncSchedules(modifiedResources); // RHQ-792, mtime is the indicator that schedules should be sync'ed too syncDriftConfigurations(modifiedResources); for (Resource modifiedResource : modifiedResources) { @@ -2830,7 +2836,7 @@ public class InventoryManager extends AgentService implements ContainerService, //don't do anything during upgrade. The resources are only started during the upgrade process. return; } - + Resource resource = container.getResource(); switch (resource.getInventoryStatus()) { case COMMITTED: { @@ -2859,20 +2865,21 @@ public class InventoryManager extends AgentService implements ContainerService, log.info("Starting resource activation and upgrade.");
long start = System.currentTimeMillis(); - + log.info("Executing the initial inventory synchronization before upgrade."); - + boolean syncResult = handleReport(new InventoryReport(getAgent())); if (!syncResult) { log.warn("Failed to sync up the inventory with the server. The resource upgrade will be disabled."); }
log.info("Starting to activate (and upgrade) resources."); - + activateAndUpgradeResourceRecursively(getPlatform(), syncResult);
- log.info("Inventory activated and upgrade requests gathered in " + (System.currentTimeMillis() - start) + "ms."); - + log.info("Inventory activated and upgrade requests gathered in " + (System.currentTimeMillis() - start) + + "ms."); + log.info("Sending the upgrade requests to the server."); resourceUpgradeDelegate.sendRequests();
@@ -2880,18 +2887,20 @@ public class InventoryManager extends AgentService implements ContainerService,
log.info("Resource activation and upgrade finished."); } catch (Throwable t) { - log.error("Resource activation or upgrade failed with an exception. An attempt to merely activate the resources will be made now.", t); + log.error( + "Resource activation or upgrade failed with an exception. An attempt to merely activate the resources will be made now.", + t);
//make sure to at least activate the resources activateAndUpgradeResourceRecursively(getPlatform(), false); } }
- private void activateAndUpgradeResourceRecursively(Resource resource, boolean doUpgrade) { + private void activateAndUpgradeResourceRecursively(Resource resource, boolean doUpgrade) { ResourceContainer container = initResourceContainer(resource); - + boolean activate = true; - + //only do upgrade inside the agent. it does not make sense in embedded mode. if (doUpgrade && configuration.isInsideAgent()) { try { @@ -2902,7 +2911,7 @@ public class InventoryManager extends AgentService implements ContainerService, activate = false; } } - + if (activate) { try { activateResource(resource, container, false); diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/upgrade/ResourceUpgradeDelegate.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/upgrade/ResourceUpgradeDelegate.java index 6dff613..c32ca97 100644 --- a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/upgrade/ResourceUpgradeDelegate.java +++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/upgrade/ResourceUpgradeDelegate.java @@ -148,7 +148,7 @@ public class ResourceUpgradeDelegate { try { //check the validity of the upgrades now that we have a complete picture //about the changes and the inventory looks like it was already upgraded. - for(ResourceUpgradeRequest request : requests) { + for (ResourceUpgradeRequest request : requests) { ResourceContainer container = inventoryManager.getResourceContainer(request.getResourceId()); if (container != null) { Resource resource = container.getResource(); @@ -158,12 +158,12 @@ public class ResourceUpgradeDelegate { //in the code below. Let's use the original resource for the error message so that we don't confuse //the user. ResourceUpgradeRequest orig = findOriginal(request); - + //orig should never be null, but let's be paranoid - if (orig != null) { + if (orig != null) { orig.updateResource(resource); } - + String errorString = "Upgrading the resource [" + resource + "] using these updates [" + request + "] would render the inventory invalid because of the following reasons: " + upgradeErrors; @@ -240,7 +240,7 @@ public class ResourceUpgradeDelegate { }
@SuppressWarnings("unchecked") - private <T extends ResourceComponent> boolean executeResourceUpgradeFacetAndStoreRequest( + private <T extends ResourceComponent<?>> boolean executeResourceUpgradeFacetAndStoreRequest( ResourceContainer resourceContainer) throws PluginContainerException {
ResourceComponent<T> parentResourceComponent = resourceContainer.getResourceContext() @@ -318,7 +318,7 @@ public class ResourceUpgradeDelegate { s.append("After the upgrade, the following resources would have the same resource key which is illegal. This is an issue of either the old or the new version of the plugin '" + resource.getResourceType().getPlugin() + "'. Please consult the documentation of the plugin to see what are the recommended steps to resolve this situation:\n"); - + //ok, this is a little tricky //this method is called when the inventory is in the state as it would look after a //successful upgrade. @@ -330,19 +330,19 @@ public class ResourceUpgradeDelegate { for (Resource r : duplicitSiblings) { ResourceUpgradeRequest fakeRequest = new ResourceUpgradeRequest(r.getId()); fakeRequest.fillInFromResource(r); - + ResourceUpgradeRequest orig = findOriginal(fakeRequest); - + //we might not find the original, because this resource might not need an upgrade. //in that case, the reporting will be accurate because upgrade didn't touch the resource. if (orig != null) { orig.updateResource(r); } - + //now we have the resource as it looked before the upgrade kicked in (which is in this //case also what it will look like after the upgrade finishes, because we're failing it). s.append(r).append(",\n"); - + //and revert the resource back to what it looked like (i.e. back to the upgraded state so //that we don't introduce side-effects in this method). if (orig != null) { @@ -395,14 +395,14 @@ public class ResourceUpgradeDelegate {
failedResourceTypesInParent.add(resource.getResourceType()); } - + private ResourceUpgradeRequest findOriginal(ResourceUpgradeRequest request) { - for(ResourceUpgradeRequest original : originalResourceData) { + for (ResourceUpgradeRequest original : originalResourceData) { if (original.equals(request)) { return original; } } - + return null; } } diff --git a/modules/core/plugin-container/src/test/java/org/rhq/core/pc/upgrade/plugins/failing/DiscComponent.java b/modules/core/plugin-container/src/test/java/org/rhq/core/pc/upgrade/plugins/failing/DiscComponent.java index 75bfbd7..65890c2 100644 --- a/modules/core/plugin-container/src/test/java/org/rhq/core/pc/upgrade/plugins/failing/DiscComponent.java +++ b/modules/core/plugin-container/src/test/java/org/rhq/core/pc/upgrade/plugins/failing/DiscComponent.java @@ -37,16 +37,16 @@ import org.rhq.core.pluginapi.upgrade.ResourceUpgradeFacet; * * @author Lukas Krejci */ -public class DiscComponent implements ResourceDiscoveryComponent<ResourceComponent>, - ResourceUpgradeFacet<ResourceComponent> { - +public class DiscComponent<T extends ResourceComponent<?>> implements ResourceDiscoveryComponent<T>, + ResourceUpgradeFacet<T> { + private static final String RESOURCE_KEY = "resource-key-failing"; private static final String RESOURCE_NAME = "resource-name-failing"; private static final String RESOURCE_DESCRIPTION = "resource-description-failing";
- public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext<ResourceComponent> context) + public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext<T> context) throws InvalidPluginConfigurationException, Exception { - + //create a marker file so that the testing code knows this method has run File dataDir = context.getParentResourceContext().getDataDirectory(); if (dataDir != null) { @@ -59,12 +59,12 @@ public class DiscComponent implements ResourceDiscoveryComponent<ResourceCompone } catch (IOException e) { } } - + return Collections.singleton(new DiscoveredResourceDetails(context.getResourceType(), RESOURCE_KEY, RESOURCE_NAME, null, RESOURCE_DESCRIPTION, context.getDefaultPluginConfiguration(), null)); }
- public ResourceUpgradeReport upgrade(ResourceUpgradeContext<ResourceComponent> inventoriedResource) { + public ResourceUpgradeReport upgrade(ResourceUpgradeContext<T> inventoriedResource) { throw new RuntimeException("Failing the upgrade purposefully."); } } diff --git a/modules/core/plugin-container/src/test/java/org/rhq/core/pc/upgrade/plugins/failing/ResComponent.java b/modules/core/plugin-container/src/test/java/org/rhq/core/pc/upgrade/plugins/failing/ResComponent.java index 4c33adc..7df5729 100644 --- a/modules/core/plugin-container/src/test/java/org/rhq/core/pc/upgrade/plugins/failing/ResComponent.java +++ b/modules/core/plugin-container/src/test/java/org/rhq/core/pc/upgrade/plugins/failing/ResComponent.java @@ -21,6 +21,7 @@ package org.rhq.core.pc.upgrade.plugins.failing;
import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; + import org.rhq.core.domain.measurement.AvailabilityType; import org.rhq.core.pluginapi.inventory.InvalidPluginConfigurationException; import org.rhq.core.pluginapi.inventory.ResourceComponent; @@ -30,17 +31,18 @@ import org.rhq.core.pluginapi.inventory.ResourceContext; * * @author Lukas Krejci */ -public class ResComponent implements ResourceComponent<ResourceComponent> { +public class ResComponent<T extends ResourceComponent<?>> implements ResourceComponent<T> { private static final Log log = LogFactory.getLog(ResComponent.class); - + public AvailabilityType getAvailability() { return AvailabilityType.UP; } - - public void start(ResourceContext<ResourceComponent> context) throws InvalidPluginConfigurationException, Exception { - log.info("~~~ starting the resource upgrade test failing component with resource key: " + context.getResourceKey()); + + public void start(ResourceContext<T> context) throws InvalidPluginConfigurationException, Exception { + log.info("~~~ starting the resource upgrade test failing component with resource key: " + + context.getResourceKey()); } - + public void stop() { } } diff --git a/modules/core/plugin-container/src/test/java/org/rhq/core/pc/upgrade/plugins/multi/base/BaseDiscoveryComponent.java b/modules/core/plugin-container/src/test/java/org/rhq/core/pc/upgrade/plugins/multi/base/BaseDiscoveryComponent.java index a03dff5..ae5dcbd 100644 --- a/modules/core/plugin-container/src/test/java/org/rhq/core/pc/upgrade/plugins/multi/base/BaseDiscoveryComponent.java +++ b/modules/core/plugin-container/src/test/java/org/rhq/core/pc/upgrade/plugins/multi/base/BaseDiscoveryComponent.java @@ -34,7 +34,7 @@ import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext; * * @author Lukas Krejci */ -public class BaseDiscoveryComponent<T extends ResourceComponent> implements ResourceDiscoveryComponent<T> { +public class BaseDiscoveryComponent<T extends ResourceComponent<?>> implements ResourceDiscoveryComponent<T> {
public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext<T> context) throws InvalidPluginConfigurationException, Exception { diff --git a/modules/core/plugin-container/src/test/java/org/rhq/core/pc/upgrade/plugins/multi/base/BaseResourceComponent.java b/modules/core/plugin-container/src/test/java/org/rhq/core/pc/upgrade/plugins/multi/base/BaseResourceComponent.java index 04d3767..5b40d2c 100644 --- a/modules/core/plugin-container/src/test/java/org/rhq/core/pc/upgrade/plugins/multi/base/BaseResourceComponent.java +++ b/modules/core/plugin-container/src/test/java/org/rhq/core/pc/upgrade/plugins/multi/base/BaseResourceComponent.java @@ -26,6 +26,7 @@ import java.util.Set;
import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; + import org.rhq.core.domain.configuration.Configuration; import org.rhq.core.domain.configuration.Property; import org.rhq.core.domain.configuration.PropertyList; @@ -40,11 +41,12 @@ import org.rhq.core.pluginapi.inventory.ResourceContext; * * @author Lukas Krejci */ -public class BaseResourceComponent<T extends ResourceComponent> implements ResourceComponent<T>, BaseResourceComponentInterface { +public class BaseResourceComponent<T extends ResourceComponent<?>> implements ResourceComponent<T>, + BaseResourceComponentInterface {
private ResourceContext<T> context; private final Log log = LogFactory.getLog(getClass()); - + public AvailabilityType getAvailability() { return AvailabilityType.UP; } @@ -53,7 +55,7 @@ public class BaseResourceComponent<T extends ResourceComponent> implements Resou log.info("Starting multi resource child component with resource key '" + context.getResourceKey() + "'."); this.context = context; } - + public void stop() { log.info("Stopping multi resource child component with resource key '" + context.getResourceKey() + "'."); } @@ -61,58 +63,58 @@ public class BaseResourceComponent<T extends ResourceComponent> implements Resou public int getOrdinal() { return context.getPluginConfiguration().getSimple("ordinal").getIntegerValue(); } - + public Map<String, Set<Integer>> getChildrenToFailUpgrade() { - + Map<String, Set<Integer>> ret = new HashMap<String, Set<Integer>>(); - + Configuration pluginConfig = context.getPluginConfiguration(); PropertyList childrenToFail = pluginConfig.getList("childrenToFail"); - + if (childrenToFail != null) { - for(Property p : childrenToFail.getList()) { + for (Property p : childrenToFail.getList()) { PropertyMap entry = (PropertyMap) p; - + String type = entry.getSimpleValue("type", null); - + PropertyList typeList = entry.getList("children"); - + if (type != null && typeList != null) { Set<Integer> ordinals = new HashSet<Integer>(); - - for(Property pp : typeList.getList()) { - ordinals.add(((PropertySimple)pp).getIntegerValue()); + + for (Property pp : typeList.getList()) { + ordinals.add(((PropertySimple) pp).getIntegerValue()); } - + ret.put(type, ordinals); } } } - + return ret; } - + public Configuration createPluginConfigurationWithMarkedFailures(Map<String, Set<Integer>> childrenToFailUpgrade) { Configuration ret = context.getPluginConfiguration().clone(); PropertyList list = new PropertyList("childrenToFail"); - - for(Map.Entry<String, Set<Integer>> entry : childrenToFailUpgrade.entrySet()) { + + for (Map.Entry<String, Set<Integer>> entry : childrenToFailUpgrade.entrySet()) { PropertyMap configEntry = new PropertyMap("childrenInType"); configEntry.put(new PropertySimple("type", entry.getKey())); - + PropertyList typeList = new PropertyList("children"); - - for(Integer childOrdinal : entry.getValue()) { + + for (Integer childOrdinal : entry.getValue()) { typeList.add(new PropertySimple("ordinal", childOrdinal)); } - + configEntry.put(typeList); - + list.add(configEntry); } - + ret.put(list); - + return ret; } } diff --git a/modules/core/plugin-container/src/test/java/org/rhq/core/pc/upgrade/plugins/multi/base/BaseUpgradingDiscoveryComponent.java b/modules/core/plugin-container/src/test/java/org/rhq/core/pc/upgrade/plugins/multi/base/BaseUpgradingDiscoveryComponent.java index a1acf50..d76328f 100644 --- a/modules/core/plugin-container/src/test/java/org/rhq/core/pc/upgrade/plugins/multi/base/BaseUpgradingDiscoveryComponent.java +++ b/modules/core/plugin-container/src/test/java/org/rhq/core/pc/upgrade/plugins/multi/base/BaseUpgradingDiscoveryComponent.java @@ -30,7 +30,7 @@ import org.rhq.core.pluginapi.upgrade.ResourceUpgradeFacet; * * @author Lukas Krejci */ -public class BaseUpgradingDiscoveryComponent<T extends BaseResourceComponent> extends BaseDiscoveryComponent<T> +public class BaseUpgradingDiscoveryComponent<T extends BaseResourceComponent<?>> extends BaseDiscoveryComponent<T> implements ResourceUpgradeFacet<T> {
public ResourceUpgradeReport upgrade(ResourceUpgradeContext<T> inventoriedResource) { @@ -45,16 +45,16 @@ public class BaseUpgradingDiscoveryComponent<T extends BaseResourceComponent> ex if (!fail && parent != null) { String typeName = inventoriedResource.getResourceType().getName(); Set<Integer> failingOrdinals = parent.getChildrenToFailUpgrade().get(typeName); - + fail = failingOrdinals != null && failingOrdinals.contains(Integer.valueOf(ordinal)); }
if (fail) { throw new RuntimeException("Failing the resource upgrade purposefully."); } - + boolean checkParentUpgraded = Boolean.parseBoolean(pluginConfig.getSimpleValue("checkParentUpgraded", "false")); - + if (checkParentUpgraded) { if (!inventoriedResource.getParentResourceContext().getResourceKey().startsWith("UPGRADED")) { throw new RuntimeException("The parent resource [" @@ -62,7 +62,7 @@ public class BaseUpgradingDiscoveryComponent<T extends BaseResourceComponent> ex + "] doesn't seem like it's upgraded but this resource expects it to be."); } } - + String newKey = pluginConfig.getSimpleValue("upgradedKey", null);
if (newKey == null) { diff --git a/modules/core/plugin-container/src/test/java/org/rhq/core/pc/upgrade/plugins/multi/base/NothingDiscoveringDiscoveryComponent.java b/modules/core/plugin-container/src/test/java/org/rhq/core/pc/upgrade/plugins/multi/base/NothingDiscoveringDiscoveryComponent.java index b6189e5..a706246 100644 --- a/modules/core/plugin-container/src/test/java/org/rhq/core/pc/upgrade/plugins/multi/base/NothingDiscoveringDiscoveryComponent.java +++ b/modules/core/plugin-container/src/test/java/org/rhq/core/pc/upgrade/plugins/multi/base/NothingDiscoveringDiscoveryComponent.java @@ -32,7 +32,8 @@ import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext; * * @author Lukas Krejci */ -public class NothingDiscoveringDiscoveryComponent<T extends ResourceComponent> implements ResourceDiscoveryComponent<T> { +public class NothingDiscoveringDiscoveryComponent<T extends ResourceComponent<?>> implements + ResourceDiscoveryComponent<T> {
public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext<T> context) throws InvalidPluginConfigurationException, Exception { diff --git a/modules/core/plugin-container/src/test/java/org/rhq/core/pc/upgrade/plugins/v1/DiscComponent.java b/modules/core/plugin-container/src/test/java/org/rhq/core/pc/upgrade/plugins/v1/DiscComponent.java index 5fbca32..7b6bcc7 100644 --- a/modules/core/plugin-container/src/test/java/org/rhq/core/pc/upgrade/plugins/v1/DiscComponent.java +++ b/modules/core/plugin-container/src/test/java/org/rhq/core/pc/upgrade/plugins/v1/DiscComponent.java @@ -9,12 +9,12 @@ import org.rhq.core.pluginapi.inventory.ResourceComponent; import org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent; import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext;
-public class DiscComponent implements ResourceDiscoveryComponent<ResourceComponent> { +public class DiscComponent<T extends ResourceComponent<?>> implements ResourceDiscoveryComponent<T> { private static final String RESOURCE_KEY = "resource-key-v1"; private static final String RESOURCE_NAME = "resource-name-v1"; private static final String RESOURCE_DESCRIPTION = "resource-description-v1";
- public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext<ResourceComponent> context) + public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext<T> context) throws InvalidPluginConfigurationException, Exception { return Collections.singleton(new DiscoveredResourceDetails(context.getResourceType(), RESOURCE_KEY, RESOURCE_NAME, null, RESOURCE_DESCRIPTION, context.getDefaultPluginConfiguration(), null)); diff --git a/modules/core/plugin-container/src/test/java/org/rhq/core/pc/upgrade/plugins/v1/ResComponent.java b/modules/core/plugin-container/src/test/java/org/rhq/core/pc/upgrade/plugins/v1/ResComponent.java index cc21fc3..e336987 100644 --- a/modules/core/plugin-container/src/test/java/org/rhq/core/pc/upgrade/plugins/v1/ResComponent.java +++ b/modules/core/plugin-container/src/test/java/org/rhq/core/pc/upgrade/plugins/v1/ResComponent.java @@ -6,12 +6,12 @@ import org.rhq.core.domain.measurement.AvailabilityType; import org.rhq.core.pluginapi.inventory.ResourceComponent; import org.rhq.core.pluginapi.inventory.ResourceContext;
-public class ResComponent implements ResourceComponent<ResourceComponent> { +public class ResComponent<T extends ResourceComponent<?>> implements ResourceComponent<T> { public AvailabilityType getAvailability() { return AvailabilityType.UP; }
- public void start(ResourceContext<ResourceComponent> context) { + public void start(ResourceContext<T> context) { LogFactory.getLog(this.getClass()).info( "~~~ Starting resource upgrade test plugin v1 component: key=" + context.getResourceKey()); } diff --git a/modules/core/plugin-container/src/test/java/org/rhq/core/pc/upgrade/plugins/v2/DiscComponent.java b/modules/core/plugin-container/src/test/java/org/rhq/core/pc/upgrade/plugins/v2/DiscComponent.java index d113d1c..d6ca18f 100644 --- a/modules/core/plugin-container/src/test/java/org/rhq/core/pc/upgrade/plugins/v2/DiscComponent.java +++ b/modules/core/plugin-container/src/test/java/org/rhq/core/pc/upgrade/plugins/v2/DiscComponent.java @@ -14,20 +14,20 @@ import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext; import org.rhq.core.pluginapi.upgrade.ResourceUpgradeContext; import org.rhq.core.pluginapi.upgrade.ResourceUpgradeFacet;
-public class DiscComponent implements ResourceDiscoveryComponent<ResourceComponent>, - ResourceUpgradeFacet<ResourceComponent> { +public class DiscComponent<T extends ResourceComponent<?>> implements ResourceDiscoveryComponent<T>, + ResourceUpgradeFacet<T> { private static final String V1_RESOURCE_KEY = "resource-key-v1"; private static final String RESOURCE_KEY = "resource-key-v2"; private static final String RESOURCE_NAME = "resource-name-v2"; private static final String RESOURCE_DESCRIPTION = "resource-description-v2";
- public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext<ResourceComponent> context) + public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext<T> context) throws InvalidPluginConfigurationException, Exception { return Collections.singleton(new DiscoveredResourceDetails(context.getResourceType(), RESOURCE_KEY, RESOURCE_NAME, null, RESOURCE_DESCRIPTION, context.getDefaultPluginConfiguration(), null)); }
- public ResourceUpgradeReport upgrade(ResourceUpgradeContext<ResourceComponent> inventoriedResource) { + public ResourceUpgradeReport upgrade(ResourceUpgradeContext<T> inventoriedResource) { if (V1_RESOURCE_KEY.equals(inventoriedResource.getResourceKey())) { ResourceUpgradeReport report = new ResourceUpgradeReport(); report.setNewResourceKey(RESOURCE_KEY); diff --git a/modules/core/plugin-container/src/test/java/org/rhq/core/pc/upgrade/plugins/v2/ResComponent.java b/modules/core/plugin-container/src/test/java/org/rhq/core/pc/upgrade/plugins/v2/ResComponent.java index 83144b2..2d31236 100644 --- a/modules/core/plugin-container/src/test/java/org/rhq/core/pc/upgrade/plugins/v2/ResComponent.java +++ b/modules/core/plugin-container/src/test/java/org/rhq/core/pc/upgrade/plugins/v2/ResComponent.java @@ -6,12 +6,12 @@ import org.rhq.core.domain.measurement.AvailabilityType; import org.rhq.core.pluginapi.inventory.ResourceComponent; import org.rhq.core.pluginapi.inventory.ResourceContext;
-public class ResComponent implements ResourceComponent<ResourceComponent> { +public class ResComponent<T extends ResourceComponent<?>> implements ResourceComponent<T> { public AvailabilityType getAvailability() { return AvailabilityType.UP; }
- public void start(ResourceContext<ResourceComponent> context) { + public void start(ResourceContext<T> context) { LogFactory.getLog(this.getClass()).info( "~~~ Starting resource upgrade test plugin v2 component: key=" + context.getResourceKey()); } diff --git a/modules/plugins/jmx/src/main/java/org/rhq/plugins/jmx/JMXComponent.java b/modules/plugins/jmx/src/main/java/org/rhq/plugins/jmx/JMXComponent.java index e7b1164..d5f08a8 100644 --- a/modules/plugins/jmx/src/main/java/org/rhq/plugins/jmx/JMXComponent.java +++ b/modules/plugins/jmx/src/main/java/org/rhq/plugins/jmx/JMXComponent.java @@ -32,7 +32,7 @@ import org.rhq.core.pluginapi.inventory.ResourceComponent; * * @author Greg Hinkle */ -public interface JMXComponent<T extends ResourceComponent> extends ResourceComponent<T> { +public interface JMXComponent<T extends ResourceComponent<?>> extends ResourceComponent<T> { public static final String PRINCIPAL_CONFIG_PROP = "principal"; public static final String CREDENTIALS_CONFIG_PROP = "credentials";
commit 78bff76c5e5a860d5ba1e6c8abc169d8a87f3c0c Author: John Mazzitelli mazz@redhat.com Date: Wed Sep 14 14:45:09 2011 -0400
make sure we show the proper values in the alert conditions, formatted based on their units.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionsEditor.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionsEditor.java index b5a41a1..92913f9 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionsEditor.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionsEditor.java @@ -42,6 +42,7 @@ import com.smartgwt.client.widgets.grid.ListGridRecord; import org.rhq.core.domain.alert.AlertCondition; import org.rhq.core.domain.configuration.definition.ConfigurationTemplate; import org.rhq.core.domain.criteria.Criteria; +import org.rhq.core.domain.measurement.MeasurementDefinition; import org.rhq.core.domain.resource.ResourceType; import org.rhq.enterprise.gui.coregui.client.alert.AlertFormatUtility; import org.rhq.enterprise.gui.coregui.client.components.table.AbstractTableAction; @@ -84,6 +85,23 @@ public class ConditionsEditor extends LocatableVLayout { public void setConditions(Set<AlertCondition> set) { conditions = new HashSet<AlertCondition>(); // make our own copy if (set != null) { + + // we need to make sure we have the full measurement definition, including the units. + // this is so we can display the condition values with the proper units. If an alert + // condition is a measurement condition, but the measurement definition isn't the full + // definition, look up the full definition from the resource type and use it. + for (AlertCondition alertCondition : set) { + MeasurementDefinition measDef = alertCondition.getMeasurementDefinition(); + if (measDef != null) { + if (measDef.getUnits() == null) { + MeasurementDefinition fullMeasDef = findMeasurementDefinition(measDef.getId()); + if (fullMeasDef != null) { + alertCondition.setMeasurementDefinition(fullMeasDef); + } + } + } + } + conditions.addAll(set); } if (table != null) { @@ -91,6 +109,18 @@ public class ConditionsEditor extends LocatableVLayout { } }
+ private MeasurementDefinition findMeasurementDefinition(int measurementDefinitionId) { + Set<MeasurementDefinition> measDefs = this.resourceType.getMetricDefinitions(); + if (measDefs != null) { + for (MeasurementDefinition measDef : measDefs) { + if (measDef.getId() == measurementDefinitionId) { + return measDef; + } + } + } + return null; + } + @Override protected void onInit() { super.onInit();
commit 76a98c3c950f1cda16209e59466403284b4fc736 Author: John Sanda jsanda@redhat.com Date: Wed Sep 14 14:21:35 2011 -0400
Adding more logging around drift detection and inventory sync
diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/DriftDetector.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/DriftDetector.java index 210fb78..6bad1b1 100644 --- a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/DriftDetector.java +++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/DriftDetector.java @@ -69,7 +69,12 @@ public class DriftDetector implements Runnable {
@Override public void run() { + log.debug("Starting drift detection.."); + long startTime = System.currentTimeMillis(); try { + if (log.isDebugEnabled()) { + log.debug("Fetching next schedule from " + scheduleQueue); + }
DriftDetectionSchedule schedule = scheduleQueue.getNextSchedule(); if (schedule == null) { @@ -78,7 +83,6 @@ public class DriftDetector implements Runnable { }
if (log.isDebugEnabled()) { - log.debug("Preparing to run drift detection for the next schedule in " + scheduleQueue); log.debug("Processing " + schedule);
} @@ -121,6 +125,8 @@ public class DriftDetector implements Runnable { } finally { try { scheduleQueue.deactivateSchedule(); + long endTime = System.currentTimeMillis(); + log.debug("Finished drift detection in " + (endTime - startTime) + " ms");
} catch (Throwable t) { Throwable cause = t.getCause(); diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/DriftManager.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/DriftManager.java index 3ee0b7d..56e66f3 100644 --- a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/DriftManager.java +++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/DriftManager.java @@ -126,7 +126,7 @@ public class DriftManager extends AgentService implements DriftAgentService, Dri
private void initSchedules(Resource r, InventoryManager inventoryMgr) { if (r.getId() == 0) { - log.debug("Will not reschedule drift detection schedules for " + r + ". It is not sync'ed yet."); + log.debug("Will not reschedule drift detection for " + r + ". It is not sync'ed yet."); return; }
@@ -136,7 +136,7 @@ public class DriftManager extends AgentService implements DriftAgentService, Dri return; }
- log.debug("Rescheduling drift detection schedules for " + r); + log.debug("Rescheduling drift detection for " + r); for (DriftConfiguration c : container.getDriftConfigurations()) { try { syncWithServer(r, c); @@ -166,9 +166,15 @@ public class DriftManager extends AgentService implements DriftAgentService, Dri // drift configuration while the agent is offline for example. At // this point we just return and allow the agent to generate the // initial snapshot file. + if (log.isDebugEnabled()) { + log.debug("The server does not have any change sets for " + toString(resource, configuration) + + ". An initial snapshot needs to be generated."); + } return; }
+ log.info("Preparing to write snapshot at version " + snapshot.getVersion() + " to disk for " + + toString(resource, configuration)); ChangeSetWriter writer = changeSetMgr.getChangeSetWriter(resource.getId(), headers);
for (Drift drift : snapshot.getEntries()) { diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/InventoryManager.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/InventoryManager.java index 5f04fe5..fe15bb5 100644 --- a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/InventoryManager.java +++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/InventoryManager.java @@ -2130,6 +2130,7 @@ public class InventoryManager extends AgentService implements ContainerService, }
private void installDriftConfigurations(Map<Integer, List<DriftConfiguration>> configsFromServer) { + log.info("Syncing drift configurations from server with local inventory..."); DriftManager driftMgr = PluginContainer.getInstance().getDriftManager(); if (driftMgr != null && driftMgr.isInitialized()) { DriftConfigurationComparator comparator = @@ -2137,6 +2138,7 @@ public class InventoryManager extends AgentService implements ContainerService, ScheduleQueue queue = driftMgr.getSchedulesQueue();
// First check for drift configurations that have been deleted + log.info("Checking for drift configurations that have been deleted on the server"); for (Integer resourceId : configsFromServer.keySet()) { Set<DriftConfiguration> configsFromServerSet = new TreeSet<DriftConfiguration>(comparator); configsFromServerSet.addAll(configsFromServer.get(resourceId)); @@ -2157,6 +2159,7 @@ public class InventoryManager extends AgentService implements ContainerService, }
// add new drift configurations received from the server + log.info("Checking for new drift configurations"); for (Integer resourceId : configsFromServer.keySet()) { for (DriftConfiguration c : configsFromServer.get(resourceId)) { if (!queue.contains(resourceId, c, comparator)) { @@ -2169,7 +2172,8 @@ public class InventoryManager extends AgentService implements ContainerService, } } } else { - log.info("DriftManager is not available. Drift configurations will be persisted but not scheduled."); + log.info("DriftManager is not available. Drift configurations will be persisted but detection will not " + + "be scheduled.");
// First check for drift configurations that have been deleted log.debug("Checking for stale drift configurations that need to be purged from inventory"); @@ -2197,6 +2201,7 @@ public class InventoryManager extends AgentService implements ContainerService, container.removeDriftConfiguration(c); File changeSetDir = new File(resourceDir, c.getName()); if (changeSetDir.exists()) { + log.debug("Purging " + changeSetDir.getPath()); purge(changeSetDir, true); } } @@ -2204,15 +2209,14 @@ public class InventoryManager extends AgentService implements ContainerService,
// Now add any any drift configurations received from the server. These // could be new or updated configurations. - log.debug("Checking for new or updated drift configurations"); + log.debug("Checking for new drift configurations"); for (Integer resourceId : configsFromServer.keySet()) { ResourceContainer container = getResourceContainer(resourceId); for (DriftConfiguration c : configsFromServer.get(resourceId)) { if (log.isDebugEnabled()) { - log.debug("Adding or updating DriftConfiguration[name: " + c.getName() + ", resourceId: " + - resourceId + "]"); + log.debug("Adding DriftConfiguration[name: " + c.getName() + ", resourceId: " + resourceId + + "]"); } - // TODO does this handle renamed configs? container.addDriftConfiguration(c); } }
commit d012274e9e688c2484a5f0196a5a55a08ef59056 Author: John Mazzitelli mazz@redhat.com Date: Wed Sep 14 13:44:44 2011 -0400
remove the Refresh button since there is nothing to refresh (the table is always fully populated) and when you click Refresh, it gets disabled and never re-enables.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deployment/BundleDeploymentView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deployment/BundleDeploymentView.java index 03484a4..966b14e 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deployment/BundleDeploymentView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deployment/BundleDeploymentView.java @@ -334,6 +334,7 @@ public class BundleDeploymentView extends LocatableVLayout implements Bookmarkab @SuppressWarnings("unchecked") private Table addMemberDeploymentsTable() { Table table = new Table(extendLocatorId("Deployments"), MSG.view_bundle_deploy_deploymentPlatforms()); + table.setShowFooterRefresh(false);
table.setTitleComponent(new HTMLFlow(MSG.view_bundle_deploy_selectARow()));
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/version/file/FileListView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/version/file/FileListView.java index 5b33200..5afe667 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/version/file/FileListView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/version/file/FileListView.java @@ -63,6 +63,7 @@ public class FileListView extends LocatableVLayout { private void viewFiles(PageList<BundleFile> files) {
Table table = new Table(extendLocatorId("BundleFiles"), MSG.view_bundle_bundleFiles()); + table.setShowFooterRefresh(false);
ListGridField id = new ListGridField(ID, MSG.common_title_id()); ListGridField name = new ListGridField(NAME, MSG.common_title_name());
commit 54dff23edceba487daa2da3868917ad4901080e5 Author: John Mazzitelli mazz@redhat.com Date: Wed Sep 14 12:32:36 2011 -0400
fix version in pom
diff --git a/modules/core/plugindoc/pom.xml b/modules/core/plugindoc/pom.xml index 8364995..5586534 100644 --- a/modules/core/plugindoc/pom.xml +++ b/modules/core/plugindoc/pom.xml @@ -5,7 +5,7 @@ <parent> <groupId>org.rhq</groupId> <artifactId>rhq-core-parent</artifactId> - <version>4.1.1-BETA1</version> + <version>4.1.0-SNAPSHOT</version> </parent>
<groupId>org.rhq</groupId>
commit 767438de0ce97f10adae37afe99b5e7fccecf24a Author: John Mazzitelli mazz@redhat.com Date: Wed Sep 14 12:32:27 2011 -0400
upgrade ems version in eclipse classpath
diff --git a/.classpath b/.classpath index 93a80cc..36d4e8c 100644 --- a/.classpath +++ b/.classpath @@ -56,7 +56,7 @@ <classpathentry exported="true" kind="var" path="M2_REPO/javax/faces/jsf-impl/1.2_14/jsf-impl-1.2_14.jar" sourcepath="/M2_REPO/javax/faces/jsf-impl/1.2_14/jsf-impl-1.2_14-sources.jar"/> <classpathentry exported="true" kind="var" path="M2_REPO/javax/el/el-api/1.0/el-api-1.0.jar"/> <classpathentry exported="true" kind="var" path="M2_REPO/com/sun/facelets/jsf-facelets/1.1.15.B1/jsf-facelets-1.1.15.B1.jar" sourcepath="/M2_REPO/com/sun/facelets/jsf-facelets/1.1.15.B1/jsf-facelets-1.1.15.B1-sources.jar"/> - <classpathentry exported="true" kind="var" path="M2_REPO/mc4j/org-mc4j-ems/1.2.15.1/org-mc4j-ems-1.2.15.1.jar" sourcepath="/M2_REPO/mc4j/org-mc4j-ems/1.2.15.1/org-mc4j-ems-1.2.15.1-sources.jar"/> + <classpathentry exported="true" kind="var" path="M2_REPO/mc4j/org-mc4j-ems/1.2.16/org-mc4j-ems-1.2.16.jar" sourcepath="/M2_REPO/mc4j/org-mc4j-ems/1.2.16/org-mc4j-ems-1.2.16-sources.jar"/> <classpathentry exported="true" kind="var" path="M2_REPO/org/opensymphony/quartz/quartz/1.6.5/quartz-1.6.5.jar" sourcepath="/M2_REPO/org/opensymphony/quartz/quartz/1.6.5/quartz-1.6.5-sources.jar"/> <classpathentry exported="true" kind="var" path="M2_REPO/javax/mail/mail/1.4.2/mail-1.4.2.jar"/> <classpathentry exported="true" kind="var" path="M2_REPO/commons-fileupload/commons-fileupload/1.2/commons-fileupload-1.2.jar"/>
commit dc9776dc3ac82bd8232f01a8b2d9ec1f7b83bbd7 Author: John Sanda jsanda@redhat.com Date: Wed Sep 14 12:07:55 2011 -0400
Do not purge change set directories for configs that have not been deleted
Prior to this commit, DriftManager was incorrectly purging change set directories at start up. This resulted in a new coverage change set being generated. Now at start up and during inventory sync, when we detect that a config has been deleted and only when it has been deleted, we purge its change set directory. There are a couple reasons we purge those directories. First, we do not want to clutter up the managed system with old, unused change set data. Secondly, and more importantly, the deletion has to be done to support renamed configs. A user can delete a config, and the create a new one with the same name. This might happen when changing filters for instance. Even though the configs have the same names, they are different, and the new config cannot use the old change set data.
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/drift/DriftSnapshot.java b/modules/core/domain/src/main/java/org/rhq/core/domain/drift/DriftSnapshot.java index 58a11c7..e5b1835 100644 --- a/modules/core/domain/src/main/java/org/rhq/core/domain/drift/DriftSnapshot.java +++ b/modules/core/domain/src/main/java/org/rhq/core/domain/drift/DriftSnapshot.java @@ -18,13 +18,13 @@ */ package org.rhq.core.domain.drift;
-import static org.rhq.core.domain.drift.DriftCategory.FILE_REMOVED; - import java.io.Serializable; import java.util.Collection; import java.util.Map; import java.util.TreeMap;
+import static org.rhq.core.domain.drift.DriftCategory.FILE_REMOVED; + /** * A representation of an agent's drift file monitoring. * @@ -34,7 +34,11 @@ public class DriftSnapshot implements Serializable {
private static final long serialVersionUID = 1L;
- private int version; + /** + * The version is initially -1 which indicates that there are no + * change sets as opposed to an empty change set. + */ + private int version = -1;
private Map<String, Drift<?, ?>> entries = new TreeMap<String, Drift<?, ?>>();
diff --git a/modules/core/domain/src/test/java/org/rhq/core/domain/drift/DriftSnapshotTest.java b/modules/core/domain/src/test/java/org/rhq/core/domain/drift/DriftSnapshotTest.java new file mode 100644 index 0000000..97f7faa --- /dev/null +++ b/modules/core/domain/src/test/java/org/rhq/core/domain/drift/DriftSnapshotTest.java @@ -0,0 +1,403 @@ +package org.rhq.core.domain.drift; + +import java.io.Serializable; +import java.util.HashSet; +import java.util.Set; + +import org.testng.annotations.Test; + +import org.rhq.core.domain.drift.DriftConfigurationDefinition.DriftHandlingMode; + +import static java.util.Arrays.asList; +import static org.rhq.core.domain.drift.DriftCategory.FILE_ADDED; +import static org.rhq.core.domain.drift.DriftCategory.FILE_CHANGED; +import static org.rhq.core.domain.drift.DriftCategory.FILE_REMOVED; +import static org.rhq.core.domain.drift.DriftChangeSetCategory.COVERAGE; +import static org.rhq.core.domain.drift.DriftChangeSetCategory.DRIFT; +import static org.rhq.core.domain.drift.DriftFileStatus.LOADED; +import static org.rhq.test.AssertUtils.assertCollectionMatchesNoOrder; +import static org.testng.Assert.assertEquals; + +@SuppressWarnings("unchecked") +public class DriftSnapshotTest { + + @Test + public void addChangeSetWithAddedFile() { + int configId = 1; + + FakeDriftChangeSet changeSet = new FakeDriftChangeSet(0, COVERAGE, configId).add(new FakeDrift(FILE_ADDED, + null, new FakeDriftFile("a1b2c3", 1024, LOADED), "/drift/1.txt")); + + DriftSnapshot snapshot = new DriftSnapshot().add(changeSet); + + assertCollectionMatchesNoOrder(changeSet.getDrifts(), snapshot.getEntries(), "Failed to build " + + "a snapshot that contains a single change set"); + assertEquals(snapshot.getVersion(), changeSet.getVersion(), "Snapshot version is wrong"); + } + + @Test + public void addChangeSetsWithAddedFiles() { + int configId = 1; + + Drift<?, ?> entry1 = new FakeDrift(FILE_ADDED, null, new FakeDriftFile("a1b2c3", 1024, LOADED), "/drift/1.txt"); + FakeDriftChangeSet changeSet1 = new FakeDriftChangeSet(0, COVERAGE, configId).add(entry1); + + Drift<?, ?> entry2 = new FakeDrift(FILE_ADDED, null, new FakeDriftFile("4a5b6c", 1024, LOADED), "/drift/2.txt"); + FakeDriftChangeSet changeSet2 = new FakeDriftChangeSet(1, DRIFT, configId).add(entry2); + + DriftSnapshot snapshot = new DriftSnapshot().add(changeSet1).add(changeSet2); + + // not sure but asSet with one arg was not working for me, so create Set manually + Set set = new HashSet<Drift<?, ?>>(); + set.add(entry1); + set.add(entry2); + assertCollectionMatchesNoOrder(set, snapshot.getEntries(), "Failed to build snapshot " + + "with two change sets and file added in second change set"); + assertEquals(snapshot.getVersion(), changeSet2.getVersion(), "Snapshot version is wrong"); + } + + @Test + public void replaceFileWithChangedVersion() { + int configId = 1; + + Drift<?, ?> entry1 = new FakeDrift(FILE_ADDED, null, new FakeDriftFile("a1b2c3", 1024, LOADED), "/drift/1.txt"); + FakeDriftChangeSet changeSet1 = new FakeDriftChangeSet(0, COVERAGE, configId).add(entry1); + + Drift<?, ?> entry2 = new FakeDrift(FILE_CHANGED, new FakeDriftFile("a1b2c3", 1024, LOADED), new FakeDriftFile( + "4d5e6f", 1024, LOADED), "/drift/1.txt"); + FakeDriftChangeSet changeSet2 = new FakeDriftChangeSet(1, DRIFT, configId).add(entry2); + + DriftSnapshot snapshot = new DriftSnapshot().add(changeSet1).add(changeSet2); + + // not sure but asSet with one arg was not working for me, so create Set manually + Set set = new HashSet<Drift<?, ?>>(); + set.add(entry2); + assertCollectionMatchesNoOrder(set, snapshot.getEntries(), "Failed to build snapshot with file changed"); + } + + @Test + public void deleteFileThatHasBeenRemoved() { + int configId = 1; + + Drift<?, ?> entry1 = new FakeDrift(FILE_ADDED, null, new FakeDriftFile("a1b2c3", 1024, LOADED), "/drift/1.txt"); + Drift<?, ?> entry2 = new FakeDrift(FILE_ADDED, null, new FakeDriftFile("d1f2a3", 1024, LOADED), "/drift/2.txt"); + FakeDriftChangeSet changeSet1 = new FakeDriftChangeSet(0, COVERAGE, configId).add(entry1).add(entry2); + + Drift entry3 = new FakeDrift(FILE_REMOVED, new FakeDriftFile("a1b2c3", 1024, LOADED), null, "/drift/1.txt"); + FakeDriftChangeSet changeSet2 = new FakeDriftChangeSet(1, DRIFT, configId).add(entry3); + + DriftSnapshot snapshot = new DriftSnapshot().add(changeSet1).add(changeSet2); + + // not sure but asSet with one arg was not working for me, so create Set manually + Set set = new HashSet<Drift<?, ?>>(); + set.add(entry2); + assertCollectionMatchesNoOrder(set, snapshot.getEntries(), "Failed to build snapshot with a file " + "removed."); + } + + @Test + public void diffShowsEntriesInLeftAndNotInRight() { + int configId = 1; + + Drift entry1 = new FakeDrift(FILE_ADDED, null, new FakeDriftFile("a1b2c3", 1024, LOADED), "/drift/1.txt"); + FakeDriftChangeSet changeSet1 = new FakeDriftChangeSet(0, COVERAGE, configId).add(entry1); + DriftSnapshot right = new DriftSnapshot().add(changeSet1); + + Drift entry2 = new FakeDrift(FILE_ADDED, null, new FakeDriftFile("a3b6c9", 1024, LOADED), "/drift/2.txt"); + FakeDriftChangeSet changeSet2 = new FakeDriftChangeSet(0, COVERAGE, configId).add(entry1).add(entry2); + DriftSnapshot left = new DriftSnapshot().add(changeSet1).add(changeSet2); + + DriftDiffReport diff = left.diff(right); + + assertCollectionMatchesNoOrder(asList(entry2), diff.getElementsNotInRight(), "Diff report does not contain " + + "elements that are in the left but not in the right."); + } + + @Test + public void diffShowsEntriesInRightAndNotInLeft() { + int configId = 1; + + Drift entry1 = new FakeDrift(FILE_ADDED, null, new FakeDriftFile("a1b2c3", 1024, LOADED), "/drift/1.txt"); + FakeDriftChangeSet changeSet1 = new FakeDriftChangeSet(0, COVERAGE, configId).add(entry1); + DriftSnapshot right = new DriftSnapshot().add(changeSet1); + + Drift entry2 = new FakeDrift(FILE_ADDED, null, new FakeDriftFile("a3b6c9", 1024, LOADED), "/drift/2.txt"); + FakeDriftChangeSet changeSet2 = new FakeDriftChangeSet(0, COVERAGE, configId).add(entry2); + DriftSnapshot left = new DriftSnapshot().add(changeSet2); + + DriftDiffReport diff = left.diff(right); + + assertCollectionMatchesNoOrder(asList(entry1), diff.getElementsNotInLeft(), "Diff report does not contain " + + "elements that are in the left but not in the right"); + } + + @Test + public void diffShowsEntriesInLeftAndRightThatAreInConflict() { + int configId = 1; + + Drift entry1 = new FakeDrift(FILE_ADDED, null, new FakeDriftFile("a1b2c3", 1024, LOADED), "/drfit/1.txt"); + FakeDriftChangeSet changeSet1 = new FakeDriftChangeSet(0, COVERAGE, configId).add(entry1); + DriftSnapshot right = new DriftSnapshot().add(changeSet1); + + Drift entry2 = new FakeDrift(FILE_ADDED, null, new FakeDriftFile("c3b2a1", 1024, LOADED), "/drfit/1.txt"); + FakeDriftChangeSet changeSet2 = new FakeDriftChangeSet(1, DRIFT, configId).add(entry2); + DriftSnapshot left = new DriftSnapshot().add(changeSet2); + + DriftDiffReport diff = left.diff(right); + + assertCollectionMatchesNoOrder(asList(entry2), diff.getElementsInConflict(), "Diff report does not contain " + + "element that are in both left and right and are in conflict"); + } + + <E> Set<E> asSet(E... elements) { + HashSet<E> set = new HashSet<E>(); + for (E element : elements) { + set.add(element); + } + return set; + } + + static class FakeDriftChangeSet implements DriftChangeSet { + + private String id; + private int version; + private DriftChangeSetCategory category; + private int configId; + private DriftHandlingMode mode = DriftHandlingMode.normal; + private Set<Drift> drifts = new HashSet<Drift>(); + private long ctime = System.currentTimeMillis(); + + public FakeDriftChangeSet() { + } + + public FakeDriftChangeSet(int version, DriftChangeSetCategory category, int configId) { + this.version = version; + this.category = category; + this.configId = configId; + } + + @Override + public String getId() { + return id; + } + + @Override + public void setId(String id) { + this.id = id; + } + + @Override + public Long getCtime() { + return ctime; + } + + @Override + public int getVersion() { + return version; + } + + @Override + public void setVersion(int version) { + this.version = version; + } + + @Override + public DriftChangeSetCategory getCategory() { + return category; + } + + @Override + public void setCategory(DriftChangeSetCategory category) { + this.category = category; + } + + @Override + public int getDriftConfigurationId() { + return configId; + } + + @Override + public void setDriftConfigurationId(int id) { + configId = id; + } + + @Override + public int getResourceId() { + return 0; + } + + @Override + public Set getDrifts() { + return drifts; + } + + @Override + public void setDrifts(Set drifts) { + this.drifts = drifts; + } + + public FakeDriftChangeSet add(Drift drift) { + drifts.add(drift); + return this; + } + + @Override + public DriftHandlingMode getDriftHandlingMode() { + return this.mode; + } + + @Override + public void setDriftHandlingMode(DriftHandlingMode mode) { + this.mode = mode; + } + } + + static class FakeDrift implements Drift { + + private String id; + private DriftCategory category; + private String path; + private DriftFile oldFile; + private DriftFile newFile; + private long ctime = System.currentTimeMillis(); + + public FakeDrift() { + } + + public FakeDrift(DriftCategory category, DriftFile oldFile, DriftFile newFile, String path) { + this.category = category; + this.oldFile = oldFile; + this.newFile = newFile; + this.path = path; + } + + @Override + public String getId() { + return id; + } + + @Override + public void setId(String id) { + this.id = id; + } + + @Override + public Long getCtime() { + return ctime; + } + + @Override + public DriftChangeSet getChangeSet() { + return null; + } + + @Override + public void setChangeSet(DriftChangeSet changeSet) { + + } + + @Override + public DriftCategory getCategory() { + return category; + } + + @Override + public void setCategory(DriftCategory category) { + this.category = category; + } + + @Override + public String getPath() { + return path; + } + + @Override + public void setPath(String path) { + this.path = path; + } + + @Override + public DriftFile getOldDriftFile() { + return oldFile; + } + + @Override + public void setOldDriftFile(DriftFile oldDriftFile) { + this.oldFile = oldDriftFile; + } + + @Override + public DriftFile getNewDriftFile() { + return newFile; + } + + @Override + public void setNewDriftFile(DriftFile newDriftFile) { + newFile = newDriftFile; + } + + @Override + public String toString() { + return "Drift[category: " + category.code() + ", oldFile: " + oldFile + ", newFile: " + newFile + + ", path: " + path + "]"; + } + } + + static class FakeDriftFile implements Serializable, DriftFile { + + private static final long serialVersionUID = 1L; + private String hash; + private long size; + private DriftFileStatus status; + private long ctime = System.currentTimeMillis(); + + public FakeDriftFile() { + } + + public FakeDriftFile(String hash, long size, DriftFileStatus status) { + this.hash = hash; + this.size = size; + this.status = status; + } + + @Override + public String getHashId() { + return hash; + } + + @Override + public void setHashId(String hashId) { + hash = hashId; + } + + @Override + public Long getCtime() { + return ctime; + } + + @Override + public Long getDataSize() { + return size; + } + + @Override + public void setDataSize(Long size) { + this.size = size; + } + + @Override + public DriftFileStatus getStatus() { + return status; + } + + @Override + public void setStatus(DriftFileStatus status) { + this.status = status; + } + + @Override + public String toString() { + return "DriftFile[hashId: " + hash + ", dataSize: " + size + ", status: " + status.ordinal() + "]"; + } + } + +} diff --git a/modules/core/domain/src/test/java/org/rhq/core/domain/drift/SnapshotTest.java b/modules/core/domain/src/test/java/org/rhq/core/domain/drift/SnapshotTest.java deleted file mode 100644 index 42cf146..0000000 --- a/modules/core/domain/src/test/java/org/rhq/core/domain/drift/SnapshotTest.java +++ /dev/null @@ -1,403 +0,0 @@ -package org.rhq.core.domain.drift; - -import static java.util.Arrays.asList; -import static org.rhq.core.domain.drift.DriftCategory.FILE_ADDED; -import static org.rhq.core.domain.drift.DriftCategory.FILE_CHANGED; -import static org.rhq.core.domain.drift.DriftCategory.FILE_REMOVED; -import static org.rhq.core.domain.drift.DriftChangeSetCategory.COVERAGE; -import static org.rhq.core.domain.drift.DriftChangeSetCategory.DRIFT; -import static org.rhq.core.domain.drift.DriftFileStatus.LOADED; -import static org.rhq.test.AssertUtils.assertCollectionMatchesNoOrder; -import static org.testng.Assert.assertEquals; - -import java.io.Serializable; -import java.util.HashSet; -import java.util.Set; - -import org.testng.annotations.Test; - -import org.rhq.core.domain.drift.DriftConfigurationDefinition.DriftHandlingMode; - -@SuppressWarnings("unchecked") -public class SnapshotTest { - - @Test - public void addChangeSetWithAddedFile() { - int configId = 1; - - FakeDriftChangeSet changeSet = new FakeDriftChangeSet(0, COVERAGE, configId).add(new FakeDrift(FILE_ADDED, - null, new FakeDriftFile("a1b2c3", 1024, LOADED), "/drift/1.txt")); - - DriftSnapshot snapshot = new DriftSnapshot().add(changeSet); - - assertCollectionMatchesNoOrder(changeSet.getDrifts(), snapshot.getEntries(), "Failed to build " - + "a snapshot that contains a single change set"); - assertEquals(snapshot.getVersion(), changeSet.getVersion(), "Snapshot version is wrong"); - } - - @Test - public void addChangeSetsWithAddedFiles() { - int configId = 1; - - Drift<?, ?> entry1 = new FakeDrift(FILE_ADDED, null, new FakeDriftFile("a1b2c3", 1024, LOADED), "/drift/1.txt"); - FakeDriftChangeSet changeSet1 = new FakeDriftChangeSet(0, COVERAGE, configId).add(entry1); - - Drift<?, ?> entry2 = new FakeDrift(FILE_ADDED, null, new FakeDriftFile("4a5b6c", 1024, LOADED), "/drift/2.txt"); - FakeDriftChangeSet changeSet2 = new FakeDriftChangeSet(1, DRIFT, configId).add(entry2); - - DriftSnapshot snapshot = new DriftSnapshot().add(changeSet1).add(changeSet2); - - // not sure but asSet with one arg was not working for me, so create Set manually - Set set = new HashSet<Drift<?, ?>>(); - set.add(entry1); - set.add(entry2); - assertCollectionMatchesNoOrder(set, snapshot.getEntries(), "Failed to build snapshot " - + "with two change sets and file added in second change set"); - assertEquals(snapshot.getVersion(), changeSet2.getVersion(), "Snapshot version is wrong"); - } - - @Test - public void replaceFileWithChangedVersion() { - int configId = 1; - - Drift<?, ?> entry1 = new FakeDrift(FILE_ADDED, null, new FakeDriftFile("a1b2c3", 1024, LOADED), "/drift/1.txt"); - FakeDriftChangeSet changeSet1 = new FakeDriftChangeSet(0, COVERAGE, configId).add(entry1); - - Drift<?, ?> entry2 = new FakeDrift(FILE_CHANGED, new FakeDriftFile("a1b2c3", 1024, LOADED), new FakeDriftFile( - "4d5e6f", 1024, LOADED), "/drift/1.txt"); - FakeDriftChangeSet changeSet2 = new FakeDriftChangeSet(1, DRIFT, configId).add(entry2); - - DriftSnapshot snapshot = new DriftSnapshot().add(changeSet1).add(changeSet2); - - // not sure but asSet with one arg was not working for me, so create Set manually - Set set = new HashSet<Drift<?, ?>>(); - set.add(entry2); - assertCollectionMatchesNoOrder(set, snapshot.getEntries(), "Failed to build snapshot with file changed"); - } - - @Test - public void deleteFileThatHasBeenRemoved() { - int configId = 1; - - Drift<?, ?> entry1 = new FakeDrift(FILE_ADDED, null, new FakeDriftFile("a1b2c3", 1024, LOADED), "/drift/1.txt"); - Drift<?, ?> entry2 = new FakeDrift(FILE_ADDED, null, new FakeDriftFile("d1f2a3", 1024, LOADED), "/drift/2.txt"); - FakeDriftChangeSet changeSet1 = new FakeDriftChangeSet(0, COVERAGE, configId).add(entry1).add(entry2); - - Drift entry3 = new FakeDrift(FILE_REMOVED, new FakeDriftFile("a1b2c3", 1024, LOADED), null, "/drift/1.txt"); - FakeDriftChangeSet changeSet2 = new FakeDriftChangeSet(1, DRIFT, configId).add(entry3); - - DriftSnapshot snapshot = new DriftSnapshot().add(changeSet1).add(changeSet2); - - // not sure but asSet with one arg was not working for me, so create Set manually - Set set = new HashSet<Drift<?, ?>>(); - set.add(entry2); - assertCollectionMatchesNoOrder(set, snapshot.getEntries(), "Failed to build snapshot with a file " + "removed."); - } - - @Test - public void diffShowsEntriesInLeftAndNotInRight() { - int configId = 1; - - Drift entry1 = new FakeDrift(FILE_ADDED, null, new FakeDriftFile("a1b2c3", 1024, LOADED), "/drift/1.txt"); - FakeDriftChangeSet changeSet1 = new FakeDriftChangeSet(0, COVERAGE, configId).add(entry1); - DriftSnapshot right = new DriftSnapshot().add(changeSet1); - - Drift entry2 = new FakeDrift(FILE_ADDED, null, new FakeDriftFile("a3b6c9", 1024, LOADED), "/drift/2.txt"); - FakeDriftChangeSet changeSet2 = new FakeDriftChangeSet(0, COVERAGE, configId).add(entry1).add(entry2); - DriftSnapshot left = new DriftSnapshot().add(changeSet1).add(changeSet2); - - DriftDiffReport diff = left.diff(right); - - assertCollectionMatchesNoOrder(asList(entry2), diff.getElementsNotInRight(), "Diff report does not contain " - + "elements that are in the left but not in the right."); - } - - @Test - public void diffShowsEntriesInRightAndNotInLeft() { - int configId = 1; - - Drift entry1 = new FakeDrift(FILE_ADDED, null, new FakeDriftFile("a1b2c3", 1024, LOADED), "/drift/1.txt"); - FakeDriftChangeSet changeSet1 = new FakeDriftChangeSet(0, COVERAGE, configId).add(entry1); - DriftSnapshot right = new DriftSnapshot().add(changeSet1); - - Drift entry2 = new FakeDrift(FILE_ADDED, null, new FakeDriftFile("a3b6c9", 1024, LOADED), "/drift/2.txt"); - FakeDriftChangeSet changeSet2 = new FakeDriftChangeSet(0, COVERAGE, configId).add(entry2); - DriftSnapshot left = new DriftSnapshot().add(changeSet2); - - DriftDiffReport diff = left.diff(right); - - assertCollectionMatchesNoOrder(asList(entry1), diff.getElementsNotInLeft(), "Diff report does not contain " - + "elements that are in the left but not in the right"); - } - - @Test - public void diffShowsEntriesInLeftAndRightThatAreInConflict() { - int configId = 1; - - Drift entry1 = new FakeDrift(FILE_ADDED, null, new FakeDriftFile("a1b2c3", 1024, LOADED), "/drfit/1.txt"); - FakeDriftChangeSet changeSet1 = new FakeDriftChangeSet(0, COVERAGE, configId).add(entry1); - DriftSnapshot right = new DriftSnapshot().add(changeSet1); - - Drift entry2 = new FakeDrift(FILE_ADDED, null, new FakeDriftFile("c3b2a1", 1024, LOADED), "/drfit/1.txt"); - FakeDriftChangeSet changeSet2 = new FakeDriftChangeSet(1, DRIFT, configId).add(entry2); - DriftSnapshot left = new DriftSnapshot().add(changeSet2); - - DriftDiffReport diff = left.diff(right); - - assertCollectionMatchesNoOrder(asList(entry2), diff.getElementsInConflict(), "Diff report does not contain " - + "element that are in both left and right and are in conflict"); - } - - <E> Set<E> asSet(E... elements) { - HashSet<E> set = new HashSet<E>(); - for (E element : elements) { - set.add(element); - } - return set; - } - - static class FakeDriftChangeSet implements DriftChangeSet { - - private String id; - private int version; - private DriftChangeSetCategory category; - private int configId; - private DriftHandlingMode mode = DriftHandlingMode.normal; - private Set<Drift> drifts = new HashSet<Drift>(); - private long ctime = System.currentTimeMillis(); - - public FakeDriftChangeSet() { - } - - public FakeDriftChangeSet(int version, DriftChangeSetCategory category, int configId) { - this.version = version; - this.category = category; - this.configId = configId; - } - - @Override - public String getId() { - return id; - } - - @Override - public void setId(String id) { - this.id = id; - } - - @Override - public Long getCtime() { - return ctime; - } - - @Override - public int getVersion() { - return version; - } - - @Override - public void setVersion(int version) { - this.version = version; - } - - @Override - public DriftChangeSetCategory getCategory() { - return category; - } - - @Override - public void setCategory(DriftChangeSetCategory category) { - this.category = category; - } - - @Override - public int getDriftConfigurationId() { - return configId; - } - - @Override - public void setDriftConfigurationId(int id) { - configId = id; - } - - @Override - public int getResourceId() { - return 0; - } - - @Override - public Set getDrifts() { - return drifts; - } - - @Override - public void setDrifts(Set drifts) { - this.drifts = drifts; - } - - public FakeDriftChangeSet add(Drift drift) { - drifts.add(drift); - return this; - } - - @Override - public DriftHandlingMode getDriftHandlingMode() { - return this.mode; - } - - @Override - public void setDriftHandlingMode(DriftHandlingMode mode) { - this.mode = mode; - } - } - - static class FakeDrift implements Drift { - - private String id; - private DriftCategory category; - private String path; - private DriftFile oldFile; - private DriftFile newFile; - private long ctime = System.currentTimeMillis(); - - public FakeDrift() { - } - - public FakeDrift(DriftCategory category, DriftFile oldFile, DriftFile newFile, String path) { - this.category = category; - this.oldFile = oldFile; - this.newFile = newFile; - this.path = path; - } - - @Override - public String getId() { - return id; - } - - @Override - public void setId(String id) { - this.id = id; - } - - @Override - public Long getCtime() { - return ctime; - } - - @Override - public DriftChangeSet getChangeSet() { - return null; - } - - @Override - public void setChangeSet(DriftChangeSet changeSet) { - - } - - @Override - public DriftCategory getCategory() { - return category; - } - - @Override - public void setCategory(DriftCategory category) { - this.category = category; - } - - @Override - public String getPath() { - return path; - } - - @Override - public void setPath(String path) { - this.path = path; - } - - @Override - public DriftFile getOldDriftFile() { - return oldFile; - } - - @Override - public void setOldDriftFile(DriftFile oldDriftFile) { - this.oldFile = oldDriftFile; - } - - @Override - public DriftFile getNewDriftFile() { - return newFile; - } - - @Override - public void setNewDriftFile(DriftFile newDriftFile) { - newFile = newDriftFile; - } - - @Override - public String toString() { - return "Drift[category: " + category.code() + ", oldFile: " + oldFile + ", newFile: " + newFile - + ", path: " + path + "]"; - } - } - - static class FakeDriftFile implements Serializable, DriftFile { - - private static final long serialVersionUID = 1L; - private String hash; - private long size; - private DriftFileStatus status; - private long ctime = System.currentTimeMillis(); - - public FakeDriftFile() { - } - - public FakeDriftFile(String hash, long size, DriftFileStatus status) { - this.hash = hash; - this.size = size; - this.status = status; - } - - @Override - public String getHashId() { - return hash; - } - - @Override - public void setHashId(String hashId) { - hash = hashId; - } - - @Override - public Long getCtime() { - return ctime; - } - - @Override - public Long getDataSize() { - return size; - } - - @Override - public void setDataSize(Long size) { - this.size = size; - } - - @Override - public DriftFileStatus getStatus() { - return status; - } - - @Override - public void setStatus(DriftFileStatus status) { - this.status = status; - } - - @Override - public String toString() { - return "DriftFile[hashId: " + hash + ", dataSize: " + size + ", status: " + status.ordinal() + "]"; - } - } - -} diff --git a/modules/core/plugin-container/mvn.out b/modules/core/plugin-container/mvn.out new file mode 100644 index 0000000..d269e4d --- /dev/null +++ b/modules/core/plugin-container/mvn.out @@ -0,0 +1,96 @@ +[INFO] +NOTE: Maven is executing in offline mode. Any artifacts not already in your local +repository will be inaccessible. + +[INFO] Scanning for projects... +[INFO] ------------------------------------------------------------------------ +[INFO] Building RHQ Plugin Container +[INFO] task-segment: [clean, install] +[INFO] ------------------------------------------------------------------------ +[INFO] [clean:clean {execution: default-clean}] +[INFO] Deleting /home/jsanda/Development/redhat/rhq/modules/core/plugin-container/target +[INFO] [enforcer:enforce {execution: enforce-versions}] +[INFO] [build-helper:maven-version {execution: default}] +[INFO] [resources:resources {execution: default-resources}] +[INFO] Using 'ISO-8859-1' encoding to copy filtered resources. +[INFO] skip non existing resourceDirectory /home/jsanda/Development/redhat/rhq/modules/core/plugin-container/src/main/resources +[INFO] [compiler:compile {execution: default-compile}] +[INFO] Compiling 105 source files to /home/jsanda/Development/redhat/rhq/modules/core/plugin-container/target/classes +[WARNING] /home/jsanda/Development/redhat/rhq/modules/core/plugin-container/src/main/java/org/rhq/core/pc/plugin/FileSystemPluginFinder.java:[124,32] [deprecation] toURL() in java.io.File has been deprecated +[WARNING] /home/jsanda/Development/redhat/rhq/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/ResourceContainer.java:[465,49] [unchecked] unchecked conversion +found : java.util.concurrent.Callable +required: java.util.concurrent.Callable<T> +[WARNING] /home/jsanda/Development/redhat/rhq/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/ResourceContainer.java:[465,48] [unchecked] unchecked method invocation: <T>submit(java.util.concurrent.Callable<T>) in java.util.concurrent.ExecutorService is applied to (java.util.concurrent.Callable) +[WARNING] /home/jsanda/Development/redhat/rhq/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/InventoryManager.java:[321,76] [unchecked] unchecked call to discoverResources(org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext<T>) as a member of the raw type org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent +[WARNING] /home/jsanda/Development/redhat/rhq/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/InventoryManager.java:[321,76] [unchecked] unchecked conversion +found : java.util.Set +required: java.util.Set<org.rhq.core.pluginapi.inventory.DiscoveredResourceDetails> +[WARNING] /home/jsanda/Development/redhat/rhq/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/InventoryManager.java:[357,69] [unchecked] unchecked call to discoverResource(org.rhq.core.domain.configuration.Configuration,org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext<T>) as a member of the raw type org.rhq.core.pluginapi.inventory.ManualAddFacet +[WARNING] /home/jsanda/Development/redhat/rhq/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/InventoryManager.java:[394,52] [unchecked] unchecked call to ResourceDiscoveryContext(org.rhq.core.domain.resource.ResourceType,T,org.rhq.core.pluginapi.inventory.ResourceContext,org.rhq.core.system.SystemInfo,java.util.List<org.rhq.core.pluginapi.inventory.ProcessScanResult>,java.util.List<org.rhq.core.domain.configuration.Configuration>,java.lang.String,org.rhq.core.pluginapi.inventory.PluginContainerDeployment) as a member of the raw type org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext +[WARNING] /home/jsanda/Development/redhat/rhq/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/InventoryManager.java:[406,60] [unchecked] unchecked call to getAdditionalClasspathUrls(org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext<T>,org.rhq.core.pluginapi.inventory.DiscoveredResourceDetails) as a member of the raw type org.rhq.core.pluginapi.inventory.ClassLoaderFacet +[WARNING] /home/jsanda/Development/redhat/rhq/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/InventoryManager.java:[406,60] [unchecked] unchecked conversion +found : java.util.List +required: java.util.List<java.net.URL> +[WARNING] /home/jsanda/Development/redhat/rhq/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/InventoryManager.java:[1534,87] [unchecked] unchecked conversion +found : org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent +required: org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent<org.rhq.core.pluginapi.inventory.ResourceComponent<capture#841 of ?>> +[WARNING] /home/jsanda/Development/redhat/rhq/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/InventoryManager.java:[1534,59] [unchecked] unchecked method invocation: <T>createResourceContext(org.rhq.core.domain.resource.Resource,T,org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent<T>) in org.rhq.core.pc.inventory.InventoryManager is applied to (org.rhq.core.domain.resource.Resource,org.rhq.core.pluginapi.inventory.ResourceComponent<capture#841 of ?>,org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent) +[WARNING] /home/jsanda/Development/redhat/rhq/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/InventoryManager.java:[2383,47] [unchecked] unchecked call to ResourceDiscoveryContext(org.rhq.core.domain.resource.ResourceType,T,org.rhq.core.pluginapi.inventory.ResourceContext,org.rhq.core.system.SystemInfo,java.util.List<org.rhq.core.pluginapi.inventory.ProcessScanResult>,java.util.List<org.rhq.core.domain.configuration.Configuration>,java.lang.String,org.rhq.core.pluginapi.inventory.PluginContainerDeployment) as a member of the raw type org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext +[WARNING] /home/jsanda/Development/redhat/rhq/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/InventoryManager.java:[2436,30] [unchecked] unchecked conversion +found : java.util.Set +required: java.util.Set<org.rhq.core.domain.resource.Resource> +[WARNING] /home/jsanda/Development/redhat/rhq/modules/core/plugin-container/src/main/java/org/rhq/core/pc/measurement/MeasurementCollectorRunner.java:[111,85] [unchecked] unchecked cast +found : java.util.Set<capture#736 of ? extends org.rhq.core.domain.measurement.MeasurementScheduleRequest> +required: java.util.Set<org.rhq.core.domain.measurement.MeasurementScheduleRequest> +[WARNING] /home/jsanda/Development/redhat/rhq/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/InventoryFile.java:[116,85] [unchecked] unchecked cast +found : java.lang.Object +required: java.util.Map<java.lang.String,org.rhq.core.pc.inventory.ResourceContainer> +[WARNING] /home/jsanda/Development/redhat/rhq/modules/core/plugin-container/src/main/java/org/rhq/core/pc/util/InventoryPrinter.java:[285,41] [unchecked] unchecked call to HashSet(java.util.Collection<? extends E>) as a member of the raw type java.util.HashSet +[WARNING] /home/jsanda/Development/redhat/rhq/modules/core/plugin-container/src/main/java/org/rhq/core/pc/util/InventoryPrinter.java:[285,41] [unchecked] unchecked conversion +found : java.util.HashSet +required: java.util.Set<org.rhq.core.domain.resource.Resource> +[WARNING] /home/jsanda/Development/redhat/rhq/modules/core/plugin-container/src/main/java/org/rhq/core/pc/configuration/StructuredAndRawConfigManagement.java:[58,25] [unchecked] unchecked conversion +found : java.util.Set +required: java.util.Set<org.rhq.core.domain.configuration.RawConfiguration> +[WARNING] /home/jsanda/Development/redhat/rhq/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/SnapshotGenerator.java:[106,19] [unchecked] unchecked call to add(E) as a member of the raw type java.util.Collection +[INFO] [resources:testResources {execution: default-testResources}] +[INFO] Using 'ISO-8859-1' encoding to copy filtered resources. +[INFO] Copying 5 resources +[WARNING] DEPRECATED [tasks]: Use target instead +[INFO] [antrun:run {execution: process-test-resources}] +[WARNING] Parameter tasks is deprecated, use target instead +[INFO] Executing tasks + +main: + [echo] SIGAR java library version used is 1.6.5.132 + [echo] Copying/unzipping SIGAR native libraries (version 1.6.5.132) to local build directory + [mkdir] Created dir: /home/jsanda/Development/redhat/rhq/modules/core/plugin-container/target/jboss-sigar + [copy] Copying 1 file to /home/jsanda/Development/redhat/rhq/modules/core/plugin-container/target/jboss-sigar + [unzip] Expanding: /home/jsanda/Development/redhat/rhq/modules/core/plugin-container/target/jboss-sigar/sigar-dist-1.6.5.132.zip into /home/jsanda/Development/redhat/rhq/modules/core/plugin-container/target/jboss-sigar + [move] Moving 22 files to /home/jsanda/Development/redhat/rhq/modules/core/plugin-container/target/jboss-sigar +[INFO] Executed tasks +[INFO] [compiler:testCompile {execution: default-testCompile}] +[INFO] Not compiling test sources +[WARNING] DEPRECATED [tasks]: Use target instead +[INFO] [antrun:run {execution: process-test-classes}] +[WARNING] Parameter tasks is deprecated, use target instead +[INFO] Executing tasks + +main: +[INFO] Executed tasks +[INFO] [surefire:test {execution: default-test}] +[INFO] Tests are skipped. +[INFO] [jar:jar {execution: default-jar}] +[INFO] Building jar: /home/jsanda/Development/redhat/rhq/modules/core/plugin-container/target/rhq-core-plugin-container-4.1.0-SNAPSHOT.jar +[INFO] [jar:jar {execution: default}] +[INFO] [jar:test-jar {execution: default}] +[INFO] Skipping packaging of the test-jar +[INFO] [install:install {execution: default-install}] +[INFO] Installing /home/jsanda/Development/redhat/rhq/modules/core/plugin-container/target/rhq-core-plugin-container-4.1.0-SNAPSHOT.jar to /home/jsanda/.m2/repository/org/rhq/rhq-core-plugin-container/4.1.0-SNAPSHOT/rhq-core-plugin-container-4.1.0-SNAPSHOT.jar +[INFO] ------------------------------------------------------------------------ +[INFO] BUILD SUCCESSFUL +[INFO] ------------------------------------------------------------------------ +[INFO] Total time: 7 seconds +[INFO] Finished at: Tue Sep 13 16:43:45 EDT 2011 +[INFO] Final Memory: 59M/481M +[INFO] ------------------------------------------------------------------------ diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/DriftManager.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/DriftManager.java index fa0ce28..3ee0b7d 100644 --- a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/DriftManager.java +++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/DriftManager.java @@ -159,6 +159,16 @@ public class DriftManager extends AgentService implements DriftAgentService, Dri "server"); DriftSnapshot snapshot = pluginContainerConfiguration.getServerServices().getDriftServerService() .getCurrentSnapshot(configuration.getId()); + + if (snapshot.getVersion() == -1) { + // A version of -1 indicates that no change sets have been reported + // for this configuration. This can occur when a user creates a + // drift configuration while the agent is offline for example. At + // this point we just return and allow the agent to generate the + // initial snapshot file. + return; + } + ChangeSetWriter writer = changeSetMgr.getChangeSetWriter(resource.getId(), headers);
for (Drift drift : snapshot.getEntries()) { @@ -187,7 +197,7 @@ public class DriftManager extends AgentService implements DriftAgentService, Dri for (File configDir : resourceDir.listFiles()) { DriftConfiguration config = new DriftConfiguration(new Configuration()); config.setName(configDir.getName()); - if (!schedulesQueue.contains(resourceId, config, comparator)) { + if (!schedulesQueue.contains(resourceId, config)) { log.info("Detected deleted drift configuration, DriftConfiguration[name: " + config.getName() + ", resourceId: " + resourceId + "]"); log.info("Deleting drift configuration directory " + configDir.getPath()); diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/InventoryManager.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/InventoryManager.java index c89575d..5f04fe5 100644 --- a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/InventoryManager.java +++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/InventoryManager.java @@ -124,6 +124,7 @@ import org.rhq.core.util.exception.ThrowableUtil; import org.rhq.core.util.exception.WrappedRemotingException;
import static org.rhq.core.domain.drift.DriftConfigurationComparator.CompareMode.BOTH_BASE_INFO_AND_DIRECTORY_SPECIFICATIONS; +import static org.rhq.core.util.file.FileUtil.purge;
/** * Manages the process of both auto-detection of servers and runtime detection of services across all plugins. Manages @@ -2172,7 +2173,9 @@ public class InventoryManager extends AgentService implements ContainerService,
// First check for drift configurations that have been deleted log.debug("Checking for stale drift configurations that need to be purged from inventory"); + File changeSetsDir = new File(configuration.getDataDirectory(), "changesets"); for (Integer resourceId : configsFromServer.keySet()) { + File resourceDir = new File(changeSetsDir, resourceId.toString()); ResourceContainer container = getResourceContainer(resourceId); Set<DriftConfiguration> resourceConfigs = new TreeSet<DriftConfiguration>( new DriftConfigurationComparator(BOTH_BASE_INFO_AND_DIRECTORY_SPECIFICATIONS)); @@ -2192,6 +2195,10 @@ public class InventoryManager extends AgentService implements ContainerService,
for (DriftConfiguration c : deleted) { container.removeDriftConfiguration(c); + File changeSetDir = new File(resourceDir, c.getName()); + if (changeSetDir.exists()) { + purge(changeSetDir, true); + } } }
@@ -2205,6 +2212,7 @@ public class InventoryManager extends AgentService implements ContainerService, log.debug("Adding or updating DriftConfiguration[name: " + c.getName() + ", resourceId: " + resourceId + "]"); } + // TODO does this handle renamed configs? container.addDriftConfiguration(c); } }
commit 63a0592f09d8d426e499ed5163c46db9463edfc6 Author: Ian Springer ian.springer@redhat.com Date: Wed Sep 14 11:01:02 2011 -0400
fix minor bug where as/as5 server discovery failed to parse the --properties command-line option if the cwd was unknown, even if the arg to the option was a relative path (cherry picked from commit 43d0562c62abd1f45f926d4d51c4438489f84061)
diff --git a/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/helper/JBossInstanceInfo.java b/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/helper/JBossInstanceInfo.java index 991c68c..24083840 100644 --- a/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/helper/JBossInstanceInfo.java +++ b/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/helper/JBossInstanceInfo.java @@ -150,14 +150,15 @@ public class JBossInstanceInfo {
case 'P': // 'P' (--properties) { - // cwd can be null if native support is not able to determine CWD. - if (null == currentWorkingDir) { - log.error("Could not determine CWD. Failed to parse argument to --properties option: " + String arg = options.getOptarg(); + + // cwd can be null if native support (i.e. SIGAR) is not able to determine it. + if (!new File(arg).isAbsolute() && currentWorkingDir == null) { + log.error("Could not determine current working directory. Failed to parse relative path argument to --properties option: " + options.getOptarg()); break; }
- String arg = options.getOptarg(); URL url; try { File workingDir = new File(currentWorkingDir); diff --git a/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/util/JBossConfigurationUtility.java b/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/util/JBossConfigurationUtility.java index 5554414..553d890 100644 --- a/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/util/JBossConfigurationUtility.java +++ b/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/util/JBossConfigurationUtility.java @@ -58,7 +58,7 @@ public class JBossConfigurationUtility if (url.getProtocol().equals("file")) { File file = (new File(url.getFile())).getCanonicalFile(); - url = file.toURL(); + url = file.toURI().toURL(); } } catch (Exception e) diff --git a/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/helper/JBossInstanceInfo.java b/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/helper/JBossInstanceInfo.java index 3ae813e..9dadd39 100644 --- a/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/helper/JBossInstanceInfo.java +++ b/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/helper/JBossInstanceInfo.java @@ -150,14 +150,15 @@ public class JBossInstanceInfo {
case 'P': // 'P' (--properties) { - // cwd can be null if native support is not able to determine CWD. - if (null == currentWorkingDir) { - log.error("Could not determine CWD. Failed to parse argument to --properties option: " + String arg = options.getOptarg(); + + // cwd can be null if native support (i.e. SIGAR) is not able to determine it. + if (!new File(arg).isAbsolute() && currentWorkingDir == null) { + log.error("Could not determine current working directory. Failed to parse relative path argument to --properties option: " + options.getOptarg()); break; }
- String arg = options.getOptarg(); URL url; try { File workingDir = new File(currentWorkingDir); diff --git a/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/util/JBossConfigurationUtility.java b/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/util/JBossConfigurationUtility.java index dff5b82..8b94c6e 100644 --- a/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/util/JBossConfigurationUtility.java +++ b/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/util/JBossConfigurationUtility.java @@ -53,7 +53,7 @@ public class JBossConfigurationUtility { url = new URL(urlSpec); if (url.getProtocol().equals("file")) { File file = (new File(url.getFile())).getCanonicalFile(); - url = file.toURL(); + url = file.toURI().toURL(); } } catch (Exception e) {
commit 95e6afc28475db9bdc8a216500e4650831d63140 Author: Stefan Negrea snegrea@redhat.com Date: Wed Sep 14 09:56:57 2011 -0500
Integration tests for mod_cluster should be run on JBoss AS6 Final going forward.
diff --git a/modules/integration-tests/mod_cluster-plugin-test/pom.xml b/modules/integration-tests/mod_cluster-plugin-test/pom.xml index ba94746..32d5429 100644 --- a/modules/integration-tests/mod_cluster-plugin-test/pom.xml +++ b/modules/integration-tests/mod_cluster-plugin-test/pom.xml @@ -18,7 +18,8 @@ <properties> <scm.module.path>modules/integration-tests/mod_cluster-plugin-test</scm.module.path> <!-- jbossas.version>6.0.0.20100429-M3</jbossas.version--> - <jbossas.version>6.0.0.M1</jbossas.version> + <!-- jbossas.version>6.0.0.M1</jbossas.version--> + <jbossas.version>6.0.0.Final</jbossas.version>
</properties>
@@ -49,11 +50,11 @@ <scope>provided</scope> </dependency>
- <dependency> + <!-- dependency> <groupId>org.jboss.integration</groupId> <artifactId>jboss-profileservice-spi</artifactId> <scope>provided</scope> - </dependency> + </dependency-->
<dependency> <groupId>${rhq.groupId}</groupId> @@ -82,11 +83,11 @@ <scope>test</scope> </dependency>
- <dependency> + <!--dependency> <groupId>org.jboss.microcontainer</groupId> <artifactId>jboss-kernel</artifactId> <scope>test</scope> - </dependency> + </dependency-->
<dependency> <groupId>org.jboss.jbossas</groupId> @@ -108,11 +109,11 @@ <scope>test</scope> </dependency>
- <dependency> + <!-- dependency> <groupId>org.jboss.security</groupId> <artifactId>jboss-security-spi</artifactId> <scope>test</scope> - </dependency> + </dependency-->
<!-- dependency> <groupId>org.jboss.javaee</groupId>
commit 866f957378256adfd16f7ec2c8d96380411f4f22 Author: Simeon Pinder spinder@redhat.com Date: Tue Sep 13 18:15:45 2011 -0400
Update to use the right build property for brew.
diff --git a/pom.xml b/pom.xml index 3c84ff1..d4a2fd3 100644 --- a/pom.xml +++ b/pom.xml @@ -1242,7 +1242,7 @@ </tstamp> <mkdir dir="target"/> <echo file="${product.buildPropertiesFile}">buildTime = ${buildTime}${line.separator}</echo> - <echo file="${product.buildPropertiesFile}" append="true">buildNumber = ${buildNumber}${line.separator}</echo> + <echo file="${product.buildPropertiesFile}" append="true">buildNumber = ${rhq.build.number}${line.separator}</echo> </tasks> </configuration> </execution>
commit 6b727542a50806a040a772708aa3f1d7142d7a01 Author: Simeon Pinder spinder@redhat.com Date: Tue Sep 13 13:23:45 2011 -0400
refactor to use one build-property file.
diff --git a/pom.xml b/pom.xml index 4297d66..3c84ff1 100644 --- a/pom.xml +++ b/pom.xml @@ -53,6 +53,7 @@ <product.supportEmail>info@rhq-project.org</product.supportEmail> <product.version>${project.version}</product.version> <product.helpDocRoot>http://support.rhq-project.org/display/RHQ/</product.helpDocRoot> + <product.buildPropertiesFile>target/build.properties</product.buildPropertiesFile>
<doUpdate>false</doUpdate>
@@ -1155,14 +1156,14 @@ <tstamp> <format property="buildTime" pattern="MM/dd/yy hh:mm aa z" locale="en,US" timezone="GMT" /> </tstamp> - <echo file="target/build.properties">buildTime = ${buildTime}${line.separator}</echo> + <echo file="${product.buildPropertiesFile}">buildTime = ${buildTime}${line.separator}</echo> <exec executable="git" outputproperty="buildNumber" failonerror="false" failifexecutionfails="false"> <arg value="log" /> <arg value="--pretty=format:%h" /> <arg value="-n1" /> </exec> - <echo file="target/build.properties" append="true">buildNumber = ${buildNumber}${line.separator}</echo> + <echo file="${product.buildPropertiesFile}" append="true">buildNumber = ${buildNumber}${line.separator}</echo> </tasks> </configuration> </execution> @@ -1202,7 +1203,7 @@ </goals> <configuration> <files> - <file>${project.build.directory}/build.properties</file> + <file>${product.buildPropertiesFile}</file> </files> <quiet>true</quiet> </configuration> @@ -1240,8 +1241,8 @@ timezone="GMT"/> </tstamp> <mkdir dir="target"/> - <echo file="target/build-time.properties" level="error">buildTime = ${maven.build.timestamp}</echo> - <echo file="target/build-number.properties" level="error">buildNumber = ${rhq.build.number}</echo> + <echo file="${product.buildPropertiesFile}">buildTime = ${buildTime}${line.separator}</echo> + <echo file="${product.buildPropertiesFile}" append="true">buildNumber = ${buildNumber}${line.separator}</echo> </tasks> </configuration> </execution> @@ -1255,7 +1256,7 @@ </goals> <configuration> <tasks> - <echo level="debug">buildTime = ${maven.build.timestamp}</echo> + <echo level="debug">buildTime = ${buildTime}</echo> <echo level="debug">buildNumber = ${rhq.build.number}</echo> </tasks> </configuration> @@ -1274,8 +1275,7 @@ </goals> <configuration> <files> - <file>${project.build.directory}/build-time.properties</file> - <file>${project.build.directory}/build-number.properties</file> + <file>${product.buildPropertiesFile}</file> </files> </configuration> </execution>
commit 5279f3cdb5cef4ff6b380e3688606b583b9df809 Author: John Sanda jsanda@redhat.com Date: Tue Sep 13 16:48:57 2011 -0400
Adding more detailed logging
diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/DriftDetector.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/DriftDetector.java index 87a4c6c..210fb78 100644 --- a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/DriftDetector.java +++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/DriftDetector.java @@ -19,13 +19,6 @@
package org.rhq.core.pc.drift;
-import static org.rhq.common.drift.FileEntry.addedFileEntry; -import static org.rhq.common.drift.FileEntry.changedFileEntry; -import static org.rhq.common.drift.FileEntry.removedFileEntry; -import static org.rhq.core.domain.drift.DriftChangeSetCategory.COVERAGE; -import static org.rhq.core.domain.drift.DriftChangeSetCategory.DRIFT; -import static org.rhq.core.util.file.FileUtil.forEachFile; - import java.io.File; import java.io.IOException; import java.util.HashSet; @@ -44,6 +37,13 @@ import org.rhq.core.domain.drift.DriftConfiguration; import org.rhq.core.util.MessageDigestGenerator; import org.rhq.core.util.file.FileVisitor;
+import static org.rhq.common.drift.FileEntry.addedFileEntry; +import static org.rhq.common.drift.FileEntry.changedFileEntry; +import static org.rhq.common.drift.FileEntry.removedFileEntry; +import static org.rhq.core.domain.drift.DriftChangeSetCategory.COVERAGE; +import static org.rhq.core.domain.drift.DriftChangeSetCategory.DRIFT; +import static org.rhq.core.util.file.FileUtil.forEachFile; + public class DriftDetector implements Runnable { private Log log = LogFactory.getLog(DriftDetector.class);
@@ -78,7 +78,9 @@ public class DriftDetector implements Runnable { }
if (log.isDebugEnabled()) { + log.debug("Preparing to run drift detection for the next schedule in " + scheduleQueue); log.debug("Processing " + schedule); + }
if (schedule.getNextScan() > (System.currentTimeMillis() + 100L)) { diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/DriftManager.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/DriftManager.java index 8ec8ad7..fa0ce28 100644 --- a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/DriftManager.java +++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/DriftManager.java @@ -432,7 +432,8 @@ public class DriftManager extends AgentService implements DriftAgentService, Dri if (updatedSchedule == null) { updatedSchedule = new DriftDetectionSchedule(resourceId, driftConfiguration); if (log.isInfoEnabled()) { - log.info("Adding " + updatedSchedule + " to " + schedulesQueue); + log.info("No matching schedule was found in the queue. This must be a request to add a new " + + "schedule. Adding " + updatedSchedule + " to " + schedulesQueue); } boolean added = schedulesQueue.addSchedule(updatedSchedule); if (added) { @@ -442,6 +443,12 @@ public class DriftManager extends AgentService implements DriftAgentService, Dri } else { log.warn("Failed to add " + updatedSchedule + " to " + schedulesQueue); } + } else { + if (log.isDebugEnabled()) { + log.debug(updatedSchedule + " has been updated and added back to " + schedulesQueue); + } else if (log.isInfoEnabled()) { + log.info(updatedSchedule + " has been updated."); + } }
InventoryManager inventoryMgr = PluginContainer.getInstance().getInventoryManager(); diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/ScheduleQueueImpl.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/ScheduleQueueImpl.java index dc02b40..e5fa56e 100644 --- a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/ScheduleQueueImpl.java +++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/ScheduleQueueImpl.java @@ -1,6 +1,9 @@ package org.rhq.core.pc.drift;
+import java.util.ArrayList; +import java.util.Arrays; import java.util.Iterator; +import java.util.List; import java.util.PriorityQueue; import java.util.concurrent.locks.ReentrantReadWriteLock;
@@ -197,15 +200,36 @@ public class ScheduleQueueImpl implements ScheduleQueue { } }
+ /** + * Generates a string representation of the schedules in the queue. The schedules that + * appear in the string are in sorted order. If there is an active schedule it will + * appear first. This method can be useful for debugging since it shows the contents of + * the queue in sorted order. Use it cautiously however as writes to the queue are + * blocked until this method returns. + * + * @return A string representation of the queue with the schedules appearing in sorted + * order. + */ @Override public String toString() { try { lock.readLock().lock(); - if (queue.isEmpty()) { + + if (activeSchedule == null && queue.isEmpty()) { return "ScheduleQueue[]"; } + + DriftDetectionSchedule[] schedules = toArray(); + Arrays.sort(schedules); + + List<DriftDetectionSchedule> list = new ArrayList<DriftDetectionSchedule>(schedules.length + 1); + if (activeSchedule != null) { + list.add(activeSchedule); + } + list.addAll(Arrays.asList(schedules)); + StringBuilder buffer = new StringBuilder("ScheduleQueue["); - for (DriftDetectionSchedule schedule : queue) { + for (DriftDetectionSchedule schedule : list) { buffer.append(schedule).append(", "); } int end = buffer.length();
commit 0eab5446fa935b7c465a305e2c5b5682234fa73f Author: Jay Shaughnessy jshaughn@redhat.com Date: Tue Sep 13 15:28:07 2011 -0400
Change rhq_drift_config.mode column to rhq_drift_config.drift_handling_mode as 'mode' is a reserved word on oracle.
diff --git a/modules/core/dbutils/src/main/scripts/dbsetup/content-schema.xml b/modules/core/dbutils/src/main/scripts/dbsetup/content-schema.xml index e1875fe..1ad1b18 100644 --- a/modules/core/dbutils/src/main/scripts/dbsetup/content-schema.xml +++ b/modules/core/dbutils/src/main/scripts/dbsetup/content-schema.xml @@ -671,7 +671,7 @@ <column name="NAME" type="VARCHAR2" size="512" required="true"/> <column name="INTERVAL" type="LONG" required="true"/> <column name="IS_ENABLED" type="BOOLEAN" required="true"/> - <column name="MODE" type="VARCHAR2" size="20" required="true"/> + <column name="DRIFT_HANDLING_MODE" type="VARCHAR2" size="20" required="true"/> <column name="CONFIG_ID" type="INTEGER" required="true" references="RHQ_CONFIG"/> <column name="RESOURCE_ID" type="INTEGER" required="false" references="RHQ_RESOURCE"/> </table> @@ -685,6 +685,7 @@ <column name="CATEGORY" type="VARCHAR2" size="20" required="true"/> <column name="RESOURCE_ID" type="INTEGER" required="true" references="RHQ_RESOURCE"/> <column name="DRIFT_CONFIG_ID" type="INTEGER" required="true" references="RHQ_DRIFT_CONFIG"/> + <!-- the drift handling mode at changeset creation time --> <column name="DRIFT_CONFIG_MODE" type="VARCHAR2" size="20" required="true"/> </table>
diff --git a/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml b/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml index 949f5bd..c02463e 100644 --- a/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml +++ b/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml @@ -3474,8 +3474,8 @@ <schema-alterColumn table="RHQ_DRIFT_CONFIG" column="INTERVAL" nullable="FALSE" /> <schema-addColumn table="RHQ_DRIFT_CONFIG" column="IS_ENABLED" columnType="BOOLEAN" /> <schema-alterColumn table="RHQ_DRIFT_CONFIG" column="IS_ENABLED" nullable="FALSE" /> - <schema-addColumn table="RHQ_DRIFT_CONFIG" column="MODE" columnType="VARCHAR2" precision="20" /> - <schema-alterColumn table="RHQ_DRIFT_CONFIG" column="MODE" nullable="FALSE" /> + <schema-addColumn table="RHQ_DRIFT_CONFIG" column="DRIFT_HANDLING_MODE" columnType="VARCHAR2" precision="20" /> + <schema-alterColumn table="RHQ_DRIFT_CONFIG" column="DRIFT_HANDLING_MODE" nullable="FALSE" /> <schema-addColumn table="RHQ_DRIFT_CONFIG" column="CONFIG_ID" columnType="INTEGER" /> <schema-alterColumn table="RHQ_DRIFT_CONFIG" column="CONFIG_ID" nullable="FALSE" /> <schema-directSQL> diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/drift/DriftConfiguration.java b/modules/core/domain/src/main/java/org/rhq/core/domain/drift/DriftConfiguration.java index 244b9c0..d7ac85a 100644 --- a/modules/core/domain/src/main/java/org/rhq/core/domain/drift/DriftConfiguration.java +++ b/modules/core/domain/src/main/java/org/rhq/core/domain/drift/DriftConfiguration.java @@ -81,7 +81,7 @@ public class DriftConfiguration implements Serializable { @Column(name = "IS_ENABLED", nullable = false) private boolean isEnabled;
- @Column(name = "MODE", nullable = false) + @Column(name = "DRIFT_HANDLING_MODE", nullable = false) @Enumerated(EnumType.STRING) private DriftHandlingMode driftHandlingMode;
commit 922581d0ccb38838abfbaa505a63b7e886ebfbbe Author: Jay Shaughnessy jshaughn@redhat.com Date: Tue Sep 13 15:33:21 2011 -0400
merge two antrun plugin sections into one with two executions
diff --git a/modules/enterprise/server/jar/pom.xml b/modules/enterprise/server/jar/pom.xml index 77750c0..f49af4e 100644 --- a/modules/enterprise/server/jar/pom.xml +++ b/modules/enterprise/server/jar/pom.xml @@ -549,14 +549,7 @@ Build-OS-Version=${os.version} </goals> </execution>
- </executions> - </plugin> - - <!-- in order to get JMS to work properly in embedded test container, extract jms-rs.rar classes --> - <plugin> - <artifactId>maven-antrun-plugin</artifactId> - <executions> - + <!-- in order to get JMS to work properly in embedded test container, extract jms-rs.rar classes --> <execution> <id>Extract JMS classes from RAR needed for JMS tests</id> <phase>process-classes</phase> @@ -582,7 +575,7 @@ Build-OS-Version=${os.version} </executions> </plugin>
- <plugin> + <plugin> <artifactId>maven-surefire-plugin</artifactId> <!-- Everything but the web service tests, this is the standard test execution --> <configuration>
commit 80561b8d01946b8e818216437245f1138b8a7c98 Author: John Sanda jsanda@redhat.com Date: Tue Sep 13 15:42:15 2011 -0400
fixing test failure
diff --git a/modules/core/plugin-container/src/test/java/org/rhq/core/pc/inventory/ResourceContainerTest.java b/modules/core/plugin-container/src/test/java/org/rhq/core/pc/inventory/ResourceContainerTest.java index fd3e68a..5432eff 100644 --- a/modules/core/plugin-container/src/test/java/org/rhq/core/pc/inventory/ResourceContainerTest.java +++ b/modules/core/plugin-container/src/test/java/org/rhq/core/pc/inventory/ResourceContainerTest.java @@ -49,7 +49,9 @@ public class ResourceContainerTest { @BeforeClass public void beforeClass() { PluginContainerConfiguration config = new PluginContainerConfiguration(); - config.setDataDirectory(new File("target/PluginContainerTest")); + File dataDir = new File("target/PluginContainerTest"); + dataDir.mkdirs(); + config.setDataDirectory(dataDir); PluginContainer pc = PluginContainer.getInstance(); pc.setConfiguration(config); pc.initialize();
commit 352b2a8f03936fc306557f5bdfe55af817310813 Author: John Sanda jsanda@redhat.com Date: Tue Sep 13 15:04:49 2011 -0400
Removing commented out, obsolete code
diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/InventoryManager.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/InventoryManager.java index 9b2396b..c89575d 100644 --- a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/InventoryManager.java +++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/InventoryManager.java @@ -2165,8 +2165,6 @@ public class InventoryManager extends AgentService implements ContainerService, } driftMgr.scheduleDriftDetection(resourceId, c); } -// driftMgr.unscheduleDriftDetection(resourceId, c); -// driftMgr.scheduleDriftDetection(resourceId, c); } } } else {
commit f52d27129e6fa57b9932d05f35e16e4e6c889d70 Author: John Sanda jsanda@redhat.com Date: Tue Sep 13 12:48:25 2011 -0400
Add change set version to headers in change set report
diff --git a/modules/common/drift/src/main/java/org/rhq/common/drift/ChangeSetReaderImpl.java b/modules/common/drift/src/main/java/org/rhq/common/drift/ChangeSetReaderImpl.java index 5ccd8bb..b8c383a 100644 --- a/modules/common/drift/src/main/java/org/rhq/common/drift/ChangeSetReaderImpl.java +++ b/modules/common/drift/src/main/java/org/rhq/common/drift/ChangeSetReaderImpl.java @@ -19,10 +19,6 @@
package org.rhq.common.drift;
-import static org.rhq.common.drift.FileEntry.addedFileEntry; -import static org.rhq.common.drift.FileEntry.changedFileEntry; -import static org.rhq.common.drift.FileEntry.removedFileEntry; - import java.io.BufferedReader; import java.io.File; import java.io.FileReader; @@ -35,6 +31,10 @@ import org.apache.commons.logging.LogFactory;
import org.rhq.core.domain.drift.DriftChangeSetCategory;
+import static org.rhq.common.drift.FileEntry.addedFileEntry; +import static org.rhq.common.drift.FileEntry.changedFileEntry; +import static org.rhq.common.drift.FileEntry.removedFileEntry; + /** * Note that this implementation does not do any validation for the most part. It assumes * that entries in the change set file contain valid, 64 character SHA-256 hashes. It @@ -99,6 +99,7 @@ public class ChangeSetReaderImpl implements ChangeSetReader { headers.setDriftConfigurationName(reader.readLine()); headers.setBasedir(reader.readLine()); headers.setType(DriftChangeSetCategory.fromCode(reader.readLine())); + headers.setVersion(Integer.parseInt(reader.readLine())); } catch (IOException e) { throw e; } catch (Throwable t) { diff --git a/modules/common/drift/src/main/java/org/rhq/common/drift/ChangeSetWriter.java b/modules/common/drift/src/main/java/org/rhq/common/drift/ChangeSetWriter.java index 44bf20e..f778e5c 100644 --- a/modules/common/drift/src/main/java/org/rhq/common/drift/ChangeSetWriter.java +++ b/modules/common/drift/src/main/java/org/rhq/common/drift/ChangeSetWriter.java @@ -42,6 +42,7 @@ import java.io.IOException; * <li>drift configuration name</li> * <li>drift configuration base directory</li> * <li>change set type flag indicating whether this is a coverage or drift changeset</li> + * <li>change set version number</li> * </ul> * <br/> * <br/> diff --git a/modules/common/drift/src/main/java/org/rhq/common/drift/ChangeSetWriterImpl.java b/modules/common/drift/src/main/java/org/rhq/common/drift/ChangeSetWriterImpl.java index b694540..fb6d7c3 100644 --- a/modules/common/drift/src/main/java/org/rhq/common/drift/ChangeSetWriterImpl.java +++ b/modules/common/drift/src/main/java/org/rhq/common/drift/ChangeSetWriterImpl.java @@ -51,6 +51,7 @@ public class ChangeSetWriterImpl implements ChangeSetWriter { writer.write(headers.getDriftConfigurationName() + "\n"); writer.write(headers.getBasedir() + "\n"); writer.write(headers.getType().code() + "\n"); + writer.write(headers.getVersion() + "\n"); }
public void write(FileEntry entry) throws IOException { diff --git a/modules/common/drift/src/main/java/org/rhq/common/drift/Headers.java b/modules/common/drift/src/main/java/org/rhq/common/drift/Headers.java index 2799a3c..f482ccb 100644 --- a/modules/common/drift/src/main/java/org/rhq/common/drift/Headers.java +++ b/modules/common/drift/src/main/java/org/rhq/common/drift/Headers.java @@ -42,6 +42,8 @@ public class Headers implements Serializable {
private int resourceId;
+ private int version; + /** * This is the id of the resource to which the change set belongs * @@ -112,4 +114,18 @@ public class Headers implements Serializable { this.type = type; }
+ /** + * @return The change set version + */ + public int getVersion() { + return version; + } + + /** + * @param version The change set version + */ + public void setVersion(int version) { + this.version = version; + } + } diff --git a/modules/common/drift/src/test/java/org/rhq/common/drift/ChangeSetReaderImplTest.java b/modules/common/drift/src/test/java/org/rhq/common/drift/ChangeSetReaderImplTest.java index c6bd763..6df07f0 100644 --- a/modules/common/drift/src/test/java/org/rhq/common/drift/ChangeSetReaderImplTest.java +++ b/modules/common/drift/src/test/java/org/rhq/common/drift/ChangeSetReaderImplTest.java @@ -23,6 +23,7 @@ public class ChangeSetReaderImplTest { "file-added-test\n" + "myresource\n" + "C\n" + + "1\n" + "A " + sha + " 0 conf/myconf.conf";
ChangeSetReaderImpl reader = new ChangeSetReaderImpl(new StringReader(changeset)); @@ -34,6 +35,7 @@ public class ChangeSetReaderImplTest { expectedHeaders.setDriftConfigurationName("file-added-test"); expectedHeaders.setBasedir("myresource"); expectedHeaders.setType(COVERAGE); + expectedHeaders.setVersion(1);
assertHeadersEquals(actualHeaders, expectedHeaders);
@@ -53,6 +55,7 @@ public class ChangeSetReaderImplTest { "file-removed-test\n" + "myresource\n" + "C\n" + + "1\n" + "R 0 " + sha + " conf/myconf.conf";
ChangeSetReaderImpl reader = new ChangeSetReaderImpl(new StringReader(changeset)); @@ -64,6 +67,7 @@ public class ChangeSetReaderImplTest { expectedHeaders.setDriftConfigurationName("file-removed-test"); expectedHeaders.setBasedir("myresource"); expectedHeaders.setType(COVERAGE); + expectedHeaders.setVersion(1);
assertHeadersEquals(actualHeaders, expectedHeaders);
@@ -84,6 +88,7 @@ public class ChangeSetReaderImplTest { "file-changed-test\n" + "myresource\n" + "C\n" + + "1\n" + "C " + newSha + " " + oldSha + " conf/myconf.conf";
ChangeSetReaderImpl reader = new ChangeSetReaderImpl(new StringReader(changeset)); @@ -95,6 +100,7 @@ public class ChangeSetReaderImplTest { expectedHeaders.setDriftConfigurationName("file-changed-test"); expectedHeaders.setBasedir("myresource"); expectedHeaders.setType(COVERAGE); + expectedHeaders.setVersion(1);
assertHeadersEquals(actualHeaders, expectedHeaders);
@@ -114,6 +120,7 @@ public class ChangeSetReaderImplTest { "file-name-test\n" + "myresource\n" + "C\n" + + "1\n" + "A " + sha + " 0 conf/file with spaces.conf";
ChangeSetReaderImpl reader = new ChangeSetReaderImpl(new StringReader(changeset)); @@ -125,6 +132,7 @@ public class ChangeSetReaderImplTest { expectedHeaders.setDriftConfigurationName("file-name-test"); expectedHeaders.setBasedir("myresource"); expectedHeaders.setType(COVERAGE); + expectedHeaders.setVersion(1);
assertHeadersEquals(actualHeaders, expectedHeaders);
@@ -153,6 +161,7 @@ public class ChangeSetReaderImplTest { "multiple-dir-entries-test\n" + "myresource\n" + "C\n" + + "1\n" + "A " + sha256("resource.conf") + " 0 conf/resource.conf\n" + "A " + sha256("resource.jar") + " 0 lib/resource.jar";
@@ -175,6 +184,7 @@ public class ChangeSetReaderImplTest { "single-dir-entry-test\n" + "myresource\n" + "C\n" + + "1\n" + "A " + sha + " 0 conf/resource.conf\n";
ChangeSetReaderImpl reader = new ChangeSetReaderImpl(new StringReader(changeset)); @@ -198,7 +208,8 @@ public class ChangeSetReaderImplTest { "1\n" + "empty-changeset-test\n" + "myresouce\n" + - "C\n"; + "C\n" + + "1\n";
ChangeSetReaderImpl reader = new ChangeSetReaderImpl(new StringReader(changeset)); int numEntries = 0; diff --git a/modules/common/drift/src/test/java/org/rhq/common/drift/ChangeSetWriterImplTest.java b/modules/common/drift/src/test/java/org/rhq/common/drift/ChangeSetWriterImplTest.java index e9efddd..40fff48 100644 --- a/modules/common/drift/src/test/java/org/rhq/common/drift/ChangeSetWriterImplTest.java +++ b/modules/common/drift/src/test/java/org/rhq/common/drift/ChangeSetWriterImplTest.java @@ -67,6 +67,7 @@ public class ChangeSetWriterImplTest { headers.setDriftConfigurationName("add-file-test"); headers.setBasedir(resourceDir.getAbsolutePath()); headers.setType(COVERAGE); + headers.setVersion(1);
ChangeSetWriterImpl writer = new ChangeSetWriterImpl(changeSetFile, headers);
@@ -76,10 +77,10 @@ public class ChangeSetWriterImplTest { File metaDataFile = writer.getChangeSetFile(); List<String> lines = readLines(new FileInputStream(metaDataFile));
- assertEquals(lines.size(), 6, "Expected to find seven lines in " + metaDataFile.getPath() + - " - five for the header followed by one file entry."); + assertEquals(lines.size(), 7, "Expected to find seven lines in " + metaDataFile.getPath() + + " - six for the header followed by one file entry."); assertHeadersEquals(lines, headers); - assertFileEntryEquals(lines.get(5), "A a34ef6 0 conf/myconf.conf"); + assertFileEntryEquals(lines.get(6), "A a34ef6 0 conf/myconf.conf"); }
@Test @@ -94,6 +95,7 @@ public class ChangeSetWriterImplTest { headers.setDriftConfigurationName("removed-file-test"); headers.setBasedir(resourceDir.getAbsolutePath()); headers.setType(COVERAGE); + headers.setVersion(1);
ChangeSetWriterImpl writer = new ChangeSetWriterImpl(changeSetFile, headers);
@@ -103,10 +105,10 @@ public class ChangeSetWriterImplTest { File metaDataFile = writer.getChangeSetFile(); List<String> lines = readLines(new FileInputStream(metaDataFile));
- assertEquals(lines.size(), 6, "Expected to find six lines in " + metaDataFile.getPath() + - " - five for the header followed by one file entry."); + assertEquals(lines.size(), 7, "Expected to find seven lines in " + metaDataFile.getPath() + + " - six for the header followed by one file entry."); assertHeadersEquals(lines, headers); - assertFileEntryEquals(lines.get(5), "R 0 a34ef6 conf/myconf.conf"); + assertFileEntryEquals(lines.get(6), "R 0 a34ef6 conf/myconf.conf"); }
@Test @@ -121,6 +123,7 @@ public class ChangeSetWriterImplTest { headers.setDriftConfigurationName("changed-file-test"); headers.setBasedir(resourceDir.getAbsolutePath()); headers.setType(COVERAGE); + headers.setVersion(1);
ChangeSetWriterImpl writer = new ChangeSetWriterImpl(changeSetFile, headers);
@@ -130,10 +133,10 @@ public class ChangeSetWriterImplTest { File metaDataFile = writer.getChangeSetFile(); List<String> lines = readLines(new FileInputStream(metaDataFile));
- assertEquals(lines.size(), 6, "Expected to find six lines in " + metaDataFile.getPath() + - " - five for the header followed by one file entry."); + assertEquals(lines.size(), 7, "Expected to find seven lines in " + metaDataFile.getPath() + + " - six for the header followed by one file entry."); assertHeadersEquals(lines, headers); - assertFileEntryEquals(lines.get(5), "C c2d55f a34ef6 conf/myconf.conf"); + assertFileEntryEquals(lines.get(6), "C c2d55f a34ef6 conf/myconf.conf"); }
/** @@ -154,6 +157,8 @@ public class ChangeSetWriterImplTest { "base directory."); assertEquals(lines.get(4), headers.getType().code(), "The fifth header entry should be the change set " + "category code"); + assertEquals(Integer.parseInt(lines.get(5)), headers.getVersion(), + "The sixth header entry should be the change set version."); }
/** @@ -168,8 +173,8 @@ public class ChangeSetWriterImplTest { String[] expectedFields = expected.split(" "); String[] actualFields = actual.split(" ");
- assertEquals(4, expectedFields.length, "<" + expected + "> should contain 4 fields"); - assertEquals(4, actualFields.length, "<" + expected + "> should contain 4 fields"); + assertEquals(expectedFields.length, 4, "<" + expected + "> should contain 4 fields"); + assertEquals(actualFields.length, 4, "<" + actual + "> should contain 4 fields");
assertEquals(actualFields[0], expectedFields[0], "The first column, the SHA-256, is wrong"); assertEquals(actualFields[1], expectedFields[1], "The second column, the old SHA-256, is wrong");
commit 0b8f83bf0d49e01f3d554a4fcd72258b0f95e08d Author: John Sanda jsanda@redhat.com Date: Mon Sep 12 16:38:49 2011 -0400
No need to reschedule drift configs that have not changed
diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/InventoryManager.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/InventoryManager.java index 3c768b9..9b2396b 100644 --- a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/InventoryManager.java +++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/InventoryManager.java @@ -2128,20 +2128,22 @@ public class InventoryManager extends AgentService implements ContainerService, } }
- private void installDriftConfigurations(Map<Integer, List<DriftConfiguration>> driftConfigurations) { + private void installDriftConfigurations(Map<Integer, List<DriftConfiguration>> configsFromServer) { DriftManager driftMgr = PluginContainer.getInstance().getDriftManager(); if (driftMgr != null && driftMgr.isInitialized()) { + DriftConfigurationComparator comparator = + new DriftConfigurationComparator(BOTH_BASE_INFO_AND_DIRECTORY_SPECIFICATIONS); + ScheduleQueue queue = driftMgr.getSchedulesQueue(); + // First check for drift configurations that have been deleted - for (Integer resourceId : driftConfigurations.keySet()) { - Set<DriftConfiguration> resourceConfigs = new TreeSet<DriftConfiguration>( - new DriftConfigurationComparator(BOTH_BASE_INFO_AND_DIRECTORY_SPECIFICATIONS)); - resourceConfigs.addAll(driftConfigurations.get(resourceId)); + for (Integer resourceId : configsFromServer.keySet()) { + Set<DriftConfiguration> configsFromServerSet = new TreeSet<DriftConfiguration>(comparator); + configsFromServerSet.addAll(configsFromServer.get(resourceId));
List<DriftConfiguration> deleted = new ArrayList<DriftConfiguration>(); - ScheduleQueue queue = driftMgr.getSchedulesQueue();
for (DriftDetectionSchedule schedule : queue.toArray()) { - if (!resourceConfigs.contains(schedule.getDriftConfiguration())) { + if (!configsFromServerSet.contains(schedule.getDriftConfiguration())) { if (log.isDebugEnabled()) { log.debug("Detected stale drift configuration. Preparing to unschedule " + schedule); } @@ -2153,12 +2155,18 @@ public class InventoryManager extends AgentService implements ContainerService, } }
- // add drift configurations received from the server. These could be - // new or updated configurations. - for (Integer resourceId : driftConfigurations.keySet()) { - for (DriftConfiguration c : driftConfigurations.get(resourceId)) { - driftMgr.unscheduleDriftDetection(resourceId, c); - driftMgr.scheduleDriftDetection(resourceId, c); + // add new drift configurations received from the server + for (Integer resourceId : configsFromServer.keySet()) { + for (DriftConfiguration c : configsFromServer.get(resourceId)) { + if (!queue.contains(resourceId, c, comparator)) { + if (log.isDebugEnabled()) { + log.debug("Detected new drift configuration. Creating new schedule for " + + "DriftConfiguration[name: " + c.getName() + ", resourceId: " + resourceId + "]"); + } + driftMgr.scheduleDriftDetection(resourceId, c); + } +// driftMgr.unscheduleDriftDetection(resourceId, c); +// driftMgr.scheduleDriftDetection(resourceId, c); } } } else { @@ -2166,11 +2174,11 @@ public class InventoryManager extends AgentService implements ContainerService,
// First check for drift configurations that have been deleted log.debug("Checking for stale drift configurations that need to be purged from inventory"); - for (Integer resourceId : driftConfigurations.keySet()) { + for (Integer resourceId : configsFromServer.keySet()) { ResourceContainer container = getResourceContainer(resourceId); Set<DriftConfiguration> resourceConfigs = new TreeSet<DriftConfiguration>( new DriftConfigurationComparator(BOTH_BASE_INFO_AND_DIRECTORY_SPECIFICATIONS)); - resourceConfigs.addAll(driftConfigurations.get(resourceId)); + resourceConfigs.addAll(configsFromServer.get(resourceId));
List<DriftConfiguration> deleted = new ArrayList<DriftConfiguration>();
@@ -2192,9 +2200,9 @@ public class InventoryManager extends AgentService implements ContainerService, // Now add any any drift configurations received from the server. These // could be new or updated configurations. log.debug("Checking for new or updated drift configurations"); - for (Integer resourceId : driftConfigurations.keySet()) { + for (Integer resourceId : configsFromServer.keySet()) { ResourceContainer container = getResourceContainer(resourceId); - for (DriftConfiguration c : driftConfigurations.get(resourceId)) { + for (DriftConfiguration c : configsFromServer.get(resourceId)) { if (log.isDebugEnabled()) { log.debug("Adding or updating DriftConfiguration[name: " + c.getName() + ", resourceId: " + resourceId + "]");
commit 8bb8c6d6a71a9f9cf391e822d96d8f22d8daa39f Author: Ian Springer ian.springer@redhat.com Date: Tue Sep 13 13:44:15 2011 -0400
[BZ 738031] upgrade EMS from 1.2.15.1 to 1.2.16 to fix failure of as5 plugin to initialize the EMS connection to an AS 6.0 instance (https://bugzilla.redhat.com/show_bug.cgi?id=738031) (cherry picked from commit a49952619b9f61fc67631583a2e679e580f97b0c)
diff --git a/pom.xml b/pom.xml index a023da4..4297d66 100644 --- a/pom.xml +++ b/pom.xml @@ -85,7 +85,7 @@ <jsf-api.version>1.2_14</jsf-api.version> <jsf-impl.version>1.2_14</jsf-impl.version> <ojdbc5.version>11.2.0.2.0</ojdbc5.version> - <ems.version>1.2.15.1</ems.version> + <ems.version>1.2.16</ems.version> <postgresql.version>9.0-801.jdbc4</postgresql.version> <h2.version>1.2.139</h2.version> <jtds.version>1.2.2</jtds.version>
commit 67a0771ffa3678ae0a36946fc69612b07b055d82 Author: Ian Springer ian.springer@redhat.com Date: Tue Sep 13 14:22:06 2011 -0400
[BZ 738050] prior to invoking plugin API methods on discovery components, make sure the context classloader is set correctly; specifically, it must be set to the parent resource component's classloader, except for platform discovery, where it must be set to the platform-plugin classloader) (https://bugzilla.redhat.com/show_bug.cgi?id=738050) (cherry picked from commit 3cd497771b43e14d9ceb945b72301816a0e40657)
diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/InventoryManager.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/InventoryManager.java index 6f6b747..3c768b9 100644 --- a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/InventoryManager.java +++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/InventoryManager.java @@ -317,7 +317,7 @@ public class InventoryManager extends AgentService implements ContainerService,
try { ResourceDiscoveryComponent proxy = this.discoveryComponentProxyFactory.getDiscoveryComponentProxy(context - .getResourceType(), component, timeout); + .getResourceType(), component, timeout, parentResourceContainer); Set<DiscoveredResourceDetails> results = proxy.discoverResources(context); return results; } catch (TimeoutException te) { @@ -337,20 +337,23 @@ public class InventoryManager extends AgentService implements ContainerService, * an empty set if nothing is discovered. This may return <code>null</code> if for some reason * we could not invoke the discovery component. * + * * @param component the discovery component that will actually go out and discover resources * @param pluginConfig the plugin configuration to be used to connect to the resource to be discovered * @param context the context for use by the discovery component + * @param parentResourceContainer * @return the details of all discovered resources, may be empty or <code>null</code> * * @throws Exception if the discovery component threw an exception */ private DiscoveredResourceDetails discoverResource(ResourceDiscoveryComponent component, - Configuration pluginConfig, ResourceDiscoveryContext context) throws Exception { + Configuration pluginConfig, ResourceDiscoveryContext context, + ResourceContainer parentResourceContainer) throws Exception { long timeout = getDiscoveryComponentTimeout(context.getResourceType());
try { ManualAddFacet proxy = this.discoveryComponentProxyFactory.getDiscoveryComponentProxy(context - .getResourceType(), component, timeout, ManualAddFacet.class); + .getResourceType(), component, timeout, ManualAddFacet.class, parentResourceContainer); DiscoveredResourceDetails result = proxy.discoverResource(pluginConfig, context); return result; } catch (TimeoutException te) { @@ -386,7 +389,7 @@ public class InventoryManager extends AgentService implements ContainerService, long timeout = getDiscoveryComponentTimeout(resourceType);
ClassLoaderFacet proxy = this.discoveryComponentProxyFactory.getDiscoveryComponentProxy(resourceType, - component, timeout, ClassLoaderFacet.class); + component, timeout, ClassLoaderFacet.class, parentContainer);
ResourceDiscoveryContext discoveryContext = new ResourceDiscoveryContext(resourceType, parentComponent, parentResourceContext, SystemInfoFactory.createSystemInfo(), null, null, this.configuration @@ -406,14 +409,14 @@ public class InventoryManager extends AgentService implements ContainerService, }
public <T extends ResourceComponent> ResourceUpgradeReport invokeDiscoveryComponentResourceUpgradeFacet( - ResourceType resourceType, ResourceDiscoveryComponent<T> component, - ResourceUpgradeContext<T> inventoriedResource) throws Throwable { + ResourceType resourceType, ResourceDiscoveryComponent<T> component, + ResourceUpgradeContext<T> inventoriedResource, ResourceContainer parentResourceContainer) throws Throwable {
long timeout = getDiscoveryComponentTimeout(resourceType); try { @SuppressWarnings("unchecked") ResourceUpgradeFacet<T> proxy = this.discoveryComponentProxyFactory.getDiscoveryComponentProxy( - resourceType, component, timeout, ResourceUpgradeFacet.class); + resourceType, component, timeout, ResourceUpgradeFacet.class, parentResourceContainer);
return proxy.upgrade(inventoriedResource); } catch (BlacklistedException e) { @@ -683,7 +686,8 @@ public class InventoryManager extends AgentService implements ContainerService,
// Ask the plugin's discovery component to find the new resource, throwing exceptions if it cannot be // found at all. - discoveredResourceDetails = discoverResource(discoveryComponent, pluginConfiguration, discoveryContext); + discoveredResourceDetails = discoverResource(discoveryComponent, pluginConfiguration, discoveryContext, + parentResourceContainer); if (discoveredResourceDetails == null) { log.info("Plugin Error: During manual add, discovery component method [" + discoveryComponent.getClass().getName() + ".discoverResource()] returned null " @@ -1513,7 +1517,7 @@ public class InventoryManager extends AgentService implements ContainerService, // wrap the discovery component in a proxy to allow us to timeout discovery invocations try { discoveryComponent = this.discoveryComponentProxyFactory.getDiscoveryComponentProxy(type, - discoveryComponent, getDiscoveryComponentTimeout(type)); + discoveryComponent, getDiscoveryComponentTimeout(type), parentResourceContainer); } catch (Exception e) { discoveryComponent = null; log.warn("Cannot give activated resource its discovery component. Cause: " + e); diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/plugin/PluginComponentFactory.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/plugin/PluginComponentFactory.java index 10aae22..c0a0fae 100644 --- a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/plugin/PluginComponentFactory.java +++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/plugin/PluginComponentFactory.java @@ -89,6 +89,20 @@ public class PluginComponentFactory implements ContainerService { log.debug("Creating discovery component [" + className + "] for resource type [" + typeName + ']'); }
+ ClassLoader classLoader = getDiscoveryComponentClassLoader(parentResourceContainer, pluginName); + + ResourceDiscoveryComponent discoveryComponent = (ResourceDiscoveryComponent) instantiateClass(classLoader, + className); + + if (log.isDebugEnabled()) { + log.debug("Created discovery component [" + className + "] for resource type [" + typeName + ']'); + } + + return discoveryComponent; + } + + public ClassLoader getDiscoveryComponentClassLoader(ResourceContainer parentResourceContainer, String pluginName) + throws PluginContainerException { // Determine what classloader to use to load the discovery component class. If the parent resource for newly // discovered resources is the root platform (or if the discovered resource is going TO BE the root platform), // we can just use the plugin classloader. If discovered resources will be children of a top level server or @@ -109,15 +123,7 @@ public class PluginComponentFactory implements ContainerService { classLoader = classLoaderMgr.obtainDiscoveryClassLoader(pluginName, parentClassLoader); } } - - ResourceDiscoveryComponent discoveryComponent = (ResourceDiscoveryComponent) instantiateClass(classLoader, - className); - - if (log.isDebugEnabled()) { - log.debug("Created discovery component [" + className + "] for resource type [" + typeName + ']'); - } - - return discoveryComponent; + return classLoader; }
/** diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/upgrade/ResourceUpgradeDelegate.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/upgrade/ResourceUpgradeDelegate.java index c659b8e..6dff613 100644 --- a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/upgrade/ResourceUpgradeDelegate.java +++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/upgrade/ResourceUpgradeDelegate.java @@ -274,7 +274,7 @@ public class ResourceUpgradeDelegate { ResourceUpgradeReport upgradeReport = null; try { upgradeReport = inventoryManager.invokeDiscoveryComponentResourceUpgradeFacet(resource.getResourceType(), - discoveryComponent, upgradeContext); + discoveryComponent, upgradeContext, parentResourceContainer); } catch (Throwable t) { log.error("ResourceUpgradeFacet threw an exception while upgrading resource [" + resource + "]", t); request.setErrorProperties(t); diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/util/DiscoveryComponentProxyFactory.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/util/DiscoveryComponentProxyFactory.java index bcbd31d..b72f019 100644 --- a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/util/DiscoveryComponentProxyFactory.java +++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/util/DiscoveryComponentProxyFactory.java @@ -41,8 +41,11 @@ import org.apache.commons.logging.LogFactory;
import org.rhq.core.clientapi.agent.PluginContainerException; import org.rhq.core.domain.resource.ResourceType; +import org.rhq.core.pc.PluginContainer; +import org.rhq.core.pc.inventory.ResourceContainer; import org.rhq.core.pc.inventory.TimeoutException; import org.rhq.core.pc.plugin.BlacklistedException; +import org.rhq.core.pc.plugin.PluginComponentFactory; import org.rhq.core.pluginapi.inventory.ClassLoaderFacet; import org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent;
@@ -65,20 +68,24 @@ public class DiscoveryComponentProxyFactory { private final Set<ResourceType> blacklist = new HashSet<ResourceType>();
/** - * Same as {@link #getDiscoveryComponentProxy(ResourceType, ResourceDiscoveryComponent, long)} except + * Same as {@link #getDiscoveryComponentProxy(org.rhq.core.domain.resource.ResourceType, org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent, long, org.rhq.core.pc.inventory.ResourceContainer)} except * this lets you provide the interface of the discovery component you want to talk to. For example, * use this to talk to the {@link ClassLoaderFacet} of a discovery component. */ @SuppressWarnings("unchecked") public <T> T getDiscoveryComponentProxy(ResourceType type, ResourceDiscoveryComponent component, long timeout, - Class<T> componentInterface) throws PluginContainerException, BlacklistedException { + Class<T> componentInterface, ResourceContainer parentResourceContainer) + throws PluginContainerException, BlacklistedException {
if (isResourceTypeBlacklisted(type)) { throw new BlacklistedException("Discovery component for resource type [" + type + "] has been blacklisted"); }
try { - ClassLoader pluginClassLoader = component.getClass().getClassLoader(); + PluginComponentFactory pluginComponentFactory = PluginContainer.getInstance().getPluginComponentFactory(); + + ClassLoader pluginClassLoader = + pluginComponentFactory.getDiscoveryComponentClassLoader(parentResourceContainer, type.getPlugin());
// This is the handler that will actually invoke the method calls. ResourceDiscoveryComponentInvocationHandler handler = new ResourceDiscoveryComponentInvocationHandler(type, @@ -99,10 +106,12 @@ public class DiscoveryComponentProxyFactory { * to make calls into the plugin discovery component and not deadlock if that plugin misbehaves and never returns * (or takes too long to return). * + * * @param type the resource type that is to be discovered by the given discovery component * @param component the discovery component to be wrapped in a timer proxy * @param timeout the time, in milliseconds, that invocations can take to invoke discovery component methods - * + * + * @param parentResourceContainer * @return the discovery component wrapped in a proxy that should be used to make calls to the component * * @throws PluginContainerException if this method failed to create the proxy @@ -111,9 +120,11 @@ public class DiscoveryComponentProxyFactory { */ @SuppressWarnings("unchecked") public ResourceDiscoveryComponent getDiscoveryComponentProxy(ResourceType type, - ResourceDiscoveryComponent component, long timeout) throws PluginContainerException, BlacklistedException { - - return getDiscoveryComponentProxy(type, component, timeout, ResourceDiscoveryComponent.class); + ResourceDiscoveryComponent component, long timeout, + ResourceContainer parentResourceContainer) + throws PluginContainerException, BlacklistedException { + return getDiscoveryComponentProxy(type, component, timeout, ResourceDiscoveryComponent.class, + parentResourceContainer); }
public void initialize() {
commit 0c62a2411dbeddc5d67f30df71b7e8948225cf61 Author: Lukas Krejci lkrejci@redhat.com Date: Tue Sep 13 18:43:22 2011 +0200
BZ 737996 - Working around the property names inconsistency in the clustered web app contexts.
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 0e5f00a..bca27da 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 @@ -235,6 +235,24 @@ public class ManagedComponentComponent extends AbstractManagedComponent implemen // MeasurementFacet Implementation --------------------------------------------
public void getValues(MeasurementReport report, Set<MeasurementScheduleRequest> metrics) throws Exception { + ManagedComponent managedComponent = prepareForMetricCollection(metrics); + RunState runState = managedComponent.getRunState(); + for (MeasurementScheduleRequest request : metrics) { + try { + String value = getMeasurement(managedComponent, request.getName()); + addValueToMeasurementReport(report, request, value); + } catch (Exception e) { + if (runState == RunState.RUNNING) { + 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); + } + } + } + } + + protected ManagedComponent prepareForMetricCollection(Set<MeasurementScheduleRequest> metrics) { // 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()); @@ -264,27 +282,18 @@ public class ManagedComponentComponent extends AbstractManagedComponent implemen } }
- ManagedComponent managedComponent = getManagedComponent(forceRefresh); - RunState runState = managedComponent.getRunState(); - for (MeasurementScheduleRequest request : metrics) { - try { - if (request.getName().equals("runState")) { - report.addData(new MeasurementDataTrait(request, runState.name())); - } else { - Object value = getSimpleValue(managedComponent, request); - addValueToMeasurementReport(report, request, value); - } - } catch (Exception e) { - if (runState == RunState.RUNNING) { - 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); - } - } + return getManagedComponent(forceRefresh); + } + + protected String getMeasurement(ManagedComponent component, String metricName) throws Exception { + if ("runState".equals(metricName)) { + return component.getRunState().name(); + } else { + Object value = getSimpleValue(managedComponent, metricName); + return value == null ? null : toString(value); } } - + protected void updateComponent(ManagedComponent managedComponent) throws Exception { log.trace("Updating " + getResourceDescription() + " with component " + toString(managedComponent) + "..."); ManagementView managementView = getConnection().getManagementView(); @@ -307,6 +316,11 @@ public class ManagedComponentComponent extends AbstractManagedComponent implemen @Nullable protected Object getSimpleValue(ManagedComponent managedComponent, MeasurementScheduleRequest request) { String metricName = request.getName(); + return getSimpleValue(managedComponent, metricName); + } + + @Nullable + protected Object getSimpleValue(ManagedComponent managedComponent, String metricName) { 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); @@ -326,7 +340,7 @@ 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/> @@ -352,7 +366,7 @@ public class ManagedComponentComponent extends AbstractManagedComponent implemen
// TODO: Move this to a utility class. @Nullable - private static Object getInnerValue(MetaValue metaValue) { + protected static Object getInnerValue(MetaValue metaValue) { if (metaValue == null) { return null; } diff --git a/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/WebApplicationContextComponent.java b/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/WebApplicationContextComponent.java index ce4a851..9c5f938 100644 --- a/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/WebApplicationContextComponent.java +++ b/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/WebApplicationContextComponent.java @@ -32,6 +32,7 @@ import org.apache.commons.logging.LogFactory; import org.jboss.deployers.spi.management.ManagementView; import org.jboss.managed.api.ComponentType; import org.jboss.managed.api.ManagedComponent; +import org.jboss.managed.api.ManagedProperty;
import org.rhq.core.domain.configuration.Configuration; import org.rhq.core.domain.measurement.MeasurementDataNumeric; @@ -62,6 +63,9 @@ public class WebApplicationContextComponent extends ManagedComponentComponent
private static final String VIRTUAL_HOST_TRAIT = "virtualHost";
+ private static final String CLUSTERED_TRAIT = "clustered"; + private static final String DISTRIBUTABLE_MANAGED_PROPERTY = "Distributable"; + // A regex for the names of all MBean:Servlet components for a WAR. private static final String SERVLET_COMPONENT_NAMES_REGEX_TEMPLATE = "jboss.web:J2EEApplication=none,J2EEServer=none," @@ -82,6 +86,8 @@ public class WebApplicationContextComponent extends ManagedComponentComponent private String servletComponentNamesRegex; private ResponseTimeLogParser logParser;
+ private boolean clustered; + @Override public void start(ResourceContext<ProfileServiceComponent> resourceContext) throws Exception { @@ -98,6 +104,15 @@ public class WebApplicationContextComponent extends ManagedComponentComponent this.logParser.setTransforms(responseTimeConfig.getTransforms()); }
+ try { + ManagedProperty distributableProp = getManagedComponent().getProperty(DISTRIBUTABLE_MANAGED_PROPERTY); + if (distributableProp != null) { + Boolean distributable = (Boolean) getInnerValue(distributableProp.getValue()); + clustered = distributable != null && distributable.booleanValue(); + } + } catch (Exception e) { + log.warn("Failed to determine whether the web app context " + resourceContext.getResourceKey() + " is clustered or not.", e); + } }
@Override @@ -106,7 +121,8 @@ public class WebApplicationContextComponent extends ManagedComponentComponent { ProfileServiceComponent warComponent = getResourceContext().getParentResourceComponent(); ManagementView managementView = warComponent.getConnection().getManagementView(); - Set<MeasurementScheduleRequest> remainingRequests = new LinkedHashSet<MeasurementScheduleRequest>(); + + ManagedComponent component = prepareForMetricCollection(requests); for (MeasurementScheduleRequest request : requests) { String metricName = request.getName(); @@ -140,10 +156,28 @@ public class WebApplicationContextComponent extends ManagedComponentComponent + RESPONSE_TIME_LOG_FILE_CONFIG_PROP + "' connection property."); // TODO: Communicate this error back to the server for display in the GUI. } + } + else if (metricName.equals(CLUSTERED_TRAIT)) + { + MeasurementDataTrait trait = new MeasurementDataTrait(request, Boolean.toString(clustered)); + report.addData(trait); } else { - remainingRequests.add(request); + String metricNameToUse = metricName; + if (clustered && !"runState".equals(metricName)) { + metricNameToUse = toUpperCaseFirstLetter(metricName); + } + + String value = getMeasurement(component, metricNameToUse); + + if (clustered && !"runState".equals(metricName) && value == null) { + //hmm... so it looks like https://issues.jboss.org/browse/JBPAPP-7172 has been fixed + //and we're getting the metric names in lower case even for clustered contexts + value = getMeasurement(component, metricName); + } + + addValueToMeasurementReport(report, request, value); } } catch (Exception e) @@ -153,9 +187,12 @@ public class WebApplicationContextComponent extends ManagedComponentComponent + " Resource with key " + getResourceContext().getResourceKey() + ".", e); } } - super.getValues(report, remainingRequests); }
+ public boolean isClustered() { + return clustered; + } + private Double getServletMetric(ManagementView managementView, String metricName) throws Exception { ComponentType servletComponentType = MoreKnownComponentTypes.MBean.Servlet.getType(); @@ -240,4 +277,14 @@ public class WebApplicationContextComponent extends ManagedComponentComponent
return result; } + + private static String toUpperCaseFirstLetter(String name) { + if (name == null || name.length() == 0) { + return name; + } + + char first = name.charAt(0); + + return Character.toUpperCase(first) + name.substring(1); + } } \ No newline at end of file diff --git a/modules/plugins/jboss-as-5/src/main/resources/META-INF/rhq-plugin.xml b/modules/plugins/jboss-as-5/src/main/resources/META-INF/rhq-plugin.xml index 5dc6600..a2d68c5 100644 --- a/modules/plugins/jboss-as-5/src/main/resources/META-INF/rhq-plugin.xml +++ b/modules/plugins/jboss-as-5/src/main/resources/META-INF/rhq-plugin.xml @@ -671,6 +671,9 @@ '>
<!ENTITY webApplicationContextMetrics ' + <metric property="clustered" dataType="trait" displayType="summary" + description="True if this web application context is clustered" defaultOn="true" defaultInterval="3600000" /> + <metric property="virtualHost" dataType="trait" displayType="summary" description="the virtual host with which this context is associated"/> @@ -1803,6 +1806,8 @@ defaultOn="true" defaultInterval="600000" dataType="measurement" category="utilization" description="The timestamp of the last message add"/>
+ <metric property="clustered" dataType="trait" description="True if this queue is clustered, false otherwise" defaultInterval="3600000" defaultOn="true"/> + <resource-configuration>
<!-- See: https://anonsvn.jboss.org/repos/jbossas/trunk/messaging/src/main/org/jboss/jms/server/destination/QueueServiceMO.java --> @@ -2140,6 +2145,8 @@ defaultOn="true" defaultInterval="600000" dataType="measurement" category="throughput" description="The count of all non durable subscriptions to this topic"/>
+ <metric property="clustered" dataType="trait" description="True if this topic is clustered, false otherwise" defaultInterval="3600000" defaultOn="true"/> + <resource-configuration>
<!-- See: https://anonsvn.jboss.org/repos/jbossas/trunk/messaging/src/main/org/jboss/jms/server/destination/TopicServiceMO.java -->
commit c069df149d473b09550339a7602e1739f99341d5 Author: John Mazzitelli mazz@redhat.com Date: Mon Sep 12 17:58:26 2011 -0400
BZ 737565 - do not allow user to pick multiple conditions using the same metric if using ALL conjunction
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionsAlertDefinitionForm.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionsAlertDefinitionForm.java index 0e11a60..d762b23 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionsAlertDefinitionForm.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionsAlertDefinitionForm.java @@ -23,16 +23,24 @@
package org.rhq.enterprise.gui.coregui.client.alert.definitions;
+import java.util.EnumSet; +import java.util.HashMap; import java.util.HashSet; import java.util.LinkedHashMap; +import java.util.Map;
import com.smartgwt.client.widgets.form.fields.SelectItem; import com.smartgwt.client.widgets.form.fields.StaticTextItem; +import com.smartgwt.client.widgets.form.fields.events.ChangeEvent; +import com.smartgwt.client.widgets.form.fields.events.ChangeHandler;
import org.rhq.core.domain.alert.AlertCondition; import org.rhq.core.domain.alert.AlertDefinition; import org.rhq.core.domain.alert.BooleanExpression; import org.rhq.core.domain.resource.ResourceType; +import org.rhq.enterprise.gui.coregui.client.CoreGUI; +import org.rhq.enterprise.gui.coregui.client.util.message.Message; +import org.rhq.enterprise.gui.coregui.client.util.message.Message.Severity; import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm; import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
@@ -44,7 +52,7 @@ public class ConditionsAlertDefinitionForm extends LocatableVLayout implements E private final ResourceType resourceType; private AlertDefinition alertDefinition;
- private SelectItem conditionExpression; + private SelectItem conditionExpression; // this is the GWT menu where the user selects ALL or ANY conjunction private ConditionsEditor conditionsEditor;
private StaticTextItem conditionExpressionStatic; @@ -153,7 +161,38 @@ public class ConditionsAlertDefinitionForm extends LocatableVLayout implements E
conditionExpressionForm.setFields(conditionExpression, conditionExpressionStatic);
- conditionsEditor = new ConditionsEditor(this.extendLocatorId("conditionsEditor"), resourceType, null); + conditionsEditor = new ConditionsEditor(this.extendLocatorId("conditionsEditor"), conditionExpression, + resourceType, null); + + conditionExpression.addChangeHandler(new ChangeHandler() { + @Override + public void onChange(ChangeEvent event) { + // Find out if this is using the ALL conjunction - if it is, we can't have more than one conditional use the same metric. + // If we do, immediately abort and warn the user. See BZ 737565 + if ((BooleanExpression.ALL.name().equals(event.getValue().toString())) + && (resourceType != null && resourceType.getMetricDefinitions() != null)) { + + HashSet<AlertCondition> conditions = conditionsEditor.getConditions(); + Map<Integer, String> metricIdsUsed = new HashMap<Integer, String>(); + for (AlertCondition condition : conditions) { + if (condition.getMeasurementDefinition() != null) { + Integer id = Integer.valueOf(condition.getMeasurementDefinition().getId()); + if (metricIdsUsed.containsKey(id)) { + String msg = MSG + .view_alert_definition_condition_editor_metricswarning(metricIdsUsed.get(id)); + Message warning = new Message(msg, Severity.Warning, EnumSet + .of(Message.Option.Transient)); + CoreGUI.getMessageCenter().notify(warning); + event.cancel(); // multiple conditions used the same metric with ALL conjunction, this doesn't work - abort (BZ 737565) + break; + } + metricIdsUsed.put(id, condition.getMeasurementDefinition().getDisplayName()); + } + } + } + return; + } + });
setMembers(conditionExpressionForm, conditionsEditor); formBuilt = true; diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionsEditor.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionsEditor.java index 4410315..b5a41a1 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionsEditor.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionsEditor.java @@ -36,6 +36,7 @@ import com.smartgwt.client.types.Overflow; import com.smartgwt.client.widgets.Window; import com.smartgwt.client.widgets.events.CloseClickHandler; import com.smartgwt.client.widgets.events.CloseClientEvent; +import com.smartgwt.client.widgets.form.fields.SelectItem; import com.smartgwt.client.widgets.grid.ListGridRecord;
import org.rhq.core.domain.alert.AlertCondition; @@ -57,12 +58,15 @@ import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableWindow; */ public class ConditionsEditor extends LocatableVLayout {
- private ResourceType resourceType; + private final ResourceType resourceType; private HashSet<AlertCondition> conditions; private Table<ConditionDataSource> table; + private final SelectItem conditionExpression;
- public ConditionsEditor(String locatorId, ResourceType resourceType, HashSet<AlertCondition> conditions) { + public ConditionsEditor(String locatorId, SelectItem conditionExpression, ResourceType resourceType, + HashSet<AlertCondition> conditions) { super(locatorId); + this.conditionExpression = conditionExpression; this.resourceType = resourceType; setConditions(conditions); } @@ -160,7 +164,8 @@ public class ConditionsEditor extends LocatableVLayout {
NewConditionEditor newConditionEditor = new NewConditionEditor( extendLocatorId("newConditionEditor"), conditions, - ConditionsEditor.this.resourceType, new Runnable() { + ConditionsEditor.this.conditionExpression, ConditionsEditor.this.resourceType, + new Runnable() { @Override public void run() { winModal.markForDestroy(); diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NewConditionEditor.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NewConditionEditor.java index 04012b1..2ee65a3 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NewConditionEditor.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NewConditionEditor.java @@ -25,8 +25,11 @@ package org.rhq.enterprise.gui.coregui.client.alert.definitions;
import java.util.ArrayList; import java.util.Comparator; +import java.util.EnumSet; +import java.util.HashMap; import java.util.HashSet; import java.util.LinkedHashMap; +import java.util.Map; import java.util.Set; import java.util.TreeSet;
@@ -45,6 +48,7 @@ import com.smartgwt.client.widgets.form.validator.IsFloatValidator;
import org.rhq.core.domain.alert.AlertCondition; import org.rhq.core.domain.alert.AlertConditionCategory; +import org.rhq.core.domain.alert.BooleanExpression; import org.rhq.core.domain.event.EventSeverity; import org.rhq.core.domain.measurement.AvailabilityType; import org.rhq.core.domain.measurement.DataType; @@ -54,6 +58,8 @@ import org.rhq.core.domain.operation.OperationDefinition; import org.rhq.core.domain.operation.OperationRequestStatus; import org.rhq.core.domain.resource.ResourceType; import org.rhq.enterprise.gui.coregui.client.CoreGUI; +import org.rhq.enterprise.gui.coregui.client.util.message.Message; +import org.rhq.enterprise.gui.coregui.client.util.message.Message.Severity; import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm;
/** @@ -70,11 +76,14 @@ public class NewConditionEditor extends LocatableDynamicForm { private static final String THRESHOLD_METRIC_ITEMNAME = "thresholdMetric"; private static final String THRESHOLD_COMPARATOR_ITEMNAME = "thresholdComparator"; private static final String THRESHOLD_ABSVALUE_ITEMNAME = "metricAbsoluteValue"; + private static final String THRESHOLD_NO_METRICS_ITEMNAME = "thresholdNoMetrics"; private static final String BASELINE_METRIC_ITEMNAME = "baselineMetric"; private static final String BASELINE_COMPARATOR_ITEMNAME = "baselineComparator"; private static final String BASELINE_PERCENTAGE_ITEMNAME = "baselinePercentage"; private static final String BASELINE_SELECTION_ITEMNAME = "baselineSelection"; + private static final String BASELINE_NO_METRICS_ITEMNAME = "baselineNoMetrics"; private static final String CHANGE_METRIC_ITEMNAME = "changeMetric"; + private static final String CHANGE_NO_METRICS_ITEMNAME = "changeNoMetrics"; private static final String CALLTIME_THRESHOLD_METRIC_ITEMNAME = "calltimeThresholdMetric"; private static final String CALLTIME_THRESHOLD_MINMAXAVG_ITEMNAME = "calltimeThresholdMinMaxAvgSelection"; private static final String CALLTIME_THRESHOLD_COMPARATOR_ITEMNAME = "calltimeThresholdComparator"; @@ -96,9 +105,11 @@ public class NewConditionEditor extends LocatableDynamicForm { private static final String RANGE_COMPARATOR_ITEMNAME = "rangeComparator"; private static final String RANGE_LO_ABSVALUE_ITEMNAME = "rangeMetricLoValue"; private static final String RANGE_HI_ABSVALUE_ITEMNAME = "rangeMetricHiValue"; + private static final String RANGE_NO_METRICS_ITEMNAME = "rangeNoMetrics";
private SelectItem conditionTypeSelectItem; private HashSet<AlertCondition> conditions; // the new condition we create goes into this set + private final SelectItem conditionExpression; // this is the GWT menu where the user selects ALL or ANY conjunction private boolean supportsMetrics = false; private boolean supportsCalltimeMetrics = false; private boolean supportsTraits = false; @@ -109,11 +120,12 @@ public class NewConditionEditor extends LocatableDynamicForm { private Runnable closeFunction; // this is called after a button is pressed and the editor should close private ResourceType resourceType;
- public NewConditionEditor(String locatorId, HashSet<AlertCondition> conditions, ResourceType rtype, - Runnable closeFunc) { + public NewConditionEditor(String locatorId, HashSet<AlertCondition> conditions, SelectItem conditionExpression, + ResourceType rtype, Runnable closeFunc) {
super(locatorId); this.conditions = conditions; + this.conditionExpression = conditionExpression; this.closeFunction = closeFunc; this.resourceType = rtype;
@@ -219,8 +231,9 @@ public class NewConditionEditor extends LocatableDynamicForm { @Override public void onClick(ClickEvent event) { if (validate(false)) { - saveNewCondition(); - closeFunction.run(); + if (saveNewCondition()) { + closeFunction.run(); + } } } }); @@ -271,7 +284,28 @@ public class NewConditionEditor extends LocatableDynamicForm { setFields(formItems.toArray(new FormItem[formItems.size()])); };
- private void saveNewCondition() { + private boolean saveNewCondition() { + + // Find out if this is using the ALL conjunction - if it is, we can't have more than one conditional use the same metric. + // If we do, immediately abort and warn the user. See BZ 737565 + if ((BooleanExpression.ALL.name().equals(this.conditionExpression.getValue().toString())) + && (supportsMetrics && this.resourceType.getMetricDefinitions() != null)) { + + Map<Integer, String> metricIdsUsed = new HashMap<Integer, String>(); + for (AlertCondition condition : this.conditions) { + if (condition.getMeasurementDefinition() != null) { + Integer id = Integer.valueOf(condition.getMeasurementDefinition().getId()); + if (metricIdsUsed.containsKey(id)) { + String msg = MSG.view_alert_definition_condition_editor_metricswarning(metricIdsUsed.get(id)); + Message warning = new Message(msg, Severity.Warning, EnumSet.of(Message.Option.Transient)); + CoreGUI.getMessageCenter().notify(warning); + return false; // multiple conditions used the same metric with ALL conjunction, this doesn't work - abort (BZ 737565) + } + metricIdsUsed.put(id, condition.getMeasurementDefinition().getDisplayName()); + } + } + } + final boolean calltimeCategory; final AlertConditionCategory category;
@@ -413,6 +447,8 @@ public class NewConditionEditor extends LocatableDynamicForm { }
this.conditions.add(newCondition); + + return true; }
private ArrayList<FormItem> buildMetricThresholdFormItems() { @@ -424,18 +460,25 @@ public class NewConditionEditor extends LocatableDynamicForm { StaticTextItem helpItem = buildHelpTextItem("thresholdHelp", helpStr, ifFunc); formItems.add(helpItem);
- formItems.add(buildMetricDropDownMenu(THRESHOLD_METRIC_ITEMNAME, false, ifFunc)); - formItems.add(buildComparatorDropDownMenu(THRESHOLD_COMPARATOR_ITEMNAME, ifFunc)); - TextItem absoluteValue = new TextItem(THRESHOLD_ABSVALUE_ITEMNAME, MSG - .view_alert_definition_condition_editor_metric_threshold_value()); - absoluteValue.setWrapTitle(false); - absoluteValue.setRequired(true); - absoluteValue.setTooltip(MSG.view_alert_definition_condition_editor_metric_threshold_value_tooltip()); - absoluteValue.setHoverWidth(200); - absoluteValue.setValidateOnChange(true); - absoluteValue.setValidators(new IsFloatValidator()); - absoluteValue.setShowIfCondition(ifFunc); - formItems.add(absoluteValue); + SelectItem metricDropDownMenu = buildMetricDropDownMenu(THRESHOLD_METRIC_ITEMNAME, false, ifFunc); + if (metricDropDownMenu != null) { + formItems.add(metricDropDownMenu); + formItems.add(buildComparatorDropDownMenu(THRESHOLD_COMPARATOR_ITEMNAME, ifFunc)); + TextItem absoluteValue = new TextItem(THRESHOLD_ABSVALUE_ITEMNAME, MSG + .view_alert_definition_condition_editor_metric_threshold_value()); + absoluteValue.setWrapTitle(false); + absoluteValue.setRequired(true); + absoluteValue.setTooltip(MSG.view_alert_definition_condition_editor_metric_threshold_value_tooltip()); + absoluteValue.setHoverWidth(200); + absoluteValue.setValidateOnChange(true); + absoluteValue.setValidators(new IsFloatValidator()); + absoluteValue.setShowIfCondition(ifFunc); + formItems.add(absoluteValue); + } else { + String noMetricsStr = MSG.view_alert_definition_condition_editor_metric_nometrics(); + StaticTextItem noMetrics = buildHelpTextItem(THRESHOLD_NO_METRICS_ITEMNAME, noMetricsStr, ifFunc); + formItems.add(noMetrics); + }
return formItems; } @@ -449,29 +492,36 @@ public class NewConditionEditor extends LocatableDynamicForm { StaticTextItem helpItem = buildHelpTextItem("rangeHelp", helpStr, ifFunc); formItems.add(helpItem);
- formItems.add(buildMetricDropDownMenu(RANGE_METRIC_ITEMNAME, false, ifFunc)); - formItems.add(buildRangeComparatorDropDownMenu(RANGE_COMPARATOR_ITEMNAME, ifFunc)); - TextItem absoluteLowValue = new TextItem(RANGE_LO_ABSVALUE_ITEMNAME, MSG - .view_alert_definition_condition_editor_metric_range_lovalue()); - absoluteLowValue.setWrapTitle(false); - absoluteLowValue.setRequired(true); - absoluteLowValue.setTooltip(MSG.view_alert_definition_condition_editor_metric_range_lovalue_tooltip()); - absoluteLowValue.setHoverWidth(200); - absoluteLowValue.setValidateOnChange(true); - absoluteLowValue.setValidators(new IsFloatValidator()); - absoluteLowValue.setShowIfCondition(ifFunc); - formItems.add(absoluteLowValue); - - TextItem absoluteHighValue = new TextItem(RANGE_HI_ABSVALUE_ITEMNAME, MSG - .view_alert_definition_condition_editor_metric_range_hivalue()); - absoluteHighValue.setWrapTitle(false); - absoluteHighValue.setRequired(true); - absoluteHighValue.setTooltip(MSG.view_alert_definition_condition_editor_metric_range_hivalue_tooltip()); - absoluteHighValue.setHoverWidth(200); - absoluteHighValue.setValidateOnChange(true); - absoluteHighValue.setValidators(new IsFloatValidator()); - absoluteHighValue.setShowIfCondition(ifFunc); - formItems.add(absoluteHighValue); + SelectItem metricDropDownMenu = buildMetricDropDownMenu(RANGE_METRIC_ITEMNAME, false, ifFunc); + if (metricDropDownMenu != null) { + formItems.add(metricDropDownMenu); + formItems.add(buildRangeComparatorDropDownMenu(RANGE_COMPARATOR_ITEMNAME, ifFunc)); + TextItem absoluteLowValue = new TextItem(RANGE_LO_ABSVALUE_ITEMNAME, MSG + .view_alert_definition_condition_editor_metric_range_lovalue()); + absoluteLowValue.setWrapTitle(false); + absoluteLowValue.setRequired(true); + absoluteLowValue.setTooltip(MSG.view_alert_definition_condition_editor_metric_range_lovalue_tooltip()); + absoluteLowValue.setHoverWidth(200); + absoluteLowValue.setValidateOnChange(true); + absoluteLowValue.setValidators(new IsFloatValidator()); + absoluteLowValue.setShowIfCondition(ifFunc); + formItems.add(absoluteLowValue); + + TextItem absoluteHighValue = new TextItem(RANGE_HI_ABSVALUE_ITEMNAME, MSG + .view_alert_definition_condition_editor_metric_range_hivalue()); + absoluteHighValue.setWrapTitle(false); + absoluteHighValue.setRequired(true); + absoluteHighValue.setTooltip(MSG.view_alert_definition_condition_editor_metric_range_hivalue_tooltip()); + absoluteHighValue.setHoverWidth(200); + absoluteHighValue.setValidateOnChange(true); + absoluteHighValue.setValidators(new IsFloatValidator()); + absoluteHighValue.setShowIfCondition(ifFunc); + formItems.add(absoluteHighValue); + } else { + String noMetricsStr = MSG.view_alert_definition_condition_editor_metric_nometrics(); + StaticTextItem noMetrics = buildHelpTextItem(RANGE_NO_METRICS_ITEMNAME, noMetricsStr, ifFunc); + formItems.add(noMetrics); + }
return formItems; } @@ -486,33 +536,41 @@ public class NewConditionEditor extends LocatableDynamicForm { formItems.add(helpItem);
// if a metric is trending (up or down), it will never have baselines calculated for it so only show dynamic metrics - formItems.add(buildMetricDropDownMenu(BASELINE_METRIC_ITEMNAME, true, ifFunc)); - formItems.add(buildComparatorDropDownMenu(BASELINE_COMPARATOR_ITEMNAME, ifFunc)); - - TextItem baselinePercentage = new TextItem(BASELINE_PERCENTAGE_ITEMNAME, MSG - .view_alert_definition_condition_editor_metric_baseline_percentage()); - baselinePercentage.setWrapTitle(false); - baselinePercentage.setRequired(true); - baselinePercentage.setTooltip(MSG.view_alert_definition_condition_editor_metric_baseline_percentage_tooltip()); - baselinePercentage.setHoverWidth(200); - baselinePercentage.setShowIfCondition(ifFunc); - baselinePercentage.setValidateOnChange(true); - baselinePercentage.setValidators(new IsFloatValidator()); - formItems.add(baselinePercentage); - - SelectItem baselineSelection = new SelectItem(BASELINE_SELECTION_ITEMNAME, MSG - .view_alert_definition_condition_editor_metric_baseline_value()); - LinkedHashMap<String, String> baselines = new LinkedHashMap<String, String>(3); - baselines.put("min", MSG.view_alert_definition_condition_editor_common_min()); // TODO can we have the current value of the min baseline - baselines.put("mean", MSG.view_alert_definition_condition_editor_common_avg()); // TODO can we have the current value of the avg baseline - baselines.put("max", MSG.view_alert_definition_condition_editor_common_max()); // TODO can we have the current value of the max baseline - baselineSelection.setValueMap(baselines); - baselineSelection.setDefaultValue("mean"); - baselineSelection.setWrapTitle(false); - baselineSelection.setWidth("*"); - baselineSelection.setRedrawOnChange(true); - baselineSelection.setShowIfCondition(ifFunc); - formItems.add(baselineSelection); + SelectItem metricDropDownMenu = buildMetricDropDownMenu(BASELINE_METRIC_ITEMNAME, true, ifFunc); + if (metricDropDownMenu != null) { + formItems.add(metricDropDownMenu); + formItems.add(buildComparatorDropDownMenu(BASELINE_COMPARATOR_ITEMNAME, ifFunc)); + + TextItem baselinePercentage = new TextItem(BASELINE_PERCENTAGE_ITEMNAME, MSG + .view_alert_definition_condition_editor_metric_baseline_percentage()); + baselinePercentage.setWrapTitle(false); + baselinePercentage.setRequired(true); + baselinePercentage.setTooltip(MSG + .view_alert_definition_condition_editor_metric_baseline_percentage_tooltip()); + baselinePercentage.setHoverWidth(200); + baselinePercentage.setShowIfCondition(ifFunc); + baselinePercentage.setValidateOnChange(true); + baselinePercentage.setValidators(new IsFloatValidator()); + formItems.add(baselinePercentage); + + SelectItem baselineSelection = new SelectItem(BASELINE_SELECTION_ITEMNAME, MSG + .view_alert_definition_condition_editor_metric_baseline_value()); + LinkedHashMap<String, String> baselines = new LinkedHashMap<String, String>(3); + baselines.put("min", MSG.view_alert_definition_condition_editor_common_min()); // TODO can we have the current value of the min baseline + baselines.put("mean", MSG.view_alert_definition_condition_editor_common_avg()); // TODO can we have the current value of the avg baseline + baselines.put("max", MSG.view_alert_definition_condition_editor_common_max()); // TODO can we have the current value of the max baseline + baselineSelection.setValueMap(baselines); + baselineSelection.setDefaultValue("mean"); + baselineSelection.setWrapTitle(false); + baselineSelection.setWidth("*"); + baselineSelection.setRedrawOnChange(true); + baselineSelection.setShowIfCondition(ifFunc); + formItems.add(baselineSelection); + } else { + String noMetricsStr = MSG.view_alert_definition_condition_editor_metric_nometrics(); + StaticTextItem noMetrics = buildHelpTextItem(BASELINE_NO_METRICS_ITEMNAME, noMetricsStr, ifFunc); + formItems.add(noMetrics); + }
return formItems; } @@ -526,7 +584,14 @@ public class NewConditionEditor extends LocatableDynamicForm { StaticTextItem helpItem = buildHelpTextItem("changeMetricHelp", helpStr, ifFunc); formItems.add(helpItem);
- formItems.add(buildMetricDropDownMenu(CHANGE_METRIC_ITEMNAME, false, ifFunc)); + SelectItem metricDropDownMenu = buildMetricDropDownMenu(CHANGE_METRIC_ITEMNAME, false, ifFunc); + if (metricDropDownMenu != null) { + formItems.add(metricDropDownMenu); + } else { + String noMetricsStr = MSG.view_alert_definition_condition_editor_metric_nometrics(); + StaticTextItem noMetrics = buildHelpTextItem(CHANGE_NO_METRICS_ITEMNAME, noMetricsStr, ifFunc); + formItems.add(noMetrics); + }
return formItems; } @@ -808,6 +873,16 @@ public class NewConditionEditor extends LocatableDynamicForm {
private SelectItem buildMetricDropDownMenu(String itemName, boolean dynamicOnly, FormItemIfFunction ifFunc) {
+ // find out if this is the ALL - if it is, we can't have more than one conditional use the same metric (BZ 737565) + Set<String> metricIdsToHide = new HashSet<String>(); + if (BooleanExpression.ALL.name().equals(this.conditionExpression.getValue().toString())) { + for (AlertCondition condition : this.conditions) { + if (condition.getMeasurementDefinition() != null) { + metricIdsToHide.add(String.valueOf(condition.getMeasurementDefinition().getId())); + } + } + } + LinkedHashMap<String, String> metricsMap = new LinkedHashMap<String, String>(); TreeSet<MeasurementDefinition> sortedDefs = new TreeSet<MeasurementDefinition>( new Comparator<MeasurementDefinition>() { @@ -822,12 +897,18 @@ public class NewConditionEditor extends LocatableDynamicForm { for (MeasurementDefinition def : sortedDefs) { if (def.getDataType() == DataType.MEASUREMENT) { if (!dynamicOnly || def.getNumericType() == NumericType.DYNAMIC) { - // use id as opposed to name for key, the name is not unique when per-minute metric is also used - metricsMap.put(String.valueOf(def.getId()), def.getDisplayName()); + String idString = String.valueOf(def.getId()); // use id, not name, for key; name is not unique when per-minute metric is also used + if (!metricIdsToHide.contains(idString)) { + metricsMap.put(idString, def.getDisplayName()); + } } } }
+ if (metricsMap.isEmpty()) { + return null; // all metrics should be hidden + } + SelectItem metricSelection = new SelectItem(itemName, MSG .view_alert_definition_condition_editor_metric_threshold_name()); metricSelection.setValueMap(metricsMap); diff --git a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties index 8a70316..8a14fb6 100644 --- a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties +++ b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties @@ -710,6 +710,7 @@ view_alert_definition_condition_editor_metric_calltime_threshold_value = Call Ti view_alert_definition_condition_editor_metric_calltime_threshold_value_tooltip = The threshold value of the metric that will trigger the condition when compared using the selected comparator. view_alert_definition_condition_editor_metric_change_tooltip = Specify the metric whose value must change to trigger the condition. view_alert_definition_condition_editor_metric_common_definition_not_found = Should have found metric definition - something is wrong +view_alert_definition_condition_editor_metric_nometrics = When using the ALL conjunction, you cannot use the same metric in multiple conditions and this alert uses all available metrics in currently existing conditions. view_alert_definition_condition_editor_metric_range_comparator = Comparator view_alert_definition_condition_editor_metric_range_comparator_inside_exclusive = Inside, exclusive view_alert_definition_condition_editor_metric_range_comparator_inside_inclusive = Inside, inclusive @@ -732,6 +733,7 @@ view_alert_definition_condition_editor_metric_threshold_value = Metric Value view_alert_definition_condition_editor_metric_threshold_value_tooltip = The threshold value of the metric that will trigger the condition when compared using the selected comparator. view_alert_definition_condition_editor_metric_trait_change_tooltip = Specify the trait whose value must change to trigger the condition. view_alert_definition_condition_editor_metric_trait_change_value = Trait +view_alert_definition_condition_editor_metricswarning = You cannot have multiple conditions that use the same metric when using the ALL conjunction. This alert definition has multiple conditions that use the metric [{0}]. view_alert_definition_condition_editor_operation_status = Operation Status view_alert_definition_condition_editor_operation_status_canceled = Canceled view_alert_definition_condition_editor_operation_status_failure = Failure diff --git a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_de.properties b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_de.properties index a952137..a396be5 100644 --- a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_de.properties +++ b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_de.properties @@ -587,6 +587,7 @@ view_alert_definition_condition_editor_metric_calltime_threshold_value = Call Ti view_alert_definition_condition_editor_metric_calltime_threshold_value_tooltip = The threshold value of the metric that will trigger the condition when compared using the selected comparator.~ view_alert_definition_condition_editor_metric_change_tooltip = Specify the metric whose value must change to trigger the condition.~ view_alert_definition_condition_editor_metric_common_definition_not_found = Should have found metric definition - something is wrong~ +##view_alert_definition_condition_editor_metric_nometrics = When using the ALL conjunction, you cannot use the same metric in multiple conditions and this alert uses all available metrics in currently existing conditions. view_alert_definition_condition_editor_metric_range_comparator = Komparator ##view_alert_definition_condition_editor_metric_range_comparator_inside_exclusive = Inside, exclusive ##view_alert_definition_condition_editor_metric_range_comparator_inside_inclusive = Inside, inclusive @@ -609,6 +610,7 @@ view_alert_definition_condition_editor_metric_threshold_value = Wert der Metrik view_alert_definition_condition_editor_metric_threshold_value_tooltip = The threshold value of the metric that will trigger the condition when compared using the selected comparator.~ view_alert_definition_condition_editor_metric_trait_change_tooltip = Specify the trait whose value must change to trigger the condition.~ view_alert_definition_condition_editor_metric_trait_change_value = Trait~ +##view_alert_definition_condition_editor_metricswarning = You cannot have multiple conditions that use the same metric when using the ALL conjunction. This alert definition has multiple conditions that use the metric [{0}]. view_alert_definition_condition_editor_operation_status = Zustand der Operation view_alert_definition_condition_editor_operation_status_canceled = Abgebrochen view_alert_definition_condition_editor_operation_status_failure = Fehler diff --git a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ja.properties b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ja.properties index f323fbc..6f6bb97 100644 --- a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ja.properties +++ b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ja.properties @@ -705,6 +705,7 @@ view_alert_definition_condition_editor_metric_calltime_threshold_value = 呼び view_alert_definition_condition_editor_metric_calltime_threshold_value_tooltip = 選択された比較子(comparator)を使って比較するとき条件が引き起こされるメトリックの閾値 view_alert_definition_condition_editor_metric_change_tooltip = 条件を引き起こすために変更しなければならない値を持つメトリックを指定します view_alert_definition_condition_editor_metric_common_definition_not_found = メトリック定義が見つかるべきです - 何かがおかしいです +##view_alert_definition_condition_editor_metric_nometrics = When using the ALL conjunction, you cannot use the same metric in multiple conditions and this alert uses all available metrics in currently existing conditions. view_alert_definition_condition_editor_metric_range_comparator = コンパレータ ##view_alert_definition_condition_editor_metric_range_comparator_inside_exclusive = Inside, exclusive ##view_alert_definition_condition_editor_metric_range_comparator_inside_inclusive = Inside, inclusive @@ -727,6 +728,7 @@ view_alert_definition_condition_editor_metric_threshold_value = メトリック view_alert_definition_condition_editor_metric_threshold_value_tooltip = メトリックの閾値は、選択されたコンパレータを使って比較されたときの条件のトリガーになります view_alert_definition_condition_editor_metric_trait_change_tooltip = 条件を引き起こすために変更しなければならない値を持つトレイとを指定します view_alert_definition_condition_editor_metric_trait_change_value = トレイト +##view_alert_definition_condition_editor_metricswarning = You cannot have multiple conditions that use the same metric when using the ALL conjunction. This alert definition has multiple conditions that use the metric [{0}]. view_alert_definition_condition_editor_operation_status = オペレーションステータス view_alert_definition_condition_editor_operation_status_canceled = キャンセル済 view_alert_definition_condition_editor_operation_status_failure = 失敗 diff --git a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_pt.properties b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_pt.properties index b16ca87..f3427bb 100644 --- a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_pt.properties +++ b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_pt.properties @@ -723,6 +723,7 @@ view_alert_definition_condition_editor_metric_calltime_threshold_value = Valor d view_alert_definition_condition_editor_metric_calltime_threshold_value_tooltip = O valor do limiar (<i>threshold</i>) da m\u00E9trica usado para disparar a condi\u00E7\u00E3o quando comparado ao mecanismo de compara\u00E7\u00E3o escolhido. view_alert_definition_condition_editor_metric_change_tooltip = Especifica a m\u00E9trica cujo valor deve ser alterado para disparar a condi\u00E7\u00E3o. view_alert_definition_condition_editor_metric_common_definition_not_found = Deve existir uma defini\u00E7\u00E3o para a m\u00E9trica - algo est\u00E1 incorreto +##view_alert_definition_condition_editor_metric_nometrics = When using the ALL conjunction, you cannot use the same metric in multiple conditions and this alert uses all available metrics in currently existing conditions. view_alert_definition_condition_editor_metric_range_comparator = Mecanismo de Compara\u00E7\u00E3o ##view_alert_definition_condition_editor_metric_range_comparator_inside_exclusive = Inside, exclusive ##view_alert_definition_condition_editor_metric_range_comparator_inside_inclusive = Inside, inclusive @@ -745,6 +746,7 @@ view_alert_definition_condition_editor_metric_threshold_value = Valor da M\u00E9 view_alert_definition_condition_editor_metric_threshold_value_tooltip = Limiar (threshold) da m\u00E9trica utilizado na compara\u00E7\u00E3o como condi\u00E7\u00E3o de disparo. view_alert_definition_condition_editor_metric_trait_change_tooltip = Specify the trait whose value must change to trigger the condition. view_alert_definition_condition_editor_metric_trait_change_value = Caracter\u00EDstica +##view_alert_definition_condition_editor_metricswarning = You cannot have multiple conditions that use the same metric when using the ALL conjunction. This alert definition has multiple conditions that use the metric [{0}]. view_alert_definition_condition_editor_operation_status = Status da Opera\u00E7\u00E3o view_alert_definition_condition_editor_operation_status_canceled = Cancelada view_alert_definition_condition_editor_operation_status_failure = Falha diff --git a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_zh.properties b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_zh.properties index 48ca5db..c0b06b3 100644 --- a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_zh.properties +++ b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_zh.properties @@ -704,6 +704,7 @@ view_alert_definition_condition_editor_metric_calltime_threshold_value = Call Ti view_alert_definition_condition_editor_metric_calltime_threshold_value_tooltip = The threshold value of the metric that will trigger the condition when compared using the selected comparator. view_alert_definition_condition_editor_metric_change_tooltip = Specify the metric whose value must change to trigger the condition. view_alert_definition_condition_editor_metric_common_definition_not_found = Should have found metric definition - something is wrong +##view_alert_definition_condition_editor_metric_nometrics = When using the ALL conjunction, you cannot use the same metric in multiple conditions and this alert uses all available metrics in currently existing conditions. view_alert_definition_condition_editor_metric_range_comparator = \u6bd4\u8f83 ##view_alert_definition_condition_editor_metric_range_comparator_inside_exclusive = Inside, exclusive ##view_alert_definition_condition_editor_metric_range_comparator_inside_inclusive = Inside, inclusive @@ -726,6 +727,7 @@ view_alert_definition_condition_editor_metric_threshold_value = \u6307\u6807\u50 view_alert_definition_condition_editor_metric_threshold_value_tooltip = The threshold value of the metric that will trigger the condition when compared using the selected comparator. view_alert_definition_condition_editor_metric_trait_change_tooltip = Specify the trait whose value must change to trigger the condition. view_alert_definition_condition_editor_metric_trait_change_value = \u7279\u5f81 +##view_alert_definition_condition_editor_metricswarning = You cannot have multiple conditions that use the same metric when using the ALL conjunction. This alert definition has multiple conditions that use the metric [{0}]. view_alert_definition_condition_editor_operation_status = \u64cd\u4f5c\u72b6\u6001 view_alert_definition_condition_editor_operation_status_canceled = Canceled view_alert_definition_condition_editor_operation_status_failure = Failure
commit 1309b991da2ed95d13bf098252dd7284733fd5a5 Author: Simeon Pinder spinder@redhat.com Date: Tue Sep 13 08:54:33 2011 -0400
BZ:733019: changed i)plugin display name to be more consistent with AS4 and AS5 ii)renamed HostController to better show relevance to AS7 inleft navigation tree.
diff --git a/modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml b/modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml index 67edbff..abd6fe3 100644 --- a/modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml +++ b/modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml @@ -42,7 +42,7 @@ ]>
<plugin name="jboss-as-7" - displayName="JBoss-AS-7-Plugin" + displayName="JBoss Application Server 7.x" description="Management of JBossAS 7" package="org.rhq.modules.plugins.jbossas7" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" @@ -75,7 +75,7 @@
</server> --> - <server name="HostController" + <server name="JBossAS7 Host Controller" discovery="BaseProcessDiscovery" class="HostControllerComponent" description="Domain controller (delegate) for this host" @@ -1903,7 +1903,7 @@ working area for individual server instances</li></ul>"/> description="A named network interface, along with required criteria for determining the IP address to associate with that interface">
<runs-inside> - <parent-resource-type name="HostController" plugin="jboss-as-7"/> + <parent-resource-type name="JBossAS7 Host Controller" plugin="jboss-as-7"/> <parent-resource-type name="Host" plugin="jboss-as-7"/> <parent-resource-type name="JBossAS7-Standalone" plugin="jboss-as-7"/> </runs-inside> @@ -1960,7 +1960,7 @@ working area for individual server instances</li></ul>"/> class="BaseComponent" > <runs-inside> - <parent-resource-type name="HostController" plugin="jboss-as-7"/> + <parent-resource-type name="JBossAS7 Host Controller" plugin="jboss-as-7"/> </runs-inside>
diff --git a/modules/plugins/jboss-as-7/src/test/resources/test-plugin.xml b/modules/plugins/jboss-as-7/src/test/resources/test-plugin.xml index 42ff024..69201e2 100644 --- a/modules/plugins/jboss-as-7/src/test/resources/test-plugin.xml +++ b/modules/plugins/jboss-as-7/src/test/resources/test-plugin.xml @@ -1,5 +1,5 @@ <plugin name="jboss-as-7" - displayName="JBoss-AS-7-Plugin" + displayName="JBoss Application Server 7.x" description="Management of JBossAS 7" package="org.rhq.modules.plugins.jbossas7" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
commit b9d4b38efd10a9d0bd2bc9790ceffe1fcb98dce5 Author: Simeon Pinder spinder@redhat.com Date: Mon Sep 12 14:28:13 2011 -0400
inserting missing profile. Make sure release number gets included in artifacts in brew builds.
diff --git a/pom.xml b/pom.xml index ab342f5..a023da4 100644 --- a/pom.xml +++ b/pom.xml @@ -1126,14 +1126,16 @@ </profile>
<!-- These plugins i)need to be active by default - ii)need to be in a profile so that deactivation is possible for brew builds --> + ii)need to be in a profile so that deactivation is possible for brew builds + + Profile activation for 'build-properties' and 'brew-generate-build-number' need to be mutually exclusive. + --> <profile> <id>build-properties</id> <activation> <file> <exists>.git</exists> </file> - </activation> <build> <plugins> @@ -1210,6 +1212,78 @@ </plugins> </build> </profile> + + <!-- Profile activated when -Dbrew=true passed in. Profile activation for 'build-properties' and 'brew-generate-build-number' + need to be mutually exclusive. --> + <profile> + <id>brew-generate-build-number</id> + <activation> + <property> + <name>brew</name> + </property> + </activation> + <build> + <plugins> + <plugin> + <artifactId>maven-antrun-plugin</artifactId> + <executions> + <execution> + <id>write-build-properties-file</id> + <goals> + <goal>run</goal> + </goals> + <phase>generate-sources</phase> + <configuration> + <tasks> + <tstamp> + <format property="buildTime" pattern="MM/dd/yy hh:mm aa z" locale="en,US" + timezone="GMT"/> + </tstamp> + <mkdir dir="target"/> + <echo file="target/build-time.properties" level="error">buildTime = ${maven.build.timestamp}</echo> + <echo file="target/build-number.properties" level="error">buildNumber = ${rhq.build.number}</echo> + </tasks> + </configuration> + </execution> + + <execution> + <id>echo-build-properties</id> + <phase>compile</phase> + <inherited>false</inherited> + <goals> + <goal>run</goal> + </goals> + <configuration> + <tasks> + <echo level="debug">buildTime = ${maven.build.timestamp}</echo> + <echo level="debug">buildNumber = ${rhq.build.number}</echo> + </tasks> + </configuration> + </execution> + </executions> + </plugin> + <plugin> + <groupId>org.codehaus.mojo</groupId> + <artifactId>properties-maven-plugin</artifactId> + <executions> + <execution> + <id>read-build-properties</id> + <phase>process-sources</phase> + <goals> + <goal>read-project-properties</goal> + </goals> + <configuration> + <files> + <file>${project.build.directory}/build-time.properties</file> + <file>${project.build.directory}/build-number.properties</file> + </files> + </configuration> + </execution> + </executions> + </plugin> + </plugins> + </build> + </profile> </profiles>