[rhq] modules/plugins
Heiko W. Rupp
pilhuhn at fedoraproject.org
Mon Aug 13 21:27:33 UTC 2012
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/SubsystemDiscovery.java | 61 +++++-----
1 file changed, 35 insertions(+), 26 deletions(-)
New commits:
commit 83c2b30289f9b11b2d0e25d02f51b1475ccd9aea
Author: Heiko W. Rupp <hwr at redhat.com>
Date: Mon Aug 13 16:34:19 2012 -0400
BZ 846385 - Make sure to use the JDG types only when he product found is JDG and the other way around.
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 deec7a3..18eb274 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
@@ -85,8 +85,9 @@ public class SubsystemDiscovery implements ResourceDiscoveryComponent<BaseCompon
lookForChildren = true;
}
- if (isIspnForJDG(context, confPath)) {
- log.debug("We have JDG as child, ignoring the {JBossAS7}Infinispan type");
+ // check if the parent is a JDG server. In this case ignore the as7 version
+ // of the type and vice versa
+ if (shouldSkipEntryWrtIspn(context, confPath)) {
return details;
}
@@ -190,40 +191,48 @@ public class SubsystemDiscovery implements ResourceDiscoveryComponent<BaseCompon
return details;
}
- private boolean isIspnForJDG(ResourceDiscoveryContext<BaseComponent<?>> context, String confPath) {
-
- // Check if this is ISPN
+ /**
+ * The as7 plugin and the JDG plugin both have a subsystem=infinispan. We need to decide
+ * which one to 'activate' depending on the type, plugin and the detected parent.
+ * Rules are:<ul>
+ * <li>If the parent is a host controller or such, there is no jdg available</li>
+ * <li>If parent is eap/as7, use the type from the as7 plugin</li>
+ * <li>If parent is a jdg server, use the type from the jdg plugin.</li>
+ * </ul>
+ *
+ *
+ * @param context The parent's resource component
+ * @param confPath The subsystem that got fed into discovery. Directly return is not subsystem=infinispan
+ * @return True if this subsystem should be skipped.
+ */
+ private boolean shouldSkipEntryWrtIspn(ResourceDiscoveryContext<BaseComponent<?>> context,
+ String confPath) {
+
+ String jdgPluginType = "JDG";
+
+ // If this is not subsystem=infinispan, we should not skip it at all
if (!"subsystem=infinispan".equals(confPath))
return false;
ResourceType ourType = context.getResourceType();
- if (ourType.getPlugin().equals("JDG"))
- return false;
+ boolean ourPluginTypeIsJdg = ourType.getPlugin().equals(jdgPluginType);
- if (!ourType.getName().equals("Infinispan"))
- return false;
+ String productType = context.getParentResourceComponent().pluginConfiguration.getSimpleValue("productType","AS7");
+ boolean isJdgProduct = jdgPluginType.equals(productType);
- // So we are {JBossAS7}Infinispan
- Set<ResourceType> parentTypes = ourType.getParentResourceTypes();
- ResourceType parent = null;
- for (ResourceType type : parentTypes) {
- if (type.getName().equals("JBossAS7 Standalone Server") && type.getPlugin().equals("JBossAS7")) {
- parent = type;
- break;
- }
- }
- if (parent==null)
+ if (ourPluginTypeIsJdg && isJdgProduct) {
+ if (log.isDebugEnabled())
+ log.debug("Ours is JDG and product is JDG");
return false;
+ }
- // So we are as7/eap and need to check now if we have a JDG plugin's ISPN resource as child
- boolean found = false;
- for (ResourceType type: parent.getChildResourceTypes()) {
- if (type.getPlugin().equals("JDG") && type.getName().equals("Infinispan")) {
- found = true;
- }
+ if (!ourPluginTypeIsJdg && !isJdgProduct) {
+ if (log.isDebugEnabled())
+ log.debug("Ours is not JDG (" + ourType.toString() + ") and product is not JDG (" + productType + ")");
+ return false;
}
- return found;
+ return true;
}
}
More information about the rhq-commits
mailing list