modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseProcessDiscovery.java | 46 ++++++----
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseServerComponent.java | 25 ++---
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/HostControllerDiscovery.java | 10 --
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/JBossProductType.java | 2
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/StandaloneASDiscovery.java | 17 ---
modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/AbstractServerComponentTest.java | 17 ++-
6 files changed, 59 insertions(+), 58 deletions(-)
New commits:
commit 1d7b80e8beb26cfc457422894c9a9fa62e16d410
Author: Thomas Segismont <tsegismo(a)redhat.com>
Date: Fri Oct 25 18:08:01 2013 +0200
Bug 1015665 - Remove bogus product name check
Introduced new pluginConfig property "expectedRuntimeProductName"
Will check this property while validating attributes
If a dependant plugin changes its product-name, it will be able to set this property in a discovery callback
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseProcessDiscovery.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseProcessDiscovery.java
index 876b1ac..85f409d 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseProcessDiscovery.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseProcessDiscovery.java
@@ -18,6 +18,8 @@
*/
package org.rhq.modules.plugins.jbossas7;
+import static java.lang.Boolean.FALSE;
+import static java.lang.Boolean.TRUE;
import static org.rhq.core.util.StringUtil.arrayToString;
import static org.rhq.core.util.StringUtil.isNotBlank;
@@ -205,6 +207,7 @@ public abstract class BaseProcessDiscovery implements ResourceDiscoveryComponent
String apiVersion = hostConfig.getDomainApiVersion();
JBossProductType productType = JBossProductType.determineJBossProductType(homeDir, apiVersion);
serverPluginConfig.setProductType(productType);
+ pluginConfig.setSimpleValue("expectedRuntimeProductName", productType.PRODUCT_NAME);
pluginConfig.setSimpleValue("hostXmlFileName", getHostXmlFileName(commandLine));
ProcessInfo agentProcess = discoveryContext.getSystemInformation().getThisProcess();
@@ -458,6 +461,7 @@ public abstract class BaseProcessDiscovery implements ResourceDiscoveryComponent
pluginConfig.put(new PropertySimple("manuallyAdded", true));
pluginConfig.put(new PropertySimple("productType",productType.name()));
+ pluginConfig.setSimpleValue("expectedRuntimeProductName", productType.PRODUCT_NAME);
DiscoveredResourceDetails detail = new DiscoveredResourceDetails(context.getResourceType(), key, name,
version, description, pluginConfig, null);
@@ -471,26 +475,36 @@ public abstract class BaseProcessDiscovery implements ResourceDiscoveryComponent
Configuration pluginConfiguration = inventoriedResource.getPluginConfiguration();
ServerPluginConfiguration serverPluginConfiguration = new ServerPluginConfiguration(pluginConfiguration);
- if (currentResourceKey.startsWith(LOCAL_RESOURCE_KEY_PREFIX)
- || currentResourceKey.startsWith(REMOTE_RESOURCE_KEY_PREFIX)) {
- // Resource key already in right format
- return null;
- }
-
ResourceUpgradeReport report = new ResourceUpgradeReport();
+ Boolean upgraded = FALSE;
+
+ if (!currentResourceKey.startsWith(LOCAL_RESOURCE_KEY_PREFIX)
+ && !currentResourceKey.startsWith(REMOTE_RESOURCE_KEY_PREFIX)) {
+ // Resource key in wrong format
+ upgraded = TRUE;
+ if (new File(currentResourceKey).isDirectory()) {
+ // Old key format for a local resource (key is base dir)
+ report.setNewResourceKey(createKeyForLocalResource(serverPluginConfiguration));
+ } else if (currentResourceKey.contains(":")) {
+ // Old key format for a remote (manually added) resource (key is base dir)
+ report.setNewResourceKey(createKeyForRemoteResource(currentResourceKey));
+ } else {
+ upgraded = FALSE;
+ log.warn("Unknown format, cannot upgrade resource key [" + currentResourceKey + "]");
+ }
+ }
- if (new File(currentResourceKey).isDirectory()) {
- // Old key format for a local resource (key is base dir)
- report.setNewResourceKey(createKeyForLocalResource(serverPluginConfiguration));
- } else if (currentResourceKey.contains(":")) {
- // Old key format for a remote (manually added) resource (key is base dir)
- report.setNewResourceKey(createKeyForRemoteResource(currentResourceKey));
- } else {
- log.warn("Unknown format, cannot upgrade resource key [" + currentResourceKey + "]");
- return null;
+ if (pluginConfiguration.getSimpleValue("expectedRuntimeProductName") == null) {
+ upgraded = TRUE;
+ pluginConfiguration.setSimpleValue("expectedRuntimeProductName",
+ serverPluginConfiguration.getProductType().PRODUCT_NAME);
+ report.setNewPluginConfiguration(pluginConfiguration);
}
- return report;
+ if (upgraded == TRUE) {
+ return report;
+ }
+ return null;
}
private String createKeyForRemoteResource(String hostPort) {
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseServerComponent.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseServerComponent.java
index 9c2a799..b226af0 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseServerComponent.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseServerComponent.java
@@ -45,7 +45,6 @@ import org.rhq.core.domain.measurement.MeasurementReport;
import org.rhq.core.domain.measurement.MeasurementScheduleRequest;
import org.rhq.core.pluginapi.availability.AvailabilityCollectorRunnable;
import org.rhq.core.pluginapi.availability.AvailabilityFacet;
-import org.rhq.core.pluginapi.component.ComponentInvocationContext;
import org.rhq.core.pluginapi.event.log.LogFileEventResourceComponentHelper;
import org.rhq.core.pluginapi.inventory.InvalidPluginConfigurationException;
import org.rhq.core.pluginapi.inventory.ResourceComponent;
@@ -205,22 +204,20 @@ public abstract class BaseServerComponent<T extends ResourceComponent<?>> extend
}
// Validate the product type (e.g. AS or EAP).
- JBossProductType runtimeType;
+ String expectedRuntimeProductName = pluginConfiguration.getSimpleValue("expectedRuntimeProductName");
try {
- String runtimeTypeString = readAttribute(getHostAddress(), "product-name");
- runtimeType = (runtimeTypeString != null && !runtimeTypeString.isEmpty()) ? JBossProductType
- .getValueByProductName(runtimeTypeString) : JBossProductType.AS;
- } catch (Exception e) {
- runtimeType = null;
- log.error("Failed to validate product type for " + getResourceDescription() + ".", e);
- }
- if (runtimeType != null) {
- JBossProductType type = serverPluginConfig.getProductType();
- if (runtimeType != type) {
+ String runtimeProductName = readAttribute(getHostAddress(), "product-name");
+ if (runtimeProductName == null || runtimeProductName.trim().isEmpty()) {
+ runtimeProductName = JBossProductType.AS.PRODUCT_NAME;
+ }
+ if (!runtimeProductName.equals(expectedRuntimeProductName)) {
throw new InvalidPluginConfigurationException(
- "The original product type discovered for this AS7 server was " + type
- + ", but the server is now reporting its product type is [" + runtimeType + "].");
+ "The original product type discovered for this server was " + expectedRuntimeProductName
+ + ", but the server is now reporting its product type is [" + runtimeProductName + "]");
}
+ } catch (Exception e) {
+ throw new InvalidPluginConfigurationException("Failed to validate product type for "
+ + getResourceDescription(), e);
}
}
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/HostControllerDiscovery.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/HostControllerDiscovery.java
index f4cbb40..92c9e31 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/HostControllerDiscovery.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/HostControllerDiscovery.java
@@ -1,6 +1,6 @@
/*
* RHQ Management Platform
- * Copyright (C) 2005-2012 Red Hat, Inc.
+ * Copyright (C) 2005-2013 Red Hat, Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
@@ -13,8 +13,8 @@
* 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.
+ * along with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
package org.rhq.modules.plugins.jbossas7;
@@ -33,10 +33,6 @@ public class HostControllerDiscovery extends BaseProcessDiscovery {
private static final String DOMAIN_CONFIG_DIR_SYSPROP = "jboss.domain.config.dir";
private static final String DOMAIN_LOG_DIR_SYSPROP = "jboss.domain.log.dir";
- private static final String DEFAULT_HOST_CONFIG_FILE_NAME = "host.xml";
-
- private CommandLineOption HOST_CONFIG_OPTION = new CommandLineOption(null, "host-config");
-
@Override
protected AS7Mode getMode() {
return AS7Mode.DOMAIN;
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/JBossProductType.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/JBossProductType.java
index 05b72e3..fa73974 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/JBossProductType.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/JBossProductType.java
@@ -32,7 +32,7 @@ public enum JBossProductType {
AS("AS", "JBoss AS 7", "JBoss Application Server 7", "AS"),
EAP("EAP", "JBoss EAP 6", "JBoss Enterprise Application Platform 6", "EAP"),
- ISPN("ISPN", "Infinispan Server", "Infinispan Server", "ISPN"),
+ ISPN("ISPN", "Infinispan Server", "Infinispan Server", "Infinispan Server"),
JDG("JDG", "JBoss JDG 6", "JBoss Data Grid 6", "Data Grid"),
JPP("JPP", "JBoss JPP 6", "JBoss Portal Platform 6", "Portal Platform"),
SOA("SOA-P", "JBoss SOA-P 6", "Red Hat JBoss Fuse Service Works", "Red Hat JBoss Fuse Service Works"),
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/StandaloneASDiscovery.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/StandaloneASDiscovery.java
index 2978343..31ad026 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/StandaloneASDiscovery.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/StandaloneASDiscovery.java
@@ -1,6 +1,6 @@
/*
* RHQ Management Platform
- * Copyright (C) 2005-2012 Red Hat, Inc.
+ * Copyright (C) 2005-2013 Red Hat, Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
@@ -13,13 +13,11 @@
* 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.
+ * along with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
package org.rhq.modules.plugins.jbossas7;
-import org.rhq.core.pluginapi.inventory.DiscoveredResourceDetails;
-import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext;
import org.rhq.core.system.ProcessInfo;
import org.rhq.modules.plugins.jbossas7.helper.HostPort;
@@ -76,15 +74,6 @@ public class StandaloneASDiscovery extends BaseProcessDiscovery {
}
@Override
- protected DiscoveredResourceDetails buildResourceDetails(ResourceDiscoveryContext discoveryContext,
- ProcessInfo process, AS7CommandLine commandLine) throws Exception {
-
- DiscoveredResourceDetails resourceDetails = super.buildResourceDetails(discoveryContext, process, commandLine);
-
- return resourceDetails;
- }
-
- @Override
protected ProcessInfo getPotentialStartScriptProcess(ProcessInfo process) {
// If the server was started via standalone.sh/bat, its parent process will be standalone.sh/bat.
return process.getParentProcess();
diff --git a/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/AbstractServerComponentTest.java b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/AbstractServerComponentTest.java
index f34a554..6ff3d06 100644
--- a/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/AbstractServerComponentTest.java
+++ b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/AbstractServerComponentTest.java
@@ -63,6 +63,7 @@ public abstract class AbstractServerComponentTest extends AbstractJBossAS7Plugin
static {
EAP6_VERSION_TO_AS7_VERSION_MAP.put("6.0.0", "7.1.2.Final-redhat-1");
EAP6_VERSION_TO_AS7_VERSION_MAP.put("6.0.1", "7.1.3.Final-redhat-4");
+ EAP6_VERSION_TO_AS7_VERSION_MAP.put("6.1.0", "7.2.0.Final-redhat-8");
}
private static final String RELEASE_VERSION_TRAIT_NAME = "_skm:release-version";
@@ -124,9 +125,13 @@ public abstract class AbstractServerComponentTest extends AbstractJBossAS7Plugin
Assert.assertNotNull(ipce, "InvalidPluginConfigurationException was not thrown by server component's "
+ "start() method due to invalid baseDir.");
- // Change the productType prop.
- JBossProductType originalProductType = serverPluginConfig.getProductType();
- serverPluginConfig.setProductType(originalProductType == JBossProductType.AS ? JBossProductType.EAP : JBossProductType.AS);
+ // Change the expectedRuntimeProductName property
+ String originalExpectedRuntimeProductName = pluginConfig.getSimpleValue("expectedRuntimeProductName");
+ if (originalExpectedRuntimeProductName.equals(JBossProductType.AS.PRODUCT_NAME)) {
+ pluginConfig.setSimpleValue("expectedRuntimeProductName", JBossProductType.EAP.PRODUCT_NAME);
+ } else {
+ pluginConfig.setSimpleValue("expectedRuntimeProductName", JBossProductType.AS.PRODUCT_NAME);
+ }
// Restart the server ResourceComponent so it picks up the changes we just made to the plugin config.
inventoryManager.deactivateResource(getServerResource());
@@ -137,9 +142,9 @@ public abstract class AbstractServerComponentTest extends AbstractJBossAS7Plugin
ipce = e;
}
- // Set the productType back to the original value and restart the component before making any assertions, to ensure
- // things aren't left in a corrupt state for remaining test methods.
- serverPluginConfig.setProductType(originalProductType);
+ // Set the expectedRuntimeProductName property back to the original value and restart the component before
+ // making any assertions, to ensure things aren't left in a corrupt state for remaining test methods.
+ pluginConfig.setSimpleValue("expectedRuntimeProductName", originalExpectedRuntimeProductName);
inventoryManager.activateResource(getServerResource(), serverContainer, true);
Assert.assertNotNull(ipce, "InvalidPluginConfigurationException was not thrown by server component's "