Skip to content
This repository has been archived by the owner on Jul 11, 2022. It is now read-only.

Commit

Permalink
Remove Wildfly8 support, change AS7 plugin to only accept apiVersion …
Browse files Browse the repository at this point in the history
…1.x and Wildfly10 plugin to accept only apiVersion 4.x
  • Loading branch information
Michael Burman committed May 19, 2016
1 parent 0d3412f commit eaa244e
Show file tree
Hide file tree
Showing 11 changed files with 244 additions and 74 deletions.
Expand Up @@ -21,7 +21,6 @@

import static java.lang.Boolean.FALSE;
import static java.lang.Boolean.TRUE;
import static org.rhq.modules.plugins.jbossas7.JBossProductType.WILDFLY8;
import static org.rhq.modules.plugins.jbossas7.jmx.ApplicationMBeansDiscoveryComponent.PluginConfigProps.BEANS_QUERY_STRING;
import static org.rhq.modules.plugins.jbossas7.jmx.ApplicationMBeansDiscoveryComponent.PluginConfigProps.NEW_RESOURCE_DESCRIPTION;
import static org.rhq.modules.plugins.jbossas7.jmx.ApplicationMBeansDiscoveryComponent.PluginConfigProps.NEW_RESOURCE_NAME;
Expand Down Expand Up @@ -250,20 +249,14 @@ public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext
LOG.warn("Could not find Managed Server socket binding offset, skipping discovery");
return Collections.emptySet();
}
if (productType != WILDFLY8) {
port = DOMAIN_REMOTING_PORT_DEFAULT;
} else {
port = HTTP_PORT_DEFAULT;
}
port = DOMAIN_REMOTING_PORT_DEFAULT;
port += offsetProp.getIntegerValue();
String[] credentials = getCredentialsForManagedAS();
username = credentials[0];
password = credentials[1];
} else if (parentComponent instanceof StandaloneASComponent) {
port = serverPluginConfiguration.getPort();
if (productType != WILDFLY8) {
port += STANDALONE_REMOTING_PORT_OFFSET;
}
port += STANDALONE_REMOTING_PORT_OFFSET;
username = serverPluginConfiguration.getUser();
password = serverPluginConfiguration.getPassword();
} else {
Expand All @@ -283,7 +276,7 @@ public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext
pluginConfig.setSimpleValue(USERNAME, username);
pluginConfig.setSimpleValue(PASSWORD, password);
pluginConfig.setSimpleValue(CLIENT_JAR_LOCATION, clientJarFile.getAbsolutePath());
pluginConfig.setSimpleValue(PROTOCOL, productType == WILDFLY8 ? "http-remoting-jmx" : "remoting-jmx");
pluginConfig.setSimpleValue(PROTOCOL, "remoting-jmx");

EmsConnection emsConnection = null;
try {
Expand Down
@@ -0,0 +1,27 @@
<!--
~ RHQ Management Platform
~ Copyright (C) 2005-2016 Red Hat, Inc.
~ All rights reserved.
~
~ This program is free software; you can redistribute it and/or modify
~ it under the terms of the GNU General Public License as published by
~ the Free Software Foundation version 2 of the License.
~
~ This program is distributed in the hope that it will be useful,
~ but WITHOUT ANY WARRANTY; without even the implied warranty of
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
~ GNU General Public License for more details.
~
~ You should have received a copy of the GNU General Public License
~ along with this program; if not, write to the Free Software Foundation, Inc,
~ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
-->

<differences>
<difference>
<className>org/rhq/modules/plugins/jbossas7/JBossProductType</className>
<differenceType>6001</differenceType>
<field>WILDFLY8</field>
<justification>Remove support for WILDFLY8</justification>
</difference>
</differences>
Expand Up @@ -233,8 +233,8 @@ protected DiscoveredResourceDetails buildResourceDetails(ResourceDiscoveryContex
pluginConfig.setSimpleValue("realm", hostConfig.getManagementSecurityRealm());
String apiVersion = hostConfig.getDomainApiVersion();
JBossProductType productType = JBossProductType.determineJBossProductType(homeDir, apiVersion);
if(productType == JBossProductType.EAP7) {
// Ignore here, use EAP7 / Wildfly 10 plugin to do the detection
if(productType == JBossProductType.UNSUPPORTED) {
// Ignore here, could be EAP7 based product
return null;
}
serverPluginConfig.setProductType(productType);
Expand Down Expand Up @@ -496,8 +496,8 @@ public DiscoveredResourceDetails discoverResource(Configuration pluginConfig, Re
+ "] as user [" + user + "]. Did you provide the correct credentials?");
}

if (productType == JBossProductType.EAP7) {
throw new InvalidPluginConfigurationException("EAP7 / Wildfly 10 are not supported by this plugin.");
if (productType == JBossProductType.UNSUPPORTED) {
throw new InvalidPluginConfigurationException("EAP7 / Wildfly based products are not supported by this plugin.");
}

HostPort hostPort = new HostPort(false);
Expand Down Expand Up @@ -783,7 +783,7 @@ private String getVersion(File homeDir, JBossProductType productType) {
// Products should have a version.txt file at root dir
File versionFile = new File(homeDir, "version.txt");
String version = getProductVersionInFile(versionFile, " - Version ", productType);
if (version == null && productType != JBossProductType.AS && productType != JBossProductType.WILDFLY8) {
if (version == null && productType != JBossProductType.AS) {
// No version.txt file. Try modules/system/layers/base/org/jboss/as/product/slot/dir/META-INF/MANIFEST.MF
String layeredProductManifestFilePath = arrayToString(
new String[] { "modules", "system", "layers", "base", "org", "jboss", "as", "product",
Expand Down Expand Up @@ -873,8 +873,6 @@ private boolean supportsPatching(JBossProductType productType, String version) {
return false;
case EAP:
return OSGI_VERSION_6_2_0.compareTo(osgiVersion) <= 0;
case WILDFLY8:
return true;
case JPP:
return false; //as of now
case SOA:
Expand Down Expand Up @@ -920,9 +918,6 @@ public ProductInfo getFromRemote() {
Integer apiVersion = getServerAttribute(connection, "management-major-version");
if (apiVersion == 1) {
productType = JBossProductType.AS;
} else {
// In the future also check for other versions of WildFly via the release-version
productType = JBossProductType.WILDFLY8;
}
}
releaseVersion = getServerAttribute(connection, "release-version");
Expand Down
Expand Up @@ -26,7 +26,6 @@
import static org.rhq.core.pluginapi.bundle.BundleHandoverResponse.FailureType.EXECUTION;
import static org.rhq.core.pluginapi.bundle.BundleHandoverResponse.FailureType.INVALID_PARAMETER;
import static org.rhq.modules.plugins.jbossas7.JBossProductType.AS;
import static org.rhq.modules.plugins.jbossas7.JBossProductType.WILDFLY8;
import static org.rhq.modules.plugins.jbossas7.util.ProcessExecutionLogger.logExecutionResults;

import java.io.File;
Expand Down Expand Up @@ -300,11 +299,7 @@ private void validateServerAttributes() throws InvalidPluginConfigurationExcepti
throw new InvalidPluginConfigurationException("Failed to validate product type for "
+ getResourceDescription(), e);
}
if (releaseVersionNumber.startsWith("8.")) {
runtimeProductName = WILDFLY8.PRODUCT_NAME;
} else {
runtimeProductName = AS.PRODUCT_NAME;
}
runtimeProductName = AS.PRODUCT_NAME;
}
if (!runtimeProductName.equals(expectedRuntimeProductName)) {
throw new InvalidPluginConfigurationException("The original product type discovered for this server was "
Expand Down
Expand Up @@ -32,15 +32,14 @@ public enum JBossProductType {

AS("AS", "JBoss AS 7", "JBoss Application Server 7", "AS"),
EAP("EAP", "JBoss EAP 6", "JBoss Enterprise Application Platform 6", "EAP"),
EAP7("EAP", "JBoss EAP 7", "JBoss Enterprise Application Platform 7", "EAP"),
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"),
WILDFLY8("WildFly", "WildFly 8", "WildFly Application Server 8", "WildFly"),
BRMS("BRMS", "JBoss BRMS", "Red Hat JBoss BRMS", "BRMS"),
BPMS("BPM Suite", "JBoss BPM Suite", "Red Hat JBoss BPM Suite", "BPM Suite"),
JDV("JDV", "Data Virt", "Red Hat JBoss Data Virtualization", "Red Hat JBoss Data Virtualization");
JDV("JDV", "Data Virt", "Red Hat JBoss Data Virtualization", "Red Hat JBoss Data Virtualization"),
UNSUPPORTED("", "", "", "");

public final String SHORT_NAME;
public final String NAME;
Expand Down Expand Up @@ -85,9 +84,6 @@ public static JBossProductType determineJBossProductType(File homeDir, String ap
// like 2.0 in "urn:jboss:domain:2.0" from <server xmlns="..." > element in standalone.xml
if (apiVersion.startsWith("1")) {
jBossProductType = JBossProductType.AS;
} else {
// We should later check for newer WildFly versions to differentiate them
jBossProductType = JBossProductType.WILDFLY8;
}
}
return jBossProductType;
Expand All @@ -107,7 +103,7 @@ public static JBossProductType getValueByProductName(String productName) {
}

private static JBossProductType determineJBossProductTypeViaProductConfFile(File homeDir, String apiVersion) throws Exception {
JBossProductType productType;
JBossProductType productType = null;
File productConfFile = new File(homeDir, "bin/product.conf");
if (productConfFile.exists()) {
// It's some product (i.e. not community AS).
Expand All @@ -124,31 +120,20 @@ private static JBossProductType determineJBossProductTypeViaProductConfFile(File
if (slot.isEmpty()) {
throw new Exception("'slot' property not found in " + productConfFile + ".");
}
if (slot.equals("eap")) {
if(apiVersion.startsWith("1")) {
productType = JBossProductType.EAP;
} else {
productType = JBossProductType.EAP7;

if(apiVersion.startsWith("1")) {
try {
String searchQuery = slot.toUpperCase();
if(searchQuery.equals("DV")) {
searchQuery = "JDV";
}
productType = valueOf(searchQuery);
} catch(IllegalArgumentException e) {
productType = AS;
}
} else if (slot.equals("ispn")) {
productType = JBossProductType.ISPN;
} else if (slot.equals("jdg")) {
productType = JBossProductType.JDG;
} else if (slot.equals("jpp")) {
productType = JBossProductType.JPP;
} else if (slot.equals("soa")) {
productType = JBossProductType.SOA;
} else if (slot.equals("brms")) {
productType = JBossProductType.BRMS;
} else if (slot.equals("bpms")) {
productType = JBossProductType.BPMS;
} else if (slot.equals("dv")) {
productType = JBossProductType.JDV;
} else {
throw new RuntimeException("Unknown product type: " + slot);
productType = UNSUPPORTED;
}
} else {
productType = null;
}

return productType;
Expand All @@ -159,8 +144,6 @@ private static JBossProductType determineJBossProductTypeViaHomeDirName(File hom
String homeDirName = homeDir.getName();
if (homeDirName.contains("-as-")) {
productType = JBossProductType.AS;
} else if (homeDirName.contains("wildfly")) {
productType = JBossProductType.WILDFLY8;
} else if (homeDirName.contains("-eap-")) {
productType = JBossProductType.EAP;
} else if (homeDirName.contains("infinispan-server")) {
Expand Down
@@ -0,0 +1,95 @@
/*
* RHQ Management Platform
* Copyright (C) 2005-2016 Red Hat, Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation version 2 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation, Inc,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
package org.rhq.modules.plugins.jbossas7;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Properties;

import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;

import static org.junit.Assert.assertEquals;

/**
* Test current product detection.
*
* @author Michael Burman
*/
public class ProductTypeTest {

@Rule
public TemporaryFolder homeDir = new TemporaryFolder();

private void createProductConf(String productName) throws IOException {
File bin = homeDir.newFolder("bin");
File productConf = new File(bin, "product.conf");
FileOutputStream fos = new FileOutputStream(productConf);
Properties productConfProps = new Properties();
productConfProps.setProperty("slot", productName);
productConfProps.store(fos, "JBoss product branding configuration");
fos.flush();
fos.close();
}

@Test
public void testProductParsing() throws Exception {
createProductConf("eap");
JBossProductType jBossProductType = JBossProductType.determineJBossProductType(homeDir.getRoot(), "1.0");
assertEquals(jBossProductType, JBossProductType.EAP);

createProductConf("dv");
jBossProductType = JBossProductType.determineJBossProductType(homeDir.getRoot(), "1.0");
assertEquals(jBossProductType, JBossProductType.JDV);

createProductConf("bpms");
jBossProductType = JBossProductType.determineJBossProductType(homeDir.getRoot(), "1.0");
assertEquals(jBossProductType, JBossProductType.BPMS);

createProductConf("ispn");
jBossProductType = JBossProductType.determineJBossProductType(homeDir.getRoot(), "1.0");
assertEquals(jBossProductType, JBossProductType.ISPN);

createProductConf("jpp");
jBossProductType = JBossProductType.determineJBossProductType(homeDir.getRoot(), "1.0");
assertEquals(jBossProductType, JBossProductType.JPP);

createProductConf("brms");
jBossProductType = JBossProductType.determineJBossProductType(homeDir.getRoot(), "1.0");
assertEquals(jBossProductType, JBossProductType.BRMS);

createProductConf("soa");
jBossProductType = JBossProductType.determineJBossProductType(homeDir.getRoot(), "1.0");
assertEquals(jBossProductType, JBossProductType.SOA);

createProductConf("jdg");
jBossProductType = JBossProductType.determineJBossProductType(homeDir.getRoot(), "1.0");
assertEquals(jBossProductType, JBossProductType.JDG);

createProductConf("undefined");
jBossProductType = JBossProductType.determineJBossProductType(homeDir.getRoot(), "1.0");
assertEquals(jBossProductType, JBossProductType.AS);

createProductConf("eap");
jBossProductType = JBossProductType.determineJBossProductType(homeDir.getRoot(), "4.0");
assertEquals(jBossProductType, JBossProductType.UNSUPPORTED);
}
}
Expand Up @@ -291,7 +291,7 @@ private void validateServerAttributes() throws InvalidPluginConfigurationExcepti
+ getResourceDescription(), e);
}
if (!runtimeProductName.equals(expectedRuntimeProductName)) {
if(serverPluginConfig.getProductType() != JBossProductType.WILDFLY10) {
if(serverPluginConfig.getProductType() != JBossProductType.WILDFLY) {
throw new InvalidPluginConfigurationException("The original product type discovered for this server was "
+ expectedRuntimeProductName + ", but the server is now reporting its product type is ["
+ runtimeProductName + "]");
Expand Down
Expand Up @@ -25,13 +25,12 @@

/**
* Metadata describing a product based on Wildfly 10
*
* @author Ian Springer
*/
public enum JBossProductType {
public enum JBossProductType {

EAP7("EAP", "EAP 7", "JBoss Enterprise Application Platform 7", "JBoss EAP"),
WILDFLY10("WildFly", "WildFly 10", "WildFly Application Server 10", "WildFly Full");
EAP("EAP", "EAP 7", "JBoss Enterprise Application Platform 7", "JBoss EAP"),
JDG("JDG", "JBoss JDG 7", "JBoss Data Grid 7", "Data Grid"),
WILDFLY("WildFly", "WildFly 10", "WildFly Application Server 10", "WildFly Full");

public final String SHORT_NAME;
public final String NAME;
Expand All @@ -55,10 +54,23 @@ public static JBossProductType getValueByProductName(String productName) {
throw new IllegalArgumentException("No product type with product-name '" + productName + "' is known.");
}

public static JBossProductType getValueByShortName(String productName) {
if(productName.equalsIgnoreCase("wildfly-full")) {
return WILDFLY;
}

for (JBossProductType productType : JBossProductType.values()) {
if (productType.SHORT_NAME.equalsIgnoreCase(productName)) {
return productType;
}
}
throw new IllegalArgumentException("No product type with product-name '" + productName + "' is known.");
}

/**
* Determines the product type of a JBoss product installation.
*
* @param homeDir the JBoss product installation directory (e.g. /opt/jboss-as-7.1.1.Final)
* @param homeDir the JBoss product installation directory (e.g. /opt/wildfly-10.0.0.Final)
*
* @param apiVersion Api version of the domain api.
* @return the product type
Expand All @@ -81,11 +93,10 @@ public static JBossProductType determineJBossProductType(File homeDir, String ap
throw new Exception("'slot' property not found in " + productConfFile + ".");
}
if(apiVersion.startsWith("4")) {
if(slot.equals("eap")) {
productType = EAP7;
} else {
// Fallback
productType = WILDFLY10;
try {
productType = getValueByShortName(slot);
} catch(IllegalArgumentException e) {
productType = WILDFLY;
}
}
}
Expand Down

0 comments on commit eaa244e

Please sign in to comment.