modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/ConfigurationManagerBean.java | 24 modules/plugins/jboss-as-7/d2d.sh | 2 modules/plugins/jboss-as-7/pom.xml | 16 modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/AS7Authenticator.java | 26 modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASConnection.java | 76 - modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASUploadConnection.java | 21 modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/AbstractBaseDiscovery.java | 287 ++- modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseComponent.java | 63 modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseProcessDiscovery.java | 323 ++-- modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseServerComponent.java | 128 + modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ConfigurationLoadDelegate.java | 47 modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ConfigurationWriteDelegate.java | 135 + modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/DatasourceComponent.java | 78 - modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/DeploymentComponent.java | 212 ++ modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/Domain2Descriptor.java | 57 modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/DomainDeploymentComponent.java | 23 modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/HostControllerComponent.java | 10 modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/JVMDiscoveryComponent.java | 53 modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/JmsComponent.java | 3 modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ManagedASComponent.java | 41 modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ManagedASDiscovery.java | 206 +- modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/NamingComponent.java | 92 + modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ServerGroupComponent.java | 2 modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/StandaloneASComponent.java | 2 modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Address.java | 46 modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Operation.java | 2 modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Result.java | 17 modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml | 736 +++++----- modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/AbstractConfigurationHandlingTest.java | 49 modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/ConfigurationLoadingTest.java | 59 modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/ConfigurationUpdatingTest.java | 122 + modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/OperationJsonTest.java | 3 modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/PathHandlingTest.java | 27 modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/XmlFileReadingTest.java | 133 + modules/plugins/jboss-as-7/src/test/resources/host1.xml | 92 + modules/plugins/jboss-as-7/src/test/resources/host2.xml | 91 + modules/plugins/jboss-as-7/src/test/resources/standalone70.xml | 433 +++++ modules/plugins/jboss-as-7/src/test/resources/standalone71.xml | 453 ++++++ modules/plugins/jboss-as-7/src/test/resources/system-props.json | 10 modules/plugins/jboss-as-7/src/test/resources/test-plugin.xml | 28 modules/plugins/jboss-as-7/src/test/resources/web.json | 62 41 files changed, 3459 insertions(+), 831 deletions(-)
New commits: commit ffe50ce9e58bfaf507c92cd96dbcd5ab53948d8b Author: Torben Jaeger torben@jit-central.com Date: Fri Feb 10 11:32:24 2012 +0100
Enable gathering of server logs.
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 bc0374a..d62c55b 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 @@ -41,6 +41,7 @@ import org.rhq.core.pluginapi.configuration.ConfigurationFacet; import org.rhq.core.pluginapi.configuration.ConfigurationUpdateReport; import org.rhq.core.pluginapi.content.ContentContext; import org.rhq.core.pluginapi.content.ContentServices; +import org.rhq.core.pluginapi.event.log.LogFileEventResourceComponentHelper; import org.rhq.core.pluginapi.inventory.CreateChildResourceFacet; import org.rhq.core.pluginapi.inventory.CreateResourceReport; import org.rhq.core.pluginapi.inventory.DeleteResourceFacet; @@ -93,6 +94,8 @@ public class BaseComponent<T extends ResourceComponent<?>> implements ResourceCo String managementUser; String managementPassword;
+ private LogFileEventResourceComponentHelper logFileEventDelegate; + /** * Return availability of this resource * @see org.rhq.core.pluginapi.inventory.ResourceComponent#getAvailability() @@ -121,6 +124,8 @@ public class BaseComponent<T extends ResourceComponent<?>> implements ResourceCo managementUser = pluginConfiguration.getSimpleValue("user","-unset-"); managementPassword = pluginConfiguration.getSimpleValue("password","-unset-"); connection = new ASConnection(host,port, managementUser, managementPassword); + logFileEventDelegate = new LogFileEventResourceComponentHelper(context); + logFileEventDelegate.startLogFileEventPollers(); } else { connection = ((BaseComponent)context.getParentResourceComponent()).getASConnection(); @@ -141,8 +146,9 @@ public class BaseComponent<T extends ResourceComponent<?>> implements ResourceCo * @see org.rhq.core.pluginapi.inventory.ResourceComponent#stop() */ public void stop() { - - + if (!(context.getParentResourceComponent() instanceof BaseComponent)) { + logFileEventDelegate.stopLogFileEventPollers(); + } }
commit e5d3ddf2655bf961252941475ff89998d0e87d6d Author: Heiko W. Rupp hwr@redhat.com Date: Thu Feb 9 21:24:33 2012 +0100
Various improvements to the as7 plugin up to (and including) master rev 24aff88ad572
diff --git a/modules/plugins/jboss-as-7/d2d.sh b/modules/plugins/jboss-as-7/d2d.sh index 16c1e57..d36d8e9 100755 --- a/modules/plugins/jboss-as-7/d2d.sh +++ b/modules/plugins/jboss-as-7/d2d.sh @@ -1,2 +1,2 @@ #!/bin/sh -java -cp target/rhq-jboss-as-7-plugin-4.1.0-SNAPSHOT.jar:/im/rhq/modules/enterprise/agent/target/rhq-agent/lib/commons-logging-1.1.0.jboss.jar:/Users/hrupp/.m2/repository/org/codehaus/jackson/jackson-core-asl/1.7.4/jackson-core-asl-1.7.4.jar:/Users/hrupp/.m2/repository/org/codehaus/jackson/jackson-mapper-asl/1.7.4/jackson-mapper-asl-1.7.4.jar org.rhq.modules.plugins.jbossas7.Domain2Descriptor $* +java -cp target/rhq-jboss-as-7-plugin-4.3.0-SNAPSHOT.jar:/im/rhq/modules/enterprise/agent/target/rhq-agent/lib/commons-logging-1.1.0.jboss.jar:/Users/hrupp/.m2/repository/org/codehaus/jackson/jackson-core-asl/1.7.4/jackson-core-asl-1.7.4.jar:/Users/hrupp/.m2/repository/org/codehaus/jackson/jackson-mapper-asl/1.7.4/jackson-mapper-asl-1.7.4.jar org.rhq.modules.plugins.jbossas7.Domain2Descriptor $* diff --git a/modules/plugins/jboss-as-7/pom.xml b/modules/plugins/jboss-as-7/pom.xml index 1cbe657..cfb5266 100644 --- a/modules/plugins/jboss-as-7/pom.xml +++ b/modules/plugins/jboss-as-7/pom.xml @@ -15,9 +15,9 @@ <name>RHQ JBossAS 7.x Plugin</name>
<properties> - <scm.module.path>TODO</scm.module.path> <json.version>${project.json.version}</json.version> <jackson.version>1.7.4</jackson.version> + <jboss.sasl.version>1.0.0.Beta9</jboss.sasl.version> </properties>
<build> @@ -50,6 +50,11 @@ <artifactId>jackson-core-asl</artifactId> <version>${jackson.version}</version> </artifactItem> + <artifactItem> + <groupId>org.jboss.sasl</groupId> + <artifactId>jboss-sasl</artifactId> + <version>${jboss.sasl.version}</version> + </artifactItem>
</artifactItems> <outputDirectory>${project.build.outputDirectory}/lib</outputDirectory> @@ -77,7 +82,7 @@ <plugins>
<plugin> - <artifactId>maven-antrun-plugin</artifactId> + <artifactId>maven-antrun-plugin</artifactId> <executions>
<execution> @@ -205,6 +210,13 @@ <scope>provided</scope> </dependency>
+ <!-- for the password hashing - we may want to copy the relevant stuff over ourselves --> + <dependency> + <groupId>org.jboss.sasl</groupId> + <artifactId>jboss-sasl</artifactId> + <version>${jboss.sasl.version}</version> + </dependency> + <dependency> <groupId>org.testng</groupId> <artifactId>testng</artifactId> diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/AS7Authenticator.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/AS7Authenticator.java new file mode 100644 index 0000000..703e177 --- /dev/null +++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/AS7Authenticator.java @@ -0,0 +1,26 @@ +package org.rhq.modules.plugins.jbossas7; + +import java.net.Authenticator; +import java.net.PasswordAuthentication; + +/** + * Authenticator to authenticate against as7 + * @author Heiko W. Rupp + */ +public class AS7Authenticator extends Authenticator { + + private String user; + private String pass; + + public AS7Authenticator(String user, String pass) { + this.user = user; + this.pass = pass; + if (this.pass==null) + this.pass=""; // prevent NPE later + } + + @Override + protected PasswordAuthentication getPasswordAuthentication() { + return new PasswordAuthentication(user,pass.toCharArray()); + } +} diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASConnection.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASConnection.java index 13c9ae6..382a145 100644 --- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASConnection.java +++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASConnection.java @@ -23,15 +23,15 @@ import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStream; +import java.net.Authenticator; import java.net.HttpURLConnection; import java.net.MalformedURLException; +import java.net.SocketTimeoutException; import java.net.URL;
import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.codehaus.jackson.JsonGenerationException; import org.codehaus.jackson.JsonNode; -import org.codehaus.jackson.map.JsonMappingException; import org.codehaus.jackson.map.ObjectMapper; import org.codehaus.jackson.map.SerializationConfig;
@@ -51,15 +51,21 @@ public class ASConnection { String urlString; private ObjectMapper mapper; public static boolean verbose = false; // This is a variable on purpose, so devs can switch it on in the debugger or in the agent - private HttpURLConnection conn; + Authenticator passwordAuthenticator ; + private String host; + private int port;
/** * Construct an ASConnection object. The real "physical" connection is done in * #executeRaw. * @param host Host of the DomainController or standalone server * @param port Port of the JSON api. + * @param user user needed for authentication + * @param password password needed for authentication */ - public ASConnection(String host, int port) { + public ASConnection(String host, int port, String user, String password) { + this.host = host; + this.port = port;
try { url = new URL("http", host, port, MANAGEMENT); @@ -69,6 +75,9 @@ public class ASConnection { throw new IllegalArgumentException(e.getMessage()); }
+ passwordAuthenticator = new AS7Authenticator(user,password); + Authenticator.setDefault(passwordAuthenticator); + // read system property "as7plugin.verbose" verbose = Boolean.getBoolean("as7plugin.verbose");
@@ -92,19 +101,25 @@ public class ASConnection { InputStream inputStream = null; BufferedReader br = null; InputStream es = null; + HttpURLConnection conn=null; long t1 = System.currentTimeMillis(); try { - conn = (HttpURLConnection) url.openConnection(); conn.setDoOutput(true); conn.setRequestMethod("POST"); - conn.addRequestProperty("Content-Type","application/json"); + conn.addRequestProperty("Content-Type", "application/json"); conn.addRequestProperty("Accept","application/json"); + conn.setConnectTimeout(10 * 1000); // 10s + conn.setReadTimeout(10 * 1000); // 10s + + if (conn.getReadTimeout()!=10*1000) + log.warn("JRE uses a broken timeout mechanism - nothing we can do"); + OutputStream out = conn.getOutputStream();
- String result = mapper.writeValueAsString(operation); + String json_to_send = mapper.writeValueAsString(operation); if (verbose) { - log.info("Json to send: " + result); + log.info("Json to send: " + json_to_send); } mapper.writeValue(out, operation);
@@ -149,6 +164,19 @@ public class ASConnection { } else { log.error("IS was null and code was " + responseCode); } + } catch (IllegalArgumentException iae) { + log.error("Illegal argument " + iae); + log.error(" for input " + operation); + } catch (SocketTimeoutException ste) { + log.error("Request to AS timed out " + ste.getMessage()); + conn.disconnect(); + Result failure = new Result(); + failure.setFailureDescription(ste.getMessage()); + failure.setOutcome("failure"); + failure.setRhqThrowable(ste); + + JsonNode ret = mapper.valueToTree(failure); + return ret;
} catch (IOException e) { log.error("Failed to get data: " + e.getMessage()); @@ -173,7 +201,7 @@ public class ASConnection { Result failure = new Result(); failure.setFailureDescription(e.getMessage()); failure.setOutcome("failure"); - failure.setThrowable(e); + failure.setRhqThrowable(e);
JsonNode ret = mapper.valueToTree(failure); return ret; @@ -183,14 +211,14 @@ public class ASConnection { try { br.close(); } catch (IOException e) { - e.printStackTrace(); // TODO: Customise this generated block + log.error(e.getMessage()); } } if (es != null) { try { es.close(); } catch (IOException e) { - e.printStackTrace(); // TODO: Customise this generated block + log.error(e.getMessage()); } } long t2 = System.currentTimeMillis(); @@ -236,6 +264,9 @@ public class ASConnection {
if (node==null) { log.warn("Operation [" + op + "] returned null"); + Result failure = new Result(); + failure.setFailureDescription("Operation [" + op + "] returned null"); + return failure; } try { Result res; @@ -245,27 +276,16 @@ public class ASConnection { res = mapper.readValue(node, Result.class); return res; } catch (IOException e) { - e.printStackTrace(); // TODO: Customise this generated block + log.error(e.getMessage()); return null; } }
- public void writeValue(OutputStream out, Object value) throws IOException, JsonGenerationException, - JsonMappingException { - // JsonGenerator jgen = _jsonFactory.createJsonGenerator(out, JsonEncoding.UTF8); - // JsonGenerator jgen = mapper.createJsonGenerator(out, JsonEncoding.UTF8); - // JsonGenerator jgen = new Js - // boolean closed = false; - // try { - // writeValue(jgen, value); - // closed = true; - // jgen.close(); - // } finally { - // if (!closed) { - // jgen.close(); - // } - // } - + public String getHost() { + return host; }
+ public int getPort() { + return port; + } } diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASUploadConnection.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASUploadConnection.java index c505b00..90316a4 100644 --- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASUploadConnection.java +++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASUploadConnection.java @@ -26,6 +26,7 @@ import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStream; import java.io.UnsupportedEncodingException; +import java.net.Authenticator; import java.net.HttpURLConnection; import java.net.URL;
@@ -53,17 +54,27 @@ public class ASUploadConnection {
private static final String UPLOAD_URL_PATH = ASConnection.MANAGEMENT + "/add-content";
- private final Log log = LogFactory.getLog(ASUploadConnection.class); + private static final Log log = LogFactory.getLog(ASUploadConnection.class);
+ Authenticator passwordAuthenticator ; BufferedOutputStream os = null; InputStream is = null; private HttpURLConnection connection; private String host; private int port;
- public ASUploadConnection(String dcHost, int port) { + public ASUploadConnection(String dcHost, int port, String user, String password) { this.host = dcHost; this.port = port; + if (user!=null) { + passwordAuthenticator = new AS7Authenticator(user,password); + Authenticator.setDefault(passwordAuthenticator); + } + } + + public ASUploadConnection(ASConnection asConnection) { + this.host=asConnection.getHost(); + this.port=asConnection.getPort(); }
public OutputStream getOutputStream(String fileName) { @@ -71,6 +82,8 @@ public class ASUploadConnection { // Create the HTTP connection to the upload URL String url = "http://" + host + ":" + port + UPLOAD_URL_PATH; connection = (HttpURLConnection) new URL(url).openConnection(); + connection.setConnectTimeout(10 * 1000); // 10s + connection.setReadTimeout(60 * 1000); // 60s connection.setDoInput(true); connection.setDoOutput(true); connection.setRequestMethod(POST_REQUEST_METHOD); @@ -122,7 +135,7 @@ public class ASUploadConnection { log.warn("- no InputStream available -");
} catch (IOException e) { - e.printStackTrace(); // TODO: Customise this generated block + log.error(e); } finally { closeQuietly(is); @@ -191,7 +204,7 @@ public class ASUploadConnection { }
} catch (Exception e) { - e.printStackTrace(); // TODO + log.error(e); return true; } } 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 8736495..c464e4b 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 @@ -24,15 +24,16 @@ import java.io.InputStream;
import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.xpath.XPath; +import javax.xml.xpath.XPathConstants; +import javax.xml.xpath.XPathExpression; +import javax.xml.xpath.XPathExpressionException; +import javax.xml.xpath.XPathFactory;
import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.w3c.dom.Document; -import org.w3c.dom.Element; -import org.w3c.dom.NodeList;
-import org.rhq.core.pluginapi.inventory.ResourceComponent; -import org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent; import org.rhq.core.system.ProcessInfo;
/** @@ -40,14 +41,24 @@ 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 class AbstractBaseDiscovery { 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; private static final String JBOSS_AS_PREFIX = "jboss-as-"; + static final String CALL_READ_STANDALONE_OR_HOST_XML_FIRST = "hostXml is null. You need to call 'readStandaloneOrHostXml' first."; protected Document hostXml; protected final Log log = LogFactory.getLog(this.getClass()); private static final String JBOSS_EAP_PREFIX = "jboss-eap-"; + private XPathFactory factory; + + + + protected AbstractBaseDiscovery() { + synchronized (this) { + factory = XPathFactory.newInstance(); + } + }
/** * Read the host.xml or standalone.xml file depending on isDomainMode. If isDomainMode is true, @@ -58,6 +69,10 @@ public abstract class AbstractBaseDiscovery<T extends ResourceComponent<?>> impl */ protected void readStandaloneOrHostXml(ProcessInfo processInfo, boolean isDomainMode) { String hostXmlFile = getHostXmlFileLocation(processInfo,isDomainMode); + readStandaloneOrHostXmlFromFile(hostXmlFile); + } + + protected void readStandaloneOrHostXmlFromFile(String hostXmlFile) { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); try { DocumentBuilder builder = factory.newDocumentBuilder(); @@ -107,115 +122,80 @@ public abstract class AbstractBaseDiscovery<T extends ResourceComponent<?>> impl */ protected HostPort getManagementPortFromHostXml(String[] commandLine) { if (hostXml==null) - throw new IllegalArgumentException("hostXml is null. You need to call 'readStandaloneOrHostXml' first."); - Element host = hostXml.getDocumentElement(); - NodeList interfaceParent = host.getElementsByTagName("management-interfaces"); - if (interfaceParent ==null || interfaceParent.getLength()==0) { - log.warn("No <management-interfaces> found in host.xml"); - return new HostPort(); - } - NodeList mgmtInterfaces = interfaceParent.item(0).getChildNodes(); - if (mgmtInterfaces==null || mgmtInterfaces.getLength()==0) { - log.warn("No <*-interface> found in host.xml"); - return new HostPort(); + throw new IllegalArgumentException(CALL_READ_STANDALONE_OR_HOST_XML_FIRST); + + String portString; + String interfaceExpession; + + String socketBindingName; + + socketBindingName = obtainXmlPropertyViaXPath( + "//management/management-interfaces/http-interface/socket-binding/@http"); + String socketInterface = obtainXmlPropertyViaXPath( + "//management/management-interfaces/http-interface/socket/@interface"); + + if (!socketInterface.isEmpty()) { + interfaceExpession = obtainXmlPropertyViaXPath( + "//interfaces/interface[@name='" + socketInterface + "']/inet-address/@value"); + portString = obtainXmlPropertyViaXPath( + "//management/management-interfaces/http-interface/socket/@port"); } - for (int i = 0 ; i < mgmtInterfaces.getLength(); i++) { - if (!(mgmtInterfaces.item(i) instanceof Element)) - continue; - - Element mgmtInterface = (Element) mgmtInterfaces.item(i); - if (mgmtInterface.getNodeName().equals("http-interface")) { - String tmp = mgmtInterface.getAttribute("port"); // TODO if we don't find it, check for socket-binding - int port; - if (!tmp.isEmpty()) - port = Integer.valueOf(tmp); - else - port = DEFAULT_MGMT_PORT; - HostPort hp = new HostPort(); - hp.isLocal=true; // TODO adjust when host != localhost - hp.port = port; - - String nIf = mgmtInterface.getAttribute("interface"); - if (!nIf.isEmpty()) - hp.host = getInterface(nIf, commandLine); - else - hp.host = "localhost"; - return hp; - } + else if (socketBindingName.isEmpty()) { + // old AS7.0, early 7.1 style + portString = obtainXmlPropertyViaXPath("//management/management-interfaces/http-interface/@port"); + String interfaceName = obtainXmlPropertyViaXPath( + "//management/management-interfaces/http-interface/@interface"); + interfaceExpession = obtainXmlPropertyViaXPath( + "/server/interfaces/interface[@name='" + interfaceName + "']/inet-address/@value"); } - return new HostPort(); - } + else { + // later AS7.1 and EAP6 standalone.xml + portString = obtainXmlPropertyViaXPath( + "/server/socket-binding-group/socket-binding[@name='" + socketBindingName + "']/@port"); + String interfaceName = obtainXmlPropertyViaXPath( + "/server/socket-binding-group/socket-binding[@name='" + socketBindingName + "']/@interface");
- /** - * Try to obtain the management interface IP from the host/standalone.xml files - * - * @param nIf Interface to look for - * @param commandLine Command line arguments of the process - * @return IP address to use - */ - private String getInterface(String nIf, String[] commandLine) { - if (hostXml==null) - throw new IllegalArgumentException("hostXml is null. You need to call 'readStandaloneOrHostXml' first."); + // TODO the next may also be expressed differently + interfaceExpession = obtainXmlPropertyViaXPath( + "/server/interfaces/interface[@name='" + interfaceName + "']/inet-address/@value");
- Element host = hostXml.getDocumentElement(); - NodeList interfaceParent = host.getElementsByTagName("interfaces"); - if (interfaceParent ==null || interfaceParent.getLength()==0) { - log.warn("No <interfaces> found in host.xml"); - return null; - } - NodeList mgmtInterfaces = interfaceParent.item(0).getChildNodes(); - if (mgmtInterfaces==null || mgmtInterfaces.getLength()==0) { - log.warn("No <*-interface> found in host.xml"); - return null; } - for (int i = 0 ; i < mgmtInterfaces.getLength(); i++) { - if (!(mgmtInterfaces.item(i) instanceof Element)) - continue; - Element mgmtInterface = (Element) mgmtInterfaces.item(i); - if (mgmtInterface.getNodeName().equals("interface")) { - String name = mgmtInterface.getAttribute("name"); - if (!name.equals(nIf)) - continue; - - NodeList nl = mgmtInterface.getChildNodes(); - if (nl!=null) { - for (int j = 0 ; j < nl.getLength(); j++) { - if (!(nl.item(j) instanceof Element)) - continue; - - String nodeName = nl.item(j).getNodeName(); - if (nodeName.equals("any-ipv4-address")) - return "0.0.0.0"; - - String value = ((Element) nl.item(j)).getAttribute("value"); - value = replaceExpression(value, commandLine); - return value; - - // TODO check for <any> and so on - } - } - } + HostPort hp = new HostPort(); + + if (!interfaceExpession.isEmpty()) + hp.host = replaceDollarExpression(interfaceExpession, commandLine, "localhost"); + else + hp.host = "localhost"; // Fallback
+ + if (portString!=null && !portString.isEmpty()) { + String tmp = replaceDollarExpression(portString,commandLine, "9990"); + hp.port = Integer.valueOf(tmp); } - return null; // TODO: Customise this generated block + else + hp.port = 9990; // Fallback to default + return hp; }
+ /** * Check if the passed value has an expression in the form of ${var} or ${var:default}, * try to resolve it. Resolution is done by looking at the command line to see if * there are -bmanagement or -Djboss.bind.address.management arguments present * + * * @param value a hostname or hostname expression * @param commandLine The command line from the process + * @param lastResort * @return resolved value */ - private String replaceExpression(String value, String[] commandLine) { + private String replaceDollarExpression(String value, String[] commandLine, String lastResort) { if (!value.contains("${")) return value;
// remove ${ } value = value.substring(2,value.length()-1); - String fallback = "localhost"; + String fallback = lastResort; String expression; if (value.contains(":")) { int i = value.indexOf(":"); @@ -231,15 +211,27 @@ public abstract class AbstractBaseDiscovery<T extends ResourceComponent<?>> impl * -D jboss.bind.address.management * or * -b management - * to find the management port + * to find the management addresss */
String ret=null; - for (String line: commandLine) { - if (line.contains("-bmanagement") || line.contains("jboss.bind.address.management")) { - ret = line.substring(line.indexOf("=")+1); - break; + for (int i = 0, commandLineLength = commandLine.length; i < commandLineLength; i++) { + String line = commandLine[i]; + if (expression.contains("address")) { + if (line.contains("-bmanagement") || line.contains("jboss.bind.address.management")) { + if (line.contains("=")) + ret = line.substring(line.indexOf("=") + 1); // -bmanagement=1.2.3.4 + else + ret = commandLine[i+1]; // -bmanagement 1.2.3.4 + break; + } + } else if (expression.contains("port")) { + if (line.contains(expression)) { + ret = line.substring(line.indexOf("=") + 1); + break; + } } + } if (ret==null) ret = fallback; @@ -250,12 +242,12 @@ public abstract class AbstractBaseDiscovery<T extends ResourceComponent<?>> impl
/** * Try to determine the host name - that is the name of a standalone server or a - * host in domain mode by looking at the standalone/host.xml files + * host in domain mode by looking at the standalone.xml/host.xml files * @return server name */ protected String findHostName() { if (hostXml==null) - throw new IllegalArgumentException("hostXml is null. You need to call 'readStandaloneOrHostXml' first."); + throw new IllegalArgumentException(CALL_READ_STANDALONE_OR_HOST_XML_FIRST);
String hostName = hostXml.getDocumentElement().getAttribute("name"); return hostName; @@ -267,29 +259,58 @@ public abstract class AbstractBaseDiscovery<T extends ResourceComponent<?>> impl */ protected HostPort getDomainControllerFromHostXml() { if (hostXml==null) - throw new IllegalArgumentException("hostXml is null. You need to call 'readStandaloneOrHostXml' first."); - - Element host = hostXml.getDocumentElement(); - NodeList dcParent = host.getElementsByTagName("domain-controller"); - if (dcParent==null || dcParent.getLength()==0) - return new HostPort(false); - NodeList interfs = dcParent.item(0).getChildNodes(); - for (int i = 0; i < interfs.getLength(); i++) { - if (!(interfs.item(i)instanceof Element)) - continue; - - Element interf = (Element) interfs.item(i); - if (interf.getNodeName().equals("local")) - return new HostPort(); - - // not local, so get the remote - HostPort hp = new HostPort(false); - hp.host = interf.getAttribute("host"); - hp.port = Integer.parseInt(interf.getAttribute("port")); - return hp; + throw new IllegalArgumentException(CALL_READ_STANDALONE_OR_HOST_XML_FIRST); + + + // first check remote, as we can't distinguish between a missing local element or + // and empty one which is the default + String remoteHost = obtainXmlPropertyViaXPath("/host/domain-controller/remote/@host"); + String portString = obtainXmlPropertyViaXPath("/host/domain-controller/remote/@port"); + + HostPort hp; + if (!remoteHost.isEmpty() && !portString.isEmpty()) { + hp = new HostPort(false); + hp.host = remoteHost; + hp.port = Integer.parseInt(portString); + } + else { + hp = new HostPort(true); + hp.port = 9999; }
- return new HostPort(false); + return hp; + + } + + String getManagementSecurtiyRealmFromHostXml() { + if (hostXml==null) + throw new IllegalArgumentException(CALL_READ_STANDALONE_OR_HOST_XML_FIRST); + + String realm = obtainXmlPropertyViaXPath("//management/management-interfaces/http-interface/@security-realm"); + + return realm; + } + + String getSecurityPropertyFileFromHostXml(String baseDir, AS7Mode mode, String realm) { + if (hostXml==null) + throw new IllegalArgumentException(CALL_READ_STANDALONE_OR_HOST_XML_FIRST); + + String fileName = obtainXmlPropertyViaXPath("//security-realms/security-realm[@name='" + realm + "']/authentication/properties/@path"); + String relDir = obtainXmlPropertyViaXPath("//security-realms/security-realm[@name='" + realm + "']/authentication/properties/@relative-to"); + + String dmode; + if (mode==AS7Mode.STANDALONE) + dmode="server"; + else + dmode="domain"; + + String fullName ; + if (relDir.equals("jboss." + dmode + ".config.dir")) + fullName = baseDir + File.separator + mode.getBaseDir() + File.separator + "configuration" + File.separator + fileName; + else + fullName = relDir + File.separator + fileName; + + return fullName; }
/** @@ -332,6 +353,34 @@ public abstract class AbstractBaseDiscovery<T extends ResourceComponent<?>> impl }
/** + * Run the passed xpathExpression on the prepopulated hostXml document and + * return the target element or attribute as a String. + * @param xpathExpression XPath Expression to evaluate + * @return String value of the Element or Attribute the XPath was pointing to. + * Null in case the xpathExpression could not be evaluated. + * @throws IllegalArgumentException if hostXml is null + * + */ + protected String obtainXmlPropertyViaXPath(String xpathExpression) { + if (hostXml==null) + throw new IllegalArgumentException(CALL_READ_STANDALONE_OR_HOST_XML_FIRST); + + + XPath xpath = factory.newXPath(); + try { + XPathExpression expr = xpath.compile(xpathExpression); + + Object result = expr.evaluate(hostXml, XPathConstants.STRING); + + return result.toString(); + } catch (XPathExpressionException e) { + log.error("Evaluation XPath expression failed: " + e.getMessage()); + return null; + } + } + + + /** * Helper class that holds information about the host,port tuple */ protected static class HostPort { 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 0aba2d3..bc0374a 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,8 @@ import java.util.List; import java.util.Map; import java.util.Set;
-public class BaseComponent<T extends ResourceComponent<?>> implements ResourceComponent<T>, MeasurementFacet, ConfigurationFacet, DeleteResourceFacet, +public class BaseComponent<T extends ResourceComponent<?>> implements ResourceComponent<T>, MeasurementFacet, ConfigurationFacet, + DeleteResourceFacet, CreateChildResourceFacet, OperationFacet { private static final String INTERNAL = "_internal:"; @@ -89,6 +90,8 @@ public class BaseComponent<T extends ResourceComponent<?>> implements ResourceCo String host; int port; private boolean verbose = ASConnection.verbose; + String managementUser; + String managementPassword;
/** * Return availability of this resource @@ -99,7 +102,7 @@ public class BaseComponent<T extends ResourceComponent<?>> implements ResourceCo ReadResource op = new ReadResource(address); Result res = connection.execute(op);
- return res.isSuccess()? AvailabilityType.UP: AvailabilityType.DOWN; + return (res!=null && res.isSuccess()) ? AvailabilityType.UP: AvailabilityType.DOWN; }
@@ -115,7 +118,9 @@ public class BaseComponent<T extends ResourceComponent<?>> implements ResourceCo host = pluginConfiguration.getSimpleValue("hostname", LOCALHOST); String portString = pluginConfiguration.getSimpleValue("port", DEFAULT_HTTP_MANAGEMENT_PORT); port = Integer.parseInt(portString); - connection = new ASConnection(host,port); + managementUser = pluginConfiguration.getSimpleValue("user","-unset-"); + managementPassword = pluginConfiguration.getSimpleValue("password","-unset-"); + connection = new ASConnection(host,port, managementUser, managementPassword); } else { connection = ((BaseComponent)context.getParentResourceComponent()).getASConnection(); @@ -164,14 +169,14 @@ public class BaseComponent<T extends ResourceComponent<?>> implements ResourceCo continue; }
- String val = (String) res.getResult(); + Object val = res.getResult(); if (val==null) // One of the AS7 ways of telling "This is not implemented" See also AS7-1454 continue;
if (req.getDataType()== DataType.MEASUREMENT) { if (!val.equals("no metrics available")) { // AS 7 returns this try { - Double d = Double.parseDouble(val); + Double d = Double.parseDouble((String)val); MeasurementDataNumeric data = new MeasurementDataNumeric(req,d); report.addData(data); } catch (NumberFormatException e) { @@ -179,7 +184,14 @@ public class BaseComponent<T extends ResourceComponent<?>> implements ResourceCo } } } else if (req.getDataType()== DataType.TRAIT) { - MeasurementDataTrait data = new MeasurementDataTrait(req,val); + + String realVal; + if (val instanceof String) + realVal = (String)val; + else + realVal = String.valueOf(val); + + MeasurementDataTrait data = new MeasurementDataTrait(req,realVal); report.addData(data); } } @@ -310,7 +322,7 @@ public class BaseComponent<T extends ResourceComponent<?>> implements ResourceCo ContentServices contentServices = cctx.getContentServices(); String resourceTypeName = report.getResourceType().getName();
- ASUploadConnection uploadConnection = new ASUploadConnection(host,port); + ASUploadConnection uploadConnection = new ASUploadConnection(host,port, managementUser, managementPassword); OutputStream out = uploadConnection.getOutputStream(details.getFileName()); contentServices.downloadPackageBitsForChildResource(cctx, resourceTypeName, details.getKey(), out);
@@ -330,13 +342,18 @@ public class BaseComponent<T extends ResourceComponent<?>> implements ResourceCo if (fileName.startsWith("C:\fakepath\")) { // TODO this is a hack as the server adds the fake path somehow fileName=fileName.substring("C:\fakepath\".length()); } - - String tmpName = fileName; // TODO figure out the tmp-name biz with the AS guys + String runtimeName = fileName; + PropertySimple rtNameProp = report.getPackageDetails().getDeploymentTimeConfiguration().getSimple("runtimeName"); + if (rtNameProp != null) { + String rtn = rtNameProp.getStringValue(); + if (rtn!=null && !rtn.isEmpty()) + runtimeName = rtn; + }
JsonNode resultNode = uploadResult.get("result"); String hash = resultNode.get("BYTES_VALUE").getTextValue();
- return runDeploymentMagicOnServer(report, fileName, tmpName, hash); + return runDeploymentMagicOnServer(report, runtimeName, fileName, hash); }
/** @@ -356,7 +373,7 @@ public class BaseComponent<T extends ResourceComponent<?>> implements ResourceCo
ASConnection connection = getASConnection();
- Operation step1 = new Operation("add","deployment",deploymentName); + Operation step1 = new Operation("add","deployment",runtimeName); // step1.addAdditionalProperty("hash", new PROPERTY_VALUE("BYTES_VALUE", hash)); List<Object> content = new ArrayList<Object>(1); Map<String,Object> contentValues = new HashMap<String,Object>(); @@ -418,6 +435,8 @@ public class BaseComponent<T extends ResourceComponent<?>> implements ResourceCo report.setStatus(CreateResourceStatus.SUCCESS); report.setResourceName(runtimeName); report.setResourceKey(resourceKey); + report.getPackageDetails().setSHA256(hash); + report.getPackageDetails().setInstallationTimestamp(System.currentTimeMillis()); log.info(" ... with success and key [" + resourceKey + "]" ); }
@@ -451,7 +470,7 @@ public class BaseComponent<T extends ResourceComponent<?>> implements ResourceCo operation = new Operation(op,theAddress); operation.addAdditionalProperty("profile",profile); } else if (what.equals("server")) { - if (context.getResourceType().getName().equals("JBossAS-Managed")) { + if (context.getResourceType().getName().equals("JBossAS7 Managed Server")) { String host = pluginConfiguration.getSimpleValue("domainHost","local"); theAddress.add("host", host); theAddress.add("server-config", myServerName); @@ -560,11 +579,6 @@ public class BaseComponent<T extends ResourceComponent<?>> implements ResourceCo ((CompositeOperation)operation).addStep(step); } } - } else if (what.equals("naming")) { - if (op.equals("jndi-view")) { - theAddress.add(address); - operation = new Operation("jndi-view",theAddress); - } }
@@ -572,6 +586,11 @@ public class BaseComponent<T extends ResourceComponent<?>> implements ResourceCo if (operation!=null) { Result result = connection.execute(operation);
+ if (result==null) { + operationResult.setErrorMessage("Connection was null - is the server running?"); + return operationResult; + } + if (!result.isSuccess()) { operationResult.setErrorMessage(result.getFailureDescription()); } 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 465e943..46a65a5 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 @@ -41,15 +41,20 @@ import org.rhq.core.domain.configuration.PropertyMap; import org.rhq.core.domain.configuration.PropertySimple; import org.rhq.core.pluginapi.event.log.LogFileEventResourceComponentHelper; import org.rhq.core.pluginapi.inventory.DiscoveredResourceDetails; +import org.rhq.core.pluginapi.inventory.InvalidPluginConfigurationException; +import org.rhq.core.pluginapi.inventory.ManualAddFacet; import org.rhq.core.pluginapi.inventory.ProcessScanResult; import org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent; import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext; import org.rhq.core.system.ProcessInfo; +import org.rhq.modules.plugins.jbossas7.json.Operation; +import org.rhq.modules.plugins.jbossas7.json.ReadAttribute; +import org.rhq.modules.plugins.jbossas7.json.Result;
/** * Discovery class */ -public class BaseProcessDiscovery extends AbstractBaseDiscovery implements ResourceDiscoveryComponent +public class BaseProcessDiscovery extends AbstractBaseDiscovery implements ResourceDiscoveryComponent, ManualAddFacet
{ static final String DORG_JBOSS_BOOT_LOG_FILE = "-Dorg.jboss.boot.log.file="; @@ -67,147 +72,221 @@ public class BaseProcessDiscovery extends AbstractBaseDiscovery implements Resou
for (ProcessScanResult psr : scans) {
- Configuration config = discoveryContext.getDefaultPluginConfiguration(); - // IF SE, then look at domain/configuration/host.xml <management interface="default" port="9990 - // for management port - String[] commandLine = psr.getProcessInfo().getCommandLine(); - String serverNameFull; - String serverName; - String psName = psr.getProcessScan().getName(); - String description = discoveryContext.getResourceType().getDescription(); - String homeDir = getHomeDirFromCommandLine(commandLine); - String version = determineServerVersionFromHomeDir(homeDir); - boolean isEAP = false; - - //retrieve specific boot log file. Override for Standalone as server.log is more appropriate - String bootLogFile = getLogFileFromCommandLine(commandLine); - String logFile = bootLogFile; - - if (homeDir.contains("eap")) { - isEAP=true; - } + try { + Configuration config = discoveryContext.getDefaultPluginConfiguration(); + // IF SE, then look at domain/configuration/host.xml <management interface="default" port="9990 + // for management port + String[] commandLine = psr.getProcessInfo().getCommandLine(); + String serverNameFull; + String serverName; + String psName = psr.getProcessScan().getName(); + String description; + String homeDir = getHomeDirFromCommandLine(commandLine); + String version = determineServerVersionFromHomeDir(homeDir); + boolean isEAP = false; + + //retrieve specific boot log file. Override for Standalone as server.log is more appropriate + String bootLogFile = getLogFileFromCommandLine(commandLine); + String logFile = bootLogFile; + + if (homeDir.contains("eap")) { + isEAP=true; + }
- if (psName.equals("HostController")) { + if (psName.equals("HostController")) { + + readStandaloneOrHostXml(psr.getProcessInfo(), true); + HostPort hp = getDomainControllerFromHostXml(); + if (hp.isLocal) { + serverName = "DomainController"; // TODO make more unique + serverNameFull = "DomainController"; + if (isEAP) + description = "Domain controller for a " + JBOSS_EAP_6 + " domain"; + else + description = "Domain controller for an " + AS7 + " domain"; + } + else { + serverName = "HostController"; // TODO make more unique + serverNameFull = "HostController"; + if (isEAP) + description = "Host controller for a " + JBOSS_EAP_6 + " host"; + else + description = "Host controller for an " + AS7 + " host"; + + } + + config.put(new PropertySimple("baseDir", homeDir)); + config.put(new PropertySimple("startScript", AS7Mode.DOMAIN.getStartScript())); + String host = findHost(psr.getProcessInfo(), true); + config.put(new PropertySimple("domainHost", host)); + + fillUserPassFromFile(config, AS7Mode.DOMAIN, homeDir); + + // provide running config + String domainConfig = getServerConfigFromCommandLine(commandLine, AS7Mode.DOMAIN); + String hostConfig = getServerConfigFromCommandLine(commandLine, AS7Mode.HOST); + config.put(new PropertySimple("domainConfig",domainConfig)); + config.put(new PropertySimple("hostConfig",hostConfig)); + + } else { // Standalone server + serverNameFull = homeDir;
- readStandaloneOrHostXml(psr.getProcessInfo(), true); - HostPort hp = getDomainControllerFromHostXml(); - if (hp.isLocal) { - serverName = "DomainController"; // TODO make more unique - serverNameFull = "DomainController"; - if (isEAP) - description = "Domain controller for a " + JBOSS_EAP_6 + " domain"; - else - description = "Domain controller for an " + AS7 + " domain"; - } - else { - serverName = "HostController"; // TODO make more unique - serverNameFull = "HostController"; if (isEAP) - description = "Host controller for a " + JBOSS_EAP_6 + " host"; + description = "Standalone " + JBOSS_EAP_6 + " server"; else - description = "Host controller for an " + AS7 + " host"; + description = "Standalone " + AS7 + " server";
- } + readStandaloneOrHostXml(psr.getProcessInfo(), false); + if ( serverNameFull.isEmpty()) { + // Try to obtain the server name + // -Dorg.jboss.boot.log.file=domain/servers/server-one/log/boot.log + // This is a hack until I know a better way to do so. + String tmp = getLogFileFromCommandLine(commandLine); + int i = tmp.indexOf("servers/"); + tmp = tmp.substring(i + 8); + tmp = tmp.substring(0, tmp.indexOf("/")); + serverNameFull = tmp;
- config.put(new PropertySimple("baseDir", homeDir)); - config.put(new PropertySimple("startScript", AS7Mode.DOMAIN.getStartScript())); - String host = findHost(psr.getProcessInfo(), true); - config.put(new PropertySimple("domainHost", host)); - - fillUserPassFromFile(config, "domain", homeDir); - - // provide running config - String domainConfig = getServerConfigFromCommandLine(commandLine, AS7Mode.DOMAIN); - String hostConfig = getServerConfigFromCommandLine(commandLine, AS7Mode.HOST); - config.put(new PropertySimple("domainConfig",domainConfig)); - config.put(new PropertySimple("hostConfig",hostConfig)); - - } else { // Standalone server - serverNameFull = homeDir; - - if (isEAP) - description = "Standalone " + JBOSS_EAP_6 + " server"; - else - description = "Standalone " + AS7 + " server"; - - readStandaloneOrHostXml(psr.getProcessInfo(), false); - if ( serverNameFull.isEmpty()) { - // Try to obtain the server name - // -Dorg.jboss.boot.log.file=domain/servers/server-one/log/boot.log - // This is a hack until I know a better way to do so. - String tmp = getLogFileFromCommandLine(commandLine); - int i = tmp.indexOf("servers/"); - tmp = tmp.substring(i + 8); - tmp = tmp.substring(0, tmp.indexOf("/")); - serverNameFull = tmp; + } + String host = findHost(psr.getProcessInfo(), false); + config.put(new PropertySimple("domainHost", host));
- } - String host = findHost(psr.getProcessInfo(), false); - config.put(new PropertySimple("domainHost", host)); + config.put(new PropertySimple("baseDir", serverNameFull));
- config.put(new PropertySimple("baseDir", serverNameFull)); + serverName = findHostName(); + if (serverName.isEmpty()) + serverName = serverNameFull;
- serverName = findHostName(); - if (serverName.isEmpty()) - serverName = serverNameFull;
+ String serverConfig = getServerConfigFromCommandLine(commandLine, AS7Mode.STANDALONE); + config.put(new PropertySimple("config",serverConfig)); + config.put(new PropertySimple("startScript",AS7Mode.STANDALONE.getStartScript()));
- String serverConfig = getServerConfigFromCommandLine(commandLine, AS7Mode.STANDALONE); - config.put(new PropertySimple("config",serverConfig)); - config.put(new PropertySimple("startScript",AS7Mode.STANDALONE.getStartScript())); + fillUserPassFromFile(config, AS7Mode.STANDALONE, serverNameFull);
- fillUserPassFromFile(config, "standalone", serverNameFull); + //preload server.log file for event log monitoring + logFile = bootLogFile.substring(0, bootLogFile.lastIndexOf("/")) + File.separator + "server.log"; + }
- //preload server.log file for event log monitoring - logFile = bootLogFile.substring(0, bootLogFile.lastIndexOf("/")) + File.separator + "server.log"; - } + if (isEAP) { + serverName = "EAP " + serverName; + version="EAP " + version; + }
- if (isEAP) { - serverName = "EAP " + serverName; - version="EAP " + version; + initLogEventSourcesConfigProp(logFile, config); + + HostPort managmentPort = getManagementPortFromHostXml(commandLine); + config.put(new PropertySimple("hostname", managmentPort.host)); + config.put(new PropertySimple("port", managmentPort.port)); + config.put(new PropertySimple("realm",getManagementSecurtiyRealmFromHostXml())); + + // String javaClazz = psr.getProcessInfo().getName(); + + /* + * We'll connect to the discovered VM on the local host, so set the jmx connection + * properties accordingly. This may only work on JDK6+, but then JDK5 is deprecated + * anyway. + */ + // config.put(new PropertySimple(JMXDiscoveryComponent.COMMAND_LINE_CONFIG_PROPERTY, + // javaClazz)); + // config.put(new PropertySimple(JMXDiscoveryComponent.CONNECTION_TYPE, + // LocalVMTypeDescriptor.class.getName())); + // + // // TODO vmid will change when the detected server is bounced - how do we follow this? + // config.put(new PropertySimple(JMXDiscoveryComponent.VMID_CONFIG_PROPERTY,psr.getProcessInfo().getPid())); + + DiscoveredResourceDetails detail = new DiscoveredResourceDetails(discoveryContext.getResourceType(), // ResourceType + serverNameFull, // key TODO distinguish per domain? + serverName, // Name + version, // TODO get via API ? + description, // Description + config, psr.getProcessInfo()); + + // Add to return values + discoveredResources.add(detail); + log.info("Discovered new ... " + discoveryContext.getResourceType() + ", " + serverNameFull); + } catch (Exception e) { + log.warn("Discovery for a " + discoveryContext.getResourceType() + " failed for process " + psr + " :" + e.getMessage()); } - - initLogEventSourcesConfigProp(logFile, config); - - HostPort managmentPort = getManagementPortFromHostXml(commandLine); - config.put(new PropertySimple("hostname", managmentPort.host)); - config.put(new PropertySimple("port", managmentPort.port)); - // String javaClazz = psr.getProcessInfo().getName(); - - /* - * We'll connect to the discovered VM on the local host, so set the jmx connection - * properties accordingly. This may only work on JDK6+, but then JDK5 is deprecated - * anyway. - */ - // config.put(new PropertySimple(JMXDiscoveryComponent.COMMAND_LINE_CONFIG_PROPERTY, - // javaClazz)); - // config.put(new PropertySimple(JMXDiscoveryComponent.CONNECTION_TYPE, - // LocalVMTypeDescriptor.class.getName())); - // - // // TODO vmid will change when the detected server is bounced - how do we follow this? - // config.put(new PropertySimple(JMXDiscoveryComponent.VMID_CONFIG_PROPERTY,psr.getProcessInfo().getPid())); - - DiscoveredResourceDetails detail = new DiscoveredResourceDetails(discoveryContext.getResourceType(), // ResourceType - serverNameFull, // key TODO distinguish per domain? - serverName, // Name - version, // TODO get via API ? - description, // Description - config, psr.getProcessInfo()); - - // Add to return values - discoveredResources.add(detail); - log.info("Discovered new ... " + discoveryContext.getResourceType() + ", " + serverNameFull); }
return discoveredResources;
}
- private void fillUserPassFromFile(Configuration config, String mode, String baseDir) { + /** + * Allow to manually add a (remote) AS7 + * @param pluginConfiguration the plugin configuration that describes how to discover the Resource being manually + * added + * @param context + * @return + * @throws InvalidPluginConfigurationException + */ + @Override + public DiscoveredResourceDetails discoverResource(Configuration pluginConfiguration, + ResourceDiscoveryContext context) throws InvalidPluginConfigurationException { + + String hostname = pluginConfiguration.getSimpleValue("hostname",null); + String portS = pluginConfiguration.getSimpleValue("port",null); + String user = pluginConfiguration.getSimpleValue("user",null); + String pass = pluginConfiguration.getSimpleValue("password",null); + + if (hostname==null || portS==null) { + throw new InvalidPluginConfigurationException("Host and port must not be null"); + } + int port = Integer.valueOf(portS); + + ASConnection connection = new ASConnection(hostname,port, user,pass); + String productVersion = getServerAttribute(connection, "product-version"); + String productName = getServerAttribute(connection,"product-name"); + String releaseVersion = getServerAttribute(connection,"release-version"); + if (productVersion == null) + productVersion = releaseVersion; + if (productName==null) + productName = "AS7"; + + String resourceKey = hostname + ":" + portS + ":" + productName; + String description; + if (productName.contains("EAP")) { + description = "Standalone JBoss Enterprise Application Platform server"; + } else if (productName.contains("EDG")) { + description = "Standalone JBoss Enterprise DataGrid server"; + } + else + description = context.getResourceType().getDescription(); + + pluginConfiguration.put(new PropertySimple("manuallyAdded",true)); + + DiscoveredResourceDetails detail = new DiscoveredResourceDetails( + context.getResourceType(), + resourceKey, + productName + " @ " + hostname + ":" + port, + productVersion, + description, + pluginConfiguration, + null + ); + + return detail; + } + + private String getServerAttribute(ASConnection connection, String attributeName) { + Operation op = new ReadAttribute(null,attributeName); + Result res = connection.execute(op); + if (!res.isSuccess()) { + throw new InvalidPluginConfigurationException("Could not connect to remote server [" + res.getFailureDescription() + "]. Did you enable management?"); + } + return (String) res.getResult(); + } + + private void fillUserPassFromFile(Configuration config, AS7Mode mode, String baseDir) { + +// String configDir = baseDir + File.separator + mode + File.separator + "configuration"; + String realm = getManagementSecurtiyRealmFromHostXml(); + String fileName = getSecurityPropertyFileFromHostXml(baseDir,mode, realm);
- String configDir = baseDir + File.separator + mode + File.separator + "configuration";
- File file = new File(configDir, "mgmt-users.properties"); + File file = new File(fileName); if (!file.exists() || !file.canRead()) { if (log.isDebugEnabled()) log.debug("No console user properties file found at [" + file.getAbsolutePath() @@ -230,11 +309,11 @@ public class BaseProcessDiscovery extends AbstractBaseDiscovery implements Resou String user = line.substring(0, line.indexOf("=")); String pass = line.substring(line.indexOf("=") + 1); config.put(new PropertySimple("user", user)); - config.put(new PropertySimple("password", pass)); +// config.put(new PropertySimple("password", pass)); // this is now hashed, so no point in supplying it
} } catch (IOException e) { - e.printStackTrace(); // TODO: Customise this generated block + log.error(e.getMessage()); } finally { if (br != null) try { @@ -260,7 +339,7 @@ public class BaseProcessDiscovery extends AbstractBaseDiscovery implements Resou is.close(); } } catch (Exception e) { - e.printStackTrace(); // TODO: Customise this generated block + log.error(e.getMessage()); } if (hostName == null) hostName = "local"; // Fallback to the installation default 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 581c4e1..34d849c 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 @@ -19,25 +19,43 @@ package org.rhq.modules.plugins.jbossas7;
import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; import java.net.ConnectException; +import java.security.NoSuchAlgorithmException; import java.util.ArrayList; +import java.util.Date; +import java.util.HashSet; import java.util.List; +import java.util.Properties; +import java.util.Set;
import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory;
+import org.jboss.sasl.util.UsernamePasswordHashUtil; + import org.rhq.core.domain.configuration.Configuration; +import org.rhq.core.domain.configuration.PropertySimple; +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.measurement.MeasurementFacet; import org.rhq.core.pluginapi.operation.OperationResult; import org.rhq.core.pluginapi.util.ProcessExecutionUtility; import org.rhq.core.system.ProcessExecution; import org.rhq.core.system.ProcessExecutionResults; +import org.rhq.modules.plugins.jbossas7.json.Address; +import org.rhq.modules.plugins.jbossas7.json.Operation; +import org.rhq.modules.plugins.jbossas7.json.ReadAttribute; import org.rhq.modules.plugins.jbossas7.json.Result;
/** * Base component for functionality that is common to Standalone AS and HostControllers * @author Heiko W. Rupp */ -public class BaseServerComponent extends BaseComponent { +public class BaseServerComponent extends BaseComponent implements MeasurementFacet {
private static final String SEPARATOR = "\n-----------------------\n"; final Log log = LogFactory.getLog(BaseServerComponent.class); @@ -103,9 +121,13 @@ public class BaseServerComponent extends BaseComponent { } processExecution.setWorkingDirectory(baseDir); processExecution.setCaptureOutput(true); - processExecution.setWaitForCompletion(2000L); // 2 seconds // TODO: Should we wait longer than two seconds? + processExecution.setWaitForCompletion(15000L); // 15 seconds // TODO: Should we wait longer than 15 seconds? processExecution.setKillOnTimeout(false);
+ String javaHomeDir = pluginConfiguration.getSimpleValue("javaHomePath",null); + if (javaHomeDir!=null) { + processExecution.getEnvironmentVariables().put("JAVA_HOME", javaHomeDir); + }
if (log.isDebugEnabled()) { log.debug("About to execute the following process: [" + processExecution + "]"); @@ -114,6 +136,8 @@ public class BaseServerComponent extends BaseComponent { logExecutionResults(results); if (results.getError()!=null) { operationResult.setErrorMessage(results.getError().getMessage()); + } else if (results.getExitCode()!=null) { + operationResult.setErrorMessage("Start failed with error code " + results.getExitCode() + ":\n" + results.getCapturedOutput()); } else { operationResult.setSimpleResult("Success"); } @@ -137,6 +161,11 @@ public class BaseServerComponent extends BaseComponent { */ protected OperationResult postProcessResult(String name, Result res) { OperationResult operationResult = new OperationResult(); + if (res==null) { + operationResult.setErrorMessage("No result received from server"); + return operationResult; + } + if (name.equals("shutdown") || name.equals("reload")) { /* * Shutdown needs a special treatment, because after sending the operation, if shutdown suceeds, @@ -144,7 +173,7 @@ public class BaseServerComponent extends BaseComponent { * reading, this is a good sign. */ if (!res.isSuccess()) { - if (res.getThrowable()!=null && (res.getThrowable() instanceof ConnectException || res.getThrowable().getMessage().equals("Connection refused"))) { + if (res.getRhqThrowable()!=null && (res.getRhqThrowable() instanceof ConnectException || res.getRhqThrowable().getMessage().equals("Connection refused"))) { operationResult.setSimpleResult("Success"); log.debug("Got a ConnectionRefused for operation " + name + " this is considered ok, as the remote server sometimes closes the communications channel before sending a reply"); } @@ -168,4 +197,97 @@ public class BaseServerComponent extends BaseComponent { return operationResult; }
+ protected OperationResult installManagementUser(Configuration parameters, Configuration pluginConfig, AS7Mode mode) { + String user = parameters.getSimpleValue("user",""); + String password = parameters.getSimpleValue("password",""); + + OperationResult result = new OperationResult(); + + PropertySimple remoteProp = pluginConfig.getSimple("manuallyAdded"); + if (remoteProp!=null && remoteProp.getBooleanValue()!= null && remoteProp.getBooleanValue()) { + result.setErrorMessage("This is a manually added server. This operation can not be used to install a management used. Use the server's 'bin/add-user.sh'"); + return result; + } + + if (user.isEmpty() || password.isEmpty()) { + result.setErrorMessage("User and Password must not be empty"); + return result; + } + + String baseDir = pluginConfig.getSimpleValue("baseDir",""); + if (baseDir.isEmpty()) { + result.setErrorMessage("No baseDir found, can not continue"); + return result; + } + String standaloneXmlFile = pluginConfig.getSimpleValue("config",mode.getDefaultXmlFile()); + + String standaloneXml = baseDir + File.separator + mode.getBaseDir() + File.separator + "configuration" + File.separator + standaloneXmlFile; + + AbstractBaseDiscovery abd = new AbstractBaseDiscovery(); + abd.readStandaloneOrHostXmlFromFile(standaloneXml); + + String realm = pluginConfig.getSimpleValue("realm","ManagementRealm"); + String propertiesFilePath = abd.getSecurityPropertyFileFromHostXml(baseDir,mode, realm); + + + Properties p = new Properties(); + try { + UsernamePasswordHashUtil util = new UsernamePasswordHashUtil(); + String value = util.generateHashedHexURP(user, realm, password.toCharArray()); + + + FileInputStream fis = new FileInputStream(propertiesFilePath); + p.load(fis); + fis.close(); + p.setProperty(user,value); + FileOutputStream fos = new FileOutputStream(propertiesFilePath); + p.store(fos,null); + fos.flush(); + fos.close(); + } catch (IOException e) { + log.error(e.getMessage()); + result.setErrorMessage(e.getMessage()); + } catch (NoSuchAlgorithmException nsae) { + log.error(nsae.getMessage()); + result.setErrorMessage(nsae.getMessage()); + } + result.setSimpleResult("User/Password set or updated"); + + return result; + } + + public void getValues(MeasurementReport report, Set metrics) throws Exception { + + Set<MeasurementScheduleRequest> requests = metrics; + Set<MeasurementScheduleRequest> leftovers = new HashSet<MeasurementScheduleRequest>(requests.size()); + + for (MeasurementScheduleRequest request: requests) { + if (request.getName().equals("startTime")) { + String path = getPath(); + if (context.getResourceType().getName().contains("Host Controller")) { + if (path!=null) + path = "host=master," + path ; // TODO is the local controller always on host=master?? AS7-3678 + else + path = "host=master"; + } + Address address = new Address(path); + address.add("core-service","platform-mbean"); + address.add("type","runtime"); + Operation op = new ReadAttribute(address,"start-time"); + Result res = getASConnection().execute(op); + + if (res.isSuccess()) { + Long startTime= (Long) res.getResult(); + MeasurementDataTrait data = new MeasurementDataTrait(request,new Date(startTime).toString()); + report.addData(data); + } + } + else { + leftovers.add(request); + } + } + + super.getValues(report, leftovers); + } + } diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ConfigurationLoadDelegate.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ConfigurationLoadDelegate.java index c844d78..4f72013 100644 --- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ConfigurationLoadDelegate.java +++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ConfigurationLoadDelegate.java @@ -120,6 +120,15 @@ public class ConfigurationLoadDelegate implements ConfigurationFacet { operation = new ReadChildrenResources(address,type); operation.addAdditionalProperty("recursive", "true"); } + else if (groupName.startsWith("child:")) { + String subPath = groupName.substring("child:".length()); + if (!subPath.contains("=")) + throw new IllegalArgumentException("subPath of 'child:' expression has no ="); + + Address address1 = new Address(address); + address1.addSegment(subPath); + operation = new ReadResource(address1); + } else { throw new IllegalArgumentException("Unknown operation in group name [" + groupName + "]"); } @@ -156,21 +165,25 @@ public class ConfigurationLoadDelegate implements ConfigurationFacet { * We may have a mismatch for groups where the <c:group name="children:*"> child is a list of maps * but the result is actually the contained map */ - if (propDef instanceof PropertyDefinitionList && (propDef.getName().equals("*"))) { + String propertyName = propDef.getName(); + if (propDef instanceof PropertyDefinitionList && (propertyName.startsWith("*"))) { propDef = ((PropertyDefinitionList) propDef).getMemberDefinition();
+ String innerPropdefName = propDef.getName(); + if (!(propDef instanceof PropertyDefinitionMap)) { log.error("Embedded child is not a map"); return; } // Now we are at map level which matches the operations results
- PropertyList list = new PropertyList("*"); + PropertyList list = new PropertyList(propertyName);
for (Map.Entry<String,Object> entry : results.entrySet()) { Object val = entry.getValue(); + String key = entry.getKey();
- PropertyMap propertyMap = loadHandlePropertyMap((PropertyDefinitionMap) propDef, val); + PropertyMap propertyMap = loadHandlePropertyMap((PropertyDefinitionMap) propDef, val, key);
if (propertyMap!=null) list.add(propertyMap); @@ -179,7 +192,6 @@ public class ConfigurationLoadDelegate implements ConfigurationFacet { config.put(list);
} else { // standard case - String propertyName = propDef.getName();
Object valueObject = results.get(propertyName); @@ -198,7 +210,7 @@ public class ConfigurationLoadDelegate implements ConfigurationFacet { config.put(propertyList); } else if (propDef instanceof PropertyDefinitionMap) { - PropertyMap propertyMap = loadHandlePropertyMap((PropertyDefinitionMap) propDef, valueObject); + PropertyMap propertyMap = loadHandlePropertyMap((PropertyDefinitionMap) propDef, valueObject, null);
if (propertyMap!=null) config.put(propertyMap); @@ -230,20 +242,35 @@ public class ConfigurationLoadDelegate implements ConfigurationFacet {
/** * Handle a Map of ... + * * @param propDef Definition of the map * @param valueObject the objects to put into the map + * @param optionalEntryName * @return the populated map */ - PropertyMap loadHandlePropertyMap(PropertyDefinitionMap propDef, Object valueObject) { + PropertyMap loadHandlePropertyMap(PropertyDefinitionMap propDef, Object valueObject, String optionalEntryName) { if (valueObject==null) return null;
- PropertyMap propertyMap = new PropertyMap(propDef.getName()); + String propDefName = propDef.getName(); + PropertyMap propertyMap = new PropertyMap(propDefName); + String specialNameProp = null; + if (propDefName.startsWith("*:")) { + specialNameProp = propDefName.substring(2); + PropertySimple additionalNameProperty = new PropertySimple(specialNameProp,optionalEntryName); + propertyMap.put(additionalNameProperty); + }
Map<String, PropertyDefinition> memberDefMap = propDef.getPropertyDefinitions(); + + + Map<String,Object> objects = (Map<String, Object>) valueObject; for (Map.Entry<String, PropertyDefinition> maEntry : memberDefMap.entrySet()) { String key = maEntry.getKey(); + if (key.equals(specialNameProp)) // Skip over specialName prop, as we have processed that already. + continue; + // special case: if the key is "*", we just pick the first element Object o ; if (key.equals("*")) @@ -257,9 +284,9 @@ public class ConfigurationLoadDelegate implements ConfigurationFacet { else if (value instanceof PropertyDefinitionList) property = loadHandlePropertyList((PropertyDefinitionList) value, o); else if (value instanceof PropertyDefinitionMap) - property = loadHandlePropertyMap((PropertyDefinitionMap) value, o); + property = loadHandlePropertyMap((PropertyDefinitionMap) value, o,null); else - throw new IllegalArgumentException("Unknown property type in map property [" + propDef.getName() +"]"); + throw new IllegalArgumentException("Unknown property type in map property [" + propDefName +"]");
if (property!=null) propertyMap.put(property); @@ -311,7 +338,7 @@ public class ConfigurationLoadDelegate implements ConfigurationFacet { Map<String,Object> map = (Map<String, Object>) obj;
PropertyMap propertyMap = loadHandlePropertyMap( - (PropertyDefinitionMap) propDef.getMemberDefinition(), map); + (PropertyDefinitionMap) propDef.getMemberDefinition(), map, null); if (propertyMap!=null) propertyList.add(propertyMap); } diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ConfigurationWriteDelegate.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ConfigurationWriteDelegate.java index e966ba3..fbf0509 100644 --- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ConfigurationWriteDelegate.java +++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ConfigurationWriteDelegate.java @@ -43,6 +43,7 @@ import org.rhq.core.pluginapi.configuration.ConfigurationUpdateReport; import org.rhq.modules.plugins.jbossas7.json.Address; import org.rhq.modules.plugins.jbossas7.json.CompositeOperation; import org.rhq.modules.plugins.jbossas7.json.Operation; +import org.rhq.modules.plugins.jbossas7.json.ReadChildrenResources; import org.rhq.modules.plugins.jbossas7.json.Result; import org.rhq.modules.plugins.jbossas7.json.WriteAttribute;
@@ -50,11 +51,12 @@ public class ConfigurationWriteDelegate implements ConfigurationFacet {
final Log log = LogFactory.getLog(this.getClass());
- private Address address; + private Address _address; private ASConnection connection; private ConfigurationDefinition configurationDefinition; private String namePropLocator; private String type; + private boolean addNewChildren;
/** * Create a new configuration delegate, that reads the attributes for the resource at address. @@ -65,7 +67,7 @@ public class ConfigurationWriteDelegate implements ConfigurationFacet { public ConfigurationWriteDelegate(ConfigurationDefinition configDef, ASConnection connection, Address address) { this.configurationDefinition = configDef; this.connection = connection; - this.address = address; + this._address = address; }
/** @@ -89,7 +91,7 @@ public class ConfigurationWriteDelegate implements ConfigurationFacet {
Configuration conf = report.getConfiguration();
- CompositeOperation cop = updateGenerateOperationFromProperties(conf); + CompositeOperation cop = updateGenerateOperationFromProperties(conf, _address);
Result result = connection.execute(cop); if (!result.isSuccess()) { @@ -103,21 +105,28 @@ public class ConfigurationWriteDelegate implements ConfigurationFacet {
}
- protected CompositeOperation updateGenerateOperationFromProperties(Configuration conf) { + protected CompositeOperation updateGenerateOperationFromProperties(Configuration conf, Address address) {
CompositeOperation cop = new CompositeOperation();
for (PropertyDefinition propDef : configurationDefinition.getNonGroupedProperties()) {
- updateProperty(conf, cop, propDef); + updateProperty(conf, cop, propDef, address); } for (PropertyGroupDefinition pgd: configurationDefinition.getGroupDefinitions()) { String groupName = pgd.getName(); namePropLocator = null; - if (groupName.startsWith("children:")) { + if (groupName.startsWith("children:")) { // children, where the key in key=value from the path is known type = groupName.substring("children:".length()); if (type.contains(":")) { namePropLocator = type.substring(type.indexOf(":") + 1); + if (namePropLocator.endsWith("+")) { // ending in + -> we need to :add new entries + namePropLocator=namePropLocator.substring(0,namePropLocator.length()-1); + addNewChildren = true; + } + else { + addNewChildren = false; + } type = type.substring(0, type.indexOf(":")); } else { @@ -126,8 +135,21 @@ public class ConfigurationWriteDelegate implements ConfigurationFacet { } List<PropertyDefinition> definitions = configurationDefinition.getPropertiesInGroup(groupName); for (PropertyDefinition def : definitions) { - updateProperty(conf,cop,def); + updateProperty(conf,cop,def, address); } + } if (groupName.startsWith("child:")) { // one named child resource + String subPath = groupName.substring("child:".length()); + if (!subPath.contains("=")) + throw new IllegalArgumentException("subPath of 'child:' expression has no ="); + + Address address1 = new Address(address); + address1.addSegment(subPath); + + List<PropertyDefinition> definitions = configurationDefinition.getPropertiesInGroup(groupName); + for (PropertyDefinition def : definitions) { + updateProperty(conf,cop,def, address1); + } +
} // TODO handle attribute: case } @@ -135,58 +157,117 @@ public class ConfigurationWriteDelegate implements ConfigurationFacet { return cop; }
- private void updateProperty(Configuration conf, CompositeOperation cop, PropertyDefinition propDef) { + private void updateProperty(Configuration conf, CompositeOperation cop, PropertyDefinition propDef, + Address baseAddress) {
// Skip over read-only properties, the AS can not use them anyway if (propDef.isReadOnly()) return;
// Handle the special case - if (propDef instanceof PropertyDefinitionList && propDef.getName().equals("*")) { + String propDefName = propDef.getName(); + if (propDef instanceof PropertyDefinitionList && propDefName.startsWith("*")) { propDef = ((PropertyDefinitionList) propDef).getMemberDefinition(); - PropertyList pl = (PropertyList) conf.get("*"); // TODO loop over the list content + PropertyList pl = (PropertyList) conf.get(propDefName); + + // check if we need to see if that property exists - get the current state of affairs from the AS + List<String> existingPropnames = new ArrayList<String>(); + if (addNewChildren) { + Operation op = new ReadChildrenResources(baseAddress,type); + Result tmp = connection.execute(op); + if (tmp.isSuccess()) { + Map<String,Object> tmpResMap = (Map<String, Object>) tmp.getResult(); + existingPropnames.addAll(tmpResMap.keySet()); + } + }
+ // Loop over the list - i.e. the individual rows that come from the server for (Property prop2 : pl.getList()) { - updateHandlePropertyMapSpecial(cop, (PropertyMap) prop2, (PropertyDefinitionMap) propDef); + updateHandlePropertyMapSpecial(cop, (PropertyMap) prop2, (PropertyDefinitionMap) propDef, baseAddress, + existingPropnames); + } + // now check about removed properties + for (String existingName : existingPropnames ) { + boolean found=false; + for (Property prop2 : pl.getList()) { + PropertyMap propMap2 = (PropertyMap) prop2; + String itemName = propMap2.getSimple(namePropLocator).getStringValue(); + if (itemName==null) { + throw new IllegalArgumentException("Map contains no entry with name '" + namePropLocator + "'"); + } + if (itemName.equals(existingName)) { + found=true; + break; + } + } + + if (!found) { + Address tmpAddr = new Address(baseAddress); + tmpAddr.add(type, existingName); + Operation operation = new Operation("remove",tmpAddr); + cop.addStep(operation); + } } + } else { // Normal cases - Property prop = conf.get(propDef.getName()); + Property prop = conf.get(propDefName);
if (prop instanceof PropertySimple) { - updateHandlePropertySimple(cop, (PropertySimple)prop, (PropertyDefinitionSimple) propDef); + updateHandlePropertySimple(cop, (PropertySimple)prop, (PropertyDefinitionSimple) propDef, baseAddress); } else if (prop instanceof PropertyList) { - updateHandlePropertyList(cop, (PropertyList) prop, (PropertyDefinitionList) propDef); + updateHandlePropertyList(cop, (PropertyList) prop, (PropertyDefinitionList) propDef, baseAddress); } else { - updateHandlePropertyMap(cop,(PropertyMap)prop,(PropertyDefinitionMap)propDef); + updateHandlePropertyMap(cop,(PropertyMap)prop,(PropertyDefinitionMap)propDef, baseAddress); } } }
- private void updateHandlePropertyMap(CompositeOperation cop, PropertyMap prop, PropertyDefinitionMap propDef) { - Map<String,Object> results = updateHandleMap(prop,propDef); + private void updateHandlePropertyMap(CompositeOperation cop, PropertyMap prop, PropertyDefinitionMap propDef, + Address address) { + Map<String,Object> results = updateHandleMap(prop,propDef, address); Operation writeAttribute = new WriteAttribute(address,prop.getName(),results); cop.addStep(writeAttribute); }
- private void updateHandlePropertyMapSpecial(CompositeOperation cop, PropertyMap prop, PropertyDefinitionMap propDef) { - Map<String,Object> results = updateHandleMap(prop,propDef); + private void updateHandlePropertyMapSpecial(CompositeOperation cop, PropertyMap prop, PropertyDefinitionMap propDef, + Address address, List<String> existingPropNames) { + Map<String,Object> results = updateHandleMap(prop,propDef, address); if (prop.get(namePropLocator)==null) { throw new IllegalArgumentException("There is no element in the map with the name " + namePropLocator); } String addrVal= ((PropertySimple)prop.get(namePropLocator)).getStringValue(); + + + // determine key from map as propDefName + String key = prop.getSimpleValue(namePropLocator, null); + if (key==null) { + throw new IllegalArgumentException("Map contains no entry with name '" + namePropLocator + "'"); + } + Address addr = new Address(address); addr.add(type,addrVal); for (Map.Entry<String,Object> entry : results.entrySet()) { - Operation writeAttribute = new WriteAttribute(addr,entry.getKey(),entry.getValue()); - cop.addStep(writeAttribute); + Operation operation; + if (!addNewChildren || existingPropNames.contains(key)) + operation = new WriteAttribute(addr,entry.getKey(),entry.getValue()); + else { + Address tmpAddr = new Address(address); + tmpAddr.add(type, key); + operation = new Operation("add",tmpAddr); + operation.addAdditionalProperty("name",key); + operation.addAdditionalProperty("value",entry.getValue()); + } + cop.addStep(operation); } + }
- private void updateHandlePropertyList(CompositeOperation cop, PropertyList prop, PropertyDefinitionList propDef) { + private void updateHandlePropertyList(CompositeOperation cop, PropertyList prop, PropertyDefinitionList propDef, + Address address) { PropertyDefinition memberDef = propDef.getMemberDefinition();
// We need to collect the list members, create an array and attach this to the cop @@ -201,7 +282,8 @@ public class ConfigurationWriteDelegate implements ConfigurationFacet {
} if (memberDef instanceof PropertyDefinitionMap) { - Map<String,Object> mapResult = updateHandleMap((PropertyMap) inner,(PropertyDefinitionMap)memberDef); + Map<String,Object> mapResult = updateHandleMap((PropertyMap) inner,(PropertyDefinitionMap)memberDef, + address); values.add(mapResult); } } @@ -210,7 +292,8 @@ public class ConfigurationWriteDelegate implements ConfigurationFacet { }
- private void updateHandlePropertySimple(CompositeOperation cop, PropertySimple propertySimple, PropertyDefinitionSimple propDef) { + private void updateHandlePropertySimple(CompositeOperation cop, PropertySimple propertySimple, + PropertyDefinitionSimple propDef, Address address) {
// If the property value is null and the property is optional, skip too if (propertySimple.getStringValue()==null && !propDef.isRequired()) @@ -221,7 +304,7 @@ public class ConfigurationWriteDelegate implements ConfigurationFacet { cop.addStep(writeAttribute); }
- private Map<String, Object> updateHandleMap(PropertyMap map, PropertyDefinitionMap mapDef) { + private Map<String, Object> updateHandleMap(PropertyMap map, PropertyDefinitionMap mapDef, Address address) { Map<String,PropertyDefinition> memberDefinitions = mapDef.getPropertyDefinitions();
Map<String,Object> results = new HashMap<String,Object>(); @@ -246,4 +329,4 @@ public class ConfigurationWriteDelegate implements ConfigurationFacet { return results; }
-} \ No newline at end of file +} diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/DatasourceComponent.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/DatasourceComponent.java index 1a44230..0543b81 100644 --- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/DatasourceComponent.java +++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/DatasourceComponent.java @@ -1,26 +1,29 @@ package org.rhq.modules.plugins.jbossas7;
-import java.util.HashMap; import java.util.List; -import java.util.Map;
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; +import org.rhq.core.domain.configuration.PropertyMap; import org.rhq.core.domain.configuration.PropertySimple; +import org.rhq.core.pluginapi.configuration.ConfigurationFacet; +import org.rhq.core.pluginapi.configuration.ConfigurationUpdateReport; import org.rhq.core.pluginapi.operation.OperationFacet; import org.rhq.core.pluginapi.operation.OperationResult; import org.rhq.modules.plugins.jbossas7.json.Address; +import org.rhq.modules.plugins.jbossas7.json.CompositeOperation; import org.rhq.modules.plugins.jbossas7.json.Operation; -import org.rhq.modules.plugins.jbossas7.json.PROPERTY_VALUE; import org.rhq.modules.plugins.jbossas7.json.Result;
/** * Handle JDBC-driver related stuff * @author Heiko W. Rupp */ -public class DatasourceComponent extends BaseComponent implements OperationFacet { +public class DatasourceComponent extends BaseComponent implements OperationFacet, ConfigurationFacet {
private static final String NOTSET = "-notset-"; private final Log log = LogFactory.getLog(DatasourceComponent.class); @@ -55,7 +58,6 @@ public class DatasourceComponent extends BaseComponent implements OperationFacet op = new Operation("add",theAddress); addRequiredToOp(op,parameters,"driver-name"); addRequiredToOp(op,parameters,"jndi-name"); - addRequiredToOp(op, parameters, "pool-name"); addRequiredToOp(op, parameters, "connection-url"); addOptionalToOp(op, parameters, "user-name"); addOptionalToOp(op,parameters,"password"); @@ -65,19 +67,41 @@ public class DatasourceComponent extends BaseComponent implements OperationFacet
Address theAddress = new Address(address); theAddress.add("xa-data-source",name); - op = new Operation("add",theAddress); - addRequiredToOp(op,parameters,"driver-name"); - addRequiredToOp(op,parameters,"jndi-name"); - addRequiredToOp(op,parameters,"pool-name"); - addRequiredToOp(op,parameters,"connection-url"); - addOptionalToOp(op,parameters,"user-name"); - addOptionalToOp(op,parameters,"password"); - addRequiredToOp(op,parameters,"xa-data-source-class"); - - Map<String,Object> props = new HashMap<String, Object>(); // TODO - props.put("_foo","_bar"); // TODO AS7-1209 - op.addAdditionalProperty("xa-data-source-properties",props); - + op = new CompositeOperation(); + Operation step1 = new Operation("add",theAddress); + addRequiredToOp(step1,parameters,"driver-name"); + addRequiredToOp(step1,parameters,"jndi-name"); + addOptionalToOp(step1,parameters,"user-name"); + addOptionalToOp(step1,parameters,"password"); + addRequiredToOp(step1,parameters,"xa-datasource-class"); + + ((CompositeOperation)op).addStep(step1); + + // handling of xa-properties -- this is now a subresource in AS7 and at least needs a connection url + String connectionUrl = parameters.getSimpleValue("connection-url",null); + if (connectionUrl==null || connectionUrl.isEmpty()) + throw new IllegalArgumentException("Connection-url must not be empty"); + Address cuAddress = new Address(theAddress); + cuAddress.add("xa-datasource-properties","connection-url"); + Operation step2 = new Operation("add",cuAddress); + step2.addAdditionalProperty("value",connectionUrl); + ((CompositeOperation)op).addStep(step2); + + + PropertyList xaPropList = parameters.getList("xa-properties"); + if (xaPropList != null) { + List<Property> xaProps = xaPropList.getList(); + for (Property prop : xaProps) { + PropertyMap pMap = (PropertyMap) prop; + PropertySimple keyProp = pMap.getSimple("key"); + PropertySimple valProp = pMap.getSimple("value"); + Address propAddress = new Address(theAddress); + propAddress.add("xa-datasource-properties",keyProp.getStringValue()); + Operation step = new Operation("add",propAddress); + step.addAdditionalProperty("value",valProp.getStringValue()); // TODO ?? + ((CompositeOperation)op).addStep(step); + } + } } else { /* @@ -121,4 +145,22 @@ public class DatasourceComponent extends BaseComponent implements OperationFacet void addOptionalToOp(Operation op, Configuration parameters, String property) { addAdditionalToOp(op,parameters,property,true); } + + @Override + public void updateResourceConfiguration(ConfigurationUpdateReport report) { + + Operation op = new Operation("disable",getAddress()); + Result res = getASConnection().execute(op); + if (!res.isSuccess()) { + report.setErrorMessage("Was not able to disable the datasource for config changes"); + return; + } + + + super.updateResourceConfiguration(report); // TODO: Customise this generated block + + op = new Operation("enable",getAddress()); + res = getASConnection().execute(op); + + } } diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/DeploymentComponent.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/DeploymentComponent.java new file mode 100644 index 0000000..c87b899 --- /dev/null +++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/DeploymentComponent.java @@ -0,0 +1,212 @@ +package org.rhq.modules.plugins.jbossas7; + +import java.io.InputStream; +import java.io.OutputStream; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import org.codehaus.jackson.JsonNode; + +import org.rhq.core.domain.configuration.Configuration; +import org.rhq.core.domain.content.PackageDetailsKey; +import org.rhq.core.domain.content.PackageType; +import org.rhq.core.domain.content.transfer.ContentResponseResult; +import org.rhq.core.domain.content.transfer.DeployIndividualPackageResponse; +import org.rhq.core.domain.content.transfer.DeployPackageStep; +import org.rhq.core.domain.content.transfer.DeployPackagesResponse; +import org.rhq.core.domain.content.transfer.RemovePackagesResponse; +import org.rhq.core.domain.content.transfer.ResourcePackageDetails; +import org.rhq.core.domain.measurement.AvailabilityType; +import org.rhq.core.domain.resource.ResourceType; +import org.rhq.core.pluginapi.content.ContentFacet; +import org.rhq.core.pluginapi.content.ContentServices; +import org.rhq.core.pluginapi.inventory.CreateResourceReport; +import org.rhq.core.pluginapi.operation.OperationFacet; +import org.rhq.core.pluginapi.operation.OperationResult; +import org.rhq.modules.plugins.jbossas7.json.Address; +import org.rhq.modules.plugins.jbossas7.json.ComplexResult; +import org.rhq.modules.plugins.jbossas7.json.Operation; +import org.rhq.modules.plugins.jbossas7.json.PROPERTY_VALUE; +import org.rhq.modules.plugins.jbossas7.json.ReadAttribute; +import org.rhq.modules.plugins.jbossas7.json.ReadChildrenResources; +import org.rhq.modules.plugins.jbossas7.json.Result; + +/** + * Deal with deployments + * @author Heiko W. Rupp + */ +public class DeploymentComponent extends BaseComponent implements OperationFacet, ContentFacet { + + private boolean verbose = ASConnection.verbose; + + @Override + public AvailabilityType getAvailability() { + Operation op = new ReadAttribute(getAddress(),"enabled"); + Result res = getASConnection().execute(op); + if (!res.isSuccess()) + return AvailabilityType.DOWN; + + if (res.getResult()== null || !(Boolean)(res.getResult())) + return AvailabilityType.DOWN; + + return AvailabilityType.UP; + } + + @Override + public OperationResult invokeOperation(String name, + Configuration parameters) throws InterruptedException, Exception { + + String action; + if (name.equals("enable")) { + action = "deploy"; + } else if (name.equals("disable")) { + action = "undeploy"; + } else { + return super.invokeOperation(name, parameters); + } + + Operation op = new Operation(action,getAddress()); + Result res = getASConnection().execute(op); + OperationResult result = new OperationResult(); + if (res.isSuccess()) + result.setSimpleResult("Success"); + else + result.setErrorMessage(res.getFailureDescription()); + + return result; + } + + + @Override + public List<DeployPackageStep> generateInstallationSteps(ResourcePackageDetails packageDetails) { + return new ArrayList<DeployPackageStep>(); + } + + @Override + public DeployPackagesResponse deployPackages(Set<ResourcePackageDetails> packages, + ContentServices contentServices) { + + log.info("Starting deployment.."); + DeployPackagesResponse response = new DeployPackagesResponse(); + + if (packages.size()!=1) { + response.setOverallRequestResult(ContentResponseResult.FAILURE); + response.setOverallRequestErrorMessage("Can only deploy one package at a time"); + log.warn("deployPackages can only deploy one package at a time"); + } + + ResourcePackageDetails detail = packages.iterator().next(); + + ASUploadConnection uploadConnection = new ASUploadConnection(getASConnection()); + OutputStream out = uploadConnection.getOutputStream(detail.getFileName()); + ResourceType resourceType = context.getResourceType(); + + log.info("trying deployment of" + resourceType.getName() + ", key=" + detail.getKey() ); + + contentServices.downloadPackageBits(context.getContentContext(), + detail.getKey(), out, true); + + JsonNode uploadResult = uploadConnection.finishUpload(); + if (verbose) + log.info(uploadResult); + + if (ASUploadConnection.isErrorReply(uploadResult)) { + response.setOverallRequestResult(ContentResponseResult.FAILURE); + response.setOverallRequestErrorMessage(ASUploadConnection.getFailureDescription(uploadResult)); + + return response; + } + JsonNode resultNode = uploadResult.get("result"); + String hash = resultNode.get("BYTES_VALUE").getTextValue(); + + + CreateResourceReport report1 = new CreateResourceReport("", resourceType, new Configuration(), + new Configuration(), detail); + //CreateResourceReport report = runDeploymentMagicOnServer(report1,detail.getKey().getName(),hash, hash); + + try { + redeployOnServer(detail.getKey().getName(), hash); + response.setOverallRequestResult(ContentResponseResult.SUCCESS); + DeployIndividualPackageResponse packageResponse = new DeployIndividualPackageResponse(detail.getKey(), ContentResponseResult.SUCCESS); + response.addPackageResponse(packageResponse); + + } + catch (Exception e) { + response.setOverallRequestResult(ContentResponseResult.FAILURE); + } + + log.info(".. result is " + response); + + return response; + } + + private void redeployOnServer(String name, String hash) throws Exception { + + Operation op = new Operation("full-replace-deployment", new Address()); + op.addAdditionalProperty("name",name); + List<Object> content = new ArrayList<Object>(1); + Map<String,Object> contentValues = new HashMap<String,Object>(); + contentValues.put("hash",new PROPERTY_VALUE("BYTES_VALUE",hash)); + content.add(contentValues); + op.addAdditionalProperty("content",content); + Result result = getASConnection().execute(op); + if (result.isRolledBack()) + throw new Exception(result.getFailureDescription()); + } + + @Override + public RemovePackagesResponse removePackages(Set<ResourcePackageDetails> packages) { + return null; // TODO: Customise this generated block + } + + @Override + public Set<ResourcePackageDetails> discoverDeployedPackages(PackageType type) { + + Set<ResourcePackageDetails> details = new HashSet<ResourcePackageDetails>(); + + // PackageType = "Deployment" + Address address1 = getAddress().getParent(); + Operation op = new ReadChildrenResources(address1,"deployment"); + ComplexResult cres = getASConnection().executeComplex(op); + + if (cres==null) + return details; + + if (!cres.isSuccess()) + return details; + + Map<String,Object> deployments = cres.getResult(); + for (String key : deployments.keySet()) { + Map<String,Object> deployment = (Map<String, Object>) deployments.get(key); + log.info("Discover package [" + key + "] for type [" + type + "]"); + + List<Map> contentList = (List<Map>) deployment.get("content"); // TODO deployments on SG or ManagedServer level have no hash + if (contentList!=null) { + + Map<String,Map> hashMap = contentList.get(0); + Map<String,String> bvMap = hashMap.get("hash"); + String content = bvMap.get("BYTES_VALUE"); + PackageDetailsKey pdKey = new PackageDetailsKey(key, + content, // no way to obtain the user defined version from the server + type.getName(), + "noarch" + ); + ResourcePackageDetails detail = new ResourcePackageDetails(pdKey); + detail.setSHA256(content); + + details.add(detail); + } + } + + return details; + } + + @Override + public InputStream retrievePackageBits(ResourcePackageDetails packageDetails) { + return null; // TODO: Customise this generated block + } +} diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/Domain2Descriptor.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/Domain2Descriptor.java index df5362c..bc7d601 100644 --- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/Domain2Descriptor.java +++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/Domain2Descriptor.java @@ -54,28 +54,47 @@ public class Domain2Descriptor { private void run(String[] args) {
D2DMode mode = null; + String user = null; + String pass = null; + int pos = 0; - if (args[0].startsWith("-")) { - if (args[0].equals("-m")) - mode = D2DMode.METRICS; - else if (args[0].equals("-p")) - mode = D2DMode.PROPERTIES; - else if (args[0].equals("-o")) - mode = D2DMode.OPERATION; - else { - usage(); - return; + boolean optionFound=false; + + String arg; + do { + arg = args[pos]; + if (arg.startsWith("-")) { + if (args[0].equals("-m")) + mode = D2DMode.METRICS; + else if (arg.equals("-p")) + mode = D2DMode.PROPERTIES; + else if (arg.equals("-o")) + mode = D2DMode.OPERATION; + else if (arg.startsWith("-U")) { + String tmp = arg.substring(2); + if (!tmp.contains(":")) + usage(); + user = tmp.substring(0,tmp.indexOf(":")); + pass = tmp.substring(tmp.indexOf(":")+1); + } + else { + usage(); + return; + } + pos++; + optionFound=true; } - pos++; - } + else + optionFound=false; + }while(optionFound);
- String path = args[pos]; + String path = arg; path = path.replaceAll("/",","); // Allow path from jboss-admin.sh's pwd command String childType = null; if (args.length>pos+1) childType = args[pos+1];
- ASConnection conn = new ASConnection("localhost",9990); + ASConnection conn = new ASConnection("localhost",9990, user, pass);
Address address = new Address(path); Operation op = new Operation("read-resource-description",address); @@ -87,6 +106,10 @@ public class Domain2Descriptor { op.addAdditionalProperty("include-runtime",true);
ComplexResult res = conn.executeComplex(op); + if (res==null) { + System.err.println("Got no result"); + return; + } if (!res.isSuccess()) { System.err.println("Failure: " + res.getFailureDescription()); return; @@ -313,6 +336,8 @@ public class Domain2Descriptor { typeString = "long"; break; case BIG_DECIMAL: typeString = "long"; break; // TODO better float or double? + case DOUBLE: + typeString = "long"; break; // TODO float or double? case LIST: typeString = "-list-"; break; // Handled below @@ -412,6 +437,7 @@ public class Domain2Descriptor { System.out.println(" -p create properties (default)"); System.out.println(" -m create metrics"); System.out.println(" -o create operations"); + System.out.println(" -U<user>:<pass> - supply credentials to talk to AS7" ); }
public enum Type { @@ -421,7 +447,8 @@ public class Domain2Descriptor { LONG, BIG_DECIMAL, OBJECT, - LIST + LIST, + DOUBLE
; } diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/DomainDeploymentComponent.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/DomainDeploymentComponent.java new file mode 100644 index 0000000..8db86c7 --- /dev/null +++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/DomainDeploymentComponent.java @@ -0,0 +1,23 @@ +package org.rhq.modules.plugins.jbossas7; + +import org.rhq.core.domain.measurement.AvailabilityType; +import org.rhq.modules.plugins.jbossas7.json.Operation; +import org.rhq.modules.plugins.jbossas7.json.ReadResource; +import org.rhq.modules.plugins.jbossas7.json.Result; + +/** + * Handle domain deployments + * @author Heiko W. Rupp + */ +public class DomainDeploymentComponent extends DeploymentComponent{ + + @Override + public AvailabilityType getAvailability() { + // Domain deployments have no 'enabled' attribute + + Operation op = new ReadResource(getAddress()); + Result res = getASConnection().execute(op); + + return (res!=null && res.isSuccess()) ? AvailabilityType.UP: AvailabilityType.DOWN; + } +} diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/HostControllerComponent.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/HostControllerComponent.java index 6168dad..b46b108 100644 --- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/HostControllerComponent.java +++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/HostControllerComponent.java @@ -39,6 +39,10 @@ public class HostControllerComponent extends BaseServerComponent implements Oper
private final Log log = LogFactory.getLog(HostControllerComponent.class);
+ public Configuration getHCConfig() { + return pluginConfiguration; + } + @Override public OperationResult invokeOperation(String name, Configuration parameters) throws InterruptedException, Exception { @@ -61,6 +65,10 @@ public class HostControllerComponent extends BaseServerComponent implements Oper
return postProcessResult(name,res); } + else if (name.equals("installRhqUser")) { + return installManagementUser(parameters, pluginConfiguration, AS7Mode.HOST); + } +
// Defer other stuff to the base component for now return super.invokeOperation(name, parameters); @@ -109,7 +117,7 @@ public class HostControllerComponent extends BaseServerComponent implements Oper else { report.setErrorMessage(res.getFailureDescription()); report.setStatus(CreateResourceStatus.FAILURE); - report.setException(res.getThrowable()); + report.setException(res.getRhqThrowable()); } return report; } diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/JVMDiscoveryComponent.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/JVMDiscoveryComponent.java new file mode 100644 index 0000000..aa870fb --- /dev/null +++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/JVMDiscoveryComponent.java @@ -0,0 +1,53 @@ +package org.rhq.modules.plugins.jbossas7; + +import java.util.HashSet; +import java.util.Set; + +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.ResourceComponent; +import org.rhq.core.pluginapi.inventory.ResourceContext; +import org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent; +import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext; + +/** + * Discovery component for special treatment of JVMs, which live below server=server-x for managed servers + * @author Heiko W. Rupp + */ +public class JVMDiscoveryComponent extends SubsystemDiscovery { + + @Override + public Set<DiscoveredResourceDetails> discoverResources( + ResourceDiscoveryContext<BaseComponent<?>> context) throws Exception { + + ResourceContext parentContext = context.getParentResourceContext(); + + + if (!parentContext.getResourceType().getName().equals("Managed Server")) + return super.discoverResources(context); + + PropertySimple pathProp = parentContext.getPluginConfiguration().getSimple("path"); + String path = pathProp.getStringValue(); + path = path.replaceAll("server-config=","server="); + path = path + ",core-service=platform-mbean"; + + Configuration config = new Configuration(); + PropertySimple ps = new PropertySimple("path",path); + config.getProperties().add(ps); + + DiscoveredResourceDetails detail = new DiscoveredResourceDetails( + context.getResourceType(), + path, + path, // dname, todo + null, + context.getResourceType().getDescription(), + config, + null + ); + + Set<DiscoveredResourceDetails> discoveredResourceDetails = new HashSet<DiscoveredResourceDetails>(); + discoveredResourceDetails.add(detail); + return discoveredResourceDetails; + } +} diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/JmsComponent.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/JmsComponent.java index ec51a16..99b1a92 100644 --- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/JmsComponent.java +++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/JmsComponent.java @@ -37,7 +37,6 @@ import org.rhq.core.pluginapi.inventory.CreateResourceReport; import org.rhq.modules.plugins.jbossas7.json.Address; import org.rhq.modules.plugins.jbossas7.json.ComplexResult; import org.rhq.modules.plugins.jbossas7.json.Operation; -import org.rhq.modules.plugins.jbossas7.json.PROPERTY_VALUE;
/** * Component class for the JMS subsystem @@ -98,7 +97,7 @@ public class JmsComponent extends BaseComponent { report.setResourceName(report.getUserSpecifiedResourceName()); }
- System.out.println(report); + log.info(report); return report; }
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ManagedASComponent.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ManagedASComponent.java index 77668dc..3873dfc 100644 --- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ManagedASComponent.java +++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ManagedASComponent.java @@ -18,13 +18,16 @@ */ package org.rhq.modules.plugins.jbossas7;
-import java.util.ArrayList; -import java.util.List; + +import java.util.Date; +import java.util.Set;
import org.rhq.core.domain.measurement.AvailabilityType; +import org.rhq.core.domain.measurement.MeasurementDataTrait; +import org.rhq.core.domain.measurement.MeasurementReport; +import org.rhq.core.domain.measurement.MeasurementScheduleRequest; import org.rhq.modules.plugins.jbossas7.json.Address; import org.rhq.modules.plugins.jbossas7.json.Operation; -import org.rhq.modules.plugins.jbossas7.json.PROPERTY_VALUE; import org.rhq.modules.plugins.jbossas7.json.ReadAttribute; import org.rhq.modules.plugins.jbossas7.json.Result;
@@ -44,13 +47,13 @@ public class ManagedASComponent extends BaseComponent { @Override public AvailabilityType getAvailability() {
- if (context.getResourceType().getName().equals("JBossAS-Managed")) { + if (context.getResourceType().getName().equals("Managed Server")) { Address theAddress = new Address(); String host = pluginConfiguration.getSimpleValue("domainHost","local"); theAddress.add("host",host); theAddress.add("server-config", myServerName); Operation getStatus = new ReadAttribute(theAddress,"status"); - Result result = null; + Result result; try { result = connection.execute(getStatus); } catch (Exception e) { @@ -69,4 +72,32 @@ public class ManagedASComponent extends BaseComponent {
return super.getAvailability(); } + + + public void getValues(MeasurementReport report, Set metrics) throws Exception { + + Set<MeasurementScheduleRequest> requests = metrics; + + for (MeasurementScheduleRequest request: requests) { + if (request.getName().equals("startTime")) { + String path = getPath(); + path = path.replace("server-config","server"); + Address address = new Address(path); + address.add("core-service","platform-mbean"); + address.add("type","runtime"); + Operation op = new ReadAttribute(address,"start-time"); + Result res = getASConnection().execute(op); + + if (res.isSuccess()) { + Long startTime= (Long) res.getResult(); + MeasurementDataTrait data = new MeasurementDataTrait(request,new Date(startTime).toString()); + report.addData(data); + } + + } + } + + super.getValues(report, metrics); + } + } diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ManagedASDiscovery.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ManagedASDiscovery.java index 585c2dc..050aef0 100644 --- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ManagedASDiscovery.java +++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ManagedASDiscovery.java @@ -20,14 +20,11 @@ package org.rhq.modules.plugins.jbossas7;
import java.io.File; import java.util.ArrayList; -import java.util.Collections; import java.util.HashSet; import java.util.List; +import java.util.Map; import java.util.Set;
-import org.w3c.dom.Element; -import org.w3c.dom.NodeList; - import org.rhq.core.domain.configuration.Configuration; import org.rhq.core.domain.configuration.PropertyList; import org.rhq.core.domain.configuration.PropertyMap; @@ -35,196 +32,158 @@ import org.rhq.core.domain.configuration.PropertySimple; import org.rhq.core.pluginapi.event.log.LogFileEventResourceComponentHelper; import org.rhq.core.pluginapi.inventory.DiscoveredResourceDetails; import org.rhq.core.pluginapi.inventory.ProcessScanResult; +import org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent; import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext; -import org.rhq.core.system.ProcessInfo; import org.rhq.modules.plugins.jbossas7.json.Address; import org.rhq.modules.plugins.jbossas7.json.ComplexResult; import org.rhq.modules.plugins.jbossas7.json.Operation; -import org.rhq.modules.plugins.jbossas7.json.PROPERTY_VALUE; +import org.rhq.modules.plugins.jbossas7.json.ReadAttribute; +import org.rhq.modules.plugins.jbossas7.json.ReadChildrenNames; import org.rhq.modules.plugins.jbossas7.json.ReadResource; +import org.rhq.modules.plugins.jbossas7.json.Result;
/** * Discovery class for managed AS 7 instances. * * @author Heiko W. Rupp */ -public class ManagedASDiscovery extends AbstractBaseDiscovery +public class ManagedASDiscovery extends AbstractBaseDiscovery implements ResourceDiscoveryComponent
{
+ private HostControllerComponent parentComponent; + /** * Run the auto-discovery */ public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext discoveryContext) throws Exception { Set<DiscoveredResourceDetails> discoveredResources = new HashSet<DiscoveredResourceDetails>();
- List<ProcessScanResult> scans = discoveryContext.getAutoDiscoveredProcesses(); + parentComponent = (HostControllerComponent) discoveryContext.getParentResourceComponent(); + Configuration hcConfig = parentComponent.getHCConfig(); + String hostName = hcConfig.getSimpleValue("domainHost", "master"); // TODO good default? + + HostInfo hostInfo = getHostInfo(hostName); + if (hostInfo==null) + return discoveredResources;
- for (ProcessScanResult psr : scans) {
+ try { // get the HostController, as this is an indicator for managed AS - String psName = psr.getProcessScan().getName(); - if (!psName.equals("HostController")) - continue;
// Now we have the host controller, lets get the host.xml file // and obtain the servers from there. - ProcessInfo processInfo = psr.getProcessInfo(); - readStandaloneOrHostXml(processInfo, true); - String hostName = findHostName(); - HostPort managementHostPort = getManagementPortFromHostXml(processInfo.getCommandLine());
- List<ServerInfo> serverNames = getServersFromHostXml(); + List<ServerInfo> serverNames; + serverNames = getManagedServers(hostName); for (ServerInfo serverInfo : serverNames) {
Configuration config = discoveryContext.getDefaultPluginConfiguration(); config.put(new PropertySimple("domainHost", hostName)); config.put(new PropertySimple("group", serverInfo.group)); - config.put(new PropertySimple("port", managementHostPort.port)); - config.put(new PropertySimple("hostname", managementHostPort.host)); if (serverInfo.bindingGroup != null) { config.put(new PropertySimple("socket-binding-group", serverInfo.bindingGroup)); - config.put(new PropertySimple("socket-binding-port-offset", serverInfo.portOffset)); } else { - HostPort dcHP = getDomainControllerFromHostXml(); - if (dcHP.port == 9999) - dcHP.port = 9990; // TODO Hack until JBAS-9306 is solved + String group = resolveSocketBindingGroup(serverInfo.group); + config.put(new PropertySimple("socket-binding-group",group));
- ServerInfo dcInfo = getBindingsFromDC(dcHP, serverInfo.group); - config.put(new PropertySimple("socket-binding-group", dcInfo.bindingGroup)); - config.put(new PropertySimple("socket-binding-port-offset", dcInfo.portOffset)); } config.put(new PropertySimple("socket-binding-port-offset", serverInfo.portOffset));
String path = "host=" + hostName + ",server-config=" + serverInfo.name; config.put(new PropertySimple("path", path));
- // TODO this fails for the downed servers. // get from the domain or other place as soon as the domain provides it. - String homeDir = getHomeDirFromCommandLine(processInfo.getCommandLine()); - initLogFile(scans, serverInfo.name, config, homeDir); + String serverLog = hcConfig.getSimpleValue("baseDir","/tmp")+File.separator+"domain/servers/"+serverInfo.name+"/log/server.log"; + initLogEventSourcesConfigProp(serverLog,config);
- String version = determineServerVersionFromHomeDir(homeDir); + String version; String resourceDescription;
String resourceName = serverInfo.name;
- if (homeDir.contains("eap")) { - version = "EAP " + version; + if (hostInfo.productName.equalsIgnoreCase("eap")) { + version = "EAP " + hostInfo.productVersion; resourceDescription = "Managed JBoss Enterprise Application Platform 6 server"; resourceName = "EAP " + resourceName; } + else if (hostInfo.productName.equalsIgnoreCase("EDG")) { + version = "EDG " + hostInfo.productVersion; + resourceDescription = "Managed JBoss Enterprise Data Grid 6 server"; + } else { resourceDescription = "Managed AS7 server"; + version = hostInfo.releaseVersion; }
DiscoveredResourceDetails detail = new DiscoveredResourceDetails(discoveryContext.getResourceType(), // ResourceType - hostName + "/" + serverInfo.name, // key - resourceName, // Name - version, // TODO get from Domain as soon as it is provided + hostName + "/" + serverInfo.name, // key + resourceName, // Name + version, // TODO get from Domain as soon as it is provided resourceDescription, // Description - config, null); + config, null);
// Add to return values discoveredResources.add(detail); log.info("Discovered new ... " + discoveryContext.getResourceType() + ", " + serverInfo); } + } catch (Exception e) { + log.warn("Discovery for a " + discoveryContext.getResourceType() + " failed for process " + " :" + e.getMessage()); } return discoveredResources; }
- private ServerInfo getBindingsFromDC(HostPort domainController, String serverGroup) { - ASConnection dcConnection = new ASConnection(domainController.host, domainController.port); - List<PROPERTY_VALUE> address = new ArrayList<PROPERTY_VALUE>(); - Address theAddress = new Address("server-group", serverGroup); - Operation op = new ReadResource(theAddress); - ComplexResult res = (ComplexResult) dcConnection.execute(op, true); - if (res.isSuccess()) { - if (res.getResult().containsKey("socket-binding-group")) { - String sbg = (String) res.getResult().get("socket-binding-group"); - - ServerInfo serverInfo = new ServerInfo(); - serverInfo.bindingGroup = sbg; - return serverInfo; - } - } - - return new ServerInfo(); + private String resolveSocketBindingGroup(String serverGroup) { + Address address = new Address("server-group",serverGroup); + Operation operation = new ReadAttribute(address,"socket-binding-group"); + Result result = parentComponent.getASConnection().execute(operation); + return (String) result.getResult(); }
- /** - * Loop through the Process scans for ManagedAS and if found extract the logfile path. - * @param scans process scan results - * @param name server name to look for - * @param config config to put the info in - * @param basePath - */ - private void initLogFile(List<ProcessScanResult> scans, String name, Configuration config, String basePath) { - - for (ProcessScanResult psr : scans) { - if (!psr.getProcessScan().getName().equals("ManagedAS")) - continue; - - String[] commandLine = psr.getProcessInfo().getCommandLine(); - - //preload server.log file for event log monitoring - String bootLogFile = getLogFileFromCommandLine(commandLine); - String logFile = bootLogFile.substring(0, bootLogFile.lastIndexOf("/")) + File.separator + "server.log"; - - if (logFile.contains(name)) - initLogEventSourcesConfigProp(logFile, config); + private List<ServerInfo> getManagedServers(String domainHost) { + Address address = new Address("host",domainHost); + Operation operation = new ReadChildrenNames(address,"server-config"); + ASConnection connection = parentComponent.getASConnection(); + Result res = connection.execute(operation); + List<String> servers = (List<String>) res.getResult(); + List<ServerInfo> ret = new ArrayList<ServerInfo>(servers.size()); + for (String server : servers) { + ServerInfo info = new ServerInfo(); + info.name = server; + ret.add(info); + + address= new Address("host",domainHost); + address.add("server-config",server); + operation = new ReadResource(address); + ComplexResult cres = connection.executeComplex(operation); + Map<String,Object> map = cres.getResult(); + info.group = (String) map.get("group"); + info.autoStart = (Boolean)map.get("auto-start"); + Integer offset = (Integer) map.get("socket-binding-port-offset"); + if (offset!=null) + info.portOffset = offset; + info.bindingGroup = (String) map.get("socket-binding-group"); } - }
- private List<ServerInfo> getServersFromHostXml() { + return ret; + }
- Element host = hostXml.getDocumentElement(); - NodeList serversElement = host.getElementsByTagName("servers"); - if (serversElement == null || serversElement.getLength() == 0) { - log.warn("No <servers> found in host.xml"); - return Collections.emptyList(); - } - NodeList servers = serversElement.item(0).getChildNodes(); - if (servers == null || servers.getLength() == 0) { - log.warn("No <server> found in host.xml"); - return Collections.emptyList(); - } - List<ServerInfo> result = new ArrayList<ServerInfo>(); - for (int i = 0; i < servers.getLength(); i++) { - if (!(servers.item(i) instanceof Element)) - continue; + private HostInfo getHostInfo(String domainHost) { + Address address = new Address("host",domainHost); + Operation operation = new ReadResource(address); + HostInfo info = new HostInfo();
- ServerInfo info = new ServerInfo(); - Element server = (Element) servers.item(i); - info.name = server.getAttribute("name"); - info.group = server.getAttribute("group"); - String autoStart = server.getAttribute("autoStart"); - if (autoStart == null || autoStart.isEmpty()) - autoStart = "false"; - info.autoStart = Boolean.getBoolean(autoStart); - - // Look for <socket-binding-group ref="standard-sockets" port-offset="250"/> - NodeList sbgs = server.getChildNodes(); - if (sbgs != null) { - for (int j = 0; j < sbgs.getLength(); j++) { - if (!(sbgs.item(j) instanceof Element)) - continue; - - Element sbg = (Element) sbgs.item(j); - if (!sbg.getNodeName().equals("socket-binding-group")) - continue; - - info.bindingGroup = sbg.getAttribute("ref"); - String portOffset = sbg.getAttribute("port-offset"); - if (portOffset != null && !portOffset.isEmpty()) - info.portOffset = Integer.parseInt(portOffset); + ComplexResult cres = parentComponent.getASConnection().executeComplex(operation); + if (!cres.isSuccess()) + return null;
- } - } - result.add(info); - } + Map<String,Object> map = cres.getResult(); + info.releaseCodeName = (String) map.get("release-codename"); + info.releaseVersion = (String)map.get("release-version"); + info.productName = (String) map.get("product-name"); + info.productVersion = (String)map.get("product-version");
- return result; + return info; }
private void initLogEventSourcesConfigProp(String fileName, Configuration pluginConfiguration) { @@ -260,4 +219,11 @@ public class ManagedASDiscovery extends AbstractBaseDiscovery } }
+ private static class HostInfo { + String name; + String productVersion; + String releaseVersion; + String productName; + String releaseCodeName; + } } diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/NamingComponent.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/NamingComponent.java new file mode 100644 index 0000000..e95c512 --- /dev/null +++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/NamingComponent.java @@ -0,0 +1,92 @@ +package org.rhq.modules.plugins.jbossas7; + +import java.util.Map; + +import org.rhq.core.domain.configuration.Configuration; +import org.rhq.core.domain.configuration.PropertyList; +import org.rhq.core.domain.configuration.PropertyMap; +import org.rhq.core.domain.configuration.PropertySimple; +import org.rhq.core.pluginapi.operation.OperationFacet; +import org.rhq.core.pluginapi.operation.OperationResult; +import org.rhq.modules.plugins.jbossas7.json.Address; +import org.rhq.modules.plugins.jbossas7.json.Operation; +import org.rhq.modules.plugins.jbossas7.json.Result; + +/** + * Component for the naming subsystem + * @author Heiko W. Rupp + */ +public class NamingComponent extends BaseComponent implements OperationFacet { + + @Override + public OperationResult invokeOperation(String name, + Configuration parameters) throws InterruptedException, Exception { + + OperationResult result = new OperationResult(); + + Operation operation; + if (name.equals("jndi-view")) { + Address address = new Address(path); + operation = new Operation("jndi-view",address); + Result res = getASConnection().execute(operation); + + if (!res.isSuccess()) { + result.setErrorMessage(res.getFailureDescription()); + return result; + } + + Configuration config = result.getComplexResults(); + + Map<String,Map> contexts = (Map<String, Map>) res.getResult(); + + String entryName = "java: contexts"; + Map<String,Map> javaContexts = contexts.get(entryName); + PropertyList javaContextsMap = fillMap(javaContexts, "java-contexts", false); + config.put(javaContextsMap); + entryName = "applications"; + Map<String,Map> applications = contexts.get(entryName); + PropertyList applicationsMap = fillMap(applications, entryName, true); + config.put(applicationsMap); + + return result; + } + + return super.invokeOperation(name,parameters); + } + + private PropertyList fillMap(Map<String, Map> contexts, String name, boolean isAppCtx) { + PropertyList pl = new PropertyList(name); + for (String entry : contexts.keySet() ) { + Map<String,Object> map = contexts.get(entry); + if (map==null) + continue; + + for (String innerkey : map.keySet()) { + PropertyMap pm = new PropertyMap(name); + pm.put(new PropertySimple("context",entry)); + pm.put(new PropertySimple("name",innerkey)); + Object val = map.get(innerkey); + if (val!=null) { + if (isAppCtx) { + Map<String,Object> cvmap = (Map<String, Object>) val; + if (cvmap.containsKey("AppName")) { + Map<String,String> nameMap = (Map<String, String>) cvmap.get("AppName"); + pm.put(new PropertySimple("value", nameMap.get("value"))); + } + else + pm.put(new PropertySimple("value",val.toString() )); + } + else { + Map<String,String> cvmap = (Map<String, String>) val; + String clazz = cvmap.get("class-name"); + String value = cvmap.get("value"); + pm.put(new PropertySimple("value",clazz + "="+ value)); + } + } + pl.add(pm); + } + } + + return pl; + } +} diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ServerGroupComponent.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ServerGroupComponent.java index c703635..c5a17a8 100644 --- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ServerGroupComponent.java +++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ServerGroupComponent.java @@ -74,7 +74,7 @@ public class ServerGroupComponent extends ManagedASComponent implements ContentF
for (ResourcePackageDetails details : packages) {
- ASUploadConnection uploadConnection = new ASUploadConnection(host,port); + ASUploadConnection uploadConnection = new ASUploadConnection(host,port, super.managementUser, super.managementPassword); String fileName = details.getFileName(); OutputStream out = uploadConnection.getOutputStream(fileName); contentServices.downloadPackageBits(cctx, details.getKey(), out, false); diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/StandaloneASComponent.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/StandaloneASComponent.java index 11a0e4d..f3c3184 100644 --- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/StandaloneASComponent.java +++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/StandaloneASComponent.java @@ -40,6 +40,8 @@ public class StandaloneASComponent extends BaseServerComponent implements Operat } else if (name.equals("restart")) { return restartServer(parameters, AS7Mode.STANDALONE);
+ } else if (name.equals("installRhqUser")) { + return installManagementUser(parameters, pluginConfiguration, AS7Mode.STANDALONE); }
// reload, shutdown go to the remote server diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Address.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Address.java index c0a9196..ad0d6cf 100644 --- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Address.java +++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Address.java @@ -83,11 +83,7 @@ public class Address {
if (tmp.contains("=")) { // strip / from the start of the key if it happens to be there - if (tmp.startsWith("/")) - tmp = tmp.substring(1); - - String[] pair = tmp.split("="); - PROPERTY_VALUE valuePair = new PROPERTY_VALUE(pair[0], pair[1]); + PROPERTY_VALUE valuePair = pathFromSegment(tmp); this.path.add(valuePair); } } @@ -95,6 +91,19 @@ public class Address { }
/** + * Generates a path from a segment in the form of key=value. + * @param segment A segment in the form key=value + * @return A path + */ + private PROPERTY_VALUE pathFromSegment(String segment) { + if (segment.startsWith("/")) + segment = segment.substring(1); + + String[] pair = segment.split("="); + return new PROPERTY_VALUE(pair[0], pair[1]); + } + + /** * Add a key value pair to the path * @param key Key part of this path element * @param value Value part of this path element @@ -103,6 +112,14 @@ public class Address { path.add(new PROPERTY_VALUE(key,value)); }
+ public void addSegment(String segment) { + if (!segment.contains("=")) + throw new IllegalArgumentException("Segment [" + segment + "] contains no '='"); + + PROPERTY_VALUE pv = pathFromSegment(segment); + path.add(pv); + } + @Override public String toString() { StringBuilder builder = new StringBuilder( "Address{" + @@ -178,4 +195,23 @@ public class Address { PROPERTY_VALUE property_value = path.get(n); return property_value.getKey() + "=" + property_value.getValue(); } + + /** + * Return the parent Address of the current one. That is the address with one + * path segment less. + * If the current address is empty (the root), an empty address is returned. + * @return parent Address + */ + public Address getParent() { + Address tmp = new Address(); + int l = path.size(); + if (l<1) + return tmp; + + for (int i = 0; i < l-1 ; i++) { + tmp.path.add(path.get(i)); + } + + return tmp; + } } diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Operation.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Operation.java index 0517ee1..23df1a5 100644 --- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Operation.java +++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Operation.java @@ -47,10 +47,12 @@ public class Operation { this.operation = operation; this.address = new Address(addressKey,addressValue); this._address = address.path; + additionalProperties = new HashMap<String, Object>(); }
public Operation(String operation, Address address) { this.operation = operation; + additionalProperties = new HashMap<String, Object>(); if (address!=null && address.path!=null) { this.address = address; this._address = address.path; diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Result.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Result.java index 42ffee7..da08eb9 100644 --- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Result.java +++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Result.java @@ -40,10 +40,12 @@ public class Result { private boolean success = false; @JsonProperty("rolled-back") private boolean rolledBack = false; + @JsonIgnore + private Throwable rhqThrowable;
/** Record throwsables during low level processing */ @JsonIgnore - private Throwable throwable; + private Map<String,Object> throwable;
public Object getResponseHeaders() { return responseHeaders; @@ -98,14 +100,23 @@ public class Result { this.rolledBack = rolledBack; }
- public Throwable getThrowable() { + public Map<String, Object> getThrowable() { return throwable; }
- public void setThrowable(Throwable throwable) { + public void setThrowable(Map<String,Object> throwable) { this.throwable = throwable; }
+ @JsonIgnore + public Throwable getRhqThrowable() { + return rhqThrowable; + } + + @JsonIgnore + public void setRhqThrowable(Throwable rhqThrowable) { + this.rhqThrowable = rhqThrowable; + }
@Override public String toString() { 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 ffc40bd..94fe410 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 @@ -50,31 +50,11 @@ xmlns:c="urn:xmlns:rhq-configuration" >
- <depends plugin="JMX" useClasses="true"/> -
<!-- TODO I think we should introduce an abstract AS7 plugin that contains some base functionality and then ~~ additional 'Personalities' for the kinds of servers (PM, SM, Standalone AS, Managed AS) -->
- <!-- TODO do we want to show the process controller at all? We have no benefit from it - <server name="ProcessController" - discovery="BaseProcessDiscovery" - class="BaseComponent" - description="Reaper process for other AS7 services" - > - - <plugin-configuration> - <c:simple-property name="hostname" default="localhost" required="true"/> - <c:simple-property name="port" default="9990" type="integer" required="true"/> - - </plugin-configuration> - - <process-scan name="ProcessController" query="process|basename|match=^java.*,arg|org.jboss.as.process-controller|match=.*"/> - - - </server> - --> <server name="JBossAS7 Host Controller" discovery="BaseProcessDiscovery" class="HostControllerComponent" @@ -84,12 +64,16 @@ <plugin-configuration> <c:simple-property name="hostname" default="localhost" required="true" description="Host name of the domain API"/> <c:simple-property name="port" default="9990" type="integer" required="true" description="Port of the domain API"/> - <c:simple-property name="user" type="string" description="Management user for a secured Host controller" required="false"/> - <c:simple-property name="password" type="password" description="Password for the management user" required="false"/> + <c:simple-property name="user" type="string" default="rhqadmin" description="Management user for a secured Host controller" required="false"/> + <c:simple-property name="password" type="password" default="rhqadmin" description="Password for the management user" required="false"/> <c:simple-property name="domainConfig" type="string" default="domain.xml" description="Running configuration (domain part)" displayName="Domain Configuration"/> <c:simple-property name="hostConfig" type="string" default="host.xml" description="Running configuration (host part)" displayName="Host Configuration"/> <c:simple-property name="baseDir" type="file" description="Base directory of the server installation" displayName="Base directory" readOnly="true" required="false"/> <c:simple-property name="startScript" type="file" default="bin/domain.sh" description="Script used to start the server. If the path is not absolute, it is relative to the base directory"/> + <c:simple-property name="javaHomePath" type="file" displayName="JAVA_HOME Path" required="false" + description="The absolute path to a JRE or JDK installation directory containing + the JVM that should be used to start and shutdown the HostController instance; + defaults to the home directory of the RHQ agent JRE."/> <c:simple-property name="domainHost" type="string" readOnly="true" required="false" description="Host name within the AS7 domain"/>
&logSources; @@ -157,7 +141,7 @@ <operation name="managed-server:remove" displayName="Remove managed server" description="Remove a managed server"> <parameters> <c:simple-property name="servername" displayName="Name of the server to remove" required="true"> - <c:option-source target="resource" expression="type=JBossAS-Managed"/> + <c:option-source target="resource" expression="type=Managed Server"/> </c:simple-property> <c:simple-property name="hostname" displayName="Name of the host where the server is on" required="true"> <c:option-source target="resource" expression="type=^Host$ plugin=jboss-as-7"/> @@ -179,6 +163,15 @@ <c:simple-property name="operationResult" description="Outcome of the stop operation"/> </results> </operation> + <operation name="installRhqUser" description="Installs a user in the server for management" displayName="Install RHQ user"> + <parameters> + <c:simple-property name="user" displayName="Username" description="Name of the management user" default="rhqadmin"/> + <c:simple-property name="password" displayName="Password" description="Password of this management user" default="rhqadmin" type="password"/> + </parameters> + <results> + <c:simple-property name="operationResult"/> + </results> + </operation>
<metric property="_internal:mgmtRequests" category="performance" dataType="measurement" defaultInterval="120000" @@ -192,6 +185,12 @@ displayType="summary" measurementType="dynamic" description="Max time for a request since last metric get" units="milliseconds" displayName="Maximum request time"/>
+ <metric property="release-codename" dataType="trait" displayName="Code name of the release" displayType="summary"/> + <metric property="release-version" dataType="trait" displayName="Version of the server" displayType="summary"/> + <metric property="product-name" dataType="trait" displayName="Name of the product"/> + <metric property="product-version" dataType="trait" displayName="Version of the product" displayType="summary"/> + <metric property="startTime" dataType="trait" displayName="Start time of the server" defaultOn="true"/> + <event name="logEntry" description="an entry in a log file"/>
<resource-configuration> @@ -205,12 +204,33 @@ </c:list-property> </c:group> --> + <c:group name="children:system-property:name+" displayName="System-properties"> + <c:list-property name="*2" displayName="Properties" required="false" readOnly="false"> + <c:map-property name="*:name" displayName="Name" readOnly="true"> + <c:simple-property name="name" displayName="Property-Name" readOnly="true"/> + <c:simple-property name="value" displayName="Value"/> + </c:map-property> + </c:list-property> + </c:group>
- <c:group name="children:extension" displayName="Installed extensions"> + <c:group name="children:path:name+" displayName="Path"> + <c:list-property name="*3" displayName="Path" required="false" + description="The standard paths provided by the system include: jboss.home - the root directory of the JBoss AS distribution; user.home - user's home directory; user.dir - user's current working directory; java.home - java installation directory; jboss.server.base.dir - root directory for an individual server instance; jboss.server.data.dir - directory the server will use for persistent data file storage; jboss.server.log.dir - directory the server will use for log file storage; jboss.server.tmp.dir - directory the server will use for temporary file storage; jboss.domain.servers.dir - directory under which a host controller will create the working area for individual server instances"> + <c:map-property name="*" displayName="Entry"> + <c:simple-property name="name" required="true" type="string" readOnly="false" + description="The name of the path. Cannot be one of the standard fixed paths provided by the system"/> + <c:simple-property name="path" required="true" type="string" readOnly="false" + description="The actual filesystem path. Treated as an absolute path, unless the 'relative-to' attribute is specified, in which case the value is treated as relative to that path."/> + <c:simple-property name="relative-to" required="false" type="string" readOnly="false" + description="The name of another previously named path, or of one of the standard paths provided by the system. If 'relative-to' is provided, the value of the 'path' attribute is treated as relative to the path specified by this attribute."/> + </c:map-property> + </c:list-property> + </c:group>
+ <c:group name="children:extension:module" displayName="Installed extensions" hiddenByDefault="true"> <c:list-property name="*" displayName="Installed extensions" readOnly="true" required="false"> <c:map-property name="*" displayName="Name" readOnly="true"> - <c:simple-property name="module" displayName="Module name"/> + <c:simple-property name="module" displayName="Module name" readOnly="true"/> </c:map-property> </c:list-property> </c:group> @@ -265,7 +285,9 @@ <operation name="server:add" displayName="Create server" description="Add a new server to this host."> <parameters> <c:simple-property name="name" description="Name of this new server" required="true"/> - <c:simple-property name="group" displayName="Server Group" description="Server group to put this sever in" default="" required="false"/> + <c:simple-property name="group" displayName="Server Group" description="Server group to put this sever in" default="" required="true"> + <c:option-source target="resource" expression="type=ServerGroup"/> + </c:simple-property> <c:simple-property name="auto-start" displayName="Autostart" description="Should this server start at boot?" type="boolean" default="false" required="true"/> </parameters> <results> @@ -274,16 +296,81 @@ </operation> <operation name="server:remove" displayName="Delete server" description="Deletes a server on this host."> <parameters> - <c:simple-property name="name" description="Name of this new server" required="true"/> + <c:simple-property name="name" description="Name of the server to be removed" required="true"/> </parameters> <results> <c:simple-property name="operationResult" description="Outcome of the delete server operation"/> </results> </operation> + + <resource-configuration> + <c:group name="children:system-property:name+" displayName="System-properties"> + <c:list-property name="*2" displayName="Properties" required="false" readOnly="false"> + <c:map-property name="*:name" displayName="Name" readOnly="true"> + <c:simple-property name="name" displayName="Property-Name" readOnly="true"/> + <c:simple-property name="value" displayName="Value"/> + </c:map-property> + </c:list-property> + </c:group> + <c:group name="children:path:name+" displayName="Path"> + <c:list-property name="*3" displayName="Path" required="false" + description="The standard paths provided by the system include: jboss.home - the root directory of the JBoss AS distribution; user.home - user's home directory; user.dir - user's current working directory; java.home - java installation directory; jboss.server.base.dir - root directory for an individual server instance; jboss.server.data.dir - directory the server will use for persistent data file storage; jboss.server.log.dir - directory the server will use for log file storage; jboss.server.tmp.dir - directory the server will use for temporary file storage; jboss.domain.servers.dir - directory under which a host controller will create the working area for individual server instances"> + <c:map-property name="*" displayName="Entry"> + <c:simple-property name="name" required="true" type="string" readOnly="false" + description="The name of the path. Cannot be one of the standard fixed paths provided by the system"/> + <c:simple-property name="path" required="true" type="string" readOnly="false" + description="The actual filesystem path. Treated as an absolute path, unless the 'relative-to' attribute is specified, in which case the value is treated as relative to that path."/> + <c:simple-property name="relative-to" required="false" type="string" readOnly="false" + description="The name of another previously named path, or of one of the standard paths provided by the system. If 'relative-to' is provided, the value of the 'path' attribute is treated as relative to the path specified by this attribute."/> + </c:map-property> + </c:list-property> + </c:group> + + </resource-configuration> + </server> + + <server name="Managed Server" + discovery="ManagedASDiscovery" + class="ManagedASComponent" + > + <plugin-configuration> + <c:simple-property name="hostname" default="localhost" displayName="Management host" required="true"/> + <c:simple-property name="port" default="9990" type="integer" displayName="Management port" required="true"/> + <c:simple-property name="domainHost" readOnly="true" description="Hostname in the domain"/> + <c:simple-property name="group" readOnly="true" displayName="Server Group" description="Server Group this instance belongs to."/> + <c:simple-property name="socket-binding-group" readOnly="true" displayName="Socket binding group" description="Socket bindings to use" required="false"/> + <c:simple-property name="socket-binding-port-offset" readOnly="true" displayName="Port Offset" type="integer" default="0" description="Offset to the base ports"/> + <c:simple-property name="path" readOnly="true" /> + + &logSources; + </plugin-configuration> + + <operation name="server:start" description="Start this server instance." displayName="Start"> + <results> + <c:simple-property name="operationResult"/> + </results> + </operation> + <operation name="server:stop" description="Stop this server instance." displayName="Stop"> + <results> + <c:simple-property name="operationResult"/> + </results> + </operation> + <operation name="server:restart" description="Restart this server instance." displayName="Restart"> + <results> + <c:simple-property name="operationResult"/> + </results> + </operation> + + <metric property="status" dataType="trait" displayName="Server state" description="Detailed server state" + displayType="summary"/> + <metric property="startTime" dataType="trait" displayName="Start time of the server" defaultOn="true"/> + + <event name="logEntry" description="an entry in a log file"/> + </server>
<service name="DomainDeployment" - class="BaseComponent" + class="DomainDeploymentComponent" discovery="SubsystemDiscovery" createDeletePolicy="both" creationDataType="content"> @@ -323,28 +410,28 @@ </service> </server>
- <server name="JBossAS7-Standalone" + <server name="JBossAS7 Standalone Server" discovery="BaseProcessDiscovery" class="StandaloneASComponent" description="Standalone AS7 server" + supportsManualAdd="true" >
<plugin-configuration> <c:simple-property name="hostname" default="localhost" required="true"/> <c:simple-property name="port" default="9990" type="integer" required="true"/> - <c:simple-property name="user" type="string" description="Management user for a secured AS" required="false"/> - <c:simple-property name="password" type="password" description="Password for the management user" required="false"/> + <c:simple-property name="user" default="rhqadmin" type="string" description="Management user for a secured AS" required="false"/> + <c:simple-property name="password" default="rhqadmin" type="password" description="Password for the management user" required="false"/> <c:simple-property name="config" type="string" default="standalone.xml" description="Running configuration" displayName="Configuration"/> <c:simple-property name="baseDir" type="file" description="Base directory of the server installation" displayName="Base directory" readOnly="true" required="false"/> <c:simple-property name="startScript" type="file" default="bin/standalone.sh" description="Script used to start the server. If the path is not absolute, it is relative to the base directory"/> - <c:list-property name="system-properties"> - <c:map-property name="system-property"> - <c:simple-property name="key" readOnly="true"/> - <c:simple-property name="value" readOnly="true"/> - </c:map-property> - </c:list-property> + <c:simple-property name="javaHomePath" type="file" displayName="JAVA_HOME Path" required="false" + description="The absolute path to a JRE or JDK installation directory containing + the JVM that should be used to start and shutdown the JBossAS instance; + defaults to the home directory of the RHQ agent JRE."/> &logSources;
+<!-- <c:group name="event" displayName="Events"> <c:list-property name="logEventSources"> <c:map-property name="logEventSource"> @@ -379,6 +466,7 @@ </c:map-property> </c:list-property> </c:group> +--> </plugin-configuration>
<process-scan name="StandaloneAS" query="process|basename|match=^java.*,arg|org.jboss.as.standalone|match=.*"/> @@ -404,6 +492,15 @@ <c:simple-property name="operationResult"/> </results> </operation> + <operation name="installRhqUser" description="Installs a user in the server for management" displayName="Install RHQ user"> + <parameters> + <c:simple-property name="user" displayName="Username" description="Name of the management user" default="rhqadmin"/> + <c:simple-property name="password" displayName="Password" description="Password of this management user" default="rhqadmin" type="password"/> + </parameters> + <results> + <c:simple-property name="operationResult"/> + </results> + </operation>
<metric property="_internal:mgmtRequests" category="performance" dataType="measurement" defaultInterval="120000" @@ -416,26 +513,46 @@ displayType="summary" measurementType="dynamic" description="Max time for a request since last metric get" units="milliseconds" displayName="Maximum request time"/>
+ <metric property="server-state" dataType="trait" displayName="Server state" description="Detailed server state" + displayType="summary"/> + <metric property="release-codename" dataType="trait" displayName="Code name of the release" displayType="summary"/> + <metric property="release-version" dataType="trait" displayName="Version of the server" displayType="summary"/> + <metric property="product-name" dataType="trait" displayName="Name of the product"/> + <metric property="product-version" dataType="trait" displayName="Version of the product" displayType="summary"/> + <metric property="startTime" dataType="trait" displayName="Start time of the server" defaultOn="true"/> + <event name="logEntry" description="an entry in a log file"/>
<resource-configuration>
-<!-- - <c:group name="attribute:schema-locations" displayName="Schema locations"> + <c:group name="children:system-property:name+" displayName="System-properties"> + <c:list-property name="*2" displayName="Properties" required="false" readOnly="false"> + <c:map-property name="*:name" displayName="Name" readOnly="true"> + <c:simple-property name="name" displayName="Property-Name" readOnly="true"/> + <c:simple-property name="value" displayName="Value"/> + </c:map-property> + </c:list-property> + </c:group>
- <c:list-property name="schema-locations" displayName="Schema locations" readOnly="true" required="false"> - <c:map-property name="*"> - <c:simple-property name="*" readOnly="true" displayName="Schema name"/> + <c:group name="children:path:name+" displayName="Path"> + <c:list-property name="*3" displayName="Path" required="false" + description="The standard paths provided by the system include: jboss.home - the root directory of the JBoss AS distribution; user.home - user's home directory; user.dir - user's current working directory; java.home - java installation directory; jboss.server.base.dir - root directory for an individual server instance; jboss.server.data.dir - directory the server will use for persistent data file storage; jboss.server.log.dir - directory the server will use for log file storage; jboss.server.tmp.dir - directory the server will use for temporary file storage; jboss.domain.servers.dir - directory under which a host controller will create the working area for individual server instances"> + <c:map-property name="*" displayName="Entry"> + <c:simple-property name="name" required="true" type="string" readOnly="false" + description="The name of the path. Cannot be one of the standard fixed paths provided by the system"/> + <c:simple-property name="path" required="true" type="string" readOnly="false" + description="The actual filesystem path. Treated as an absolute path, unless the 'relative-to' attribute is specified, in which case the value is treated as relative to that path."/> + <c:simple-property name="relative-to" required="false" type="string" readOnly="false" + description="The name of another previously named path, or of one of the standard paths provided by the system. If 'relative-to' is provided, the value of the 'path' attribute is treated as relative to the path specified by this attribute."/> </c:map-property> </c:list-property> </c:group> --->
- <c:group name="children:extension" displayName="Installed extensions"> + <c:group name="children:extension:module" displayName="Installed extensions" hiddenByDefault="true">
- <c:list-property name="*" displayName="Installed extensions" readOnly="true" required="false"> + <c:list-property name="*1" displayName="Installed extensions" readOnly="true" required="false"> <c:map-property name="*" displayName="Name" readOnly="true"> - <c:simple-property name="module" displayName="Module name"/> + <c:simple-property name="module" displayName="Module name" readOnly="true"/> </c:map-property> </c:list-property> </c:group> @@ -445,188 +562,188 @@
</server>
- <server name="JBossAS-Managed" - discovery="ManagedASDiscovery" - class="ManagedASComponent" - > - <plugin-configuration> - <c:simple-property name="hostname" default="localhost" displayName="Management host" required="true"/> - <c:simple-property name="port" default="9990" type="integer" displayName="Management port" required="true"/> - <c:simple-property name="domainHost" readOnly="true" description="Hostname in the domain"/> - <c:simple-property name="group" readOnly="true" displayName="Server Group" description="Server Group this instance belongs to."/> - <c:simple-property name="socket-binding-group" readOnly="true" displayName="Socket binding group" description="Socket bindings to use"/> - <c:simple-property name="socket-binding-port-offset" readOnly="true" displayName="Port Offset" type="integer" default="0" description="Offset to the base ports"/> - <c:simple-property name="path" readOnly="true" />
- &logSources; - <c:group name="event" displayName="Events"> - <c:list-property name="logEventSources"> - <c:map-property name="logEventSource"> - <c:simple-property name="logFilePath" type="file" summary="true" - description="The absolute path to the source log file."/> - <c:simple-property name="enabled" type="boolean" summary="true" - description="A flag indicating whether of not this log Event source is currently - enabled (i.e. whether the associated log file should be tailed for - new entries)."/> - <c:simple-property name="dateFormat" required="false" - description="The date format to use when parsing the dates in log entries. The - format must be in the syntax defined by the Java SimpleDateFormat - class. If not specified, the three date formats that are predefined - by Log4J (ISO8601, DATE, and ABSOLUTE) will be tried."/> - <c:simple-property name="includesPattern" required="false" - description="A regular expression against which a log entry's detail is matched - to determine if an Event should be fired for that entry. If not - specified, no filtering of log entries will be done based on their - detail."/> - <c:simple-property name="minimumSeverity" required="false" default="error" - description="The minimum severity of Events that should be collected for this - source. If not specified, there is no minimum severity (i.e. all - events will be collected)."> - <c:property-options> - <c:option name="debug" value="debug"/> - <c:option name="info" value="info"/> - <c:option name="warn" value="warn"/> - <c:option name="error" value="error"/> - <c:option name="fatal" value="fatal"/> - </c:property-options> - </c:simple-property> - </c:map-property> - </c:list-property> - </c:group> + <server name="JVM" + discovery="JVMDiscoveryComponent" + class="BaseComponent" + description="Information about the underlying JVM" + singleton="true"> + <runs-inside> + <parent-resource-type name="Managed Server" plugin="jboss-as-7"/> + <parent-resource-type name="Host" plugin="jboss-as-7"/> + <parent-resource-type name="JBossAS7 Standalone Server" plugin="jboss-as-7"/> + </runs-inside> + + <plugin-configuration> + <c:simple-property name="path" readOnly="true" default="core-service=platform-mbean"/> </plugin-configuration>
- <!-- Scan for host controller is intentional --> - <process-scan name="HostController" query="process|basename|match=^java.*,arg|org.jboss.as.host-controller|match=.*"/> - <process-scan name="ManagedAS" query="process|basename|match=^java.*,arg|org.jboss.as.server|match=.*"/> + <service name="Operating System" + discovery="SubsystemDiscovery" + class="BaseComponent" + singleton="true" + >
- <operation name="server:start" description="Start this server instance." displayName="Start"> - <results> - <c:simple-property name="operationResult"/> - </results> - </operation> - <operation name="server:stop" description="Stop this server instance." displayName="Stop"> - <results> - <c:simple-property name="operationResult"/> - </results> - </operation> - <operation name="server:restart" description="Restart this server instance." displayName="Restart"> - <results> - <c:simple-property name="operationResult"/> - </results> - </operation> + <plugin-configuration> + <c:simple-property name="path" readOnly="true" default="type=operating-system"/> + </plugin-configuration>
- <metric property="status" dataType="trait" displayName="Server state" description="Detailed server state" - displayType="summary"/> + <metric property="available-processors" + description="The number of processors available to the Java virtual machine."/> + <metric property="system-load-average" + description="The system load average for the last minute. The load average may not be available on some platforms; if the load average is not available, a negative value is returned."/> + </service>
- <event name="logEntry" description="an entry in a log file"/> + <service name="Runtime" + discovery="SubsystemDiscovery" + class="BaseComponent" + singleton="true" + >
- </server> + <plugin-configuration> + <c:simple-property name="path" readOnly="true" default="type=runtime"/> + </plugin-configuration>
+ <metric property="uptime" description="The uptime of the Java virtual machine in milliseconds."/> + </service>
- <server name="JBoss AS JVM" - description="JVM of the JBossAS" - sourcePlugin="JMX" - sourceType="JMX Server" - discovery="org.rhq.plugins.jmx.EmbeddedJMXServerDiscoveryComponent" - class="org.rhq.plugins.jmx.JMXServerComponent" - singleton="true"> - <runs-inside> - <parent-resource-type name="JBossAS-Managed" plugin="jboss-as-7"/> - <parent-resource-type name="JBossAS7-Standalone" plugin="jboss-as-7"/> - </runs-inside> - </server> + <service name="Threading" + discovery="SubsystemDiscovery" + class="BaseComponent" + >
- <server name="Messaging" + <plugin-configuration> + <c:simple-property name="path" readOnly="true" default="type=threading"/> + </plugin-configuration> + + <metric property="thread-count" description="The current number of live threads including both daemon and non-daemon threads."/> + <metric property="peak-thread-count" description="The peak live thread count since the Java virtual machine started or peak was reset."/> + <metric property="total-started-thread-count" description="The total number of threads created and also started since the Java virtual machine started."/> + <metric property="daemon-thread-count" description="The current number of live daemon threads."/> + <metric property="current-thread-cpu-time" description="The total CPU time for the current thread in nanoseconds, or -1 if 'thread-cpu-time-enabled' is 'false'. A Java virtual machine implementation may not support CPU time measurement. If 'thread-cpu-time-supported', is 'false' undefined."/> + <metric property="current-thread-user-time" description="The CPU time that the current thread has executed in user mode in nanoseconds, or -1 if 'thread-cpu-time-enabled' is 'false'. A Java virtual machine implementation may not support CPU time measurement. If 'thread-cpu-time-supported', is 'false' the result will be undefined "/> + + <resource-configuration> + <c:simple-property name="thread-contention-monitoring-enabled" required="false" type="boolean" readOnly="false" description="Whether thread contention monitoring is enabled."/> + <c:simple-property name="thread-cpu-time-enabled" required="false" type="boolean" readOnly="false" description="Whether thread CPU time measurement is enabled."/> + <c:list-property name="all-thread-ids" description="All live thread IDs. If a security manager is installed and the caller does not have ManagementPermission('monitor'), the result will be undefined." readOnly="true"> + <c:simple-property name="all-thread-ids" readOnly="true"/> + </c:list-property> + <c:simple-property name="thread-contention-monitoring-supported" required="false" type="boolean" readOnly="true" description="Whether the Java virtual machine supports thread contention monitoring."/> + <c:simple-property name="thread-cpu-time-supported" required="false" type="boolean" readOnly="true" description="Whether the Java virtual machine implementation supports CPU time measurement for any thread."/> + <c:simple-property name="current-thread-cpu-time-supported" required="false" type="boolean" readOnly="true" description="Whether the Java virtual machine supports CPU time measurement for the current thread."/> + <c:simple-property name="object-monitor-usage-supported" required="false" type="boolean" readOnly="true" description="Whether the Java virtual machine supports monitoring of object monitor usage."/> + <c:simple-property name="synchronizer-usage-supported" required="false" type="boolean" readOnly="true" description="Whether the Java virtual machine supports monitoring of ownable synchronizer usage."/> + </resource-configuration> + </service> + + + + </server> + + <server name="Messaging-Provider" discovery="SubsystemDiscovery" class="BaseComponent" - description="The HornetQ based messaging subsystem" + description="The messaging subsystems" singleton="true" > <runs-inside> <parent-resource-type name="Profile" plugin="jboss-as-7"/> - <parent-resource-type name="JBossAS7-Standalone" plugin="jboss-as-7"/> + <parent-resource-type name="JBossAS7 Standalone Server" plugin="jboss-as-7"/> </runs-inside>
<plugin-configuration> <c:simple-property name="path" readOnly="true" default="subsystem=messaging"/> </plugin-configuration>
- <operation name="destination:add" displayName="Add destination" description="Add a Queue or Topic"> - <parameters> - <c:simple-property name="name" description="Name of the Destination" required="true"/> - <c:list-property name="entries" description="The JNDI names the destination should be bound to." required="true"> - <c:simple-property name="entry" description="A single JNDI name. Note, this is relative to java:jboss/jms/"/> - </c:list-property> - <c:simple-property name="type" description="Type of Destination to create" default="Queue"> - <c:property-options> - <c:option value="jms-queue" name="Queue"/> - <c:option value="jms-topic" name="Topic"/> - </c:property-options> - </c:simple-property> - <c:simple-property name="durable" description="Defines whether the queue is durable (for Queues only)." type="boolean" default="false"/> - </parameters> - <results> - <c:simple-property name="operationResult"/> - </results> - </operation> - <operation name="destination:remove" displayName="Remove Destination" description="Remove a destination"> - <parameters> - <c:simple-property name="name" description="Name of the Destination" required="true"/> - </parameters> - <results> - <c:simple-property name="operationResult"/> - </results> - </operation> - - <resource-configuration> - <c:simple-property name="journal-min-files" /> - <c:simple-property name="journal-type" /> - </resource-configuration> + <server name="HornetQ" + discovery="SubsystemDiscovery" + class="BaseComponent" + description="The HornetQ based messaging subsystem" + >
- <service name="JMS Queue" - discovery="SubsystemDiscovery" - class="JmsComponent" - createDeletePolicy="delete-only" - > <plugin-configuration> - <c:simple-property name="path" readOnly="true" default="jms-queue"/> + <c:simple-property name="path" readOnly="true" default="hornetq-server"/> </plugin-configuration>
+ + <operation name="destination:add" displayName="Add destination" description="Add a Queue or Topic"> + <parameters> + <c:simple-property name="name" description="Name of the Destination" required="true"/> + <c:list-property name="entries" description="The JNDI names the destination should be bound to." required="true"> + <c:simple-property name="entry" description="A single JNDI name. Note, this is relative to java:jboss/jms/"/> + </c:list-property> + <c:simple-property name="type" description="Type of Destination to create" default="Queue"> + <c:property-options> + <c:option value="jms-queue" name="Queue"/> + <c:option value="jms-topic" name="Topic"/> + </c:property-options> + </c:simple-property> + <c:simple-property name="durable" description="Defines whether the queue is durable (for Queues only)." type="boolean" default="false"/> + </parameters> + <results> + <c:simple-property name="operationResult"/> + </results> + </operation> + <operation name="destination:remove" displayName="Remove Destination" description="Remove a destination"> + <parameters> + <c:simple-property name="name" description="Name of the Destination" required="true"/> + </parameters> + <results> + <c:simple-property name="operationResult"/> + </results> + </operation> + <resource-configuration> - <c:simple-property name="durable" required="false" type="boolean" readOnly="true" default="false" - description="Whether the queue is durable or not."/> - <c:list-property name="entries" required="false" readOnly="true" - description="The jndi names the queue will be bound to."> - <c:simple-property name="entries" type="string"/> - </c:list-property> - <c:simple-property name="selector" required="false" type="string" readOnly="true" description="The queue selector."/> - </resource-configuration> - </service> - <service name="JMS Topic" - discovery="SubsystemDiscovery" - class="JmsComponent" - createDeletePolicy="delete-only" - > - <plugin-configuration> - <c:simple-property name="path" readOnly="true" default="jms-topic"/> - </plugin-configuration> - <resource-configuration> - <c:list-property name="entries" required="false" readOnly="true" - description="The jndi names the queue will be bound to."> - <c:simple-property name="entries" type="string"/> - </c:list-property> + <c:simple-property name="journal-min-files" /> + <c:simple-property name="journal-type" /> </resource-configuration> - </service> - <service name="Connection-Factory" - discovery="SubsystemDiscovery" - class="JmsComponent" - createDeletePolicy="both" - > - <plugin-configuration> - <c:simple-property name="path" readOnly="true" default="connection-factory"/> - </plugin-configuration> - </service>
+ <service name="JMS Queue" + discovery="SubsystemDiscovery" + class="JmsComponent" + createDeletePolicy="delete-only" + > + <plugin-configuration> + <c:simple-property name="path" readOnly="true" default="jms-queue"/> + </plugin-configuration> + + <resource-configuration> + <c:simple-property name="durable" required="false" type="boolean" readOnly="true" default="false" + description="Whether the queue is durable or not."/> + <c:list-property name="entries" required="false" readOnly="true" + description="The jndi names the queue will be bound to."> + <c:simple-property name="entries" type="string"/> + </c:list-property> + <c:simple-property name="selector" required="false" type="string" readOnly="true" description="The queue selector."/> + </resource-configuration> + </service> + <service name="JMS Topic" + discovery="SubsystemDiscovery" + class="JmsComponent" + createDeletePolicy="delete-only" + > + <plugin-configuration> + <c:simple-property name="path" readOnly="true" default="jms-topic"/> + </plugin-configuration> + <resource-configuration> + <c:list-property name="entries" required="false" readOnly="true" + description="The jndi names the queue will be bound to."> + <c:simple-property name="entries" type="string"/> + </c:list-property> + </resource-configuration> + </service> + <service name="Connection-Factory" + discovery="SubsystemDiscovery" + class="JmsComponent" + createDeletePolicy="both" + > + <plugin-configuration> + <c:simple-property name="path" readOnly="true" default="connection-factory"/> + </plugin-configuration> + </service> + + </server> </server>
<server name="JBossWeb" @@ -637,7 +754,7 @@
<runs-inside> <parent-resource-type name="Profile" plugin="jboss-as-7"/> - <parent-resource-type name="JBossAS7-Standalone" plugin="jboss-as-7"/> + <parent-resource-type name="JBossAS7 Standalone Server" plugin="jboss-as-7"/> </runs-inside>
<plugin-configuration> @@ -649,61 +766,64 @@ description="The web container's default virtual server."/> <c:simple-property name="native" required="false" type="boolean" readOnly="true" defaultValue="true" description="Add the native initialization listener to the web container."/> - <c:map-property name="configuration" description="The common web container configuration." > - <c:map-property name="static-resources" description="Configuration for static resources" > - <c:simple-property name="listings" required="false" type="boolean" readOnly="true" defaultValue="false" + <c:simple-property name="instance-id" readOnly="true" required="false" type="string" description="The identifier for this server instance."/> + <c:group name="child:configuration=static-resources" displayName="Static Resources" > + <c:simple-property name="listings" required="false" type="boolean" defaultValue="false" description="Enable folder listings."/> - <c:simple-property name="sendfile" required="false" type="integer" readOnly="true" defaultValue="49152" + <c:simple-property name="sendfile" required="false" type="integer" defaultValue="49152" description="Enable sendfile if possible, for files bigger than the specified byte size."/> - <c:simple-property name="read-only" required="false" type="boolean" readOnly="true" defaultValue="true" + <c:simple-property name="file-encoding" required="false" description="Force a file encoding." type="string"/> + <c:simple-property name="read-only" required="false" type="boolean" defaultValue="true" description="Allow write HTTP methods (PUT, DELETE)."/> - <c:simple-property name="webdav" required="false" type="boolean" readOnly="true" defaultValue="false" + <c:simple-property name="webdav" required="false" type="boolean" defaultValue="false" description="Enable WebDAV functionality."/> <c:simple-property name="secret" required="false" type="string" readOnly="true" description="Secret for WebDAV locking operations."/> - <c:simple-property name="max-depth" required="false" type="integer" readOnly="true" defaultValue="3" + <c:simple-property name="max-depth" required="false" type="integer" defaultValue="3" description="Maximum recursion for PROPFIND."/> - <c:simple-property name="disabled" required="false" type="boolean" readOnly="true" defaultValue="false" + <c:simple-property name="disabled" required="false" type="boolean" defaultValue="false" + description="Enable the default Servlet mapping."/> + </c:group> + <c:group name="child:configuration=jsp-configuration" displayName="JSP Configuration"> + <c:simple-property name="development" required="false" type="boolean" default="false" + description="Enable the development mode, which gives more information when an error occurs. And also enables automatic JSP recompiles."/> + <c:simple-property name="disabled" required="false" type="boolean" defaultValue="false" description="Enable the JSP container."/> - </c:map-property> - <c:map-property name="jsp-configuration" description="JSP container configuration"> - <c:simple-property name="development" required="false" type="boolean" readOnly="true" defaultValue="false" - description="Enable the development mode, which gives more information when an error occurs."/> - <c:simple-property name="file-encoding" required="false" type="string" readOnly="true" description="Force a file encoding."/> - <c:simple-property name="keep-generated" required="false" type="boolean" readOnly="true" defaultValue="true" + <c:simple-property name="keep-generated" required="false" type="boolean" defaultValue="true" description="Keep the generated Servlets."/> <c:simple-property name="trim-spaces" required="false" type="boolean" readOnly="true" defaultValue="true" - description="Trim some spaces from the generated Servlet."/> - <c:simple-property name="tag-pooling" required="false" type="boolean" readOnly="true" defaultValue="true" + description="Trim some spaces from the generated Servlet."/> <!-- TODO make r/w when https://issues.jboss.org/browse/AS7-3097 is solved --> + <c:simple-property name="tag-pooling" required="false" type="boolean" defaultValue="true" description="Enable tag pooling."/> - <c:simple-property name="mapped-file" required="false" type="boolean" readOnly="true" defaultValue="true" + <c:simple-property name="mapped-file" required="false" type="boolean" defaultValue="true" description="Map to the JSP source."/> - <c:simple-property name="check-interval" required="false" type="integer" readOnly="true" defaultValue="0" - description="Check interval for JSP updates using a background thread."/> - <c:simple-property name="modification-test-interval" required="false" type="integer" readOnly="true" defaultValue="4" + <c:simple-property name="check-interval" required="false" type="integer" defaultValue="60" + description="Check interval in seconds for JSP updates using a background thread."/> <!-- TODO revisit default when https://issues.jboss.org/browse/AS7-3098 is fixed --> + <c:simple-property name="modification-test-interval" required="false" type="integer" defaultValue="4" description="Minimum amount of time between two tests for updates, in seconds."/> - <c:simple-property name="recompile-on-fail" required="false" type="boolean" readOnly="true" defaultValue="false" + <c:simple-property name="recompile-on-fail" required="false" type="boolean" defaultValue="false" description="Retry failed JSP compilations on each request."/> - <c:simple-property name="smap" required="false" type="boolean" readOnly="true" defaultValue="false" + <c:simple-property name="smap" required="false" type="boolean" defaultValue="false" description="Enable SMAP."/> - <c:simple-property name="dump-smap" required="false" type="boolean" readOnly="true" defaultValue="false" + <c:simple-property name="dump-smap" required="false" type="boolean" defaultValue="false" description="Write SMAP data to a file."/> - <c:simple-property name="generate-strings-as-char-arrays" required="false" type="boolean" readOnly="true" + <c:simple-property name="generate-strings-as-char-arrays" required="false" type="boolean" defaultValue="false" description="Generate String constants as char arrays."/> - <c:simple-property name="error-on-use-bean-invalid-class-attribute" required="false" type="boolean" readOnly="true" defaultValue="false" + <c:simple-property name="error-on-use-bean-invalid-class-attribute" required="false" type="boolean" defaultValue="false" description="Enable errors when using a bad class in useBean."/> - <c:simple-property name="scratch-dir" required="false" type="string" readOnly="true" description="Specify a different work directory."/> - <c:simple-property name="source-vm" required="false" type="string" readOnly="true" defaultValue="1.5" + <c:simple-property name="scratch-dir" required="false" type="string" description="Specify a different work directory."/> + <c:simple-property name="source-vm" required="false" type="string" defaultValue="1.5" description="Source VM level for compilation."/> - <c:simple-property name="target-vm" required="false" type="string" readOnly="true" defaultValue="1.5" + <c:simple-property name="target-vm" required="false" type="string" defaultValue="1.5" description="Target VM level for compilation."/> - <c:simple-property name="java-encoding" required="false" type="string" readOnly="true" defaultValue="UTF-8" + <c:simple-property name="java-encoding" required="false" type="string" defaultValue="UTF-8" description="Specify the encoding used for Java sources."/> - <c:simple-property name="x-powered-by" required="false" type="boolean" readOnly="true" defaultValue="true" + <c:simple-property name="x-powered-by" required="false" type="boolean" defaultValue="true" description="Enable advertising the JSP engine in x-powered-by."/> - <c:simple-property name="display-source-fragment" required="false" type="boolean" readOnly="true" defaultValue="true" + <c:simple-property name="display-source-fragment" required="false" type="boolean" defaultValue="true" description="When a runtime error occurs, attempts to display corresponding JSP source fragment."/> - </c:map-property> + </c:group> + <!-- <c:group name="child:configuration=container" displayName="Container"> <c:list-property name="mime-mapping" description="A mime-mapping definition." > <c:map-property name="mime-mapping" > <c:simple-property name="name" description="A MIME mapping name"/> @@ -713,8 +833,8 @@ <c:list-property name="welcome-file" description="A welcome file declaration." > <c:simple-property name="welcome-file" /> </c:list-property> - </c:map-property> - </resource-configuration> + </c:group> +--> </resource-configuration>
<service name="Connector" discovery="SubsystemDiscovery" @@ -726,41 +846,41 @@ </plugin-configuration>
- <metric property="bytesSent" measurementType="trendsup"/> - <metric property="bytesReceived" measurementType="trendsup"/> - <metric property="processingTime" measurementType="trendsup" units="milliseconds"/> - <metric property="errorCount" measurementType="trendsup" displayType="summary"/> - <metric property="maxTime" units="milliseconds"/> - <metric property="requestCount" measurementType="trendsup" displayType="summary"/> + <metric property="bytesSent" measurementType="trendsup" description="Number of byte sent by the connector."/> + <metric property="bytesReceived" measurementType="trendsup" description="Number of byte received by the connector (POST data)."/> + <metric property="processingTime" measurementType="trendsup" units="milliseconds" description="Processing time used by the connector. Im milli-seconds."/> + <metric property="errorCount" measurementType="trendsup" displayType="summary" description="Number of error that occurs when processing requests by the connector."/> + <metric property="maxTime" units="milliseconds" description="Max time spent to process a requests."/> + <metric property="requestCount" measurementType="trendsup" displayType="summary" description="Number of the request processed by the connector."/>
<resource-configuration> - <c:simple-property name="protocol" required="true" type="string" readOnly="true" description="The web connector protocol."/> - <c:simple-property name="socket-binding" required="true" type="string" readOnly="true" + <c:simple-property name="protocol" required="true" type="string" description="The web connector protocol."/> + <c:simple-property name="socket-binding" required="true" type="string" description="The web connector socket-binding reference, this connector should be bound to."> <c:option-source target="configuration" expression="socket-binding=name:type=SocketBindingGroup"/> <!-- TODO different for Domain vs standalone --> </c:simple-property> - <c:simple-property name="scheme" type="string" readOnly="true" default="http" description="The web connector scheme." required="true"/> - <c:simple-property name="executor" type="string" readOnly="true" required="false" + <c:simple-property name="scheme" type="string" default="http" description="The web connector scheme." required="true"/> + <c:simple-property name="executor" type="string" required="false" description="The name of the executor that should be used for the processing threads of this connector. Defaults to using an internal pool."/> - <c:simple-property name="enabled" type="boolean" readOnly="true" defaultValue="true" + <c:simple-property name="enabled" type="boolean" default="true" description="Defines whether the connector should be started on startup."/> - <c:simple-property name="enable-lookups" type="boolean" readOnly="true" defaultValue="false" + <c:simple-property name="enable-lookups" type="boolean" defaultValue="false" description="Enable DNS lookups for Servlet API."/> - <c:simple-property name="proxy-name" type="string" readOnly="true" required="false" + <c:simple-property name="proxy-name" type="string" required="false" description="The host name that will be used when sending a redirect. The default value is null."/> - <c:simple-property name="proxy-port" type="integer" readOnly="true" required="false" + <c:simple-property name="proxy-port" type="integer" required="false" description="The port that will be used when sending a redirect."/> - <c:simple-property name="max-post-size" type="integer" readOnly="true" defaultValue="2097152" + <c:simple-property name="max-post-size" type="integer" defaultValue="2097152" description="Maximum size in bytes of a POST request that can be parsed by the container."/> - <c:simple-property name="max-save-post-size" type="integer" readOnly="true" defaultValue="4096" + <c:simple-property name="max-save-post-size" type="integer" defaultValue="4096" description="Maximum size in bytes of a POST request that will be saved during certain authentication schemes."/> <c:simple-property name="secure" type="boolean" readOnly="true" defaultValue="false" description="Indicates if content sent or recieved by the connector is secured from the user perspective."/> <c:simple-property name="redirect-port" type="integer" readOnly="true" defaultValue="8443" description="The port for redirection to a secure connector."/> - <c:simple-property name="max-connections" type="integer" readOnly="true" required="false" + <c:simple-property name="max-connections" type="integer" required="false" description="Amount of concurrent connections that can be processed by the connector with optimum performance. The default value depends on the connector used."/> - <c:list-property name="virtual-server" description="The list of virtual servers that can be accessed through this connector. The default is to allow all virtual servers." readOnly="true" required="false"> + <c:list-property name="virtual-server" description="The list of virtual servers that can be accessed through this connector. The default is to allow all virtual servers." required="false"> <c:simple-property name="virtual-server" /> </c:list-property> <c:map-property name="ssl" description="The SSL configuration of the connector." readOnly="true" required="false"> @@ -795,10 +915,10 @@ </plugin-configuration>
<resource-configuration> - <c:list-property name="alias" > + <c:list-property name="alias" description="The virtual server aliases" displayName="Virtual server aliases" > <c:simple-property name="alias" /> </c:list-property> - <c:simple-property name="default-web-module" type="string" readOnly="true" defaultValue="ROOT.war" + <c:simple-property name="default-web-module" type="string" defaultValue="ROOT.war" description="The web module deployment name that will be mapped as the root webapp."/> <c:map-property name="access-log" description="The access log configuration for this virtual server." > <c:simple-property name="pattern" type="string" readOnly="true" defaultValue="common" required="false" description="The access log pattern."/> @@ -825,7 +945,7 @@ </c:list-property> </c:map-property> </c:list-property> - <c:simple-property name="enable-welcome-root" type="boolean" /> + <c:simple-property name="enable-welcome-root" type="boolean" description="Whether or not the bundled welcome directory is used as the root web context."/> </resource-configuration> </service>
@@ -841,7 +961,7 @@
<runs-inside> <parent-resource-type name="Profile" plugin="jboss-as-7"/> - <parent-resource-type name="JBossAS7-Standalone" plugin="jboss-as-7"/> + <parent-resource-type name="JBossAS7 Standalone Server" plugin="jboss-as-7"/> </runs-inside>
<plugin-configuration> @@ -877,7 +997,7 @@
<runs-inside> <parent-resource-type name="Profile" plugin="jboss-as-7"/> - <parent-resource-type name="JBossAS7-Standalone" plugin="jboss-as-7"/> + <parent-resource-type name="JBossAS7 Standalone Server" plugin="jboss-as-7"/> </runs-inside>
<plugin-configuration> @@ -903,11 +1023,10 @@ <parameters> <c:simple-property name="name" required="true" description="Name of the datasource"/> <c:simple-property name="driver-name" required="true"> - <c:option-source target="resource" expression="type=^Deployment$" filter="sameHierarchy"/> + <c:option-source target="resource" expression="type=^Deployment$" filter=".*.jar"/> </c:simple-property> <c:simple-property name="jndi-name" description="JNDI-Name of the Datasource" required="true"/> <c:simple-property name="connection-url" description="URL for the connection to the database" required="true"/> - <c:simple-property name="pool-name" description="Name of the pool" required="true"/> <c:simple-property name="user-name" description="User name for DB-connections" required="false" /> <c:simple-property name="password" description="Password" type="password" required="false"/> </parameters> @@ -920,15 +1039,14 @@ <parameters> <c:simple-property name="name" required="true" description="Name of the datasource"/> <c:simple-property name="driver-name" required="true"> - <c:option-source target="resource" expression="type=^Deployment$"/> + <c:option-source target="resource" expression="type=^Deployment$" filter=".*.jar"/> </c:simple-property> - <c:simple-property name="xa-data-source-class" required="true" description="xa-data-source-class"/> + <c:simple-property name="xa-datasource-class" required="true" description="xa-datasource-class"/> + <c:simple-property name="connection-url" required="true" description="Connection URL. Will be turned into an Xa-property)"/> <c:simple-property name="jndi-name" description="JNDI-Name of the Datasource" required="true"/> - <c:simple-property name="connection-url" description="URL for the connection to the database" required="true"/> - <c:simple-property name="pool-name" description="Name of the pool" required="true"/> <c:simple-property name="user-name" description="User name for DB-connections" required="false" /> <c:simple-property name="password" description="Password" type="password" required="false"/> - <c:list-property name="xa-properties" displayName="XA Properties" description="Additional XA Properties" required="false"> + <c:list-property name="xa-properties" displayName="XA Properties" description="Additional XA Properties (connection url is set above)" required="false"> <c:map-property name="xa-properties"> <c:simple-property name="key" displayName="Key" description="Key of the property"/> <c:simple-property name="value" displayName="Value" description="Value of the property"/> @@ -994,17 +1112,13 @@ description="The number of times that statements from the cache were used"/> <metric property="AverageBlockingTime" units="milliseconds" description="The average time spent blocking for a connection"/> - <metric property="MaxWaitTime" units="milliseconds" - description="The maximum wait time for a connection" displayType="summary"/> <metric property="ActiveCount" description="The active count"/> <metric property="CreatedCount" description="The created count" measurementType="trendsup"/> <metric property="MaxCreationTime" description="The maximum time for creating a physical connection" units="milliseconds"/> - <metric property="MaxWaitCount" description="The maximum number of threads waiting for a connection" units="milliseconds" displayType="summary"/> <metric property="TotalCreationTime" description="The total time spent creating physical connections" measurementType="trendsup" units="milliseconds"/> <metric property="AvailableCount" description="The available count" units="milliseconds"/> <metric property="MaxUsedCount" description="The maximum number of connections used"/> - <metric property="TimedOut" description="The timed out count" measurementType="trendsup" displayType="summary"/> <metric property="TotalBlockingTime" description="The total blocking time" measurementType="trendsup" units="milliseconds"/> <metric property="AverageCreationTime" description="The average time spent creating a physical connection" units="milliseconds"/> <metric property="DestroyedCount" description="The destroyed count" measurementType="trendsup"/> @@ -1020,8 +1134,6 @@ description="Defines the JDBC driver the datasource should use with this format: driver-name>#major-version.minor-version where driver-name is the fully qualifed name of the JDBC driver class"/> <c:simple-property name="new-connection-sql" type="string" readOnly="true" required="false" description="Specifies an SQL statement to execute whenever a connection is added to the connection pool."/> - <c:simple-property name="pool-name" type="string" readOnly="true" - description="Specifies the pool name for the datasource used for management"/> <c:simple-property name="url-delimiter" type="string" readOnly="true" description="Specifies the delimeter for URLs in connection-url for HA datasources" required="false"/> <c:simple-property name="url-selector-strategy-class-name" type="string" readOnly="true" @@ -1165,11 +1277,10 @@ <metric property="DestroyedCount" description="The destroyed count" measurementType="trendsup"/>
<resource-configuration> - <c:simple-property name="xa-data-source-class" required="true" type="string" readOnly="true" description="The fully qualifed name of the javax.sql.XADataSource implementation"/> + <c:simple-property name="xa-datasource-class" required="true" type="string" readOnly="true" description="The fully qualifed name of the javax.sql.XADataSource implementation"/> <c:simple-property name="jndi-name" required="true" type="string" readOnly="true" description="Specifies the JNDI name for the datasource"/> <c:simple-property name="driver-name" required="true" type="string" readOnly="true" description="Defines the JDBC driver the datasource should use. It is a symbolic name matching the the name of installed driver. In case the driver is deployed as jar, the name is the name of deployment unit"/> <c:simple-property name="new-connection-sql" required="false" type="string" readOnly="true" description="Specifies an SQL statement to execute whenever a connection is added to the connection pool."/> - <c:simple-property name="pool-name" required="false" type="string" readOnly="true" description="Specifies the pool name for the datasource used for management"/> <c:simple-property name="url-delimiter" required="false" type="string" readOnly="true" description="Specifies the delimeter for URLs in connection-url for HA datasources"/> <c:simple-property name="url-selector-strategy-class-name" required="false" type="string" readOnly="true" description="A class that implements org.jboss.jca.adapters.jdbc.URLSelectorStrategy"/> <c:simple-property name="use-java-context" required="false" type="boolean" readOnly="true" description="Setting this to false will bind the DataSource into global JNDI;"/> @@ -1178,7 +1289,7 @@ <c:simple-property name="min-pool-size" required="false" type="integer" readOnly="false" description="The min-pool-size element indicates the minimum number of connections a pool should hold. These are not created until a Subject is known from a request for a connection."/> <c:simple-property name="pool-prefill" required="false" type="boolean" readOnly="false" description="Whether to attempt to prefill the connection pool. Changing this value require a server restart."/> <c:simple-property name="pool-use-strict-min" required="false" type="boolean" readOnly="false" description="Define if the min-pool-size should be considered a strictly."/> - <c:simple-property name="interliving" required="false" type="boolean" readOnly="true" description="An element to enable interleaving for XA connection factories"/> + <c:simple-property name="interleaving" required="false" type="boolean" readOnly="true" description="An element to enable interleaving for XA connection factories"/> <c:simple-property name="no-tx-separate-pool" required="false" type="boolean" readOnly="true" description="Oracle does not like XA connections getting used both inside and outside a JTA transaction. To workaround the problem you can create separate sub-pools for the different context"/> <c:simple-property name="pad-xid" required="false" type="boolean" readOnly="true" description="Should the Xid be padded"/> <c:simple-property name="same-rm-override" required="false" type="boolean" readOnly="true" description="The is-same-rm-override element allows one to unconditionally set whether the javax.transaction.xa.XAResource.isSameRM(XAResource) returns true or false"/> @@ -1245,6 +1356,16 @@ </c:map-property> --> <c:simple-property name="no-recovery" required="false" type="boolean" readOnly="true" description="if true no recovery are tried for this connection pool"/> + + + <c:group name="children:xa-datasource-properties:key+" displayName="XA Datasource Properties"> + <c:list-property name="*2" displayName="Properties" required="false" readOnly="true"> + <c:map-property name="*:key" displayName="Name" readOnly="true"> + <c:simple-property name="key" displayName="Property-Name" readOnly="true"/> + <c:simple-property name="value" displayName="Value" readOnly="true"/> + </c:map-property> + </c:list-property> + </c:group> </resource-configuration> </service>
@@ -1293,7 +1414,7 @@
<runs-inside> <parent-resource-type name="Profile" plugin="jboss-as-7"/> - <parent-resource-type name="JBossAS7-Standalone" plugin="jboss-as-7"/> + <parent-resource-type name="JBossAS7 Standalone Server" plugin="jboss-as-7"/> </runs-inside>
<plugin-configuration> @@ -1310,7 +1431,7 @@
<runs-inside> <parent-resource-type name="Profile" plugin="jboss-as-7"/> - <parent-resource-type name="JBossAS7-Standalone" plugin="jboss-as-7"/> + <parent-resource-type name="JBossAS7 Standalone Server" plugin="jboss-as-7"/> </runs-inside>
<plugin-configuration> @@ -1634,7 +1755,7 @@ working area for individual server instances</li></ul>"/>
<runs-inside> <parent-resource-type name="Profile" plugin="jboss-as-7"/> - <parent-resource-type name="JBossAS7-Standalone" plugin="jboss-as-7"/> + <parent-resource-type name="JBossAS7 Standalone Server" plugin="jboss-as-7"/> </runs-inside>
<plugin-configuration> @@ -1669,7 +1790,7 @@ working area for individual server instances</li></ul>"/>
<runs-inside> <parent-resource-type name="Profile" plugin="jboss-as-7"/> - <parent-resource-type name="JBossAS7-Standalone" plugin="jboss-as-7"/> + <parent-resource-type name="JBossAS7 Standalone Server" plugin="jboss-as-7"/> </runs-inside>
<plugin-configuration> @@ -1699,7 +1820,7 @@ working area for individual server instances</li></ul>"/> > <runs-inside> <parent-resource-type name="Profile" plugin="jboss-as-7"/> - <parent-resource-type name="JBossAS7-Standalone" plugin="jboss-as-7"/> + <parent-resource-type name="JBossAS7 Standalone Server" plugin="jboss-as-7"/> </runs-inside>
<plugin-configuration> @@ -1747,7 +1868,7 @@ working area for individual server instances</li></ul>"/>
<runs-inside> <parent-resource-type name="Profile" plugin="jboss-as-7"/> - <parent-resource-type name="JBossAS7-Standalone" plugin="jboss-as-7"/> + <parent-resource-type name="JBossAS7 Standalone Server" plugin="jboss-as-7"/> </runs-inside>
<plugin-configuration> @@ -1805,7 +1926,7 @@ working area for individual server instances</li></ul>"/>
<runs-inside> <parent-resource-type name="Profile" plugin="jboss-as-7"/> - <parent-resource-type name="JBossAS7-Standalone" plugin="jboss-as-7"/> + <parent-resource-type name="JBossAS7 Standalone Server" plugin="jboss-as-7"/> </runs-inside>
<plugin-configuration> @@ -1859,7 +1980,7 @@ working area for individual server instances</li></ul>"/>
<runs-inside> <parent-resource-type name="Profile" plugin="jboss-as-7"/> - <parent-resource-type name="JBossAS7-Standalone" plugin="jboss-as-7"/> <!-- FAKE as "runs inside Profile" only does not work --> + <parent-resource-type name="JBossAS7 Standalone Server" plugin="jboss-as-7"/> <!-- FAKE as "runs inside Profile" only does not work --> </runs-inside>
<plugin-configuration> @@ -1882,28 +2003,34 @@ working area for individual server instances</li></ul>"/>
<server name="Naming" discovery="SubsystemDiscovery" - class="BaseComponent" + class="NamingComponent" singleton="true" >
<runs-inside> <parent-resource-type name="Host" plugin="jboss-as-7"/> - <parent-resource-type name="JBossAS7-Standalone" plugin="jboss-as-7"/> + <parent-resource-type name="JBossAS7 Standalone Server" plugin="jboss-as-7"/> </runs-inside>
<plugin-configuration> <c:simple-property name="path" readOnly="true" default="subsystem=naming"/> </plugin-configuration>
- <operation name="naming:jndi-view" displayName="JNDIView" description="Peek at the JNDI tree"> + <operation name="jndi-view" displayName="JNDIView" description="Peek at the JNDI tree"> <results> - <c:list-property name="operationResult"> - <c:list-property name="innerContext"> - <c:map-property name="innerContexts"> - <c:simple-property name="class-name"/> - <c:simple-property name="value"/> - </c:map-property> - </c:list-property> + <c:list-property name="java-contexts"> + <c:map-property name="context"> + <c:simple-property name="context" /> + <c:simple-property name="name"/> + <c:simple-property name="value"/> + </c:map-property> + </c:list-property> + <c:list-property name="applications"> + <c:map-property name="context"> + <c:simple-property name="context" /> + <c:simple-property name="name"/> + <c:simple-property name="value"/> + </c:map-property> </c:list-property> </results> </operation> @@ -1918,7 +2045,7 @@ working area for individual server instances</li></ul>"/> <runs-inside> <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"/> + <parent-resource-type name="JBossAS7 Standalone Server" plugin="jboss-as-7"/> </runs-inside>
<plugin-configuration> @@ -1931,7 +2058,7 @@ working area for individual server instances</li></ul>"/> class="BaseComponent" > <runs-inside> - <parent-resource-type name="JBossAS7-Standalone" plugin="jboss-as-7"/> + <parent-resource-type name="JBossAS7 Standalone Server" plugin="jboss-as-7"/> </runs-inside>
@@ -2012,24 +2139,35 @@ working area for individual server instances</li></ul>"/> </service>
<service name="Deployment" - class="BaseComponent" + class="DeploymentComponent" discovery="SubsystemDiscovery" createDeletePolicy="both" creationDataType="content">
- <runs-inside> - <parent-resource-type name="ServerGroup" plugin="jboss-as-7"/> - <parent-resource-type name="JBossAS7-Standalone" plugin="jboss-as-7"/> + <parent-resource-type name="ServerGroup" plugin="jboss-as-7"/> <!-- TODO --> + <parent-resource-type name="JBossAS7 Standalone Server" plugin="jboss-as-7"/> + <parent-resource-type name="Managed Server" plugin="jboss-as-7"/> <!-- TODO --> </runs-inside> <plugin-configuration> <c:simple-property name="path" default="deployment" readOnly="true"/> </plugin-configuration>
+ <operation name="enable"> + <results> + <c:simple-property name="operationResult"/> + </results> + </operation> + <operation name="disable"> + <results> + <c:simple-property name="operationResult"/> + </results> + </operation> + <content name="file" category="deployable" isCreationType="true" description="Deployments on this server group"> <configuration> <c:group name="deployment" displayName="Deployment Options"> - <c:simple-property name="runtimeName" required="false"/> + <c:simple-property name="runtimeName" required="false" description="Runtime name of the uploaded file (e.g. 'my.war'). If not present, the file name is used."/> </c:group> </configuration> </content> @@ -2043,7 +2181,7 @@ working area for individual server instances</li></ul>"/> singleton="true" > <runs-inside> - <parent-resource-type name="JBossAS7-Standalone" plugin="jboss-as-7"/> + <parent-resource-type name="JBossAS7 Standalone Server" plugin="jboss-as-7"/> </runs-inside> <plugin-configuration> <c:simple-property name="path" default="subsystem=deployment-scanner" readOnly="true"/> diff --git a/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/AbstractConfigurationHandlingTest.java b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/AbstractConfigurationHandlingTest.java index 16c94f9..1af2f2f 100644 --- a/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/AbstractConfigurationHandlingTest.java +++ b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/AbstractConfigurationHandlingTest.java @@ -18,6 +18,9 @@ */ package org.rhq.modules.plugins.jbossas7;
+import java.io.BufferedReader; +import java.io.InputStream; +import java.io.InputStreamReader; import java.net.URL; import java.util.List;
@@ -28,7 +31,8 @@ import javax.xml.bind.util.ValidationEventCollector; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.codehaus.jackson.JsonNode; -import org.testng.annotations.BeforeSuite; +import org.codehaus.jackson.map.ObjectMapper; +import org.codehaus.jackson.node.ObjectNode;
import org.rhq.core.clientapi.agent.metadata.ConfigurationMetadataParser; import org.rhq.core.clientapi.agent.metadata.InvalidPluginDescriptorException; @@ -36,6 +40,7 @@ import org.rhq.core.clientapi.descriptor.DescriptorPackages; import org.rhq.core.clientapi.descriptor.plugin.PluginDescriptor; import org.rhq.core.clientapi.descriptor.plugin.ServerDescriptor; import org.rhq.core.domain.configuration.definition.ConfigurationDefinition; +import org.rhq.modules.plugins.jbossas7.json.Address; import org.rhq.modules.plugins.jbossas7.json.Operation;
/** @@ -87,6 +92,22 @@ public class AbstractConfigurationHandlingTest { return null; }
+ protected String loadJsonFromFile(String fileName) throws Exception { + InputStream inputStream = this.getClass().getClassLoader().getResourceAsStream(fileName); + BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream)); + try { + StringBuilder builder = new StringBuilder(); + String line; + while ((line = reader.readLine()) != null) { + builder.append(line); + } + return builder.toString(); + } + finally { + reader.close(); + } + } + /** * Provide a fake connection, that will return the * content we provide via #setContent @@ -97,7 +118,7 @@ public class AbstractConfigurationHandlingTest { JsonNode content;
public FakeConnection() { - super("localhost", 1234); + super("localhost", 1234, "fake", "fake"); }
public void setContent(JsonNode content) { @@ -108,6 +129,30 @@ public class AbstractConfigurationHandlingTest { public JsonNode executeRaw(Operation operation) { if (content==null) throw new IllegalStateException("Content not yet set"); + + Address address = operation.getAddress(); + if (address!=null && !address.isEmpty()) { + // we need to clone the content and then for the result find the right sub-content to put into result and + // return this one. + + // find the sub-content we want + String[] parts = address.getPath().split("="); + String key = parts[0]; + String val = parts[1]; + JsonNode result = content.get("result"); + JsonNode keyNode = result.get(key); + JsonNode valNode = keyNode.get(val); + + // clone the original content + ObjectMapper tmpMapper = new ObjectMapper(); + JsonNode tmp = tmpMapper.createObjectNode(); + ((ObjectNode)tmp).putAll(((ObjectNode)content)); + + // replace the result with the sub-content + ((ObjectNode)tmp).put("result",valNode); + + return tmp; + } return content; } } diff --git a/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/ConfigurationLoadingTest.java b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/ConfigurationLoadingTest.java index 0a46516..8e3704b 100644 --- a/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/ConfigurationLoadingTest.java +++ b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/ConfigurationLoadingTest.java @@ -21,6 +21,7 @@ package org.rhq.modules.plugins.jbossas7; import java.io.BufferedReader; import java.io.InputStream; import java.io.InputStreamReader; +import java.util.Collection; import java.util.List; import java.util.Map;
@@ -416,20 +417,50 @@ public class ConfigurationLoadingTest extends AbstractConfigurationHandlingTest
}
- private String loadJsonFromFile(String fileName) throws Exception { - InputStream inputStream = this.getClass().getClassLoader().getResourceAsStream(fileName); - BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream)); - try { - StringBuilder builder = new StringBuilder(); - String line; - while ((line = reader.readLine()) != null) { - builder.append(line); - } - return builder.toString(); - } - finally { - reader.close(); - } + public void test9() throws Exception { + String resultString = loadJsonFromFile("web.json"); + ConfigurationDefinition definition = loadDescriptor("test9"); + + ObjectMapper mapper = new ObjectMapper(); + ComplexResult result = mapper.readValue(resultString,ComplexResult.class); + JsonNode json = mapper.valueToTree(result); + + FakeConnection connection = new FakeConnection(); + connection.setContent(json); + + ConfigurationLoadDelegate delegate = new ConfigurationLoadDelegate(definition,connection,null); + Configuration config = delegate.loadResourceConfiguration(); + assert config!=null; + Collection<Property> properties = config.getProperties(); + assert properties.size()==6 : "Got " + properties.size() + " props instead of 6: " + properties.toString(); + PropertySimple simple = config.getSimple("check-interval"); + assert simple !=null; + Integer integerValue = simple.getIntegerValue(); + assert integerValue !=null : "check-interval was null"; + assert integerValue ==17 : "check-interval was not 17 but " + integerValue; + PropertySimple disabled = config.getSimple("disabled"); + assert disabled !=null : "disabled was null"; + Boolean booleanValue = disabled.getBooleanValue(); + assert booleanValue !=null; + assert booleanValue; + PropertySimple listings = config.getSimple("listings"); + assert listings !=null; + Boolean booleanValue1 = listings.getBooleanValue(); + assert booleanValue1 !=null; + assert !booleanValue1; + PropertySimple simple1 = config.getSimple("max-depth"); + assert simple1 !=null; + Integer integerValue1 = simple1.getIntegerValue(); + assert integerValue1 !=null; + assert integerValue1 ==3; + PropertySimple simple2 = config.getSimple("default-virtual-server"); + assert simple2 !=null; + String stringValue = simple2.getStringValue(); + assert stringValue !=null; + assert stringValue.equals("default-host"); + + + }
} diff --git a/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/ConfigurationUpdatingTest.java b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/ConfigurationUpdatingTest.java index d021ab2..703722a 100644 --- a/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/ConfigurationUpdatingTest.java +++ b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/ConfigurationUpdatingTest.java @@ -21,6 +21,7 @@ package org.rhq.modules.plugins.jbossas7; import java.util.List; import java.util.Map;
+import org.codehaus.jackson.JsonNode; import org.codehaus.jackson.map.ObjectMapper; import org.codehaus.jackson.map.SerializationConfig; import org.testng.annotations.BeforeSuite; @@ -31,6 +32,8 @@ import org.rhq.core.domain.configuration.PropertyList; import org.rhq.core.domain.configuration.PropertyMap; import org.rhq.core.domain.configuration.PropertySimple; import org.rhq.core.domain.configuration.definition.ConfigurationDefinition; +import org.rhq.modules.plugins.jbossas7.json.Address; +import org.rhq.modules.plugins.jbossas7.json.ComplexResult; import org.rhq.modules.plugins.jbossas7.json.CompositeOperation; import org.rhq.modules.plugins.jbossas7.json.Operation;
@@ -62,7 +65,7 @@ public class ConfigurationUpdatingTest extends AbstractConfigurationHandlingTest conf.put(new PropertySimple("needed","test")); conf.put(new PropertySimple("optional",null));
- CompositeOperation cop = delegate.updateGenerateOperationFromProperties(conf); + CompositeOperation cop = delegate.updateGenerateOperationFromProperties(conf, new Address());
assert cop.numberOfSteps() == 1; Operation step1 = cop.step(0); @@ -89,7 +92,7 @@ public class ConfigurationUpdatingTest extends AbstractConfigurationHandlingTest
conf.put(propertyList);
- CompositeOperation cop = delegate.updateGenerateOperationFromProperties(conf); + CompositeOperation cop = delegate.updateGenerateOperationFromProperties(conf, new Address());
assert cop.numberOfSteps() == 1 : "#Steps should be 1 but were " + cop.numberOfSteps(); Operation step1 = cop.step(0); @@ -120,7 +123,7 @@ public class ConfigurationUpdatingTest extends AbstractConfigurationHandlingTest
conf.put(propertyMap);
- CompositeOperation cop = delegate.updateGenerateOperationFromProperties(conf); + CompositeOperation cop = delegate.updateGenerateOperationFromProperties(conf, new Address());
assert cop.numberOfSteps() == 1 : "#Steps should be 1 but were " + cop.numberOfSteps(); Operation step1 = cop.step(0); @@ -148,7 +151,7 @@ public class ConfigurationUpdatingTest extends AbstractConfigurationHandlingTest
conf.put(propertyMap);
- CompositeOperation cop = delegate.updateGenerateOperationFromProperties(conf); + CompositeOperation cop = delegate.updateGenerateOperationFromProperties(conf, new Address());
assert cop.numberOfSteps() == 1 : "#Steps should be 1 but were " + cop.numberOfSteps(); Operation step1 = cop.step(0); @@ -176,7 +179,7 @@ public class ConfigurationUpdatingTest extends AbstractConfigurationHandlingTest
conf.put(propertyMap);
- CompositeOperation cop = delegate.updateGenerateOperationFromProperties(conf); + CompositeOperation cop = delegate.updateGenerateOperationFromProperties(conf, new Address());
assert cop.numberOfSteps() == 1 : "#Steps should be 1 but were " + cop.numberOfSteps(); Operation step1 = cop.step(0); @@ -207,7 +210,7 @@ public class ConfigurationUpdatingTest extends AbstractConfigurationHandlingTest
conf.put(propertyList);
- CompositeOperation cop = delegate.updateGenerateOperationFromProperties(conf); + CompositeOperation cop = delegate.updateGenerateOperationFromProperties(conf, new Address());
assert cop.numberOfSteps() == 1 : "#Steps should be 1 but were " + cop.numberOfSteps(); Operation step1 = cop.step(0); @@ -240,7 +243,7 @@ public class ConfigurationUpdatingTest extends AbstractConfigurationHandlingTest conf.put(propertyList); conf.put(new PropertySimple("port-offset",0));
- CompositeOperation cop = delegate.updateGenerateOperationFromProperties(conf); + CompositeOperation cop = delegate.updateGenerateOperationFromProperties(conf, new Address());
assert cop.numberOfSteps() == 3 : "#Steps should be 3 but were " + cop.numberOfSteps(); Operation step1 = cop.step(0); @@ -289,7 +292,7 @@ public class ConfigurationUpdatingTest extends AbstractConfigurationHandlingTest conf.put(propertyList); conf.put(new PropertySimple("port-offset",0));
- CompositeOperation cop = delegate.updateGenerateOperationFromProperties(conf); + CompositeOperation cop = delegate.updateGenerateOperationFromProperties(conf, new Address());
assert cop.numberOfSteps() == 5 : "#Steps should be 5 but were " + cop.numberOfSteps(); Operation step1 = cop.step(0); @@ -317,4 +320,107 @@ public class ConfigurationUpdatingTest extends AbstractConfigurationHandlingTest assert step4.getAddress().get(0).equals("socket-binding=https"); assert step5.getAddress().get(0).equals("socket-binding=https"); } + + public void test9() throws Exception { + + ConfigurationDefinition definition = loadDescriptor("test9"); + + FakeConnection connection = new FakeConnection(); + + ConfigurationWriteDelegate delegate = new ConfigurationWriteDelegate(definition,connection,null); + + Configuration conf = new Configuration(); + + conf.put(new PropertySimple("default-virtual-server","hulla")); // this is read-only and must not show up in result + conf.put(new PropertySimple("test-prop","Heiko")); + conf.put(new PropertySimple("check-interval",23)); + conf.put(new PropertySimple("disabled",true)); + conf.put(new PropertySimple("listings",false)); + conf.put(new PropertySimple("max-depth",17)); + + CompositeOperation cop = delegate.updateGenerateOperationFromProperties(conf, new Address()); + + assert cop.numberOfSteps() == 5 : "#Steps should be 5 but were " + cop.numberOfSteps(); + + Operation step1 = cop.step(0); + Operation step2 = cop.step(1); + Operation step3 = cop.step(2); + Operation step4 = cop.step(3); + Operation step5 = cop.step(4); + + assert step1.getAddress().isEmpty(); + assert step2.getAddress().size()==1; + assert step3.getAddress().size()==1; + assert step4.getAddress().size()==1; + assert step5.getAddress().size()==1; + assert step2.getAddress().get(0).equals("configuration=jsp-configuration"); + assert step3.getAddress().get(0).equals("configuration=jsp-configuration"); + assert step4.getAddress().get(0).equals("configuration=static-resources"); + assert step5.getAddress().get(0).equals("configuration=static-resources"); + + assert step1.getAdditionalProperties().get("name").equals("test-prop"); + assert step1.getAdditionalProperties().get("value").equals("Heiko"); + assert step2.getAdditionalProperties().get("name").equals("check-interval"); + assert step2.getAdditionalProperties().get("value").equals("23"); + + } + + public void test10() throws Exception { + + ConfigurationDefinition definition = loadDescriptor("test10"); + + FakeConnection connection = new FakeConnection(); + String resultString = loadJsonFromFile("system-props.json"); + + ObjectMapper mapper = new ObjectMapper(); + ComplexResult result = mapper.readValue(resultString,ComplexResult.class); + JsonNode json = mapper.valueToTree(result); + + connection.setContent(json); + + + ConfigurationWriteDelegate delegate = new ConfigurationWriteDelegate(definition,connection,null); + + Configuration conf = new Configuration(); + + // We have properties 'bar' and 'hello' on the server + // update 'bar', add 'hulla' and remove 'hello' + + PropertyList propertyList = new PropertyList("*2"); + PropertyMap propertyMap = new PropertyMap("*"); + propertyMap.put(new PropertySimple("name","hulla")); + propertyMap.put(new PropertySimple("value","hopp")); + propertyList.add(propertyMap); + propertyMap = new PropertyMap("*"); + propertyMap.put(new PropertySimple("name","bar")); + propertyMap.put(new PropertySimple("value","42!")); + propertyList.add(propertyMap); + conf.put(propertyList); + + + CompositeOperation cop = delegate.updateGenerateOperationFromProperties(conf, new Address()); + + assert cop.numberOfSteps() == 3 : "#Steps should be 3 but were " + cop.numberOfSteps(); + + Operation step1 = cop.step(0); + Operation step2 = cop.step(1); + Operation step3 = cop.step(2); + + assert step1.getAddress().size()==1; + assert step2.getAddress().size()==1; + assert step3.getAddress().size()==1; + assert step1.getAddress().get(0).equals("system-property=hulla"); + assert step2.getAddress().get(0).equals("system-property=bar"); + assert step3.getAddress().get(0).equals("system-property=hello"); + assert step1.getOperation().equals("add"); + assert step2.getOperation().equals("write-attribute"); + assert step3.getOperation().equals("remove"); + + assert step1.getAdditionalProperties().get("name").equals("hulla"); + assert step1.getAdditionalProperties().get("value").equals("hopp"); + assert step2.getAdditionalProperties().get("name").equals("value"); // This is the name of the property + assert step2.getAdditionalProperties().get("value").equals("42!"); + assert step3.getAdditionalProperties().isEmpty(); + + } } diff --git a/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/OperationJsonTest.java b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/OperationJsonTest.java index 354ab8d..2dcd49f 100644 --- a/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/OperationJsonTest.java +++ b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/OperationJsonTest.java @@ -59,7 +59,8 @@ public class OperationJsonTest { assert op!=null; assert op.getOperation()!=null : "op.operation was null!"; assert op.getOperation().equals(operation.getOperation()) : "Operation is " + op.getOperation(); - assert op.getName().equals("socket-binding") : "attribute name is " + op.getName(); + assert op.getName()!=null : "op.getName is null"; + assert op.getName().equals("socket-binding") : "attribute name is " + op.getName() + " and not 'socket-binding'"; assert op.getValue().equals("jndi") : "attribute value is " + op.getValue(); assert op.getAddress().size()==2 : "Address did not contain 2 parts, but " + op.getAddress().size();
diff --git a/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/PathHandlingTest.java b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/PathHandlingTest.java index 113bc53..882d377 100644 --- a/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/PathHandlingTest.java +++ b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/PathHandlingTest.java @@ -60,4 +60,31 @@ public class PathHandlingTest { assert a.size()==3 : "Size was not 3, but "+ a.size(); assert !a.isEmpty(); } + + public void getParent1() throws Exception { + String path = "subsystem=jms,profile=default,queue=foo"; + Address a = new Address(path); + Address b = a.getParent(); + assert b!=null; + assert b.size()==2; + assert b.get(0).equals("subsystem=jms"); + assert b.get(1).equals("profile=default"); + } + + public void getParent2() throws Exception { + Address a = new Address(); + Address b = a.getParent(); + assert b!=null; + assert b.isEmpty(); + assert b.size()==0; + } + + public void getParent3() throws Exception { + Address a = new Address("foo=bar"); + Address b = a.getParent(); + assert b!=null; + assert b.isEmpty(); + assert b.size()==0; + } + } diff --git a/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/XmlFileReadingTest.java b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/XmlFileReadingTest.java new file mode 100644 index 0000000..2365d19 --- /dev/null +++ b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/XmlFileReadingTest.java @@ -0,0 +1,133 @@ +package org.rhq.modules.plugins.jbossas7; + +import java.net.URL; + +import org.testng.annotations.Test; + +/** + * Test the ability to read information from the AS7 xml files (standalone.xml and so on) + * @author Heiko W. Rupp + */ +@Test +public class XmlFileReadingTest { + + public void hostPort70() throws Exception { + + BaseProcessDiscovery bd = new BaseProcessDiscovery(); + URL url = getClass().getClassLoader().getResource("standalone70.xml"); + bd.readStandaloneOrHostXmlFromFile(url.getFile()); + + AbstractBaseDiscovery.HostPort hp = bd.getManagementPortFromHostXml(new String[]{}); + System.out.println(hp); + assert hp.host.equals("127.0.0.70") : "Host is " + hp.host; + assert hp.port==19990 : "Port is " + hp.port; + } + + public void hostPort71() throws Exception { + + BaseProcessDiscovery bd = new BaseProcessDiscovery(); + URL url = getClass().getClassLoader().getResource("standalone71.xml"); + bd.readStandaloneOrHostXmlFromFile(url.getFile()); + + AbstractBaseDiscovery.HostPort hp = bd.getManagementPortFromHostXml(new String[]{}); + System.out.println(hp); + // hp : HostPort{host='localhost', port=9990, isLocal=true} + assert hp.host.equals("127.0.0.71") : "Host is " + hp.host; + assert hp.port==29990 : "Port is " + hp.port; + } + + public void domainController1() throws Exception { + + BaseProcessDiscovery bd = new BaseProcessDiscovery(); + URL url = getClass().getClassLoader().getResource("host1.xml"); + bd.readStandaloneOrHostXmlFromFile(url.getFile()); + + AbstractBaseDiscovery.HostPort hp = bd.getDomainControllerFromHostXml(); + assert hp.isLocal : "DC is not local as expected: " + hp; + + } + + public void domainController2() throws Exception { + + BaseProcessDiscovery bd = new BaseProcessDiscovery(); + URL url = getClass().getClassLoader().getResource("host2.xml"); + bd.readStandaloneOrHostXmlFromFile(url.getFile()); + + AbstractBaseDiscovery.HostPort hp = bd.getDomainControllerFromHostXml(); + assert "192.168.100.1".equals(hp.host) : "DC is at " + hp.host; + assert hp.port == 9559 : "DC port is at " + hp.port; + } + + + + public void testXpath70() throws Exception { + + BaseProcessDiscovery bd = new BaseProcessDiscovery(); + URL url = getClass().getClassLoader().getResource("standalone70.xml"); + bd.readStandaloneOrHostXmlFromFile(url.getFile()); + +/* + String realm = bd.obtainXmlPropertyViaXPath("/management/management-interfaces/http-interface/@security-realm"); + assert "ManagementRealm".equals(realm) : "Realm was " + realm; +*/ + + String pathExpr = "//management/management-interfaces/http-interface/@port"; + String port = bd.obtainXmlPropertyViaXPath(pathExpr); + assert "19990".equals(port) : "Port was [" + port + "]"; + + pathExpr = "//management/management-interfaces/http-interface/@interface"; + String interfName = bd.obtainXmlPropertyViaXPath(pathExpr); + assert "management".equals(interfName) : "Interface was " + interfName; + + pathExpr = "/server/interfaces/interface[@name='" + interfName + "']/inet-address/@value"; + String interfElem = bd.obtainXmlPropertyViaXPath(pathExpr); + assert "${jboss.bind.address.management:127.0.0.70}".equals(interfElem) : "InterfElem was " + interfElem; + + } + + + public void testXpath71() throws Exception { + + BaseProcessDiscovery bd = new BaseProcessDiscovery(); + URL url = getClass().getClassLoader().getResource("standalone71.xml"); + bd.readStandaloneOrHostXmlFromFile(url.getFile()); + + String realm = bd.obtainXmlPropertyViaXPath("//management/management-interfaces/http-interface/@security-realm"); + assert "ManagementRealm".equals(realm) : "Realm was " + realm; + String sbindingRef = bd.obtainXmlPropertyViaXPath( + ("//management/management-interfaces/http-interface/socket-binding/@http")); + assert "management-http".equals(sbindingRef): "Socketbinding was " + sbindingRef; + + String pathExpr = "/server/socket-binding-group/socket-binding[@name='" + sbindingRef + "']/@port"; + String port = bd.obtainXmlPropertyViaXPath(pathExpr); + assert "29990".equals(port) : "Port was [" + port + "]"; + + pathExpr = "/server/socket-binding-group/socket-binding[@name='" + sbindingRef + "']/@interface"; + String interfName = bd.obtainXmlPropertyViaXPath(pathExpr); + assert "management".equals(interfName) : "Interface was " + interfName; + + pathExpr = "/server/interfaces/interface[@name='" + interfName + "']/inet-address/@value"; + String interfElem = bd.obtainXmlPropertyViaXPath(pathExpr); + assert "${jboss.bind.address.management:127.0.0.71}".equals(interfElem) : "InterfElem was " + interfElem; + + } + + public void testGetRealm() throws Exception { + + BaseProcessDiscovery bd = new BaseProcessDiscovery(); + URL url = getClass().getClassLoader().getResource("standalone71.xml"); + bd.readStandaloneOrHostXmlFromFile(url.getFile()); + + String realm = bd.obtainXmlPropertyViaXPath("//management/management-interfaces/http-interface/@security-realm"); + assert "ManagementRealm".equals(realm) : "Realm was " + realm; + + String xpathExpression = "//management//security-realm[@name ='%s']/authentication/properties/@path"; + + String propsFileName = bd.obtainXmlPropertyViaXPath(String.format(xpathExpression,realm)); + assert "mgmt-users.properties".equals(propsFileName) : "File name was " + propsFileName; + + String propsFilePathRel = bd.obtainXmlPropertyViaXPath("//management//security-realm[@name ='" + realm + "']/authentication/properties/@relative-to"); + assert "jboss.server.config.dir".equals(propsFilePathRel) : "Path was " + propsFileName; + + } +} diff --git a/modules/plugins/jboss-as-7/src/test/resources/host1.xml b/modules/plugins/jboss-as-7/src/test/resources/host1.xml new file mode 100644 index 0000000..2e35b78 --- /dev/null +++ b/modules/plugins/jboss-as-7/src/test/resources/host1.xml @@ -0,0 +1,92 @@ +<!-- + ~ JBoss, Home of Professional Open Source. + ~ Copyright 2010, Red Hat, Inc., and individual contributors + ~ as indicated by the @author tags. See the copyright.txt file in the + ~ distribution for a full listing of individual contributors. + ~ + ~ This is free software; you can redistribute it and/or modify it + ~ under the terms of the GNU Lesser General Public License as + ~ published by the Free Software Foundation; either version 2.1 of + ~ the License, or (at your option) any later version. + ~ + ~ This software 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 + ~ Lesser General Public License for more details. + ~ + ~ You should have received a copy of the GNU Lesser General Public + ~ License along with this software; if not, write to the Free + ~ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + ~ 02110-1301 USA, or see the FSF site: http://www.fsf.org. + --> + +<host xmlns="urn:jboss:domain:1.1" + name="master"> + + <management> + <security-realms> + <security-realm name="ManagementRealm"> + <authentication> + <properties path="mgmt-users.properties" relative-to="jboss.domain.config.dir"/> + </authentication> + </security-realm> + </security-realms> + <management-interfaces> + <native-interface security-realm="ManagementRealm"> + <socket interface="management" port="9999"/> + </native-interface> + <http-interface security-realm="ManagementRealm"> + <socket interface="management" port="9990"/> + </http-interface> + </management-interfaces> + </management> + + <domain-controller> + <local/> + <!-- Alternative remote domain controller configuration with a host and port --> + <!-- <remote host="192.168.100.1" port="9999"/> --> + </domain-controller> + + <interfaces> + <interface name="management"> + <inet-address value="${jboss.bind.address.management:127.0.0.1}"/> + </interface> + <interface name="public"> + <inet-address value="${jboss.bind.address:127.0.0.1}"/> + </interface> + </interfaces> + + <jvms> + <jvm name="default"> + <heap size="64m" max-size="128m"/> + </jvm> + </jvms> + + <servers> + <server name="server-one" group="main-server-group"> + <!-- server-one inherits the default socket-group declared in the server-group --> + <jvm name="default"> + <!-- Remote JPDA debugging for a specific server + <jvm-options> + <option value="-Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=n"/> + </jvm-options> + --> + </jvm> + </server> + + <server name="server-two" group="main-server-group" auto-start="true"> + <!-- server-two avoids port conflicts by incrementing the ports in + the default socket-group declared in the server-group --> + <socket-binding-group ref="standard-sockets" port-offset="150"/> + <jvm name="default"> + <heap size="64m" max-size="256m"/> + </jvm> + </server> + + <server name="server-three" group="other-server-group" auto-start="false"> + <!-- server-three avoids port conflicts by incrementing the ports in + the default socket-group declared in the server-group --> + <socket-binding-group ref="ha-sockets" port-offset="250"/> + </server> + </servers> +</host> diff --git a/modules/plugins/jboss-as-7/src/test/resources/host2.xml b/modules/plugins/jboss-as-7/src/test/resources/host2.xml new file mode 100644 index 0000000..38ada1a --- /dev/null +++ b/modules/plugins/jboss-as-7/src/test/resources/host2.xml @@ -0,0 +1,91 @@ +<!-- + ~ JBoss, Home of Professional Open Source. + ~ Copyright 2010, Red Hat, Inc., and individual contributors + ~ as indicated by the @author tags. See the copyright.txt file in the + ~ distribution for a full listing of individual contributors. + ~ + ~ This is free software; you can redistribute it and/or modify it + ~ under the terms of the GNU Lesser General Public License as + ~ published by the Free Software Foundation; either version 2.1 of + ~ the License, or (at your option) any later version. + ~ + ~ This software 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 + ~ Lesser General Public License for more details. + ~ + ~ You should have received a copy of the GNU Lesser General Public + ~ License along with this software; if not, write to the Free + ~ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + ~ 02110-1301 USA, or see the FSF site: http://www.fsf.org. + --> + +<host xmlns="urn:jboss:domain:1.1" + name="master"> + + <management> + <security-realms> + <security-realm name="ManagementRealm"> + <authentication> + <properties path="mgmt-users.properties" relative-to="jboss.domain.config.dir"/> + </authentication> + </security-realm> + </security-realms> + <management-interfaces> + <native-interface security-realm="ManagementRealm"> + <socket interface="management" port="9999"/> + </native-interface> + <http-interface security-realm="ManagementRealm"> + <socket interface="management" port="9990"/> + </http-interface> + </management-interfaces> + </management> + + <domain-controller> + <!-- Alternative remote domain controller configuration with a host and port --> + <remote host="192.168.100.1" port="9559"/> + </domain-controller> + + <interfaces> + <interface name="management"> + <inet-address value="${jboss.bind.address.management:127.0.0.1}"/> + </interface> + <interface name="public"> + <inet-address value="${jboss.bind.address:127.0.0.1}"/> + </interface> + </interfaces> + + <jvms> + <jvm name="default"> + <heap size="64m" max-size="128m"/> + </jvm> + </jvms> + + <servers> + <server name="server-one" group="main-server-group"> + <!-- server-one inherits the default socket-group declared in the server-group --> + <jvm name="default"> + <!-- Remote JPDA debugging for a specific server + <jvm-options> + <option value="-Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=n"/> + </jvm-options> + --> + </jvm> + </server> + + <server name="server-two" group="main-server-group" auto-start="true"> + <!-- server-two avoids port conflicts by incrementing the ports in + the default socket-group declared in the server-group --> + <socket-binding-group ref="standard-sockets" port-offset="150"/> + <jvm name="default"> + <heap size="64m" max-size="256m"/> + </jvm> + </server> + + <server name="server-three" group="other-server-group" auto-start="false"> + <!-- server-three avoids port conflicts by incrementing the ports in + the default socket-group declared in the server-group --> + <socket-binding-group ref="ha-sockets" port-offset="250"/> + </server> + </servers> +</host> diff --git a/modules/plugins/jboss-as-7/src/test/resources/standalone70.xml b/modules/plugins/jboss-as-7/src/test/resources/standalone70.xml new file mode 100644 index 0000000..e07b9ef --- /dev/null +++ b/modules/plugins/jboss-as-7/src/test/resources/standalone70.xml @@ -0,0 +1,433 @@ +<!-- + ~ JBoss, Home of Professional Open Source. + ~ Copyright 2011, Red Hat, Inc., and individual contributors + ~ as indicated by the @author tags. See the copyright.txt file in the + ~ distribution for a full listing of individual contributors. + ~ + ~ This is free software; you can redistribute it and/or modify it + ~ under the terms of the GNU Lesser General Public License as + ~ published by the Free Software Foundation; either version 2.1 of + ~ the License, or (at your option) any later version. + ~ + ~ This software 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 + ~ Lesser General Public License for more details. + ~ + ~ You should have received a copy of the GNU Lesser General Public + ~ License along with this software; if not, write to the Free + ~ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + ~ 02110-1301 USA, or see the FSF site: http://www.fsf.org. + --> + +<server xmlns="urn:jboss:domain:1.1"> + + <extensions> + <extension module="org.jboss.as.clustering.infinispan"/> + <extension module="org.jboss.as.connector"/> + <extension module="org.jboss.as.deployment-scanner"/> + <extension module="org.jboss.as.ee"/> + <extension module="org.jboss.as.ejb3"/> + <extension module="org.jboss.as.jacorb"/> + <extension module="org.jboss.as.jaxrs"/> + <extension module="org.jboss.as.jmx"/> + <extension module="org.jboss.as.jpa"/> + <extension module="org.jboss.as.logging"/> + <extension module="org.jboss.as.mail"/> + <extension module="org.jboss.as.messaging"/> + <extension module="org.jboss.as.naming"/> + <extension module="org.jboss.as.osgi"/> + <extension module="org.jboss.as.remoting"/> + <extension module="org.jboss.as.sar"/> + <extension module="org.jboss.as.security"/> + <extension module="org.jboss.as.threads"/> + <extension module="org.jboss.as.transactions"/> + <extension module="org.jboss.as.web"/> + <extension module="org.jboss.as.webservices"/> + <extension module="org.jboss.as.weld"/> + </extensions> + + <management> + <security-realms> + <security-realm name="PropertiesMgmtSecurityRealm"> + <authentication> + <properties path="mgmt-users.properties" relative-to="jboss.server.config.dir"/> + </authentication> + </security-realm> + </security-realms> + <management-interfaces> + <native-interface interface="management" port="9999"/> + <http-interface interface="management" port="19990"/> + </management-interfaces> + </management> + + <profile> + <subsystem xmlns="urn:jboss:domain:logging:1.1"> + <console-handler name="CONSOLE"> + <level name="INFO"/> + <formatter> + <pattern-formatter pattern="%d{HH:mm:ss,SSS} %-5p [%c] (%t) %s%E%n"/> + </formatter> + </console-handler> + + <periodic-rotating-file-handler name="FILE"> + <level name="INFO"/> + <formatter> + <pattern-formatter pattern="%d{HH:mm:ss,SSS} %-5p [%c] (%t) %s%E%n"/> + </formatter> + <file relative-to="jboss.server.log.dir" path="server.log"/> + <suffix value=".yyyy-MM-dd"/> + </periodic-rotating-file-handler> + + <logger category="com.arjuna"> + <level name="WARN"/> + </logger> + <logger category="org.apache.tomcat.util.modeler"> + <level name="WARN"/> + </logger> + <logger category="sun.rmi"> + <level name="WARN"/> + </logger> + <logger category="jacorb"> + <level name="WARN"/> + </logger> + <!-- set jacorb.config to ERROR to avoid the "jacorb.properties not found" messages during startup --> + <logger category="jacorb.config"> + <level name="ERROR"/> + </logger> + + <root-logger> + <level name="INFO"/> + <handlers> + <handler name="CONSOLE"/> + <handler name="FILE"/> + </handlers> + </root-logger> + </subsystem> + <subsystem xmlns="urn:jboss:domain:datasources:1.0"> + <datasources> + <datasource jndi-name="java:jboss/datasources/ExampleDS" enabled="true" use-java-context="true" + pool-name="H2DS"> + <connection-url>jdbc:h2:mem:test;DB_CLOSE_DELAY=-1</connection-url> + <driver>h2</driver> + <pool></pool> + <security> + <user-name>sa</user-name> + <password>sa</password> + </security> + </datasource> + <drivers> + <driver name="h2" module="com.h2database.h2"> + <xa-datasource-class>org.h2.jdbcx.JdbcDataSource</xa-datasource-class> + </driver> + </drivers> + </datasources> + </subsystem> + <subsystem xmlns="urn:jboss:domain:deployment-scanner:1.0"> + <deployment-scanner scan-interval="5000" relative-to="jboss.server.base.dir" path="deployments"/> + </subsystem> + <subsystem xmlns="urn:jboss:domain:ee:1.0" /> + <subsystem xmlns="urn:jboss:domain:ejb3:1.2" > + + <remote connector-ref="remoting-connector" thread-pool-name="default" /> + <async thread-pool-name="default" /> + + <timer-service thread-pool-name="default" > + <data-store path="timer-service-data" relative-to="jboss.server.data.dir"/> + </timer-service> + + <!-- EJB3 pools --> + <pools> + <bean-instance-pools> + <strict-max-pool name="slsb-strict-max-pool" max-pool-size="20" instance-acquisition-timeout="5" + instance-acquisition-timeout-unit="MINUTES"/> + + <strict-max-pool name="mdb-strict-max-pool" max-pool-size="20" instance-acquisition-timeout="5" + instance-acquisition-timeout-unit="MINUTES"/> + </bean-instance-pools> + </pools> + + <!-- Default MDB configurations --> + <mdb> + <resource-adapter-ref resource-adapter-name="hornetq-ra"/> + <bean-instance-pool-ref pool-name="mdb-strict-max-pool"/> + </mdb> + + <!-- Session bean configurations --> + <session-bean> + <stateless> + <bean-instance-pool-ref pool-name="slsb-strict-max-pool"/> + </stateless> + </session-bean> + + <default-stateful-access-timeout>5000</default-stateful-access-timeout> + <default-singleton-access-timeout>5000</default-singleton-access-timeout> + + <thread-pools> + <thread-pool name="default" max-threads="10" keepalive-time="100" /> + </thread-pools> + </subsystem> + <subsystem xmlns="urn:jboss:domain:infinispan:1.0" default-cache-container="hibernate"> + <cache-container name="hibernate" default-cache="local-query"> + <local-cache name="entity"> + <eviction strategy="LRU" max-entries="10000"/> + <expiration max-idle="100000"/> + </local-cache> + <local-cache name="local-query"> + <eviction strategy="LRU" max-entries="10000"/> + <expiration max-idle="100000"/> + </local-cache> + <local-cache name="timestamps"> + <eviction strategy="NONE"/> + </local-cache> + </cache-container> + </subsystem> + <subsystem xmlns="urn:jboss:domain:jacorb:1.0"> + <orb name="JBoss" print-version="off" giop-minor-version="2"> + <connection max-managed-buf-size="24" outbuf-cache-timeout="-1"/> + <naming root-context="JBoss/Naming/root" export-corbaloc="on"/> + </orb> + <poa monitoring="off" queue-wait="off"> + <request-processors pool-size="2" max-threads="8"/> + </poa> + <interop sun="on" chunk-custom-rmi-valuetypes="on" strict-check-on-tc-creation="off"/> + </subsystem> + <subsystem xmlns="urn:jboss:domain:jaxrs:1.0"/> + <subsystem xmlns="urn:jboss:domain:jca:1.0"> + <archive-validation enabled="false"/> + <bean-validation enabled="false"/> + <default-workmanager> + <short-running-threads blocking="true"> + <core-threads count="10" per-cpu="20"/> + <queue-length count="10" per-cpu="20"/> + <max-threads count="10" per-cpu="20"/> + <keepalive-time time="10" unit="seconds"/> + </short-running-threads> + <long-running-threads blocking="true"> + <core-threads count="10" per-cpu="20"/> + <queue-length count="10" per-cpu="20"/> + <max-threads count="10" per-cpu="20"/> + <keepalive-time time="10" unit="seconds"/> + </long-running-threads> + </default-workmanager> + </subsystem> + <subsystem xmlns="urn:jboss:domain:jmx:1.1" show-model="true"> + <jmx-connector registry-binding="jmx-connector-registry" server-binding="jmx-connector-server" /> + </subsystem> + <subsystem xmlns="urn:jboss:domain:jpa:1.0"> + <jpa default-datasource=""/> + </subsystem> + <subsystem xmlns="urn:jboss:domain:mail:1.0"> + <mail-session jndi-name="java:jboss/mail/Default"> + <smtp-server address="localhost" port="25"/> + </mail-session> + </subsystem> + <subsystem xmlns="urn:jboss:domain:messaging:1.1"> + <hornetq-server> + <!-- Default journal file size is 10Mb, reduced here to 100k for faster first boot --> + <journal-file-size>102400</journal-file-size> + <journal-min-files>2</journal-min-files> + <journal-type>NIO</journal-type> + <!-- disable messaging persistence --> + <persistence-enabled>false</persistence-enabled> + + <connectors> + <netty-connector name="netty" socket-binding="messaging"/> + <netty-connector name="netty-throughput" socket-binding="messaging-throughput"> + <param key="batch-delay" value="50"/> + </netty-connector> + <in-vm-connector name="in-vm" server-id="0"/> + </connectors> + + <acceptors> + <netty-acceptor name="netty" socket-binding="messaging"/> + <netty-acceptor name="netty-throughput" socket-binding="messaging-throughput"> + <param key="batch-delay" value="50"/> + <param key="direct-deliver" value="false"/> + </netty-acceptor> + <in-vm-acceptor name="in-vm" server-id="0"/> + </acceptors> + + <security-settings> + <security-setting match="#"> + <permission type="createNonDurableQueue" roles="guest"/> + <permission type="deleteNonDurableQueue" roles="guest"/> + <permission type="consume" roles="guest"/> + <permission type="send" roles="guest"/> + </security-setting> + </security-settings> + + <address-settings> + <!--default for catch all--> + <address-setting match="#"> + <dead-letter-address>jms.queue.DLQ</dead-letter-address> + <expiry-address>jms.queue.ExpiryQueue</expiry-address> + <redelivery-delay>0</redelivery-delay> + <max-size-bytes>10485760</max-size-bytes> + <message-counter-history-day-limit>10</message-counter-history-day-limit> + <address-full-policy>BLOCK</address-full-policy> + </address-setting> + </address-settings> + + <!--JMS Stuff--> + <jms-connection-factories> + <connection-factory name="InVmConnectionFactory"> + <connectors> + <connector-ref connector-name="in-vm"/> + </connectors> + <entries> + <entry name="java:/ConnectionFactory"/> + </entries> + </connection-factory> + <connection-factory name="RemoteConnectionFactory"> + <connectors> + <connector-ref connector-name="netty"/> + </connectors> + <entries> + <entry name="RemoteConnectionFactory"/> + </entries> + </connection-factory> + <pooled-connection-factory name="hornetq-ra"> + <transaction mode="xa"/> + <connectors> + <connector-ref connector-name="in-vm"/> + </connectors> + <entries> + <entry name="java:/JmsXA"/> + </entries> + </pooled-connection-factory> + </jms-connection-factories> + + <jms-destinations> + <jms-queue name="testQueue"> + <entry name="queue/test"/> + </jms-queue> + <jms-topic name="testTopic"> + <entry name="topic/test"/> + </jms-topic> + </jms-destinations> + </hornetq-server> + </subsystem> + <subsystem xmlns="urn:jboss:domain:naming:1.0"/> + <subsystem xmlns="urn:jboss:domain:osgi:1.1" activation="lazy"> + <configuration pid="org.apache.felix.webconsole.internal.servlet.OsgiManager"> + <property name="manager.root" value="jboss-osgi"/> + </configuration> + <properties> + <!-- Specifies the beginning start level of the framework --> + <property name="org.osgi.framework.startlevel.beginning">1</property> + </properties> + <capabilities> + <!-- modules registered with the OSGi layer on startup --> + <capability name="javax.api"/> + <capability name="javax.servlet.api"/> + <capability name="javax.transaction.api"/> + <!-- bundles installed on startup --> + <capability name="org.apache.aries.util"/> + <capability name="org.jboss.osgi.webconsole"/> + <capability name="org.osgi.compendium"/> + <!-- bundles started in startlevel 1 --> + <capability name="org.apache.felix.log" startlevel="1"/> + <capability name="org.jboss.osgi.logging" startlevel="1"/> + <capability name="org.apache.felix.configadmin" startlevel="1"/> + <capability name="org.jboss.as.osgi.configadmin" startlevel="1"/> + <!-- bundles started in startlevel 2 --> + <capability name="org.apache.aries.jmx" startlevel="2"/> + <capability name="org.apache.felix.eventadmin" startlevel="2"/> + <capability name="org.apache.felix.metatype" startlevel="2"/> + <capability name="org.apache.felix.scr" startlevel="2"/> + <capability name="org.apache.felix.webconsole" startlevel="2"/> + <capability name="org.jboss.netty" startlevel="2"/> + <capability name="org.jboss.osgi.jmx" startlevel="2"/> + <capability name="org.jboss.osgi.http" startlevel="2"/> + <capability name="org.projectodd.stilts" startlevel="2"/> + <!-- bundles started in startlevel 3 --> + <capability name="org.jboss.osgi.blueprint" startlevel="3"/> + <capability name="org.jboss.osgi.webapp" startlevel="3"/> + <capability name="org.jboss.osgi.xerces" startlevel="3"/> + </capabilities> + </subsystem> + <subsystem xmlns="urn:jboss:domain:remoting:1.0"> + <connector name="remoting-connector" socket-binding="remoting"/> + </subsystem> + <subsystem xmlns="urn:jboss:domain:resource-adapters:1.0" /> + <subsystem xmlns="urn:jboss:domain:sar:1.0"/> + <subsystem xmlns="urn:jboss:domain:security:1.0"> + <security-domains> + <security-domain name="other" cache-type="default"> + <authentication> + <login-module code="UsersRoles" flag="required"/> + </authentication> + </security-domain> + </security-domains> + </subsystem> + <subsystem xmlns="urn:jboss:domain:threads:1.0"/> + <subsystem xmlns="urn:jboss:domain:transactions:1.0"> + <recovery-environment socket-binding="txn-recovery-environment" status-socket-binding="txn-status-manager"/> + <core-environment> + <process-id> + <uuid/> + </process-id> + </core-environment> + <coordinator-environment default-timeout="300"/> + </subsystem> + <subsystem xmlns="urn:jboss:domain:web:1.0" default-virtual-server="default-host"> + <connector name="http" scheme="http" protocol="HTTP/1.1" socket-binding="http"/> + <virtual-server name="default-host" enable-welcome-root="true"> + <alias name="localhost"/> + <alias name="example.com"/> + </virtual-server> + </subsystem> + <subsystem xmlns="urn:jboss:domain:webservices:1.0"> + <modify-wsdl-address>true</modify-wsdl-address> + <wsdl-host>localhost</wsdl-host> + <!-- + <wsdl-port>8080</wsdl-port> + <wsdl-secure-port>8443</wsdl-secure-port> + --> + <endpoint-config xmlns:ws="urn:jboss:jbossws-jaxws-config:4.0"> + ws:config-nameStandard-Endpoint-Config</ws:config-name> + </endpoint-config> + <endpoint-config xmlns:ws="urn:jboss:jbossws-jaxws-config:4.0"> + ws:config-nameRecording-Endpoint-Config</ws:config-name> + ws:pre-handler-chains + <handler-chain xmlns="http://java.sun.com/xml/ns/javaee"> + <protocol-bindings>##SOAP11_HTTP ##SOAP11_HTTP_MTOM ##SOAP12_HTTP ##SOAP12_HTTP_MTOM + </protocol-bindings> + <handler> + <handler-name>RecordingHandler</handler-name> + <handler-class>org.jboss.ws.common.invocation.RecordingServerHandler</handler-class> + </handler> + </handler-chain> + </ws:pre-handler-chains> + </endpoint-config> + </subsystem> + <subsystem xmlns="urn:jboss:domain:weld:1.0"/> + </profile> + + <interfaces> + <interface name="management"> + <inet-address value="${jboss.bind.address.management:127.0.0.70}"/> + </interface> + <interface name="public"> + <inet-address value="${jboss.bind.address:127.0.0.70}"/> + </interface> + </interfaces> + + <socket-binding-group name="standard-sockets" default-interface="public"> + <socket-binding name="http" port="8080"/> + <socket-binding name="https" port="8443"/> + <socket-binding name="jacorb" port="3528"/> + <socket-binding name="jacorb-ssl" port="3529"/> + <socket-binding name="jmx-connector-registry" interface="management" port="1090"/> + <socket-binding name="jmx-connector-server" interface="management" port="1091"/> + <socket-binding name="jndi" port="1099"/> + <socket-binding name="messaging" port="5445"/> + <socket-binding name="messaging-throughput" port="5455"/> + <socket-binding name="osgi-http" interface="management" port="8090"/> + <socket-binding name="remoting" port="4447"/> + <socket-binding name="txn-recovery-environment" port="4712"/> + <socket-binding name="txn-status-manager" port="4713"/> + </socket-binding-group> + +</server> diff --git a/modules/plugins/jboss-as-7/src/test/resources/standalone71.xml b/modules/plugins/jboss-as-7/src/test/resources/standalone71.xml new file mode 100644 index 0000000..0de6d00 --- /dev/null +++ b/modules/plugins/jboss-as-7/src/test/resources/standalone71.xml @@ -0,0 +1,453 @@ +<!-- + ~ JBoss, Home of Professional Open Source. + ~ Copyright 2011, Red Hat, Inc., and individual contributors + ~ as indicated by the @author tags. See the copyright.txt file in the + ~ distribution for a full listing of individual contributors. + ~ + ~ This is free software; you can redistribute it and/or modify it + ~ under the terms of the GNU Lesser General Public License as + ~ published by the Free Software Foundation; either version 2.1 of + ~ the License, or (at your option) any later version. + ~ + ~ This software 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 + ~ Lesser General Public License for more details. + ~ + ~ You should have received a copy of the GNU Lesser General Public + ~ License along with this software; if not, write to the Free + ~ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + ~ 02110-1301 USA, or see the FSF site: http://www.fsf.org. + --> + +<server xmlns="urn:jboss:domain:1.1"> + + <extensions> + <extension module="org.jboss.as.clustering.infinispan"/> + <extension module="org.jboss.as.cmp"/> + <extension module="org.jboss.as.connector"/> + <extension module="org.jboss.as.deployment-scanner"/> + <extension module="org.jboss.as.ee"/> + <extension module="org.jboss.as.ejb3"/> + <extension module="org.jboss.as.jacorb"/> + <extension module="org.jboss.as.jaxr"/> + <extension module="org.jboss.as.jaxrs"/> + <extension module="org.jboss.as.jdr"/> + <extension module="org.jboss.as.jmx"/> + <extension module="org.jboss.as.jpa"/> + <extension module="org.jboss.as.logging"/> + <extension module="org.jboss.as.mail"/> + <extension module="org.jboss.as.messaging"/> + <extension module="org.jboss.as.naming"/> + <extension module="org.jboss.as.osgi"/> + <extension module="org.jboss.as.pojo"/> + <extension module="org.jboss.as.remoting"/> + <extension module="org.jboss.as.sar"/> + <extension module="org.jboss.as.security"/> + <extension module="org.jboss.as.threads"/> + <extension module="org.jboss.as.transactions"/> + <extension module="org.jboss.as.web"/> + <extension module="org.jboss.as.webservices"/> + <extension module="org.jboss.as.weld"/> + </extensions> + + <management> + <security-realms> + <security-realm name="ManagementRealm"> + <authentication> + <properties path="mgmt-users.properties" relative-to="jboss.server.config.dir"/> + </authentication> + </security-realm> + </security-realms> + <management-interfaces> + <native-interface security-realm="ManagementRealm"> + <socket-binding native="management-native"/> + </native-interface> + <http-interface security-realm="ManagementRealm"> + <socket-binding http="management-http"/> + </http-interface> + </management-interfaces> + </management> + + <profile> + <subsystem xmlns="urn:jboss:domain:logging:1.1"> + <console-handler name="CONSOLE"> + <level name="INFO"/> + <formatter> + <pattern-formatter pattern="%d{HH:mm:ss,SSS} %-5p [%c] (%t) %s%E%n"/> + </formatter> + </console-handler> + + <periodic-rotating-file-handler name="FILE"> + <formatter> + <pattern-formatter pattern="%d{HH:mm:ss,SSS} %-5p [%c] (%t) %s%E%n"/> + </formatter> + <file relative-to="jboss.server.log.dir" path="server.log"/> + <suffix value=".yyyy-MM-dd"/> + <append value="true"/> + </periodic-rotating-file-handler> + + <logger category="com.arjuna"> + <level name="WARN"/> + </logger> + <logger category="org.apache.tomcat.util.modeler"> + <level name="WARN"/> + </logger> + <logger category="sun.rmi"> + <level name="WARN"/> + </logger> + <logger category="jacorb"> + <level name="WARN"/> + </logger> + <!-- set jacorb.config to ERROR to avoid the "jacorb.properties not found" messages during startup --> + <logger category="jacorb.config"> + <level name="ERROR"/> + </logger> + + <root-logger> + <level name="INFO"/> + <handlers> + <handler name="CONSOLE"/> + <handler name="FILE"/> + </handlers> + </root-logger> + </subsystem> + <subsystem xmlns="urn:jboss:domain:cmp:1.0"/> + <subsystem xmlns="urn:jboss:domain:datasources:1.0"> + <datasources> + <datasource jndi-name="java:jboss/datasources/ExampleDS" enabled="true" use-java-context="true" + pool-name="H2DS"> + <connection-url>jdbc:h2:mem:test;DB_CLOSE_DELAY=-1</connection-url> + <driver>h2</driver> + <pool></pool> + <security> + <user-name>sa</user-name> + <password>sa</password> + </security> + </datasource> + <drivers> + <driver name="h2" module="com.h2database.h2"> + <xa-datasource-class>org.h2.jdbcx.JdbcDataSource</xa-datasource-class> + </driver> + </drivers> + </datasources> + </subsystem> + <subsystem xmlns="urn:jboss:domain:deployment-scanner:1.0"> + <deployment-scanner scan-interval="5000" relative-to="jboss.server.base.dir" path="deployments"/> + </subsystem> + <subsystem xmlns="urn:jboss:domain:ee:1.0" /> + <subsystem xmlns="urn:jboss:domain:ejb3:1.2" > + + <remote connector-ref="remoting-connector" thread-pool-name="default" /> + <async thread-pool-name="default" /> + + <timer-service thread-pool-name="default" > + <data-store path="timer-service-data" relative-to="jboss.server.data.dir"/> + </timer-service> + + <!-- EJB3 pools --> + <pools> + <bean-instance-pools> + <strict-max-pool name="slsb-strict-max-pool" max-pool-size="20" instance-acquisition-timeout="5" + instance-acquisition-timeout-unit="MINUTES"/> + + <strict-max-pool name="mdb-strict-max-pool" max-pool-size="20" instance-acquisition-timeout="5" + instance-acquisition-timeout-unit="MINUTES"/> + </bean-instance-pools> + </pools> + + <!-- Default MDB configurations --> + <mdb> + <resource-adapter-ref resource-adapter-name="hornetq-ra"/> + <bean-instance-pool-ref pool-name="mdb-strict-max-pool"/> + </mdb> + + <!-- Session bean configurations --> + <session-bean> + <stateless> + <bean-instance-pool-ref pool-name="slsb-strict-max-pool"/> + </stateless> + <stateful default-access-timeout="5000"/> + <singleton default-access-timeout="5000"/> + </session-bean> + + <thread-pools> + <thread-pool name="default" max-threads="10" keepalive-time="100" /> + </thread-pools> + </subsystem> + <subsystem xmlns="urn:jboss:domain:infinispan:1.0" default-cache-container="hibernate"> + <cache-container name="hibernate" default-cache="local-query"> + <local-cache name="entity"> + <eviction strategy="LRU" max-entries="10000"/> + <expiration max-idle="100000"/> + </local-cache> + <local-cache name="local-query"> + <eviction strategy="LRU" max-entries="10000"/> + <expiration max-idle="100000"/> + </local-cache> + <local-cache name="timestamps"> + <eviction strategy="NONE"/> + </local-cache> + </cache-container> + </subsystem> + <subsystem xmlns="urn:jboss:domain:jacorb:1.1"/> + <subsystem xmlns="urn:jboss:domain:jaxr:1.0"> + <datasource jndi-name="java:jboss/datasources/ExampleDS"/> + </subsystem> + <subsystem xmlns="urn:jboss:domain:jaxrs:1.0"/> + <subsystem xmlns="urn:jboss:domain:jca:1.0"> + <archive-validation enabled="false"/> + <bean-validation enabled="false"/> + <default-workmanager> + <short-running-threads blocking="true"> + <core-threads count="10" per-cpu="20"/> + <queue-length count="10" per-cpu="20"/> + <max-threads count="10" per-cpu="20"/> + <keepalive-time time="10" unit="seconds"/> + </short-running-threads> + <long-running-threads blocking="true"> + <core-threads count="10" per-cpu="20"/> + <queue-length count="10" per-cpu="20"/> + <max-threads count="10" per-cpu="20"/> + <keepalive-time time="10" unit="seconds"/> + </long-running-threads> + </default-workmanager> + </subsystem> + <subsystem xmlns="urn:jboss:domain:jdr:1.0"/> + <subsystem xmlns="urn:jboss:domain:jmx:1.1" show-model="true"> + <jmx-connector registry-binding="jmx-connector-registry" server-binding="jmx-connector-server" /> + </subsystem> + <subsystem xmlns="urn:jboss:domain:jpa:1.0"> + <jpa default-datasource=""/> + </subsystem> + <subsystem xmlns="urn:jboss:domain:mail:1.0"> + <mail-session jndi-name="java:jboss/mail/Default"> + <smtp-server address="localhost" port="25"/> + </mail-session> + </subsystem> + <subsystem xmlns="urn:jboss:domain:messaging:1.1"> + <hornetq-server> + <!-- Default journal file size is 10Mb, reduced here to 100k for faster first boot --> + <journal-file-size>102400</journal-file-size> + <journal-min-files>2</journal-min-files> + <!-- disable messaging persistence --> + <persistence-enabled>false</persistence-enabled> + + <connectors> + <netty-connector name="netty" socket-binding="messaging-client"/> + <netty-connector name="netty-throughput" socket-binding="messaging-throughput-client"> + <param key="batch-delay" value="50"/> + </netty-connector> + <in-vm-connector name="in-vm" server-id="0"/> + </connectors> + + <acceptors> + <netty-acceptor name="netty" socket-binding="messaging"/> + <netty-acceptor name="netty-throughput" socket-binding="messaging-throughput"> + <param key="batch-delay" value="50"/> + <param key="direct-deliver" value="false"/> + </netty-acceptor> + <in-vm-acceptor name="in-vm" server-id="0"/> + </acceptors> + + <security-settings> + <security-setting match="#"> + <permission type="createNonDurableQueue" roles="guest"/> + <permission type="deleteNonDurableQueue" roles="guest"/> + <permission type="consume" roles="guest"/> + <permission type="send" roles="guest"/> + </security-setting> + </security-settings> + + <address-settings> + <!--default for catch all--> + <address-setting match="#"> + <dead-letter-address>jms.queue.DLQ</dead-letter-address> + <expiry-address>jms.queue.ExpiryQueue</expiry-address> + <redelivery-delay>0</redelivery-delay> + <max-size-bytes>10485760</max-size-bytes> + <message-counter-history-day-limit>10</message-counter-history-day-limit> + <address-full-policy>BLOCK</address-full-policy> + </address-setting> + </address-settings> + + <!--JMS Stuff--> + <jms-connection-factories> + <connection-factory name="InVmConnectionFactory"> + <connectors> + <connector-ref connector-name="in-vm"/> + </connectors> + <entries> + <entry name="java:/ConnectionFactory"/> + </entries> + </connection-factory> + <connection-factory name="RemoteConnectionFactory"> + <connectors> + <connector-ref connector-name="netty"/> + </connectors> + <entries> + <entry name="RemoteConnectionFactory"/> + </entries> + </connection-factory> + <pooled-connection-factory name="hornetq-ra"> + <transaction mode="xa"/> + <connectors> + <connector-ref connector-name="in-vm"/> + </connectors> + <entries> + <entry name="java:/JmsXA"/> + </entries> + </pooled-connection-factory> + </jms-connection-factories> + + <jms-destinations> + <jms-queue name="testQueue"> + <entry name="queue/test"/> + </jms-queue> + <jms-topic name="testTopic"> + <entry name="topic/test"/> + </jms-topic> + </jms-destinations> + </hornetq-server> + </subsystem> + <subsystem xmlns="urn:jboss:domain:naming:1.0"/> + <subsystem xmlns="urn:jboss:domain:osgi:1.1" activation="lazy"> + <configuration pid="org.apache.felix.webconsole.internal.servlet.OsgiManager"> + <property name="manager.root" value="jboss-osgi"/> + </configuration> + <properties> + <!-- Specifies the beginning start level of the framework --> + <property name="org.osgi.framework.startlevel.beginning">1</property> + </properties> + <capabilities> + <!-- modules registered with the OSGi layer on startup --> + <capability name="javax.api"/> + <capability name="javax.servlet.api"/> + <capability name="javax.transaction.api"/> + <!-- bundles installed on startup --> + <capability name="org.apache.aries.util"/> + <capability name="org.jboss.osgi.webconsole"/> + <capability name="org.osgi.compendium"/> + <!-- bundles started in startlevel 1 --> + <capability name="org.apache.felix.log" startlevel="1"/> + <capability name="org.jboss.osgi.logging" startlevel="1"/> + <capability name="org.apache.felix.configadmin" startlevel="1"/> + <capability name="org.jboss.as.osgi.configadmin" startlevel="1"/> + <!-- bundles started in startlevel 2 --> + <capability name="org.apache.aries.jmx" startlevel="2"/> + <capability name="org.apache.felix.eventadmin" startlevel="2"/> + <capability name="org.apache.felix.metatype" startlevel="2"/> + <capability name="org.apache.felix.scr" startlevel="2"/> + <capability name="org.apache.felix.webconsole" startlevel="2"/> + <capability name="org.jboss.netty" startlevel="2"/> + <capability name="org.jboss.osgi.jmx" startlevel="2"/> + <capability name="org.jboss.osgi.http" startlevel="2"/> + <capability name="org.projectodd.stilts" startlevel="2"/> + <!-- bundles started in startlevel 3 --> + <capability name="org.jboss.osgi.blueprint" startlevel="3"/> + <capability name="org.jboss.osgi.webapp" startlevel="3"/> + <capability name="org.jboss.osgi.xerces" startlevel="3"/> + </capabilities> + </subsystem> + <subsystem xmlns="urn:jboss:domain:pojo:1.0" /> + <subsystem xmlns="urn:jboss:domain:remoting:1.0"> + <connector name="remoting-connector" socket-binding="remoting"/> + </subsystem> + <subsystem xmlns="urn:jboss:domain:resource-adapters:1.0" /> + <subsystem xmlns="urn:jboss:domain:sar:1.0"/> + <subsystem xmlns="urn:jboss:domain:security:1.0"> + <security-domains> + <security-domain name="other" cache-type="default"> + <authentication> + <login-module code="UsersRoles" flag="required"/> + </authentication> + </security-domain> + <security-domain name="jboss-web-policy" cache-type="default"> + <authorization> + <policy-module code="Delegating" flag="required"/> + </authorization> + </security-domain> + <security-domain name="jboss-ejb-policy" cache-type="default"> + <authorization> + <policy-module code="Delegating" flag="required"/> + </authorization> + </security-domain> + </security-domains> + </subsystem> + <subsystem xmlns="urn:jboss:domain:threads:1.0"/> + <subsystem xmlns="urn:jboss:domain:transactions:1.1"> + <recovery-environment socket-binding="txn-recovery-environment" status-socket-binding="txn-status-manager"/> + <core-environment> + <process-id> + <uuid/> + </process-id> + </core-environment> + <coordinator-environment default-timeout="300"/> + </subsystem> + <subsystem xmlns="urn:jboss:domain:web:1.0" default-virtual-server="default-host"> + <connector name="http" scheme="http" protocol="HTTP/1.1" socket-binding="http"/> + <virtual-server name="default-host" enable-welcome-root="true"> + <alias name="localhost"/> + <alias name="example.com"/> + </virtual-server> + </subsystem> + <subsystem xmlns="urn:jboss:domain:webservices:1.0"> + <modify-wsdl-address>true</modify-wsdl-address> + <wsdl-host>${jboss.bind.address:127.0.0.1}</wsdl-host> + <!-- + <wsdl-port>8080</wsdl-port> + <wsdl-secure-port>8443</wsdl-secure-port> + --> + <endpoint-config xmlns:ws="urn:jboss:jbossws-jaxws-config:4.0"> + ws:config-nameStandard-Endpoint-Config</ws:config-name> + </endpoint-config> + <endpoint-config xmlns:ws="urn:jboss:jbossws-jaxws-config:4.0"> + ws:config-nameRecording-Endpoint-Config</ws:config-name> + ws:pre-handler-chains + <handler-chain xmlns="http://java.sun.com/xml/ns/javaee"> + <protocol-bindings>##SOAP11_HTTP ##SOAP11_HTTP_MTOM ##SOAP12_HTTP ##SOAP12_HTTP_MTOM + </protocol-bindings> + <handler> + <handler-name>RecordingHandler</handler-name> + <handler-class>org.jboss.ws.common.invocation.RecordingServerHandler</handler-class> + </handler> + </handler-chain> + </ws:pre-handler-chains> + </endpoint-config> + </subsystem> + <subsystem xmlns="urn:jboss:domain:weld:1.0"/> + </profile> + + <interfaces> + <interface name="management"> + <inet-address value="${jboss.bind.address.management:127.0.0.71}"/> + </interface> + <interface name="public"> + <inet-address value="${jboss.bind.address:127.0.0.71}"/> + </interface> + </interfaces> + + <socket-binding-group name="standard-sockets" default-interface="public"> + <socket-binding name="http" port="8080"/> + <socket-binding name="https" port="8443"/> + <socket-binding name="jacorb" port="3528"/> + <socket-binding name="jacorb-ssl" port="3529"/> + <socket-binding name="jmx-connector-registry" interface="management" port="1090"/> + <socket-binding name="jmx-connector-server" interface="management" port="1091"/> + <socket-binding name="management-native" interface="management" port="9999"/> + <socket-binding name="management-http" interface="management" port="29990"/> + <socket-binding name="messaging" port="5445"/> + <socket-binding name="messaging-throughput" port="5455"/> + <socket-binding name="osgi-http" interface="management" port="8090"/> + <socket-binding name="remoting" port="4447"/> + <socket-binding name="txn-recovery-environment" port="4712"/> + <socket-binding name="txn-status-manager" port="4713"/> + <outbound-socket-binding name="messaging-client"> + <local-destination socket-binding-ref="messaging"/> + </outbound-socket-binding> + <outbound-socket-binding name="messaging-throughput-client"> + <local-destination socket-binding-ref="messaging-throughput"/> + </outbound-socket-binding> + </socket-binding-group> + +</server> diff --git a/modules/plugins/jboss-as-7/src/test/resources/system-props.json b/modules/plugins/jboss-as-7/src/test/resources/system-props.json new file mode 100644 index 0000000..da211cc --- /dev/null +++ b/modules/plugins/jboss-as-7/src/test/resources/system-props.json @@ -0,0 +1,10 @@ +{ + "outcome" : "success", + "result" : + { + "bar" : + {"value" : "44"}, + "hello" : + {"value" : "world"} + } +} \ No newline at end of file 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 69201e2..173d2be 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 @@ -89,6 +89,34 @@
</server>
+ <server class="foo" discovery="foo" name="test9"> + <resource-configuration> + <c:simple-property name="default-virtual-server" type="string" readOnly="true"/> + <c:simple-property name="test-prop" type="string" required="true" defaultValue="Hello"/> + <c:group name="child:configuration=jsp-configuration"> + <c:simple-property name="check-interval" type="integer" units="seconds" readOnly="false" default="1"/> + <c:simple-property name="disabled" type="boolean" default="false"/> + </c:group> + <c:group name="child:configuration=static-resources"> + <c:simple-property name="listings" default="true" type="boolean"/> + <c:simple-property name="max-depth" default="9" type="integer" /> + </c:group> + </resource-configuration> + </server> + + <server class="foo" discovery="foo" name="test10"> + <resource-configuration> + <c:group name="children:system-property:name+" displayName="System-properties"> + <c:list-property name="*2" displayName="Properties" required="false" readOnly="false"> + <c:map-property name="*:name" displayName="Name" readOnly="true"> + <c:simple-property name="name" displayName="Property-Name" readOnly="true"/> + <c:simple-property name="value" displayName="Value"/> + </c:map-property> + </c:list-property> + </c:group> + </resource-configuration> + </server> + <server class="foo" discovery="foo" name="simple1">
<resource-configuration> diff --git a/modules/plugins/jboss-as-7/src/test/resources/web.json b/modules/plugins/jboss-as-7/src/test/resources/web.json new file mode 100644 index 0000000..96f0565 --- /dev/null +++ b/modules/plugins/jboss-as-7/src/test/resources/web.json @@ -0,0 +1,62 @@ +{ + "outcome" : "success", + "result" : + + + {"default-virtual-server" : "default-host", + "native" : true, + "configuration" : { + "container" : {}, + "static-resources" : { + "disabled" : false, + "listings" : false, + "max-depth" : 3, + "read-only" : true, + "sendfile" : 49152, + "webdav" : false}, + "jsp-configuration" : { + "check-interval" : 17, + "development" : false, + "disabled" : true, + "display-source-fragment" : true, + "dump-smap" : false, + "error-on-use-bean-invalid-class-attribute" : false, + "generate-strings-as-char-arrays" : false, + "java-encoding" : "UTF-8", + "keep-generated" : true, + "mapped-file" : true, + "modification-test-interval" : "7", + "recompile-on-fail" : false, + "smap" : false, + "source-vm" : "1.5", + "tag-pooling" : true, + "target-vm" : "1.5", + "trim-spaces" : true, + "x-powered-by" : true} + }, + "connector" : { + "http" : { + "enable-lookups" : true, + "enabled" : true, + "max-post-size" : 2097152, + "max-save-post-size" : 4096, + "protocol" : "HTTP/1.1", + "redirect-port" : 8443, + "scheme" : "http", + "secure" : false, + "socket-binding" : "http", + "ssl" : null, + "virtual-server" : null} + }, + + "virtual-server" : { + "default-host" : { + "access-log" : null, + "alias" : ["localhost","example.com"], + "default-web-module" : "ROOT.war", + "enable-welcome-root" : true, + "rewrite" : null, + "sso" : null} + } + } +}
commit abb8746798455eeeefa989688c4a52169062ac95 Author: Heiko W. Rupp hwr@redhat.com Date: Thu Feb 9 21:23:06 2012 +0100
Support for filtering in <c:option-source> elements.
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/ConfigurationManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/ConfigurationManagerBean.java index 60550be..11750c1 100644 --- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/ConfigurationManagerBean.java +++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/ConfigurationManagerBean.java @@ -25,6 +25,8 @@ import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; +import java.util.regex.Matcher; +import java.util.regex.Pattern;
import javax.ejb.EJB; import javax.ejb.Stateless; @@ -2511,6 +2513,11 @@ public class ConfigurationManagerBean implements ConfigurationManagerLocal, Conf PropertyOptionsSource pos = pds.getOptionsSource(); PropertyOptionsSource.TargetType tt = pos.getTargetType(); String expression = pos.getExpression(); + String filter = pos.getFilter(); + Pattern filterPattern = null; + if (filter!=null) + filterPattern = Pattern.compile(filter); + if (tt == PropertyOptionsSource.TargetType.RESOURCE || tt == PropertyOptionsSource.TargetType.CONFIGURATION) { ResourceCriteria criteria = new ResourceCriteria();
@@ -2533,10 +2540,21 @@ public class ConfigurationManagerBean implements ConfigurationManagerLocal, Conf
if (tt == PropertyOptionsSource.TargetType.RESOURCE) {
- PropertyDefinitionEnumeration pde = new PropertyDefinitionEnumeration(composite.getResource() - .getName(), "" + composite.getResource().getName()); - // TODO filter -- or leave up to search expression?? + String name = composite.getResource().getName(); + // filter if the user provided a filter + + if (filterPattern !=null ) { + Matcher m = filterPattern.matcher(name); + if (m.matches()) { + PropertyDefinitionEnumeration pde = new PropertyDefinitionEnumeration(name, "" + name); pds.getEnumeratedValues().add(pde); + } + } else { // Filter is null -> none provided -> do not filter + PropertyDefinitionEnumeration pde = new PropertyDefinitionEnumeration(name, "" + name); + pds.getEnumeratedValues().add(pde); + + } + } else if (tt == PropertyOptionsSource.TargetType.CONFIGURATION) { // for configuration we need to drill down into the resource configuration if (!handleConfigurationTarget(pds, expression, composite.getResource()))
rhq-commits@lists.fedorahosted.org