modules/core/plugin-test-util/src/main/java/org/rhq/core/plugin/testutil/AbstractAgentPluginTest.java
| 4
modules/plugins/jboss-as-7/pom.xml
| 56 +++++++++-
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASConnection.java
| 53 ++++-----
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASUploadConnection.java
| 11 +
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/AbstractBaseDiscovery.java
| 26 ++--
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseComponent.java
| 2
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseProcessDiscovery.java
| 2
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseServerComponent.java
| 4
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/HornetQComponent.java
| 6 -
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/HostControllerDiscovery.java
| 8 -
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ManagedASDiscovery.java
| 3
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/StandaloneASDiscovery.java
| 4
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Address.java
| 2
modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml
| 8 -
modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/XmlFileReadingTest.java
| 4
modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/domain/DomainServerComponentTest.java
| 8 -
modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/domain/DomainSocketBindingTest.java
| 10 -
modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/standalone/SocketBindingTest.java
| 4
modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/standalone/StandaloneServerComponentTest.java
| 12 +-
modules/plugins/platform/src/main/java/org/rhq/plugins/platform/LinuxPlatformComponent.java
| 51 +++++----
20 files changed, 166 insertions(+), 112 deletions(-)
New commits:
commit 60eff4ace2f42790a3edceb22db6b4e0986e26b9
Author: Ian Springer <ian.springer(a)redhat.com>
Date: Fri Mar 30 10:27:52 2012 -0400
make sure itests run in desired order; use exec plugin, rather than arquillian plugin,
in pom to start as7 standalone instance; various minor tweaks; turn down some logging to
make log less cluttered
diff --git a/modules/plugins/jboss-as-7/pom.xml b/modules/plugins/jboss-as-7/pom.xml
index 2c6a98e..6aa58df 100644
--- a/modules/plugins/jboss-as-7/pom.xml
+++ b/modules/plugins/jboss-as-7/pom.xml
@@ -297,9 +297,9 @@
</execution>
</executions>
</plugin>
-
+<!--
<plugin>
- <!-- use the arquillian plugin to start/stop the standalone server -->
+ <!- - use the arquillian plugin to start/stop the standalone server -
->
<groupId>org.jboss.arquillian.maven</groupId>
<artifactId>arquillian-maven-plugin</artifactId>
<version>1.0.0.Alpha2</version>
@@ -343,15 +343,63 @@
</dependencies>
</plugin>
-
+-->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2.1.jbossorg-3</version>
<executions>
+
+ <execution>
+ <id>start-as7-standalone</id>
+ <phase>pre-integration-test</phase>
+ <goals>
+ <goal>exec</goal>
+ </goals>
+ <configuration>
+ <background>true</background>
+ <!-- test blocks until the port at backgroundPollingAddress is
available (waiting for starting) -->
+ <!-- when maven jvm exits, this plugin will kill the running servers
-->
+
<backgroundPollingAddress>${jboss.standalone.bindAddress}:${jboss.standalone.nativeManagementPort}
+ </backgroundPollingAddress>
+ <executable>${java.home}/bin/java</executable>
+ <arguments>
+ <!-- Process Controller Java options -->
+ <argument>-D[Standalone]</argument>
+ <argument>-server</argument>
+ <argument>-XX:+UseCompressedOops</argument>
+ <argument>-XX:+TieredCompilation</argument>
+ <argument>-Xms64m</argument>
+ <argument>-Xmx512m</argument>
+ <argument>-XX:MaxPermSize=256m</argument>
+ <argument>-Djava.net.preferIPv4Stack=true</argument>
+ <argument>-Dorg.jboss.resolver.warning=true</argument>
+
<argument>-Dsun.rmi.dgc.client.gcInterval=3600000</argument>
+
<argument>-Dsun.rmi.dgc.server.gcInterval=3600000</argument>
+
<argument>-Djboss.modules.system.pkgs=org.jboss.byteman</argument>
+ <argument>-Djava.awt.headless=true</argument>
+
<argument>-Djboss.server.default.config=standalone.xml</argument>
+
<argument>-Dorg.jboss.boot.log.file=${jboss7.home}/standalone/log/boot.log</argument>
+
<argument>-Dlogging.configuration=file:${jboss7.home}/standalone/configuration/logging.properties</argument>
+ <argument>-jar</argument>
+ <argument>${jboss7.home}/jboss-modules.jar</argument>
+ <argument>-mp</argument>
+ <argument>${jboss7.home}/modules</argument>
+ <argument>-jaxpmodule</argument>
+ <argument>javax.xml.jaxp-provider</argument>
+ <argument>org.jboss.as.standalone</argument>
+ <argument>-Djboss.home.dir=${jboss7.home}</argument>
+
<argument>-Djboss.bind.address.management=${jboss.standalone.bindAddress}</argument>
+
<argument>-Djboss.bind.address=${jboss.standalone.bindAddress}</argument>
+
<argument>-Djboss.bind.address.unsecure=${jboss.standalone.bindAddress}</argument>
+
<argument>-Djboss.socket.binding.port-offset=${jboss.standalone.portOffset}</argument>
+ </arguments>
+ </configuration>
+ </execution>
+
<execution>
- <id>start-jboss7-host-controller</id>
+ <id>start-as7-domain</id>
<phase>pre-integration-test</phase>
<goals>
<goal>exec</goal>
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 5c1356a..39c3bd9 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
@@ -38,6 +38,7 @@ import org.codehaus.jackson.map.ObjectMapper;
import org.codehaus.jackson.map.SerializationConfig;
import org.rhq.core.pluginapi.inventory.InvalidPluginConfigurationException;
+import org.rhq.core.util.stream.StreamUtil;
import org.rhq.modules.plugins.jbossas7.json.ComplexResult;
import org.rhq.modules.plugins.jbossas7.json.Operation;
import org.rhq.modules.plugins.jbossas7.json.Result;
@@ -114,7 +115,7 @@ public class ASConnection {
* @see #executeComplex(org.rhq.modules.plugins.jbossas7.json.Operation)
*/
public JsonNode executeRaw(Operation operation) {
- return executeRaw(operation, 10);
+ return executeRaw(operation, 20);
}
/**
@@ -169,8 +170,8 @@ public class ASConnection {
}
InputStream inputStream;
- BufferedReader br = null;
- InputStream es = null;
+ BufferedReader inputReader = null;
+ InputStream errorStream = null;
try {
//add additional request property to include-defaults=true to all requests.
//if it's already set we leave it alone and assume that Operation creator
is taking over control.
@@ -215,17 +216,13 @@ public class ASConnection {
}
if (inputStream != null) {
- br = new BufferedReader(new InputStreamReader(inputStream));
- String line;
- StringBuilder builder = new StringBuilder();
- while ((line = br.readLine()) != null) {
- builder.append(line);
- }
+ inputReader = new BufferedReader(new InputStreamReader(inputStream));
+ String responseBody = StreamUtil.slurp(inputReader);
String outcome;
JsonNode operationResult;
- if (builder.length() > 0) {
- outcome = builder.toString();
+ if (responseBody.length() > 0) {
+ outcome = responseBody;
operationResult = mapper.readTree(outcome);
if (verbose) {
ObjectMapper om2 = new ObjectMapper();
@@ -240,26 +237,27 @@ public class ASConnection {
noResult.setOutcome("failure");
operationResult = mapper.valueToTree(noResult);
}
+
return operationResult;
} else {
//if not properly authorized sends plugin exception for visual indicator
in the ui.
if (responseCode == HttpURLConnection.HTTP_UNAUTHORIZED
|| responseCode == HttpURLConnection.HTTP_BAD_METHOD) {
if (log.isDebugEnabled()) {
- log.debug("[" + url + "] Response was empty and
response code was " + responseCode + " "
+ log.debug("Response to " + operation + " was empty
and response code was " + responseCode + " "
+ conn.getResponseMessage() + ".");
}
throw new InvalidPluginConfigurationException(
"Credentials for plugin to connect to AS7 management
interface are invalid. Update Connection Settings with valid credentials.");
} else {
- log.error("[" + url + "] Response was empty and
response code was " + responseCode + " "
- + conn.getResponseMessage() + ".");
+ log.error("Response to " + operation + " was empty and
response code was " + responseCode + " ("
+ + conn.getResponseMessage() + ").");
}
}
} catch (IllegalArgumentException iae) {
- log.error("Illegal argument " + iae + "\n\t for input " +
operation);
+ log.error("Illegal argument for input " + operation + ":
" + iae.getMessage());
} catch (SocketTimeoutException ste) {
- log.error("Request to AS timed out " + ste.getMessage());
+ log.error(operation + " timed out: " + ste.getMessage());
conn.disconnect();
Result failure = new Result();
failure.setFailureDescription(ste.getMessage());
@@ -269,20 +267,20 @@ public class ASConnection {
JsonNode ret = mapper.valueToTree(failure);
return ret;
} catch (IOException e) {
- log.error("Failed to get data: " + e.getMessage());
+ log.error("Failed to get data: " + e);
//the following code is in place to help keep-alive http connection re-use to
occur.
if (conn != null) {//on error conditions it's still necessary to read the
response so JDK knows can reuse
//the http connections behind the scenes.
- es = conn.getErrorStream();
- if (es != null) {
- BufferedReader dr = new BufferedReader(new InputStreamReader(es));
+ errorStream = conn.getErrorStream();
+ if (errorStream != null) {
+ BufferedReader dr = new BufferedReader(new
InputStreamReader(errorStream));
String ignore = null;
try {
while ((ignore = dr.readLine()) != null) {
//already reported error. just empty stream.
}
- es.close();
+ errorStream.close();
} catch (IOException e1) {
// ignore
}
@@ -298,20 +296,21 @@ public class ASConnection {
return ret;
} finally {
- if (br != null) {
+ if (inputReader != null) {
try {
- br.close();
+ inputReader.close();
} catch (IOException e) {
- log.error(e.getMessage());
+ log.error("Failed to close HTTP connection input stream: "
+ e.getMessage());
}
}
- if (es != null) {
+ if (errorStream != null) {
try {
- es.close();
+ errorStream.close();
} catch (IOException e) {
- log.error(e.getMessage());
+ log.error("Failed to close HTTP connection error stream: "
+ e.getMessage());
}
}
+
long t2 = System.currentTimeMillis();
PluginStats stats = PluginStats.getInstance();
stats.incrementRequestCount();
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 c4c5c03..c225406 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
@@ -115,8 +115,10 @@ public class ASUploadConnection {
os.flush();
int code = connection.getResponseCode();
- log.info("Response code for file upload: " + code);
- if (code==500)
+ if (code != 200) {
+ log.warn("Response code for file upload: " + code + "
" + connection.getResponseMessage());
+ }
+ if (code == 500)
is = connection.getErrorStream();
else
is = connection.getInputStream();
@@ -208,7 +210,6 @@ public class ASUploadConnection {
String reason = reasonNode.getTextValue();
return true;
}
-
} catch (Exception e) {
log.error(e);
return true;
@@ -217,12 +218,12 @@ public class ASUploadConnection {
return false;
}
-
private void closeQuietly(final Closeable closeable) {
if(closeable != null) {
try {
closeable.close();
- } catch (final IOException e) {}
+ } catch (final IOException ignore) {
+ }
}
}
}
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 a1993bc..aaa688a 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
@@ -92,12 +92,12 @@ public abstract class AbstractBaseDiscovery<T extends
ResourceComponent<?>> impl
* @see #readStandaloneOrHostXmlFromFile(String) for how to obtain the parsed xml
* @param commandLine Command line arguments of the process to
*/
- protected HostPort getManagementPortFromHostXml(String[] commandLine) {
+ protected HostPort getManagementHostPortFromHostXml(String[] commandLine) {
if (hostXml == null)
throw new IllegalArgumentException(CALL_READ_STANDALONE_OR_HOST_XML_FIRST);
String portString;
- String interfaceExpession;
+ String interfaceExpression;
String socketBindingName;
@@ -106,10 +106,10 @@ public abstract class AbstractBaseDiscovery<T extends
ResourceComponent<?>> impl
String portOffset = null;
if (!socketInterface.isEmpty()) {
- interfaceExpession =
obtainXmlPropertyViaXPath("//interfaces/interface[@name='" +
socketInterface
+ interfaceExpression =
obtainXmlPropertyViaXPath("//interfaces/interface[@name='" +
socketInterface
+ "']/inet-address/@value");
- if (interfaceExpession.isEmpty()) {
- interfaceExpession =
obtainXmlPropertyViaXPath("//interfaces/interface[@name='" +
socketInterface
+ if (interfaceExpression.isEmpty()) {
+ interfaceExpression =
obtainXmlPropertyViaXPath("//interfaces/interface[@name='" +
socketInterface
+ "']/loopback-address/@value");
}
portString =
obtainXmlPropertyViaXPath("//management/management-interfaces/http-interface/socket/@port");
@@ -117,10 +117,10 @@ public abstract class AbstractBaseDiscovery<T extends
ResourceComponent<?>> impl
// 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
+ interfaceExpression =
obtainXmlPropertyViaXPath("/server/interfaces/interface[@name='" +
interfaceName
+ "']/inet-address/@value");
- if (interfaceExpession.isEmpty()) {
- interfaceExpession =
obtainXmlPropertyViaXPath("/server/interfaces/interface[@name='" +
interfaceName
+ if (interfaceExpression.isEmpty()) {
+ interfaceExpression =
obtainXmlPropertyViaXPath("/server/interfaces/interface[@name='" +
interfaceName
+ "']/loopback-address/@value");
}
} else {
@@ -136,17 +136,17 @@ public abstract class AbstractBaseDiscovery<T extends
ResourceComponent<?>> impl
portOffset = obtainXmlPropertyViaXPath(xpathExpression);
// TODO the next may also be expressed differently
- interfaceExpession =
obtainXmlPropertyViaXPath("/server/interfaces/interface[@name='" +
interfaceName
+ interfaceExpression =
obtainXmlPropertyViaXPath("/server/interfaces/interface[@name='" +
interfaceName
+ "']/inet-address/@value");
- if (interfaceExpession.isEmpty()) {
- interfaceExpession =
obtainXmlPropertyViaXPath("/server/interfaces/interface[@name='" +
interfaceName
+ if (interfaceExpression.isEmpty()) {
+ interfaceExpression =
obtainXmlPropertyViaXPath("/server/interfaces/interface[@name='" +
interfaceName
+ "']/loopback-address/@value");
}
}
HostPort hp = new HostPort();
- if (!interfaceExpession.isEmpty())
- hp.host = replaceDollarExpression(interfaceExpession, commandLine,
"localhost");
+ if (!interfaceExpression.isEmpty())
+ hp.host = replaceDollarExpression(interfaceExpression, commandLine,
"localhost");
else
hp.host = "localhost"; // Fallback
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 590da14..cea3ee6 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
@@ -163,7 +163,7 @@ public class BaseComponent<T extends ResourceComponent<?>>
implements AS7Compone
String reqName = req.getName();
ComplexRequest request = null;
- Operation op = null;
+ Operation op;
if (reqName.contains(":")) {
request = ComplexRequest.create(reqName);
op = new ReadAttribute(address, request.getProp());
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 2eec0d5..bffac1c 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
@@ -116,7 +116,7 @@ public abstract class BaseProcessDiscovery extends
AbstractBaseDiscovery
fillUserPassFromFile(pluginConfig, getMode(), baseDir);
File logFile = getLogFile(getLogDir(process, baseDir));
initLogEventSourcesConfigProp(logFile.getPath(), pluginConfig);
- HostPort managementHostPort = getManagementPortFromHostXml(commandLine);
+ HostPort managementHostPort = getManagementHostPortFromHostXml(commandLine);
pluginConfig.put(new PropertySimple("hostname",
managementHostPort.host));
pluginConfig.put(new PropertySimple("port", managementHostPort.port));
pluginConfig.put(new PropertySimple("realm",
getManagementSecurityRealmFromHostXml()));
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 20e5518..79fc444 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
@@ -357,8 +357,8 @@ public class BaseServerComponent<T extends
ResourceComponent<?>> extends BaseCom
Result res = getASConnection().execute(op);
if (res.isSuccess()) {
- Long startTime= (Long) res.getResult();
- MeasurementDataTrait data = new MeasurementDataTrait(request,new
Date(startTime).toString());
+ Long startTime = (Long) res.getResult();
+ MeasurementDataTrait data = new MeasurementDataTrait(request, new
Date(startTime).toString());
report.addData(data);
}
}
diff --git
a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/HornetQComponent.java
b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/HornetQComponent.java
index c578607..d07ebeb 100644
---
a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/HornetQComponent.java
+++
b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/HornetQComponent.java
@@ -40,10 +40,8 @@ public class HornetQComponent extends BaseComponent {
targetAddress.add(targetType.as7name,resourceName);
List<String> entries;
- Operation op;
-
Result res;
- op = new Operation("read-operation-description",targetAddress);
+ Operation op = new
Operation("read-operation-description",targetAddress);
op.addAdditionalProperty("name","add");
ComplexResult cres = getASConnection().executeComplex(op);
Map<String,Map<String,Object>> definitions;
@@ -205,7 +203,7 @@ public class HornetQComponent extends BaseComponent {
/**
* Create a Type
* @param descriptorName type name as it is listed in the plugin descriptor
- * @param as7name the type undder which as7 knows it.
+ * @param as7name the type by which as7 knows it.
*/
CreationType(String descriptorName, String as7name) {
diff --git
a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/HostControllerDiscovery.java
b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/HostControllerDiscovery.java
index a7e684d..140cef6 100644
---
a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/HostControllerDiscovery.java
+++
b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/HostControllerDiscovery.java
@@ -82,14 +82,16 @@ public class HostControllerDiscovery extends BaseProcessDiscovery {
@Override
protected String buildDefaultResourceName(HostPort hostPort, String configName,
JBossProductType productType) {
- String suffix = (hostPort.isLocal) ? "Domain Controller" : "Host
Controller";
+ boolean isDomainController = hostPort.isLocal;
+ String suffix = (isDomainController) ? "Domain Controller" : "Host
Controller";
return configName + " " + productType.NAME + " " + suffix;
}
@Override
protected String buildDefaultResourceDescription(HostPort hostPort, JBossProductType
productType) {
- String prefix = (hostPort.isLocal) ? "Domain controller" : "Host
controller";
- String suffix = (hostPort.isLocal) ? "domain" : "host";
+ boolean isDomainController = hostPort.isLocal;
+ String prefix = (isDomainController) ? "Domain controller" : "Host
controller";
+ String suffix = (isDomainController) ? "domain" : "host";
return prefix + " for a " + productType.FULL_NAME + " " +
suffix;
}
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 69bd8d4..0308fd1 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
@@ -45,8 +45,7 @@ import org.rhq.modules.plugins.jbossas7.json.Result;
*
* @author Heiko W. Rupp
*/
-public class ManagedASDiscovery extends
AbstractBaseDiscovery<HostControllerComponent<?>>
- {
+public class ManagedASDiscovery extends
AbstractBaseDiscovery<HostControllerComponent<?>> {
private HostControllerComponent parentComponent;
diff --git
a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/StandaloneASDiscovery.java
b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/StandaloneASDiscovery.java
index 2075385..848f0e7 100644
---
a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/StandaloneASDiscovery.java
+++
b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/StandaloneASDiscovery.java
@@ -97,8 +97,8 @@ public class StandaloneASDiscovery extends BaseProcessDiscovery {
}
@Override
- protected HostPort getManagementPortFromHostXml(String[] commandLine) {
- HostPort managementPort = super.getManagementPortFromHostXml(commandLine);
+ protected HostPort getManagementHostPortFromHostXml(String[] commandLine) {
+ HostPort managementPort = super.getManagementHostPortFromHostXml(commandLine);
if (!managementPort.withOffset) {
managementPort = checkForSocketBindingOffset(managementPort, commandLine);
}
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 504be88..9fbe31b 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
@@ -49,7 +49,7 @@ public class Address {
}
/**
- * Construct an Addres by cloning another
+ * Construct an Address by cloning another
* @param other Address to clone
*/
public Address(Address other) {
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 47ad52d..cec63da 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
@@ -118,8 +118,7 @@
<metric property="_internal:mgmtRequests"
category="performance" dataType="measurement"
defaultInterval="120000"
displayType="summary" measurementType="trendsup"
description="Number of requests sent to the controller"
- displayName="Number of management requests"
- />
+ displayName="Number of management requests"/>
<metric property="_internal:requestTime"
category="performance" dataType="measurement"
defaultInterval="120000"
displayType="summary" measurementType="trendsup"
description="Total time for requests" units="milliseconds"
displayName="Time used for management requests"/>
@@ -424,6 +423,7 @@
</service>
</server>
+
<server name="JBossAS7 Standalone Server"
discovery="StandaloneASDiscovery"
class="StandaloneASComponent"
@@ -495,10 +495,10 @@
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"
+ <metric property="server-state" dataType="trait"
displayName="Server State" description="Detailed server state"
displayType="summary"/>
&serverKindMetrics;
- <metric property="startTime" dataType="trait"
displayName="Start time of the server" defaultOn="true"/>
+ <metric property="startTime" dataType="trait"
displayName="Server Start Time" defaultOn="true"/>
<event name="logEntry" description="an entry in a log
file"/>
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
index 7c7c70f..243574e 100644
---
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
@@ -17,7 +17,7 @@ public class XmlFileReadingTest {
URL url = getClass().getClassLoader().getResource("standalone70.xml");
bd.readStandaloneOrHostXmlFromFile(url.getFile());
- AbstractBaseDiscovery.HostPort hp = bd.getManagementPortFromHostXml(new
String[]{});
+ AbstractBaseDiscovery.HostPort hp = bd.getManagementHostPortFromHostXml(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;
@@ -29,7 +29,7 @@ public class XmlFileReadingTest {
URL url = getClass().getClassLoader().getResource("standalone71.xml");
bd.readStandaloneOrHostXmlFromFile(url.getFile());
- AbstractBaseDiscovery.HostPort hp = bd.getManagementPortFromHostXml(new
String[]{});
+ AbstractBaseDiscovery.HostPort hp = bd.getManagementHostPortFromHostXml(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;
diff --git
a/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/domain/DomainServerComponentTest.java
b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/domain/DomainServerComponentTest.java
index 5400e57..a4b6123 100644
---
a/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/domain/DomainServerComponentTest.java
+++
b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/domain/DomainServerComponentTest.java
@@ -57,7 +57,7 @@ public class DomainServerComponentTest extends
AbstractServerComponentTest {
return "jboss.domain.portOffset";
}
- @Test(priority = 20, groups = "discovery")
+ @Test(priority = 1000, groups = "discovery")
@RunDiscovery
public void testDomainServerDiscovery() throws Exception {
super.testAutoDiscovery();
@@ -65,20 +65,20 @@ public class DomainServerComponentTest extends
AbstractServerComponentTest {
// ******************************* METRICS ******************************* //
@Override
- @Test(priority = 21, enabled = true)
+ @Test(priority = 1001, enabled = true)
public void testMetricsHaveNonNullValues() throws Exception {
super.testMetricsHaveNonNullValues();
}
@Override
- @Test(priority = 21, enabled = true)
+ @Test(priority = 1002, enabled = true)
public void testReleaseVersionTrait() throws Exception {
super.testReleaseVersionTrait();
}
// ******************************* OPERATIONS ******************************* //
// TODO: Re-enable this once "shutdown" operation has been fixed.
- @Test(priority = 22, enabled = false)
+ @Test(priority = 1003, enabled = false)
public void testDomainServerShutdownAndStartOperations() throws Exception {
super.testShutdownAndStartOperations();
}
diff --git
a/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/domain/DomainSocketBindingTest.java
b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/domain/DomainSocketBindingTest.java
index 0dd5d0c..f7730c8 100644
---
a/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/domain/DomainSocketBindingTest.java
+++
b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/domain/DomainSocketBindingTest.java
@@ -54,7 +54,7 @@ public class DomainSocketBindingTest extends AbstractJBossAS7PluginTest
{
public static final ResourceType RESOURCE_TYPE = new
ResourceType("SocketBindingGroup", PLUGIN_NAME, ResourceCategory.SERVICE,
null);
private static final String RESOURCE_KEY =
"socket-binding-group=standard-sockets";
- @Test(priority = 10,groups = "discovery")
+ @Test(priority = 1010,groups = "discovery")
@RunDiscovery(discoverServices = true, discoverServers = true)
public void runDiscovery() throws Exception {
Resource platform = this.pluginContainer.getInventoryManager().getPlatform();
@@ -68,13 +68,13 @@ public class DomainSocketBindingTest extends
AbstractJBossAS7PluginTest {
}
- @Test(priority = 11)
+ @Test(priority = 1011)
public void loadBindings() throws Exception {
loadConfig();
}
- @Test(priority = 11)
+ @Test(priority = 1011)
public void addBinding() throws Exception {
Configuration configuration = loadConfig();
@@ -104,7 +104,7 @@ public class DomainSocketBindingTest extends
AbstractJBossAS7PluginTest {
assert pl.getList().size() == count+1 : "Got only " +
pl.getList().size() + " items, expected "+ (count+1);
}
- @Test(priority = 11)
+ @Test(priority = 1011)
public void addModifyBinding() throws Exception {
Configuration configuration = loadConfig();
@@ -146,7 +146,7 @@ public class DomainSocketBindingTest extends
AbstractJBossAS7PluginTest {
}
- @Test(priority = 11)
+ @Test(priority = 1011)
public void addRemoveBinding() throws Exception {
Configuration configuration = loadConfig();
diff --git
a/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/standalone/SocketBindingTest.java
b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/standalone/SocketBindingTest.java
index 99f8347..279efdf 100644
---
a/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/standalone/SocketBindingTest.java
+++
b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/standalone/SocketBindingTest.java
@@ -56,13 +56,13 @@ public class SocketBindingTest extends AbstractJBossAS7PluginTest {
private static final String RESOURCE_KEY =
"socket-binding-group=standard-sockets";
@Test(priority = 10,groups = "discovery")
- @RunDiscovery(discoverServices = true, discoverServers = true) public void
doSomeDiscovery() throws Exception {
+ @RunDiscovery(discoverServices = true, discoverServers = true)
+ public void doSomeDiscovery() throws Exception {
Resource platform = this.pluginContainer.getInventoryManager().getPlatform();
assertNotNull(platform);
assertEquals(platform.getInventoryStatus(), InventoryStatus.COMMITTED);
Thread.sleep(20*1000L); // delay so that PC gets a chance to scan for resources
-
}
@Test(priority = 11)
diff --git
a/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/standalone/StandaloneServerComponentTest.java
b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/standalone/StandaloneServerComponentTest.java
index a221a27..9bd1d56 100644
---
a/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/standalone/StandaloneServerComponentTest.java
+++
b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/standalone/StandaloneServerComponentTest.java
@@ -64,7 +64,7 @@ public class StandaloneServerComponentTest extends
AbstractServerComponentTest {
return "jboss.standalone.portOffset";
}
- @Test(priority = 10, groups = "discovery")
+ @Test(priority = 1, groups = "discovery")
@RunDiscovery
public void testStandaloneServerDiscovery() throws Exception {
super.testAutoDiscovery();
@@ -72,31 +72,31 @@ public class StandaloneServerComponentTest extends
AbstractServerComponentTest {
// ******************************* METRICS ******************************* //
@Override
- @Test(priority = 11, enabled = true)
+ @Test(priority = 2, enabled = true)
public void testMetricsHaveNonNullValues() throws Exception {
super.testMetricsHaveNonNullValues();
}
@Override
- @Test(priority = 11, enabled = true)
+ @Test(priority = 3, enabled = true)
public void testReleaseVersionTrait() throws Exception {
super.testReleaseVersionTrait();
}
// ******************************* OPERATIONS ******************************* //
- @Test(priority = 12)
+ @Test(priority = 4)
public void testReloadOperation() throws Exception {
invokeOperationAndAssertSuccess(getServerResource(), RELOAD_OPERATION_NAME,
null);
}
// TODO: Re-enable this once "shutdown" operation has been fixed.
- @Test(priority = 13, enabled = false)
+ @Test(priority = 5, enabled = false)
public void testStandaloneServerShutdownAndStartOperations() throws Exception {
super.testShutdownAndStartOperations();
}
// TODO: Re-enable once fixed.
- @Test(priority = 13, dependsOnMethods =
"testStandaloneServerShutdownAndStartOperations", enabled = false)
+ @Test(priority = 5, dependsOnMethods =
"testStandaloneServerShutdownAndStartOperations", enabled = false)
public void testRestartOperation() throws Exception {
AvailabilityType avail = getAvailability(getServerResource());
assertEquals(avail, AvailabilityType.UP);
commit 5ed1b78e4863ef169825f18c2562297831d2d7f1
Author: Ian Springer <ian.springer(a)redhat.com>
Date: Fri Mar 30 09:51:54 2012 -0400
use longs, not ints, for timeout vars
diff --git
a/modules/core/plugin-test-util/src/main/java/org/rhq/core/plugin/testutil/AbstractAgentPluginTest.java
b/modules/core/plugin-test-util/src/main/java/org/rhq/core/plugin/testutil/AbstractAgentPluginTest.java
index 8a28883..05e1578 100644
---
a/modules/core/plugin-test-util/src/main/java/org/rhq/core/plugin/testutil/AbstractAgentPluginTest.java
+++
b/modules/core/plugin-test-util/src/main/java/org/rhq/core/plugin/testutil/AbstractAgentPluginTest.java
@@ -151,7 +151,7 @@ public abstract class AbstractAgentPluginTest extends Arquillian {
protected AvailabilityType getAvailability(Resource resource)
throws PluginContainerException {
ResourceContainer resourceContainer =
this.pluginContainer.getInventoryManager().getResourceContainer(resource);
- int timeoutMillis = 5000;
+ long timeoutMillis = 5000;
AvailabilityFacet availFacet =
resourceContainer.createResourceComponentProxy(AvailabilityFacet.class,
FacetLockType.READ, timeoutMillis, false, false);
AvailabilityType avail;
@@ -292,7 +292,7 @@ public abstract class AbstractAgentPluginTest extends Arquillian {
+ "] is defined for ResourceType {" + resourceType.getPlugin()
+ "}" + resourceType.getName() + ".");
ResourceContainer resourceContainer =
this.pluginContainer.getInventoryManager().getResourceContainer(resource);
- int timeoutMillis = 7000;
+ long timeoutMillis = 5000;
MeasurementFacet measurementFacet =
resourceContainer.createResourceComponentProxy(MeasurementFacet.class,
FacetLockType.READ, timeoutMillis, false, false);
MeasurementReport report = new MeasurementReport();
commit 8281cfec83438bad0251a739b106a25d338b0d25
Author: Ian Springer <ian.springer(a)redhat.com>
Date: Thu Mar 29 16:41:34 2012 -0400
don't attempt to do any yum stuff if the internal yum server is disabled
diff --git
a/modules/plugins/platform/src/main/java/org/rhq/plugins/platform/LinuxPlatformComponent.java
b/modules/plugins/platform/src/main/java/org/rhq/plugins/platform/LinuxPlatformComponent.java
index 38833eb..1f336fa 100644
---
a/modules/plugins/platform/src/main/java/org/rhq/plugins/platform/LinuxPlatformComponent.java
+++
b/modules/plugins/platform/src/main/java/org/rhq/plugins/platform/LinuxPlatformComponent.java
@@ -1,6 +1,6 @@
/*
* RHQ Management Platform
- * Copyright (C) 2005-2008 Red Hat, Inc.
+ * Copyright (C) 2005-2012 Red Hat, Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
@@ -57,6 +57,7 @@ import org.rhq.plugins.platform.content.yum.YumProxy;
import org.rhq.plugins.platform.content.yum.YumServer;
public class LinuxPlatformComponent extends PosixPlatformComponent implements
ContentFacet {
+
// the prefix for all distro trait names
private static final String DISTRO_TRAIT_NAME_PREFIX = "distro.";
@@ -66,15 +67,12 @@ public class LinuxPlatformComponent extends PosixPlatformComponent
implements Co
private final Log log = LogFactory.getLog(LinuxPlatformComponent.class);
- private ContentContext contentContext;
-
- private YumServer yumServer = new YumServer();
- private YumProxy yumProxy = new YumProxy();
+ private YumServer yumServer;
+ private YumProxy yumProxy;
private boolean enableContentDiscovery = false;
private boolean enableInternalYumServer = false;
-
@Override
public void start(ResourceContext context) {
super.start(context);
@@ -106,17 +104,17 @@ public class LinuxPlatformComponent extends PosixPlatformComponent
implements Co
startWithContentContext(context.getContentContext());
-
return;
}
@Override
public void stop() {
-
- try {
- yumServer.halt();
- } catch (Exception e) {
- log.warn("Failed to shutdown the yum server", e);
+ if (yumServer != null) {
+ try {
+ yumServer.halt();
+ } catch (Exception e) {
+ log.warn("Failed to shutdown the yum server.", e);
+ }
}
super.stop();
@@ -124,17 +122,18 @@ public class LinuxPlatformComponent extends PosixPlatformComponent
implements Co
private void startWithContentContext(ContentContext context) {
if (this.enableInternalYumServer) {
+ yumServer = new YumServer();
+ yumProxy = new YumProxy();
+
int port = yumPort();
log.debug("yum port=[" + port + "]");
- this.contentContext = context;
try {
YumContext yumContext = new PluginContext(port, this.resourceContext,
context);
yumServer.start(yumContext);
yumProxy.init(this.resourceContext);
-
} catch (Exception e) {
- log.error("Start failed:", e);
+ log.error("Failed to start yum server.", e);
}
} else {
log.info("Internal yum server is disabled.");
@@ -163,6 +162,10 @@ public class LinuxPlatformComponent extends PosixPlatformComponent
implements Co
}
public DeployPackagesResponse deployPackages(Set<ResourcePackageDetails>
packages, ContentServices contentServices) {
+ if (!this.enableInternalYumServer) {
+ throw new UnsupportedOperationException("Internal yum server is disabled
- this operation is a no-op.");
+ }
+
try {
DeployPackagesResponse result = new
DeployPackagesResponse(ContentResponseResult.SUCCESS);
List<String> pkgs = new ArrayList<String>();
@@ -188,6 +191,10 @@ public class LinuxPlatformComponent extends PosixPlatformComponent
implements Co
}
public RemovePackagesResponse removePackages(Set<ResourcePackageDetails>
packages) {
+ if (!this.enableInternalYumServer) {
+ throw new UnsupportedOperationException("Internal yum server is disabled
- this operation is a no-op.");
+ }
+
try {
RemovePackagesResponse result = new
RemovePackagesResponse(ContentResponseResult.SUCCESS);
List<String> pkgs = new ArrayList<String>();
@@ -223,14 +230,13 @@ public class LinuxPlatformComponent extends PosixPlatformComponent
implements Co
@Override
public OperationResult invokeOperation(String name, Configuration parameters) throws
Exception {
if ("cleanYumMetadataCache".equals(name)) {
- if (this.yumServer.isStarted()) {
- log.info("Cleaning yum metadata");
- yumServer.cleanMetadata();
- yumProxy.cleanMetadata();
- return new OperationResult();
- } else {
- throw new UnsupportedOperationException("Internal yum server is
disabled, this operation is a no-op");
+ if (!this.enableInternalYumServer) {
+ throw new UnsupportedOperationException("Internal yum server is
disabled - this operation is a no-op.");
}
+ log.info("Cleaning yum metadata...");
+ yumServer.cleanMetadata();
+ yumProxy.cleanMetadata();
+ return new OperationResult();
}
return super.invokeOperation(name, parameters);
@@ -253,4 +259,5 @@ public class LinuxPlatformComponent extends PosixPlatformComponent
implements Co
PropertySimple p =
this.resourceContext.getPluginConfiguration().getSimple("yumPort");
return ((p != null) ? p.getIntegerValue() : 9080);
}
+
}
\ No newline at end of file