[rhq] Branch 'jsanda/cassandra-plugin' - 2 commits - modules/plugins
by snegrea
modules/plugins/cassandra/src/main/resources/META-INF/rhq-plugin.xml | 2
modules/plugins/jmx/src/main/java/org/rhq/plugins/jmx/JMXServerComponent.java | 33 ++++++----
2 files changed, 24 insertions(+), 11 deletions(-)
New commits:
commit f523eb50cf96aa4f213acf38ffff2898321d7090
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Fri Oct 26 11:55:25 2012 -0500
Correct parameter name to match execution code.
diff --git a/modules/plugins/cassandra/src/main/resources/META-INF/rhq-plugin.xml b/modules/plugins/cassandra/src/main/resources/META-INF/rhq-plugin.xml
index 50a24fa..1966ea3 100644
--- a/modules/plugins/cassandra/src/main/resources/META-INF/rhq-plugin.xml
+++ b/modules/plugins/cassandra/src/main/resources/META-INF/rhq-plugin.xml
@@ -400,7 +400,7 @@
</operation>
<operation name="restoreSnapshot" description="Restore the column family from a previously taken snapshot.">
<parameters>
- <c:simple-property name="name" required="true" type="string" description="Snapshot Name">
+ <c:simple-property name="snapshotName" required="true" type="string" description="Snapshot Name">
<c:option-source target="configuration" expression="snapshots/snapshot=name"/>
</c:simple-property>
</parameters>
commit 4c9f26dc5301d3f3e4cd7ac128d496b5dfa2ae4c
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Fri Oct 26 11:53:17 2012 -0500
Updating the JMX plugin to check if the connection is still open or valid before returning the connection object. In case the connection is no longer valid, the code will attempt to reconnect to the server.
The reconnection code was already used in the availability method. This change only expands its usage.
diff --git a/modules/plugins/jmx/src/main/java/org/rhq/plugins/jmx/JMXServerComponent.java b/modules/plugins/jmx/src/main/java/org/rhq/plugins/jmx/JMXServerComponent.java
index 1b6dd2c..e510c44 100644
--- a/modules/plugins/jmx/src/main/java/org/rhq/plugins/jmx/JMXServerComponent.java
+++ b/modules/plugins/jmx/src/main/java/org/rhq/plugins/jmx/JMXServerComponent.java
@@ -24,7 +24,6 @@ package org.rhq.plugins.jmx;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-
import org.mc4j.ems.connection.EmsConnection;
import org.mc4j.ems.connection.support.ConnectionProvider;
@@ -44,7 +43,7 @@ import org.rhq.plugins.jmx.util.ConnectionProviderFactory;
* versions. The same holds true for Hibernate applications - multiple connections can be created
* to different versions of the Hibernate MBean and due to the isolation of each connection, there
* are no version incompatibility errors that will occur.
- *
+ *
* @author Greg Hinkle
* @author John Mazzitelli
*/
@@ -106,18 +105,13 @@ public class JMXServerComponent<T extends ResourceComponent<?>> implements JMXCo
}
public EmsConnection getEmsConnection() {
+ this.reconnectIfDisconnected();
+
return this.connection;
}
public AvailabilityType getAvailability() {
- if ((connectionProvider) == null || !connectionProvider.isConnected()) {
- try {
- internalStart();
- } catch (Exception e) {
- log.debug("Still unable to reconnect to " + context.getResourceType() + "[" + context.getResourceKey()
- + "] due to error: " + e);
- }
- }
+ this.reconnectIfDisconnected();
return ((connectionProvider != null) && connectionProvider.isConnected()) ? AvailabilityType.UP
: AvailabilityType.DOWN;
@@ -127,4 +121,23 @@ public class JMXServerComponent<T extends ResourceComponent<?>> implements JMXCo
return this.context;
}
+ /**
+ * This method will attempt to reestablish the connection to the JMX server
+ * if it detects that the current connection is no longer open or valid.
+ *
+ * The code that detects if a connection is still open or valid is in the external
+ * EMS library and depends on the type of connection provider. Please read the EMS
+ * documentation and code for more details on how ConnectionProvider.isConnected()
+ * works for different supported providers.
+ */
+ private synchronized void reconnectIfDisconnected() {
+ if ((connectionProvider) == null || !connectionProvider.isConnected()) {
+ try {
+ internalStart();
+ } catch (Exception e) {
+ log.debug("Still unable to reconnect to " + context.getResourceType() + "[" + context.getResourceKey()
+ + "] due to error: " + e);
+ }
+ }
+ }
}
\ No newline at end of file
11 years, 6 months
[rhq] Branch 'feature/cassandra-backend' - 2 commits - modules/common modules/enterprise
by John Sanda
modules/common/cassandra-common/src/main/java/org/rhq/cassandra/DeploymentOptions.java | 47 ++++++++-
modules/enterprise/gui/installer/src/main/java/org/rhq/enterprise/gui/installer/client/Installer.java | 20 ++++
modules/enterprise/gui/installer/src/main/java/org/rhq/enterprise/gui/installer/client/shared/ServerProperties.java | 2
modules/enterprise/server/appserver/src/main/scripts/rhq-container.build.xml | 14 ++
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cassandra/CassandraClusterManagerBean.java | 50 ++++++----
5 files changed, 108 insertions(+), 25 deletions(-)
New commits:
commit 01b12e00f66560e63f00487dccd79c3c7d33a317
Author: John Sanda <jsanda(a)redhat.com>
Date: Fri Oct 26 08:06:59 2012 -0400
update start up logic to first look at system properties for cluster configuration
Since cluster configuration properties are now in rhq-server.properties they are
made available as system properties. Now at start up we first look cluster
config property values in system properties and then fall back to the values in
cassandra.properties for defaults if system properties are not defined. Logic
has also been added to only do the unmanaged deployment if it is an embedded
cluster.
diff --git a/modules/common/cassandra-common/src/main/java/org/rhq/cassandra/DeploymentOptions.java b/modules/common/cassandra-common/src/main/java/org/rhq/cassandra/DeploymentOptions.java
index 3aee5a3..e2c6edb 100644
--- a/modules/common/cassandra-common/src/main/java/org/rhq/cassandra/DeploymentOptions.java
+++ b/modules/common/cassandra-common/src/main/java/org/rhq/cassandra/DeploymentOptions.java
@@ -25,13 +25,20 @@
package org.rhq.cassandra;
+import java.io.IOException;
+import java.io.InputStream;
import java.util.Properties;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
/**
* @author John Sanda
*/
public class DeploymentOptions {
+ private final Log log = LogFactory.getLog(DeploymentOptions.class);
+
private String bundleFileName;
private String bundleName;
private String bundleVersion;
@@ -42,17 +49,49 @@ public class DeploymentOptions {
private String loggingLevel;
public DeploymentOptions() {
+ init(loadProperties());
+ }
+
+ private Properties loadProperties() {
+ InputStream stream = null;
+ try {
+ stream = getClass().getResourceAsStream("/cassandra.properties");
+ Properties props = new Properties();
+ props.load(stream);
+
+ return props;
+ } catch (IOException e) {
+ throw new RuntimeException("Unable to create DeploymentOptions. An error occurred while loading " +
+ "cassandra.properties", e);
+ } finally {
+ if (stream != null) {
+ try {
+ stream.close();
+ } catch (IOException e) {
+ String msg = "An error occurred while closing input stream on cassandra.properties";
+ log.info(msg, e);
+ }
+ }
+ }
}
public DeploymentOptions(Properties properties) {
+ init(properties);
+ }
+
+ private void init(Properties properties) {
setBundleFileName(properties.getProperty("rhq.cassandra.bundle.filename"));
setBundleName(properties.getProperty("rhq.cassandra.bundle.name"));
setBundleVersion(properties.getProperty("rhq.cassandra.bundle.version"));
- setClusterDir(properties.getProperty("rhq.cassandra.cluster.dir"));
- setNumNodes(Integer.parseInt(properties.getProperty("rhq.cassandra.cluster.num-nodes")));
+ setClusterDir(System.getProperty("rhq.cassandra.cluster.dir",
+ properties.getProperty("rhq.cassandra.cluster.dir")));
+ setNumNodes(Integer.parseInt(System.getProperty("rhq.cassandra.cluster.num-nodes",
+ properties.getProperty("rhq.cassandra.cluster.num-nodes"))));
setAutoDeploy(Boolean.valueOf(properties.getProperty("rhq.cassandra.cluster.auto-deploy")));
- setEmbedded(Boolean.valueOf(properties.getProperty("rhq.cassandra.cluster.is-embedded")));
- setLoggingLevel(properties.getProperty("rhq.cassandra.logging.level"));
+ setEmbedded(Boolean.valueOf(System.getProperty("rhq.cassandra.cluster.is-embedded",
+ properties.getProperty("rhq.cassandra.cluster.is-embedded"))));
+ setLoggingLevel(System.getProperty("rhq.cassandra.logging.level",
+ properties.getProperty("rhq.cassandra.logging.level")));
}
public String getBundleFileName() {
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cassandra/CassandraClusterManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cassandra/CassandraClusterManagerBean.java
index 7a0fbaa..00660a2 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cassandra/CassandraClusterManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cassandra/CassandraClusterManagerBean.java
@@ -47,8 +47,8 @@ import org.apache.commons.logging.LogFactory;
import org.quartz.JobDataMap;
import org.quartz.SchedulerException;
-import org.rhq.cassandra.CassandraException;
import org.rhq.cassandra.BootstrapDeployer;
+import org.rhq.cassandra.CassandraException;
import org.rhq.cassandra.DeploymentOptions;
import org.rhq.core.domain.auth.Subject;
import org.rhq.core.domain.bundle.Bundle;
@@ -64,13 +64,16 @@ import org.rhq.core.domain.resource.Resource;
import org.rhq.core.domain.resource.ResourceCategory;
import org.rhq.core.domain.resource.group.ResourceGroup;
import org.rhq.core.domain.util.PageList;
+import org.rhq.core.util.PropertiesFileUpdate;
import org.rhq.core.util.stream.StreamUtil;
import org.rhq.enterprise.server.auth.SubjectManagerLocal;
import org.rhq.enterprise.server.bundle.BundleManagerLocal;
+import org.rhq.enterprise.server.core.CoreServerMBean;
import org.rhq.enterprise.server.resource.ResourceManagerLocal;
import org.rhq.enterprise.server.resource.ResourceNotFoundException;
import org.rhq.enterprise.server.resource.group.ResourceGroupManagerLocal;
import org.rhq.enterprise.server.scheduler.SchedulerLocal;
+import org.rhq.enterprise.server.util.LookupUtil;
/**
* @author John Sanda
@@ -98,20 +101,12 @@ public class CassandraClusterManagerBean implements CassandraClusterManagerLocal
@Override
@TransactionAttribute(NEVER)
public void installBundle() throws CassandraException {
- Properties deploymentProps = null;
- try {
- deploymentProps = loadDeploymentProps();
- } catch (IOException e) {
- String msg = "An error occurred while trying to load cassandra.properties. Cannot proceed with " +
- "Cassandra bundle installation";
- logException(msg, e);
- throw new CassandraException(msg, e);
- }
+ DeploymentOptions deploymentOptions = new DeploymentOptions();
File deployBaseDir = getDeployBaseDir();
Subject overlord = subjectManager.getOverlord();
- String bundleName = deploymentProps.getProperty("rhq.cassandra.bundle.name");
- String bundleVersionString = deploymentProps.getProperty("rhq.cassandra.bundle.version");
- String bundleFileName = deploymentProps.getProperty("rhq.cassandra.bundle.filename");
+ String bundleName = deploymentOptions.getBundleName();
+ String bundleVersionString = deploymentOptions.getBundleVersion();
+ String bundleFileName = deploymentOptions.getBundleFileName();
Bundle bundle = null;
try {
bundle = getBundle(overlord, bundleName);
@@ -130,16 +125,37 @@ public class CassandraClusterManagerBean implements CassandraClusterManagerLocal
throw new CassandraException(msg, e);
}
- BootstrapDeployer deployer = new BootstrapDeployer();
- deployer.setDeploymentOptions(new DeploymentOptions(deploymentProps));
- deployer.deploy();
+ String seeds;
+ if (deploymentOptions.isEmbedded()) {
+ BootstrapDeployer deployer = new BootstrapDeployer();
+ deployer.setDeploymentOptions(deploymentOptions);
+ seeds = deployer.getCassandraHosts();
+
+ // need to save the seeds list back to rhq-server.properties.
+ CoreServerMBean coreServer = LookupUtil.getCoreServer();
+ File installDir = coreServer.getInstallDir();
+ File binDir = new File(installDir, "bin");
+ File serverProperties = new File(binDir, "rhq-server.properties");
+ PropertiesFileUpdate propsFile = new PropertiesFileUpdate(serverProperties.getAbsolutePath());
+
+ try {
+ propsFile.update("rhq.cassandra.cluster.seeds", seeds);
+ } catch (IOException e) {
+ log.warn("Failed to update rhq.cassandra.cluster.seeds property in " + serverProperties, e);
+ }
+
+ deployer.deploy();
+
+ } else {
+ seeds = System.getProperty("rhq.cassandra.cluster.seeds");
+ }
String jobTrigger = "CassandraClusterHeartBeatTrigger - " + UUID.randomUUID().toString();
String jobGroup = CassandraClusterHeartBeatJob.JOB_NAME + "Group";
JobDataMap jobDataMap = new JobDataMap();
jobDataMap.put(CassandraClusterHeartBeatJob.KEY_CONNECTION_TIMEOUT, "100");
- jobDataMap.put(CassandraClusterHeartBeatJob.KEY_CASSANDRA_HOSTS, deployer.getCassandraHosts());
+ jobDataMap.put(CassandraClusterHeartBeatJob.KEY_CASSANDRA_HOSTS, seeds);
try {
scheduler.scheduleRepeatingJob(CassandraClusterHeartBeatJob.JOB_NAME, jobGroup, jobDataMap,
commit 540462a1afac65efeaec68e07bf55b3c10419cd8
Author: John Sanda <jsanda(a)redhat.com>
Date: Fri Oct 26 07:59:16 2012 -0400
Adding initial support to specify cassandra hosts during installation
A section, that currently has just a single field, has been added to the
installer to allow the user to enter the hostnames where cassandra will run.
Those hostnames are then persisted to rhq-server.properties.
diff --git a/modules/enterprise/gui/installer/src/main/java/org/rhq/enterprise/gui/installer/client/Installer.java b/modules/enterprise/gui/installer/src/main/java/org/rhq/enterprise/gui/installer/client/Installer.java
index 2dd4e4c..73383be 100644
--- a/modules/enterprise/gui/installer/src/main/java/org/rhq/enterprise/gui/installer/client/Installer.java
+++ b/modules/enterprise/gui/installer/src/main/java/org/rhq/enterprise/gui/installer/client/Installer.java
@@ -529,6 +529,25 @@ public class Installer implements EntryPoint {
databaseForm.setFields(dbType, dbConnectionUrl, dbUsername, dbPassword, buttonSpacer, testConnectionButton,
dbExistingSchemaOption);
+ final DynamicForm metricsDatabaseForm = new DynamicForm();
+ metricsDatabaseForm.setAutoWidth();
+ metricsDatabaseForm.setPadding(5);
+ metricsDatabaseForm.setCellPadding(5);
+ metricsDatabaseForm.setWrapItemTitles(false);
+ metricsDatabaseForm.setIsGroup(true);
+ metricsDatabaseForm.setGroupTitle("Metrics Database Settings");
+
+ TextItem hostNames = new TextItem(ServerProperties.PROP_CASSANDRA_CLUSTER_SEEDS, "Metrics Database Nodes");
+ hostNames.setWidth(fieldWidth);
+ hostNames.addChangedHandler(new ChangedHandler() {
+ @Override
+ public void onChanged(ChangedEvent event) {
+ updateServerProperty(ServerProperties.PROP_CASSANDRA_CLUSTER_SEEDS, String.valueOf(event.getValue()));
+ }
+ });
+
+ metricsDatabaseForm.setFields(hostNames);
+
////////////////////////////////////////////////////////
// The Server Settings form
@@ -677,6 +696,7 @@ public class Installer implements EntryPoint {
simpleForm.setHeight100();
simpleForm.setDefaultLayoutAlign(Alignment.CENTER);
simpleForm.addMember(databaseForm);
+ simpleForm.addMember(metricsDatabaseForm);
simpleForm.addMember(serverSettingsForm);
return simpleForm;
diff --git a/modules/enterprise/gui/installer/src/main/java/org/rhq/enterprise/gui/installer/client/shared/ServerProperties.java b/modules/enterprise/gui/installer/src/main/java/org/rhq/enterprise/gui/installer/client/shared/ServerProperties.java
index 7a04a6a..81e2e6c 100644
--- a/modules/enterprise/gui/installer/src/main/java/org/rhq/enterprise/gui/installer/client/shared/ServerProperties.java
+++ b/modules/enterprise/gui/installer/src/main/java/org/rhq/enterprise/gui/installer/client/shared/ServerProperties.java
@@ -113,6 +113,8 @@ public class ServerProperties {
public static final String PROP_MM_AT_START = "rhq.server.maintenance-mode-at-startup";
public static final String PROP_OPERATION_TIMEOUT = "rhq.server.operation-timeout";
+ public static final String PROP_CASSANDRA_CLUSTER_SEEDS = "rhq.cassandra.cluster.seeds";
+
// this list contains all the properties that are to have boolean values (true | false)
public static final Set<String> BOOLEAN_PROPERTIES;
static {
diff --git a/modules/enterprise/server/appserver/src/main/scripts/rhq-container.build.xml b/modules/enterprise/server/appserver/src/main/scripts/rhq-container.build.xml
index b1944a7..b23c0a4 100644
--- a/modules/enterprise/server/appserver/src/main/scripts/rhq-container.build.xml
+++ b/modules/enterprise/server/appserver/src/main/scripts/rhq-container.build.xml
@@ -558,6 +558,12 @@ rhq.autoinstall.enabled=${rhq.autoinstall.enabled}
rhq.autoinstall.database=auto
rhq.autoinstall.public-endpoint-address=
+# Cassandra cluster configuration settings
+# A comma-delimited list of hostnames on which Cassandra will run. Cassandra
+# nodes use this list to discover other nodes and learn about the cluster
+# topology.
+rhq.cassandra.cluster.seeds=
+
</echo>
</target>
@@ -585,14 +591,11 @@ rhq.autoinstall.public-endpoint-address=
<copy todir="${project.build.outputDirectory}" verbose="true">
<fileset dir="src/main/dev-resources" />
</copy>
- <echo>Putting a developer setting in rhq-server.properties to turn on/off strict agent update version checking</echo>
- <echo file="${project.build.outputDirectory}/bin/rhq-server.properties" append="true">rhq.server.agent-update.nonstrict-version-check=true</echo>
<loadproperties>
<zipentry zipfile="${settings.localRepository}/org/rhq/rhq-cassandra-common/${project.version}/rhq-cassandra-common-${project.version}.jar"
name="cassandra.properties"/>
</loadproperties>
<echo file="${project.build.outputDirectory}/bin/rhq-server.properties" append="true">
-
# The following properties that begin with a prefix of rhq.cassandra are ONLY for
# development/testing environments where an embedded cluster is used. These properties are
# loaded from the cassandra.properties file in the rhq-cassandra-common module. Note that
@@ -614,7 +617,10 @@ rhq.autoinstall.public-endpoint-address=
#
# The log4j logging level to use on each node.
# rhq.cassandra.logging.level=${rhq.cassandra.logging.level}
- </echo>
+
+</echo>
+ <echo>Putting a developer setting in rhq-server.properties to turn on/off strict agent update version checking</echo>
+ <echo file="${project.build.outputDirectory}/bin/rhq-server.properties" append="true">rhq.server.agent-update.nonstrict-version-check=true</echo>
</target>
<!-- The prepare-release target must be run AFTER the resources:resources goal has executed. -->
11 years, 6 months
[rhq] Branch 'feature/cassandra-backend' - modules/common modules/enterprise
by John Sanda
modules/common/cassandra-common/src/main/resources/cassandra.properties | 28 +++++++++-
modules/enterprise/server/appserver/src/main/scripts/rhq-container.build.xml | 28 ++++++++++
2 files changed, 54 insertions(+), 2 deletions(-)
New commits:
commit 478338738f47ec2a4c0b919c031a3b888bd97b1c
Author: John Sanda <jsanda(a)redhat.com>
Date: Wed Oct 24 21:16:08 2012 -0400
Include cassandra related properties in rhq-server.properties in dev builds
The container build script has been updated so that rhq-server.properties will
include properties that affect embedded cluster deployments. This only happens
when the dev profile is active during the build.
diff --git a/modules/common/cassandra-common/src/main/resources/cassandra.properties b/modules/common/cassandra-common/src/main/resources/cassandra.properties
index 35015bf..a5d1083 100644
--- a/modules/common/cassandra-common/src/main/resources/cassandra.properties
+++ b/modules/common/cassandra-common/src/main/resources/cassandra.properties
@@ -1,10 +1,34 @@
+# These properties are used for the Cassandra bundle deployment and for embedded cluster
+# deployments. Properties that affect embedded cluster deployments are used only in
+# development and test environments, not production environments.
+
rhq.cassandra.bundle.filename=/cassandra-bundle.zip
rhq.cassandra.bundle.name=RHQ Cassandra Bundle
rhq.cassandra.bundle.version=1.0
+# The remaining properties pertain to cluster configuration and are only used in
+# development and testing environments when an embedded cluster is used. These properties
+# are also loaded into the container build (when the dev profile is active) in the
+# rhq-container.build.xml script. If you add any properties below here that pertain to
+# cluster configuration for an embedded cluster, please also update
+# rhq-container.build.xml. This is done as a convenience for developers so that they can
+# just update rhq-server.properties to change the cluster configuration.
+#
+#
+# Accepts a value of true or false and specifies whether or not the cluster is embedded.
+# Note that if this property is set to false, the other, remaining cluster configuration
+# properties that are set will be ignored as they are only used with embedded clusters.
+rhq.cassandra.cluster.is-embedded=true
+
+# The directory in which cluster nodes will be installed.
rhq.cassandra.cluster.dir=${rhq.rootDir}/cassandra
+
+# The number of nodes in the cluster. This specifies how many nodes to install and
+# configure. The top level or base directory for each node will be nodeN where N is the
+# node number.
rhq.cassandra.cluster.num-nodes=2
+
rhq.cassandra.cluster.auto-deploy=true
-rhq.cassandra.cluster.auto-start=true
-rhq.cassandra.cluster.is-embedded=true
+
+# The log4j logging level to use on each node.
rhq.cassandra.logging.level=DEBUG
diff --git a/modules/enterprise/server/appserver/src/main/scripts/rhq-container.build.xml b/modules/enterprise/server/appserver/src/main/scripts/rhq-container.build.xml
index 1da4a9a..b1944a7 100644
--- a/modules/enterprise/server/appserver/src/main/scripts/rhq-container.build.xml
+++ b/modules/enterprise/server/appserver/src/main/scripts/rhq-container.build.xml
@@ -587,6 +587,34 @@ rhq.autoinstall.public-endpoint-address=
</copy>
<echo>Putting a developer setting in rhq-server.properties to turn on/off strict agent update version checking</echo>
<echo file="${project.build.outputDirectory}/bin/rhq-server.properties" append="true">rhq.server.agent-update.nonstrict-version-check=true</echo>
+ <loadproperties>
+ <zipentry zipfile="${settings.localRepository}/org/rhq/rhq-cassandra-common/${project.version}/rhq-cassandra-common-${project.version}.jar"
+ name="cassandra.properties"/>
+ </loadproperties>
+ <echo file="${project.build.outputDirectory}/bin/rhq-server.properties" append="true">
+
+# The following properties that begin with a prefix of rhq.cassandra are ONLY for
+# development/testing environments where an embedded cluster is used. These properties are
+# loaded from the cassandra.properties file in the rhq-cassandra-common module. Note that
+# the properties file is loaded from the artifact in the local maven repo, not from the
+# module directory in the source tree.
+#
+# Accepts a value of true or false and specifies whether or not the cluster is embedded.
+# Note that if this property is set to false, any of the following rhq.cassandra.*
+# properties that are set will be ignored as they are only used with embedded clusters.
+# rhq.cassandra.cluster.is-embedded=${rhq.cassandra.cluster.is-embedded}
+#
+# The directory in which cluster nodes will be installed.
+# rhq.cassandra.cluster.dir=${rhq.cassandra.cluster.dir}
+#
+# The number of nodes in the cluster. This specifies how many nodes to install and
+# configure. The top level or base directory for each node will be nodeN where N is the
+# node number.
+# rhq.cassandra.cluster.num-nodes=${rhq.cassandra.cluster.num-nodes}
+#
+# The log4j logging level to use on each node.
+# rhq.cassandra.logging.level=${rhq.cassandra.logging.level}
+ </echo>
</target>
<!-- The prepare-release target must be run AFTER the resources:resources goal has executed. -->
11 years, 6 months
[rhq] Branch 'spinder/plugin-dev' - 4 commits - modules/helpers
by Simeon Pinder
modules/helpers/pluginGen/pom.xml | 46 +++++++++
modules/helpers/pluginGen/src/main/java/org/rhq/helpers/ui/ManagedHive.java | 50 +++++++++-
2 files changed, 92 insertions(+), 4 deletions(-)
New commits:
commit 152669d9dd859899b86c146d495abcb2eb9d47b4
Author: Simeon Pinder <spinder(a)fulliautomatix.conchfritter.com>
Date: Wed Oct 24 19:07:33 2012 -0400
Add command line processing to modify ports or remote api choice.
diff --git a/modules/helpers/pluginGen/src/main/java/org/rhq/helpers/ui/ManagedHive.java b/modules/helpers/pluginGen/src/main/java/org/rhq/helpers/ui/ManagedHive.java
index 30108cb..bb15fbd 100644
--- a/modules/helpers/pluginGen/src/main/java/org/rhq/helpers/ui/ManagedHive.java
+++ b/modules/helpers/pluginGen/src/main/java/org/rhq/helpers/ui/ManagedHive.java
@@ -116,6 +116,10 @@ import org.rhq.helpers.ui.RemoteApi.Protocol;
public class ManagedHive extends JFrame {
static Logger LOG = Logger.getLogger(ManagedHive.class.getName());
+ private static String REMOTE_PROTOCOL = "--remote-protocol";
+ private static String REMOTE_PROTOCOL_PORT = "--remote-port";
+ private static String HELP = "--help";
+ private static String HELP1 = "-h";
/******************* Startup/initialization & Components *************/
/** Simple command line launch mechanism
* @param args
@@ -123,9 +127,47 @@ public class ManagedHive extends JFrame {
public static void main(String[] args) {
//allow way to switch between protocols at server startup
if (args.length > 0) {
- String remoteApiProtocoal = args[0];
- if (remoteApiProtocoal.trim().equalsIgnoreCase("HTTP")) {
- ManagedHive.defaultProtocol = Protocol.HTTP_JSON;
+ for (int i = 0; i < args.length; i++) {
+ String argument = args[i];
+ argument = argument.toLowerCase();
+ //determine remote protocol type
+ if (argument.startsWith(REMOTE_PROTOCOL)) {
+ //default to JSON over socket
+ ManagedHive.defaultProtocol = Protocol.JSON;
+ //split on = to get value
+ String[] selection = argument.split("=");
+ if ((selection != null) && (selection.length == 2) && (selection[1].equalsIgnoreCase("HTTP"))) {
+ ManagedHive.defaultProtocol = Protocol.HTTP_JSON;
+ }
+ }
+ //determine remote protocol port. This is optional and first available will be
+ //selected if the requested port is not actually available.
+ if (argument.startsWith(REMOTE_PROTOCOL_PORT)) {
+ //already defaulted to 9876
+ //split on = to get value
+ String[] selection = argument.split("=");
+ if ((selection != null) && (selection.length == 2)) {
+ String value = selection[1];
+ int valueInt = -1;
+ try {
+ valueInt = Integer.parseInt(value);
+ if ((valueInt > -1) && (valueInt < 66000)) {
+ ManagedHive.defaultRemoteApiPort = valueInt;
+ }//otherwise ignore
+ } catch (NumberFormatException nfe) {
+ }
+ }
+ }
+
+ if ((argument.startsWith(HELP) || argument.startsWith(HELP1))) {
+ String acceptableInput = "Ex. java -jar ManagedHive.jar -Drhq.virtual.hive "
+ + "--remote-protocol=http --remote-port=9876 \n"
+ + "Ex. java -jar ManagedHive.jar -h \t(displays acceptable input and exits)\n"
+ + "Ex. java -jar ManagedHive.jar --help \t(displays acceptable input and exits)\n"
+ + "Ex. java -jar ManagedHive.jar \t\t(no arguments, runs with defaults. No discovery differentiator)";
+ System.out.println(acceptableInput);
+ System.exit(0);//bail
+ }
}
}
new ManagedHive();
commit cc7ca1b39b3962cb92f93f12407b2ffdd390fe8f
Author: Simeon Pinder <spinder(a)fulliautomatix.conchfritter.com>
Date: Wed Oct 24 16:51:44 2012 -0400
Fix small issue with runtime processing for remote interface.
diff --git a/modules/helpers/pluginGen/src/main/java/org/rhq/helpers/ui/ManagedHive.java b/modules/helpers/pluginGen/src/main/java/org/rhq/helpers/ui/ManagedHive.java
index bf9560e..30108cb 100644
--- a/modules/helpers/pluginGen/src/main/java/org/rhq/helpers/ui/ManagedHive.java
+++ b/modules/helpers/pluginGen/src/main/java/org/rhq/helpers/ui/ManagedHive.java
@@ -124,7 +124,7 @@ public class ManagedHive extends JFrame {
//allow way to switch between protocols at server startup
if (args.length > 0) {
String remoteApiProtocoal = args[0];
- if (remoteApiProtocoal.trim().toUpperCase().indexOf("HTTP") > 0) {
+ if (remoteApiProtocoal.trim().equalsIgnoreCase("HTTP")) {
ManagedHive.defaultProtocol = Protocol.HTTP_JSON;
}
}
commit bb2797403b78852d15efad24ed1b6c5e41e0c4b4
Author: Simeon Pinder <spinder(a)fulliautomatix.conchfritter.com>
Date: Wed Oct 24 16:26:24 2012 -0400
generate executable jar for Managed Resource.
diff --git a/modules/helpers/pluginGen/pom.xml b/modules/helpers/pluginGen/pom.xml
index e1418f4..4bba6a8 100644
--- a/modules/helpers/pluginGen/pom.xml
+++ b/modules/helpers/pluginGen/pom.xml
@@ -71,6 +71,31 @@
<version>2.1</version>
</plugin>
+ <!-- Builds standalone executable jar for the managed virtual resource.
+ Resource defaults to running simple socket managed interface.
+ -->
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-shade-plugin</artifactId>
+ <version>2.0</version>
+ <executions>
+ <execution>
+ <phase>package</phase>
+ <goals>
+ <goal>shade</goal>
+ </goals>
+ <configuration>
+ <finalName>ManagedHive</finalName>
+ <transformers>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
+ <mainClass>org.rhq.helpers.ui.ManagedHive</mainClass>
+ </transformer>
+ </transformers>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+
</plugins>
</build>
commit 0105651cdb89c3b22717b0e774b89dae3b172bfb
Author: Simeon Pinder <spinder(a)fulliautomatix.conchfritter.com>
Date: Wed Oct 24 16:07:28 2012 -0400
update build dependencies.
diff --git a/modules/helpers/pluginGen/pom.xml b/modules/helpers/pluginGen/pom.xml
index 62bf822..e1418f4 100644
--- a/modules/helpers/pluginGen/pom.xml
+++ b/modules/helpers/pluginGen/pom.xml
@@ -92,6 +92,27 @@
<artifactId>rhq-pluginAnnotations</artifactId>
<version>4.5.0-SNAPSHOT</version>
</dependency>
+ <dependency>
+ <groupId>org.apache.httpcomponents</groupId>
+ <artifactId>httpclient</artifactId>
+ <version>4.2.1</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.httpcomponents</groupId>
+ <artifactId>httpcore</artifactId>
+ <version>4.2.1</version>
+ </dependency>
+ <dependency>
+ <groupId>org.codehaus.jackson</groupId>
+ <artifactId>jackson-mapper-asl</artifactId>
+ <version>1.8.5</version>
+ </dependency>
+ <dependency>
+ <groupId>org.codehaus.jackson</groupId>
+ <artifactId>jackson-core-asl</artifactId>
+ <version>1.8.5</version>
+ </dependency>
+
</dependencies>
<profiles>
diff --git a/modules/helpers/pluginGen/src/main/java/org/rhq/helpers/ui/ManagedHive.java b/modules/helpers/pluginGen/src/main/java/org/rhq/helpers/ui/ManagedHive.java
index 557fd34..bf9560e 100644
--- a/modules/helpers/pluginGen/src/main/java/org/rhq/helpers/ui/ManagedHive.java
+++ b/modules/helpers/pluginGen/src/main/java/org/rhq/helpers/ui/ManagedHive.java
@@ -64,13 +64,13 @@ import javax.swing.border.TitledBorder;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
-import org.apache.commons.httpclient.HttpStatus;
import org.apache.http.HttpEntity;
import org.apache.http.HttpEntityEnclosingRequest;
import org.apache.http.HttpException;
import org.apache.http.HttpRequest;
import org.apache.http.HttpResponse;
import org.apache.http.HttpResponseInterceptor;
+import org.apache.http.HttpStatus;
import org.apache.http.MethodNotSupportedException;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.DefaultConnectionReuseStrategy;
11 years, 6 months
[rhq] Branch 'jsanda/cassandra-plugin' - 2 commits - modules/enterprise modules/plugins
by snegrea
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/ConfigurationGWTService.java | 3
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/schedule/AbstractOperationScheduleDetailsView.java | 3
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/operation/schedule/GroupOperationScheduleDetailsView.java | 5
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/configuration/ResourceConfigurationEditView.java | 9 -
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/schedule/ResourceOperationScheduleDetailsView.java | 5
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/factory/ResourceFactoryConfigurationStep.java | 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ConfigurationGWTServiceImpl.java | 4
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/ConfigurationManagerBean.java | 67 ++++------
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/ConfigurationManagerLocal.java | 3
modules/plugins/cassandra/src/main/resources/META-INF/rhq-plugin.xml | 6
modules/plugins/hardware/src/main/java/org/rhq/plugins/hardware/SmartDiskComponent.java | 4
11 files changed, 62 insertions(+), 49 deletions(-)
New commits:
commit 1265c65eeabdd73acd3f2550316b563b85af342c
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Wed Oct 24 18:08:05 2012 -0500
Fix compilation error in unused plugin.
diff --git a/modules/plugins/hardware/src/main/java/org/rhq/plugins/hardware/SmartDiskComponent.java b/modules/plugins/hardware/src/main/java/org/rhq/plugins/hardware/SmartDiskComponent.java
index ec7bb9f..2421e67 100644
--- a/modules/plugins/hardware/src/main/java/org/rhq/plugins/hardware/SmartDiskComponent.java
+++ b/modules/plugins/hardware/src/main/java/org/rhq/plugins/hardware/SmartDiskComponent.java
@@ -115,8 +115,8 @@ public class SmartDiskComponent implements ResourceComponent, MeasurementFacet {
public static void main(String[] args) throws Exception {
SmartDiskComponent sdc = new SmartDiskComponent();
- sdc.start(new ResourceContext(new Resource("/dev/sda", "foo", new ResourceType()), null, null, null, null, null,
- null, null, null, null, null, null, PluginContainerDeployment.AGENT));
+ sdc.start(new ResourceContext(new Resource("/dev/sda", "foo", new ResourceType()), null, null, null, null,
+ null, null, null, null, null, null, null, null, PluginContainerDeployment.AGENT));
sdc.getValues(null, null);
}
commit 4ac376b36feeef4b0be60f557e63220fbcf461b2
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Wed Oct 24 18:07:27 2012 -0500
Add support for resource self-referencing option sources.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/ConfigurationGWTService.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/ConfigurationGWTService.java
index 638e645..06207cd 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/ConfigurationGWTService.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/ConfigurationGWTService.java
@@ -88,5 +88,6 @@ public interface ConfigurationGWTService extends RemoteService {
void deleteGroupResourceConfigurationUpdate(Integer groupId, Integer[] groupResourceConfigUpdateIds)
throws RuntimeException;
- ConfigurationDefinition getOptionValuesForConfigDefinition(ConfigurationDefinition definition) throws RuntimeException;
+ ConfigurationDefinition getOptionValuesForConfigDefinition(int resourceId, ConfigurationDefinition definition)
+ throws RuntimeException;
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/schedule/AbstractOperationScheduleDetailsView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/schedule/AbstractOperationScheduleDetailsView.java
index f4066f0..0f54af0 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/schedule/AbstractOperationScheduleDetailsView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/schedule/AbstractOperationScheduleDetailsView.java
@@ -117,6 +117,7 @@ public abstract class AbstractOperationScheduleDetailsView extends
}
protected abstract boolean hasControlPermission();
+ protected abstract int getResourceId();
@Override
public String getListViewPath() {
@@ -457,7 +458,7 @@ public abstract class AbstractOperationScheduleDetailsView extends
}
ConfigurationGWTServiceAsync configurationService = GWTServiceLookup.getConfigurationService();
- configurationService.getOptionValuesForConfigDefinition(parametersDefinition,
+ configurationService.getOptionValuesForConfigDefinition(getResourceId(), parametersDefinition,
new AsyncCallback<ConfigurationDefinition>() {
@Override
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/operation/schedule/GroupOperationScheduleDetailsView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/operation/schedule/GroupOperationScheduleDetailsView.java
index 013bc85..0ce98d3 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/operation/schedule/GroupOperationScheduleDetailsView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/operation/schedule/GroupOperationScheduleDetailsView.java
@@ -61,6 +61,11 @@ public class GroupOperationScheduleDetailsView extends AbstractOperationSchedule
}
@Override
+ protected int getResourceId() {
+ return -1;
+ }
+
+ @Override
protected void init(final boolean isReadOnly) {
if (isNewRecord()) {
ResourceDatasource resourceDatasource = new ResourceDatasource();
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/configuration/ResourceConfigurationEditView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/configuration/ResourceConfigurationEditView.java
index 4e87eb0..f0947ac 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/configuration/ResourceConfigurationEditView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/configuration/ResourceConfigurationEditView.java
@@ -121,7 +121,7 @@ public class ResourceConfigurationEditView extends LocatableVLayout implements P
buttonbar.destroy();
removeMember(buttonbar);
}
-
+
GWTServiceLookup.getConfigurationService().getLatestResourceConfigurationUpdate(resource.getId(),
new AsyncCallback<ResourceConfigurationUpdate>() {
@Override
@@ -134,14 +134,15 @@ public class ResourceConfigurationEditView extends LocatableVLayout implements P
refreshing = false;
return;
}
-
+
ResourceTypeRepository.Cache.getInstance().getResourceTypes(resource.getResourceType().getId(),
EnumSet.of(MetadataType.resourceConfigurationDefinition), new TypeLoadedCallback() {
@Override
public void onTypesLoaded(ResourceType type) {
ConfigurationGWTServiceAsync configurationService = GWTServiceLookup.getConfigurationService();
- configurationService.getOptionValuesForConfigDefinition(
- type.getResourceConfigurationDefinition(), new AsyncCallback<ConfigurationDefinition>(){
+ configurationService.getOptionValuesForConfigDefinition(resource.getId(),
+ type.getResourceConfigurationDefinition(),
+ new AsyncCallback<ConfigurationDefinition>() {
@Override
public void onFailure(Throwable throwable) {
refreshing = false;
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/schedule/ResourceOperationScheduleDetailsView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/schedule/ResourceOperationScheduleDetailsView.java
index bebe550..00f72ae 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/schedule/ResourceOperationScheduleDetailsView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/schedule/ResourceOperationScheduleDetailsView.java
@@ -24,4 +24,9 @@ public class ResourceOperationScheduleDetailsView extends AbstractOperationSched
return this.resourceComposite.getResourcePermission().isControl();
}
+ @Override
+ protected int getResourceId() {
+ return this.resourceComposite.getResource().getId();
+ }
+
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/factory/ResourceFactoryConfigurationStep.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/factory/ResourceFactoryConfigurationStep.java
index 1806348..0319435 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/factory/ResourceFactoryConfigurationStep.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/factory/ResourceFactoryConfigurationStep.java
@@ -101,7 +101,7 @@ public class ResourceFactoryConfigurationStep extends AbstractWizardStep impleme
this.startingConfig = wizard.getNewResourceStartingConfiguration();
ConfigurationGWTServiceAsync configurationService = GWTServiceLookup.getConfigurationService();
- configurationService.getOptionValuesForConfigDefinition(def,
+ configurationService.getOptionValuesForConfigDefinition(-1, def,
new AsyncCallback<ConfigurationDefinition>() {
public void onSuccess(ConfigurationDefinition result) {
createAndAddConfigurationEditor(result);
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ConfigurationGWTServiceImpl.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ConfigurationGWTServiceImpl.java
index 04bfdcb..d351f7a 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ConfigurationGWTServiceImpl.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ConfigurationGWTServiceImpl.java
@@ -352,11 +352,11 @@ public class ConfigurationGWTServiceImpl extends AbstractGWTServiceImpl implemen
}
@Override
- public ConfigurationDefinition getOptionValuesForConfigDefinition(ConfigurationDefinition definition)
+ public ConfigurationDefinition getOptionValuesForConfigDefinition(int resourceId, ConfigurationDefinition definition)
throws RuntimeException {
try {
ConfigurationDefinition def = configurationManager.getOptionsForConfigurationDefinition(
- getSessionSubject(), definition);
+ getSessionSubject(), resourceId, definition);
return SerialUtility.prepare(def, "ConfigurationService.getOptionValuesForPropertySimple");
} catch (Throwable t) {
throw getExceptionToThrowToClient(t);
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 6f18088..b252022 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
@@ -92,7 +92,6 @@ import org.rhq.core.domain.resource.Resource;
import org.rhq.core.domain.resource.ResourceError;
import org.rhq.core.domain.resource.ResourceErrorType;
import org.rhq.core.domain.resource.ResourceType;
-import org.rhq.core.domain.resource.composite.ResourceComposite;
import org.rhq.core.domain.resource.group.GroupCategory;
import org.rhq.core.domain.resource.group.ResourceGroup;
import org.rhq.core.domain.resource.group.composite.ResourceGroupComposite;
@@ -2458,26 +2457,27 @@ public class ConfigurationManagerBean implements ConfigurationManagerLocal, Conf
return updates;
}
- public ConfigurationDefinition getOptionsForConfigurationDefinition(Subject subject, ConfigurationDefinition def) {
+ public ConfigurationDefinition getOptionsForConfigurationDefinition(Subject subject, int resourceId,
+ ConfigurationDefinition def) {
for (Map.Entry<String, PropertyDefinition> entry : def.getPropertyDefinitions().entrySet()) {
PropertyDefinition pd = entry.getValue();
if (pd instanceof PropertyDefinitionSimple) {
PropertyDefinitionSimple pds = (PropertyDefinitionSimple) pd;
- handlePDS(subject, pds);
+ handlePDS(subject, resourceId, pds);
} else if (pd instanceof PropertyDefinitionList) {
PropertyDefinitionList pdl = (PropertyDefinitionList) pd;
PropertyDefinition memberDef = pdl.getMemberDefinition();
if (memberDef instanceof PropertyDefinitionSimple) {
PropertyDefinitionSimple pds = (PropertyDefinitionSimple) memberDef;
- handlePDS(subject, pds);
+ handlePDS(subject, resourceId, pds);
} else if (memberDef instanceof PropertyDefinitionMap) {
PropertyDefinitionMap pdm = (PropertyDefinitionMap) memberDef;
for (PropertyDefinition inner : pdm.getPropertyDefinitions()) {
if (inner instanceof PropertyDefinitionSimple) {
- handlePDS(subject, (PropertyDefinitionSimple) inner);
+ handlePDS(subject, resourceId, (PropertyDefinitionSimple) inner);
}
log.debug("3 ____[ " + inner.toString() + " in " + pdl.toString() + " ]____ not yet supported");
}
@@ -2489,7 +2489,7 @@ public class ConfigurationManagerBean implements ConfigurationManagerLocal, Conf
PropertyDefinitionMap pdm = (PropertyDefinitionMap) pd;
for (PropertyDefinition inner : pdm.getPropertyDefinitions()) {
if (inner instanceof PropertyDefinitionSimple) {
- handlePDS(subject, (PropertyDefinitionSimple) inner);
+ handlePDS(subject, resourceId, (PropertyDefinitionSimple) inner);
} else {
log.debug("4 ____[ " + inner.toString() + " in " + pdm.toString() + " ]____ not yet supported");
}
@@ -2507,7 +2507,7 @@ public class ConfigurationManagerBean implements ConfigurationManagerLocal, Conf
* @param subject Subject of the caller - may limit search results
* @param pds the PropertyDefinitionSimple to work on
*/
- private void handlePDS(Subject subject, PropertyDefinitionSimple pds) {
+ private void handlePDS(Subject subject, int resourceId, PropertyDefinitionSimple pds) {
if (pds.getOptionsSource() != null) {
// evaluate the source parameters
@@ -2520,33 +2520,35 @@ public class ConfigurationManagerBean implements ConfigurationManagerLocal, Conf
filterPattern = Pattern.compile(filter);
if (tt == PropertyOptionsSource.TargetType.RESOURCE || tt == PropertyOptionsSource.TargetType.CONFIGURATION) {
+ List<Resource> resources = null;
ResourceCriteria criteria = new ResourceCriteria();
if (tt == PropertyOptionsSource.TargetType.CONFIGURATION) {
// split out expression part for target=configuration
// return if no property specifier is given
String expr = expression;
- if (!expr.contains(":")) {
+ if (expr.contains(":")) {
+ expr = expr.substring(expr.indexOf(':') + 1);
+ criteria.setSearchExpression(expr);
+ resources = resourceManager.findResourcesByCriteria(subject, criteria);
+ } else if (resourceId >= 0) {
+ resources = new ArrayList<Resource>();
+ resources.add(resourceManager.getResourceById(subject, resourceId));
+ } else {
log.warn("Option source expression for property " + pds.getName()
+ " and target configuration contains no ':'");
return;
}
-
- expr = expr.substring(expr.indexOf(':')+1);
- criteria.setSearchExpression(expr);
} else {
criteria.setSearchExpression(expression);
+ resources = resourceManager.findResourcesByCriteria(subject, criteria);
}
- List<ResourceComposite> composites = resourceManager
- .findResourceCompositesByCriteria(subject, criteria);
- for (ResourceComposite composite : composites) {
-
+ for (Resource resource : resources) {
if (tt == PropertyOptionsSource.TargetType.RESOURCE) {
+ String name = resource.getName();
- String name = composite.getResource().getName();
// filter if the user provided a filter
-
if (filterPattern != null) {
Matcher m = filterPattern.matcher(name);
if (m.matches()) {
@@ -2556,12 +2558,10 @@ public class ConfigurationManagerBean implements ConfigurationManagerLocal, Conf
} 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()))
+ if (!handleConfigurationTarget(pds, expression, resource))
return;
}
@@ -2590,23 +2590,22 @@ public class ConfigurationManagerBean implements ConfigurationManagerLocal, Conf
*/
private boolean handleConfigurationTarget(PropertyDefinitionSimple pds, String expression, Resource resource) {
Configuration configuration = resource.getResourceConfiguration();
- Property p;
- String propName = expression.substring(0, expression.indexOf(":"));
- boolean isMapOrList = expression.contains("=");
+ if (expression.indexOf(":") != -1) {
+ expression = expression.substring(0, expression.indexOf(":"));
+ }
+
+ boolean isMapOrList = expression.contains("=");
+ Property p;
if (isMapOrList) {
- String mapPropLocation = propName.substring(0, propName.indexOf("="));
- String mapPropName;
+ String mapPropLocation = expression.substring(0, expression.indexOf("="));
if (mapPropLocation.contains("/")) {
- // List of maps
- mapPropName = mapPropLocation.substring(0,mapPropLocation.indexOf('/'));
+ mapPropLocation = mapPropLocation.substring(0, mapPropLocation.indexOf('/'));
}
- else {
- mapPropName = mapPropLocation;
- }
- p = configuration.get(mapPropName);
- } else
- p = configuration.get(propName);
+ p = configuration.get(mapPropLocation);
+ } else {
+ p = configuration.get(expression);
+ }
if (p == null) {
log.warn("Option source expression for property " + pds.getName() + " and target configuration not found");
@@ -2644,7 +2643,7 @@ public class ConfigurationManagerBean implements ConfigurationManagerLocal, Conf
return false;
}
String subPropName;
- subPropName = propName.substring(propName.indexOf("=") + 1);
+ subPropName = expression.substring(expression.indexOf("=") + 1);
for (Property tmp : propertyList) {
PropertyMap pm = (PropertyMap) tmp;
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/ConfigurationManagerLocal.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/ConfigurationManagerLocal.java
index 9b49959..f090362 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/ConfigurationManagerLocal.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/ConfigurationManagerLocal.java
@@ -570,5 +570,6 @@ public interface ConfigurationManagerLocal {
PageList<GroupPluginConfigurationUpdate> findGroupPluginConfigurationUpdatesByCriteria(Subject subject,
GroupPluginConfigurationUpdateCriteria criteria);
- ConfigurationDefinition getOptionsForConfigurationDefinition(Subject subject, ConfigurationDefinition def);
+ ConfigurationDefinition getOptionsForConfigurationDefinition(Subject subject, int resourceId,
+ ConfigurationDefinition def);
}
\ No newline at end of file
diff --git a/modules/plugins/cassandra/src/main/resources/META-INF/rhq-plugin.xml b/modules/plugins/cassandra/src/main/resources/META-INF/rhq-plugin.xml
index e3c33d0..50a24fa 100644
--- a/modules/plugins/cassandra/src/main/resources/META-INF/rhq-plugin.xml
+++ b/modules/plugins/cassandra/src/main/resources/META-INF/rhq-plugin.xml
@@ -209,7 +209,7 @@
<c:simple-property name="objectName" readOnly="true" type="string" default="org.apache.cassandra.metrics:type=ClientRequestMetrics,name=ReadUnavailables"/>
<c:simple-property name="nameTemplate" readOnly="true" type="string" default="Read Unavailables" />
</plugin-configuration>
- <metric property="Count" displayName="Read Unavailable" measurementType="trendsup" displayType="summary" description="Number of read unavailable occurred for this node"/>
+ <metric property="Count" displayName="Read Unavailables" measurementType="trendsup" displayType="summary" description="Number of read unavailable occurred for this node"/>
</service>
<service name="WriteTimeouts"
@@ -400,8 +400,8 @@
</operation>
<operation name="restoreSnapshot" description="Restore the column family from a previously taken snapshot.">
<parameters>
- <c:simple-property name="snapshotName" required="true" type="string" description="Snapshot Name">
- <c:option-source target="configuration" expression="snapshots:type=ColumnFamily"/>
+ <c:simple-property name="name" required="true" type="string" description="Snapshot Name">
+ <c:option-source target="configuration" expression="snapshots/snapshot=name"/>
</c:simple-property>
</parameters>
<results>
11 years, 6 months
[rhq] Branch 'feature/cassandra-backend' - 6 commits - .classpath modules/common modules/core modules/enterprise modules/test-utils
by John Sanda
.classpath | 6
modules/common/jboss-as-dmr-client/src/main/java/org/rhq/common/jbossas/client/controller/CoreJBossASClient.java | 15
modules/common/jboss-as-dmr-client/src/main/java/org/rhq/common/jbossas/client/controller/DatasourceJBossASClient.java | 73
modules/core/domain/src/test/java/org/rhq/core/domain/test/AbstractEJB3Test.java | 7
modules/enterprise/gui/installer/src/main/java/org/rhq/enterprise/gui/installer/server/servlet/ServerInstallUtil.java | 26
modules/enterprise/server/appserver/src/main/scripts/rhq-container.build.xml | 5
modules/enterprise/server/itests/pom.xml | 51
modules/enterprise/server/itests/src/test/java/org/rhq/enterprise/server/alert/AlertDefinitionWithComplexNotificationsTest.java | 12
modules/enterprise/server/itests/src/test/java/org/rhq/enterprise/server/drift/AbstractDriftServerTest.java | 2
modules/enterprise/server/itests/src/test/java/org/rhq/enterprise/server/drift/DriftTemplateManagerBeanTest.java | 2
modules/enterprise/server/itests/src/test/java/org/rhq/enterprise/server/drift/JPADriftServerBeanTest.java | 2
modules/enterprise/server/itests/src/test/java/org/rhq/enterprise/server/drift/ManageDriftDefinitionsTest.java | 2
modules/enterprise/server/itests/src/test/java/org/rhq/enterprise/server/drift/ManageSnapshotsTest.java | 2
modules/enterprise/server/jar/pom.xml | 58
modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/alert/test/AlertConditionTest.java | 5
modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/core/CoreServerServiceImplTest.java | 5
modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/group/test/LdapGroupManagerBeanTest.java | 2
modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/metadata/MetadataBeanTest.java | 16
modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/metadata/ResourceMetadataManagerBeanTest.java | 2
modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/metadata/test/UpdatePluginMetadataTestBase.java | 10
modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/scheduler/jobs/DataPurgeJobTest.java | 14
modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/test/AbstractEJB3Test.java | 751 ++++++----
modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/test/LargeGroupTestBase.java | 8
modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/test/OldAbstractEJB3Test.java | 445 +++++
modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/test/TransactionCallback.java | 7
modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/test/TransactionCallbackReturnable.java | 7
modules/test-utils/src/main/java/org/rhq/test/JPAUtils.java | 149 -
27 files changed, 1211 insertions(+), 473 deletions(-)
New commits:
commit 270cb3b5f588dff83b47b4137b120dec23f2aeb3
Merge: 4bca271 b423892
Author: John Sanda <jsanda(a)redhat.com>
Date: Wed Oct 24 14:45:04 2012 -0400
Merge branch 'rhq-on-as7' into feature/cassandra-backend
Conflicts:
modules/common/jboss-as-dmr-client/src/main/java/org/rhq/common/jbossas/client/controller/DatasourceJBossASClient.java
diff --cc .classpath
index e17d7ef,5570123..587f064
--- a/.classpath
+++ b/.classpath
@@@ -323,8 -325,8 +327,10 @@@
<classpathentry exported="true" kind="var" path="M2_REPO/org/picketbox/picketbox/4.0.7.Final/picketbox-4.0.7.Final.jar"/>
<classpathentry exported="true" kind="var" path="M2_REPO/jboss/jboss-embeddable-ejb3/jboss-ejb3-all/1.0.0.Alpha9/jboss-ejb3-all-1.0.0.Alpha9.jar"/>
<classpathentry exported="true" kind="var" path="JDK_HOME/lib/tools.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/apache/thrift/libthrift/0.7.0/libthrift-0.7.0.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/hectorclient/hector-core/1.1-1/hector-core-1.1-1.jar"/>
<classpathentry kind="var" path="M2_REPO/org/jboss/remotingjmx/remoting-jmx/1.0.2.Final/remoting-jmx-1.0.2.Final.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/mozilla/rhino/1.7R4/rhino-1.7R4.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/python/jython-standalone/2.5.2/jython-standalone-2.5.2.jar"/>
<classpathentry kind="output" path="eclipse-classes"/>
</classpath>
diff --cc modules/enterprise/gui/installer/src/main/java/org/rhq/enterprise/gui/installer/server/servlet/ServerInstallUtil.java
index 33badf9,6d002de..bd9d134
--- a/modules/enterprise/gui/installer/src/main/java/org/rhq/enterprise/gui/installer/server/servlet/ServerInstallUtil.java
+++ b/modules/enterprise/gui/installer/src/main/java/org/rhq/enterprise/gui/installer/server/servlet/ServerInstallUtil.java
@@@ -424,8 -422,6 +424,8 @@@ public class ServerInstallUtil
"org.rhq.postgres", "org.postgresql.xa.PGXADataSource");
final ModelNode oracleDriverRequest = client.createNewJdbcDriverRequest(JDBC_DRIVER_ORACLE, "org.rhq.oracle",
"oracle.jdbc.xa.client.OracleXADataSource");
+ final ModelNode cassandraDriverRequest = client.createNewJdbcDriverRequest(JDBC_DRIVER_CASSANDRA,
- "org.apache-extras.cassandra-jdbc", "org.apache.cassandra.cql.jdbc.CassandraDataSource", false);
++ "org.apache-extras.cassandra-jdbc", null);
// if we are to use Oracle, we throw an exception if we can't create the Oracle datasource. We also try to
// create the Postgres datasource but because it isn't needed, we don't throw exceptions if that fails, we
commit 4bca271847d4d9fd6e0c0185a7b66e3cf9a2dec9
Author: John Sanda <jsanda(a)redhat.com>
Date: Wed Oct 24 11:57:50 2012 -0400
First pass at generating jdbc driver and data source configuration
The installer code is updated in this commit to generate the cassandra jdbc
driver and data source configurations that go into standalone-full.xml. Right
now the connection url is hard code to localhost.
diff --git a/modules/common/jboss-as-dmr-client/src/main/java/org/rhq/common/jbossas/client/controller/DatasourceJBossASClient.java b/modules/common/jboss-as-dmr-client/src/main/java/org/rhq/common/jbossas/client/controller/DatasourceJBossASClient.java
index b1f7a98..8b6667c 100644
--- a/modules/common/jboss-as-dmr-client/src/main/java/org/rhq/common/jbossas/client/controller/DatasourceJBossASClient.java
+++ b/modules/common/jboss-as-dmr-client/src/main/java/org/rhq/common/jbossas/client/controller/DatasourceJBossASClient.java
@@ -137,12 +137,25 @@ public class DatasourceJBossASClient extends JBossASClient {
* @return the request to create the JDBC driver configuration.
*/
public ModelNode createNewJdbcDriverRequest(String name, String moduleName, String driverXaClassName) {
- String dmrTemplate = "" //
- + "{" //
- + "\"driver-module-name\" => \"%s\" " //
- + ", \"driver-xa-datasource-class-name\" => \"%s\" " //
- + "}";
+ return createNewJdbcDriverRequest(name, moduleName, driverXaClassName, true);
+ }
+ public ModelNode createNewJdbcDriverRequest(String name, String moduleName, String driverXaClassName,
+ boolean isXA) {
+ String dmrTemplate;
+ if (isXA) {
+ dmrTemplate =
+ "{" +
+ "\"driver-module-name\" => \"%s\" " +
+ ", \"driver-xa-datasource-class-name\" => \"%s\" " +
+ "}";
+ } else {
+ dmrTemplate =
+ "{" +
+ "\"driver-module-name\" => \"%s\" " +
+ ", \"driver-datasource-class-name\" => \"%s\" " +
+ "}";
+ }
String dmr = String.format(dmrTemplate, moduleName, driverXaClassName);
Address addr = Address.root().add(SUBSYSTEM, SUBSYSTEM_DATASOURCES, JDBC_DRIVER, name);
@@ -239,6 +252,53 @@ public class DatasourceJBossASClient extends JBossASClient {
return createBatchRequest(batch);
}
+ public ModelNode createNewDatasourceRequest(String name, String connectionUrlExpression, String driverName,
+ boolean jta, Map<String, String> connectionProperties) {
+
+ String jndiName = "java:jboss/datasources/" + name;
+
+ String dmrTemplate = "" //
+ + "{" //
+ + "\"connection-url\" => expression \"%s\" " //
+ + ", \"driver-name\" => \"%s\" " //
+ + ", \"jndi-name\" => \"%s\" " //
+ + ", \"jta\" => %s " //
+ + ", \"use-java-context\" => true " //
+ + "}";
+
+ String dmr = String.format(dmrTemplate, connectionUrlExpression, driverName, jndiName, jta);
+
+ Address addr = Address.root().add(SUBSYSTEM, SUBSYSTEM_DATASOURCES, DATA_SOURCE, name);
+ final ModelNode request1 = ModelNode.fromString(dmr);
+ request1.get(OPERATION).set(ADD);
+ request1.get(ADDRESS).set(addr.getAddressNode());
+
+ // if there are no conn properties, no need to create a batch request, there is only one ADD request to make
+ if (connectionProperties == null || connectionProperties.size() == 0) {
+ return request1;
+ }
+
+ // create a batch of requests - the first is the main one, the rest create each conn property
+ ModelNode[] batch = new ModelNode[1 + connectionProperties.size()];
+ batch[0] = request1;
+ int n = 1;
+ for (Map.Entry<String, String> entry : connectionProperties.entrySet()) {
+ addr = Address.root().add(SUBSYSTEM, SUBSYSTEM_DATASOURCES, DATA_SOURCE, name, CONNECTION_PROPERTIES,
+ entry.getKey());
+ final ModelNode requestN = new ModelNode();
+ requestN.get(OPERATION).set(ADD);
+ requestN.get(ADDRESS).set(addr.getAddressNode());
+ if (entry.getValue().indexOf("${") > -1) {
+ requestN.get(VALUE).setExpression(entry.getValue());
+ } else {
+ requestN.get(VALUE).set(entry.getValue());
+ }
+ batch[n++] = requestN;
+ }
+
+ return createBatchRequest(batch);
+ }
+
/**
* Returns a ModelNode that can be used to create an XA datasource.
* Callers are free to tweek the datasource request that is returned,
diff --git a/modules/enterprise/gui/installer/src/main/java/org/rhq/enterprise/gui/installer/server/servlet/ServerInstallUtil.java b/modules/enterprise/gui/installer/src/main/java/org/rhq/enterprise/gui/installer/server/servlet/ServerInstallUtil.java
index 6d002de..33badf9 100644
--- a/modules/enterprise/gui/installer/src/main/java/org/rhq/enterprise/gui/installer/server/servlet/ServerInstallUtil.java
+++ b/modules/enterprise/gui/installer/src/main/java/org/rhq/enterprise/gui/installer/server/servlet/ServerInstallUtil.java
@@ -147,10 +147,12 @@ public class ServerInstallUtil {
private static final String RHQ_DATASOURCE_NAME_NOTX = "NoTxRHQDS";
private static final String RHQ_DATASOURCE_NAME_XA = "RHQDS";
+ private static final String CASSANDRA_DATASOURCE_NAME = "CassandraDS";
private static final String RHQ_DS_SECURITY_DOMAIN = "RHQDSSecurityDomain";
private static final String RHQ_REST_SECURITY_DOMAIN = "RHQRESTSecurityDomain";
private static final String JDBC_DRIVER_POSTGRES = "postgres";
private static final String JDBC_DRIVER_ORACLE = "oracle";
+ private static final String JDBC_DRIVER_CASSANDRA = "cassandra";
private static final String JMS_ALERT_CONDITION_QUEUE = "AlertConditionQueue";
private static final String JMS_DRIFT_CHANGESET_QUEUE = "DriftChangesetQueue";
private static final String JMS_DRIFT_FILE_QUEUE = "DriftFileQueue";
@@ -422,6 +424,8 @@ public class ServerInstallUtil {
"org.rhq.postgres", "org.postgresql.xa.PGXADataSource");
final ModelNode oracleDriverRequest = client.createNewJdbcDriverRequest(JDBC_DRIVER_ORACLE, "org.rhq.oracle",
"oracle.jdbc.xa.client.OracleXADataSource");
+ final ModelNode cassandraDriverRequest = client.createNewJdbcDriverRequest(JDBC_DRIVER_CASSANDRA,
+ "org.apache-extras.cassandra-jdbc", "org.apache.cassandra.cql.jdbc.CassandraDataSource", false);
// if we are to use Oracle, we throw an exception if we can't create the Oracle datasource. We also try to
// create the Postgres datasource but because it isn't needed, we don't throw exceptions if that fails, we
@@ -483,6 +487,12 @@ public class ServerInstallUtil {
throw new RuntimeException("bad db type"); // this should never happen; should have never gotten to this point with a bad type
}
+ ModelNode cassandraResults = client.execute(cassandraDriverRequest);
+ if (!DatasourceJBossASClient.isSuccess(cassandraResults)) {
+ throw new FailureException(cassandraResults, "Failed to create Cassandra database driver");
+ } else {
+ LOG.info("Deployed Cassandra JDBC driver");
+ }
}
/**
@@ -508,6 +518,7 @@ public class ServerInstallUtil {
default:
throw new RuntimeException("bad db type"); // this should never happen; should have never gotten to this point with a bad type
}
+ createNewDatasources_Cassandra(mcc);
LOG.info("Created datasources");
@@ -562,6 +573,21 @@ public class ServerInstallUtil {
}
}
+ private static void createNewDatasources_Cassandra(ModelControllerClient mcc) throws Exception {
+ DatasourceJBossASClient client = new DatasourceJBossASClient(mcc);
+ String connectionURL = "jdbc:cassandra://localhost:9160/system?version=3.0.0";
+ ModelNode dsRequest = client.createNewDatasourceRequest(CASSANDRA_DATASOURCE_NAME, connectionURL,
+ JDBC_DRIVER_CASSANDRA, false, new HashMap<String, String>());
+
+ ModelNode batch = DatasourceJBossASClient.createBatchRequest(dsRequest);
+ ModelNode results = client.execute(batch);
+ if (!DatasourceJBossASClient.isSuccess(results)) {
+ throw new FailureException(results, "Failed to create Cassandra data source");
+ } else {
+ LOG.info("Created Cassandra data source");
+ }
+ }
+
private static void createNewDatasources_Oracle(ModelControllerClient mcc) throws Exception {
final HashMap<String, String> props = new HashMap<String, String>(2);
final DatasourceJBossASClient client = new DatasourceJBossASClient(mcc);
diff --git a/modules/enterprise/server/appserver/src/main/scripts/rhq-container.build.xml b/modules/enterprise/server/appserver/src/main/scripts/rhq-container.build.xml
index 43e84e5..1da4a9a 100644
--- a/modules/enterprise/server/appserver/src/main/scripts/rhq-container.build.xml
+++ b/modules/enterprise/server/appserver/src/main/scripts/rhq-container.build.xml
@@ -201,14 +201,13 @@
toDir="${jboss.modules.dir}/org/apache-extras/cassandra-jdbc/main" failonerror="false" verbose="true"/>
<copy file="${settings.localRepository}/com/google/code/findbugs/jsr305/${cassandra.jdbc.jsr305.version}/jsr305-${cassandra.jdbc.jsr305.version}.jar"
toDir="${jboss.modules.dir}/org/apache-extras/cassandra-jdbc/main" failonerror="false" verbose="true"/>
- <echo file="${jboss.modules.dir}/org/apache-extras/cassandra-jdbc/main/module.xml">
- <![CDATA[<?xml version="1.0" encoding="UTF-8"?>
+ <echo file="${jboss.modules.dir}/org/apache-extras/cassandra-jdbc/main/module.xml"><![CDATA[<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.1" name="org.apache-extras.cassandra-jdbc">
<resources>
<resource-root path="cassandra-jdbc-${cassandra.jdbc.version}.jar"/>
<resource-root path="cassandra-clientutil-${cassandra.version}.jar"/>
<resource-root path="cassandra-thrift-${cassandra.version}.jar"/>
- <resource-root path="libthrift-${cassandra.thrift}.jar"/>
+ <resource-root path="libthrift-${cassandra.thrift.version}.jar"/>
<resource-root path="jsr305-${cassandra.jdbc.jsr305.version}.jar"/>
<resource-root path="guava-${cassandra.jdbc.guava.version}.jar"/>
</resources>
commit b423892e0a62f0945f2d2d82a3b1f0e9d41c45a0
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Wed Oct 24 11:13:21 2012 -0400
support adding a JDBC driver that does not support XA
diff --git a/modules/common/jboss-as-dmr-client/src/main/java/org/rhq/common/jbossas/client/controller/DatasourceJBossASClient.java b/modules/common/jboss-as-dmr-client/src/main/java/org/rhq/common/jbossas/client/controller/DatasourceJBossASClient.java
index b1f7a98..ab44796 100644
--- a/modules/common/jboss-as-dmr-client/src/main/java/org/rhq/common/jbossas/client/controller/DatasourceJBossASClient.java
+++ b/modules/common/jboss-as-dmr-client/src/main/java/org/rhq/common/jbossas/client/controller/DatasourceJBossASClient.java
@@ -132,18 +132,28 @@ public class DatasourceJBossASClient extends JBossASClient {
* @param name the name of the JDBC driver (this is not the name of the JDBC jar or the module name, it is
* just a convienence name of the JDBC driver configuration).
* @param moduleName the name of the JBossAS module where the JDBC driver is installed
- * @param driverXaClassName the JDBC driver's XA datasource classname
+ * @param driverXaClassName the JDBC driver's XA datasource classname (null if XA is not supported)
*
* @return the request to create the JDBC driver configuration.
*/
public ModelNode createNewJdbcDriverRequest(String name, String moduleName, String driverXaClassName) {
- String dmrTemplate = "" //
- + "{" //
- + "\"driver-module-name\" => \"%s\" " //
- + ", \"driver-xa-datasource-class-name\" => \"%s\" " //
- + "}";
-
- String dmr = String.format(dmrTemplate, moduleName, driverXaClassName);
+ String dmrTemplate;
+ String dmr;
+
+ if (driverXaClassName != null) {
+ dmrTemplate = "" //
+ + "{" //
+ + "\"driver-module-name\" => \"%s\" " //
+ + ", \"driver-xa-datasource-class-name\" => \"%s\" " //
+ + "}";
+ dmr = String.format(dmrTemplate, moduleName, driverXaClassName);
+ } else {
+ dmrTemplate = "" //
+ + "{" //
+ + "\"driver-module-name\" => \"%s\" " //
+ + "}";
+ dmr = String.format(dmrTemplate, moduleName);
+ }
Address addr = Address.root().add(SUBSYSTEM, SUBSYSTEM_DATASOURCES, JDBC_DRIVER, name);
final ModelNode request = ModelNode.fromString(dmr);
commit 42d055452d1c9784053c1853daab063cd94ae484
Author: Jay Shaughnessy <jshaughn(a)jshaughn.csb>
Date: Mon Oct 22 14:09:17 2012 -0400
Just get things to build after removal of embeddable ejb3 and
new AbstractEJB3Test based on Arquillian. Not close to running,
lots of band-aids and placeholders...
diff --git a/modules/core/domain/src/test/java/org/rhq/core/domain/test/AbstractEJB3Test.java b/modules/core/domain/src/test/java/org/rhq/core/domain/test/AbstractEJB3Test.java
index 711630b..a83b0ef 100644
--- a/modules/core/domain/src/test/java/org/rhq/core/domain/test/AbstractEJB3Test.java
+++ b/modules/core/domain/src/test/java/org/rhq/core/domain/test/AbstractEJB3Test.java
@@ -16,6 +16,7 @@ import javax.persistence.PersistenceContext;
import javax.transaction.TransactionManager;
import org.testng.AssertJUnit;
+import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.jboss.arquillian.container.test.api.Deployment;
@@ -228,7 +229,7 @@ public abstract class AbstractEJB3Test extends Arquillian {
*
* Instead, override {@link #afterMethod()}.
*/
- @BeforeMethod
+ @AfterMethod(alwaysRun = true)
protected void __afterMethod() throws Exception {
// currently no special handling necessary
afterMethod();
@@ -373,11 +374,11 @@ public abstract class AbstractEJB3Test extends Arquillian {
}
protected void assertEquals(String msg, int expected, int actual) {
- AssertJUnit.assertEquals(expected, actual);
+ AssertJUnit.assertEquals(msg, expected, actual);
}
protected void assertEquals(String msg, String expected, String actual) {
- AssertJUnit.assertEquals(expected, actual);
+ AssertJUnit.assertEquals(msg, expected, actual);
}
protected void fail(String message) {
diff --git a/modules/enterprise/server/itests/pom.xml b/modules/enterprise/server/itests/pom.xml
index d17fa7d..68425c80b 100644
--- a/modules/enterprise/server/itests/pom.xml
+++ b/modules/enterprise/server/itests/pom.xml
@@ -33,6 +33,57 @@
need the embeddable-ejb3 jar above the standard ejb3 jars because we need the embeddble packages
loaded when testing. -->
+ <dependency>
+ <groupId>org.jboss.spec</groupId>
+ <artifactId>jboss-javaee-6.0</artifactId>
+ <version>${jboss.javaee6.spec.version}</version>
+ <scope>provided</scope>
+ <type>pom</type>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.as</groupId>
+ <artifactId>jboss-as-arquillian-container-managed</artifactId>
+ <version>${jboss.version}</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.arquillian.testng</groupId>
+ <artifactId>arquillian-testng-container</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.shrinkwrap</groupId>
+ <artifactId>shrinkwrap-impl-base</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.shrinkwrap.resolver</groupId>
+ <artifactId>shrinkwrap-resolver-api</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.shrinkwrap.resolver</groupId>
+ <artifactId>shrinkwrap-resolver-api-maven</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.shrinkwrap.resolver</groupId>
+ <artifactId>shrinkwrap-resolver-impl-maven</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.arquillian.protocol</groupId>
+ <artifactId>arquillian-protocol-servlet</artifactId>
+ <scope>test</scope>
+ </dependency>
+
<dependency>
<groupId>org.rhq</groupId>
<artifactId>test-utils</artifactId>
diff --git a/modules/enterprise/server/itests/src/test/java/org/rhq/enterprise/server/alert/AlertDefinitionWithComplexNotificationsTest.java b/modules/enterprise/server/itests/src/test/java/org/rhq/enterprise/server/alert/AlertDefinitionWithComplexNotificationsTest.java
index d89855e..9ab2cf9 100644
--- a/modules/enterprise/server/itests/src/test/java/org/rhq/enterprise/server/alert/AlertDefinitionWithComplexNotificationsTest.java
+++ b/modules/enterprise/server/itests/src/test/java/org/rhq/enterprise/server/alert/AlertDefinitionWithComplexNotificationsTest.java
@@ -27,7 +27,6 @@ import java.util.List;
import java.util.Set;
import javax.persistence.EntityManager;
-import javax.transaction.TransactionManager;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -67,11 +66,9 @@ import org.rhq.enterprise.server.TestServerPluginService;
import org.rhq.enterprise.server.auth.SessionManager;
import org.rhq.enterprise.server.test.AbstractEJB3Test;
import org.rhq.enterprise.server.test.TestServerCommunicationsService;
+import org.rhq.enterprise.server.test.TransactionCallback;
import org.rhq.enterprise.server.util.LookupUtil;
import org.rhq.enterprise.server.util.ResourceTreeHelper;
-import org.rhq.test.JPAUtils;
-import org.rhq.test.TransactionCallback;
-import org.rhq.test.TransactionCallbackWithContext;
/**
*
@@ -569,9 +566,9 @@ public class AlertDefinitionWithComplexNotificationsTest extends AbstractEJB3Tes
private void removeNoExceptions(final Object o) {
try {
- JPAUtils.executeInTransaction(new TransactionCallbackWithContext<Void>() {
- @Override
- public Void execute(TransactionManager tm, EntityManager em) {
+ executeInTransaction(new TransactionCallback() {
+ public void execute() {
+ EntityManager em = getEntityManager();
Object o2 = em.merge(o);
if (o2 instanceof Resource) {
@@ -579,7 +576,6 @@ public class AlertDefinitionWithComplexNotificationsTest extends AbstractEJB3Tes
} else {
em.remove(o2);
}
- return null;
}
});
} catch (Exception e) {
diff --git a/modules/enterprise/server/itests/src/test/java/org/rhq/enterprise/server/drift/AbstractDriftServerTest.java b/modules/enterprise/server/itests/src/test/java/org/rhq/enterprise/server/drift/AbstractDriftServerTest.java
index bc8cf51..4f43c5d 100644
--- a/modules/enterprise/server/itests/src/test/java/org/rhq/enterprise/server/drift/AbstractDriftServerTest.java
+++ b/modules/enterprise/server/itests/src/test/java/org/rhq/enterprise/server/drift/AbstractDriftServerTest.java
@@ -48,7 +48,7 @@ import org.rhq.enterprise.server.plugin.ServerPluginsLocal;
import org.rhq.enterprise.server.test.AbstractEJB3Test;
import org.rhq.enterprise.server.test.TestServerCommunicationsService;
import org.rhq.enterprise.server.util.ResourceTreeHelper;
-import org.rhq.test.TransactionCallback;
+import org.rhq.enterprise.server.test.TransactionCallback;
@Test(groups = "drift", sequential = true)
public abstract class AbstractDriftServerTest extends AbstractEJB3Test {
diff --git a/modules/enterprise/server/itests/src/test/java/org/rhq/enterprise/server/drift/DriftTemplateManagerBeanTest.java b/modules/enterprise/server/itests/src/test/java/org/rhq/enterprise/server/drift/DriftTemplateManagerBeanTest.java
index 81601f3..bbd93b1 100644
--- a/modules/enterprise/server/itests/src/test/java/org/rhq/enterprise/server/drift/DriftTemplateManagerBeanTest.java
+++ b/modules/enterprise/server/itests/src/test/java/org/rhq/enterprise/server/drift/DriftTemplateManagerBeanTest.java
@@ -63,7 +63,7 @@ import org.rhq.core.domain.resource.ResourceType;
import org.rhq.core.domain.util.PageList;
import org.rhq.enterprise.server.safeinvoker.HibernateDetachUtility;
import org.rhq.test.AssertUtils;
-import org.rhq.test.TransactionCallback;
+import org.rhq.enterprise.server.test.TransactionCallback;
public class DriftTemplateManagerBeanTest extends AbstractDriftServerTest {
diff --git a/modules/enterprise/server/itests/src/test/java/org/rhq/enterprise/server/drift/JPADriftServerBeanTest.java b/modules/enterprise/server/itests/src/test/java/org/rhq/enterprise/server/drift/JPADriftServerBeanTest.java
index e117707..dee42d9 100644
--- a/modules/enterprise/server/itests/src/test/java/org/rhq/enterprise/server/drift/JPADriftServerBeanTest.java
+++ b/modules/enterprise/server/itests/src/test/java/org/rhq/enterprise/server/drift/JPADriftServerBeanTest.java
@@ -53,7 +53,7 @@ import org.rhq.core.domain.drift.dto.DriftDTO;
import org.rhq.core.domain.drift.dto.DriftFileDTO;
import org.rhq.core.domain.util.PageList;
import org.rhq.test.AssertUtils;
-import org.rhq.test.TransactionCallback;
+import org.rhq.enterprise.server.test.TransactionCallback;
@Test(dependsOnGroups = "pinning")
public class JPADriftServerBeanTest extends AbstractDriftServerTest {
diff --git a/modules/enterprise/server/itests/src/test/java/org/rhq/enterprise/server/drift/ManageDriftDefinitionsTest.java b/modules/enterprise/server/itests/src/test/java/org/rhq/enterprise/server/drift/ManageDriftDefinitionsTest.java
index 11b4a68..564264a 100644
--- a/modules/enterprise/server/itests/src/test/java/org/rhq/enterprise/server/drift/ManageDriftDefinitionsTest.java
+++ b/modules/enterprise/server/itests/src/test/java/org/rhq/enterprise/server/drift/ManageDriftDefinitionsTest.java
@@ -29,7 +29,7 @@ import org.rhq.core.domain.resource.ResourceType;
import org.rhq.core.domain.util.PageList;
import org.rhq.enterprise.server.safeinvoker.HibernateDetachUtility;
import org.rhq.test.AssertUtils;
-import org.rhq.test.TransactionCallback;
+import org.rhq.enterprise.server.test.TransactionCallback;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
diff --git a/modules/enterprise/server/itests/src/test/java/org/rhq/enterprise/server/drift/ManageSnapshotsTest.java b/modules/enterprise/server/itests/src/test/java/org/rhq/enterprise/server/drift/ManageSnapshotsTest.java
index bb132fe..a214621 100644
--- a/modules/enterprise/server/itests/src/test/java/org/rhq/enterprise/server/drift/ManageSnapshotsTest.java
+++ b/modules/enterprise/server/itests/src/test/java/org/rhq/enterprise/server/drift/ManageSnapshotsTest.java
@@ -55,7 +55,7 @@ import org.rhq.core.domain.drift.JPADriftSet;
import org.rhq.core.domain.server.EntitySerializer;
import org.rhq.core.domain.util.PageList;
import org.rhq.test.AssertUtils;
-import org.rhq.test.TransactionCallback;
+import org.rhq.enterprise.server.test.TransactionCallback;
@Test(dependsOnGroups = "pinning")
public class ManageSnapshotsTest extends AbstractDriftServerTest {
diff --git a/modules/enterprise/server/jar/pom.xml b/modules/enterprise/server/jar/pom.xml
index ad383e2..0eaa6d9 100644
--- a/modules/enterprise/server/jar/pom.xml
+++ b/modules/enterprise/server/jar/pom.xml
@@ -107,9 +107,60 @@
<!--================ Test Deps ================-->
<!-- Note, the test deps are intentionally placed above the other scoped deps because of classpath
- reasons. Maven orders the [test] classpath in the order listed in the pom. We specifically
- need the embeddable-ejb3 jar above the standard ejb3 jars because we need the embeddble packages
- loaded when testing. -->
+ reasons. Maven orders the [test] classpath in the order listed in the pom. -->
+
+ <dependency>
+ <groupId>org.jboss.spec</groupId>
+ <artifactId>jboss-javaee-6.0</artifactId>
+ <version>${jboss.javaee6.spec.version}</version>
+ <scope>provided</scope>
+ <type>pom</type>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.as</groupId>
+ <artifactId>jboss-as-arquillian-container-managed</artifactId>
+ <version>${jboss.version}</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.arquillian.testng</groupId>
+ <artifactId>arquillian-testng-container</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.shrinkwrap</groupId>
+ <artifactId>shrinkwrap-impl-base</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.shrinkwrap.resolver</groupId>
+ <artifactId>shrinkwrap-resolver-api</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.shrinkwrap.resolver</groupId>
+ <artifactId>shrinkwrap-resolver-api-maven</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.shrinkwrap.resolver</groupId>
+ <artifactId>shrinkwrap-resolver-impl-maven</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.arquillian.protocol</groupId>
+ <artifactId>arquillian-protocol-servlet</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+
<dependency>
<groupId>org.jboss.as</groupId>
@@ -165,7 +216,6 @@
</dependency>
<!-- NOTE: The remaining test deps correspond to the classes contained in hibernate-all.jar and thirdparty-all.jar. -->
-
<dependency>
<groupId>org.javassist</groupId>
<artifactId>javassist</artifactId>
diff --git a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/alert/test/AlertConditionTest.java b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/alert/test/AlertConditionTest.java
index 5116a90..97694e3 100644
--- a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/alert/test/AlertConditionTest.java
+++ b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/alert/test/AlertConditionTest.java
@@ -66,6 +66,7 @@ import org.rhq.enterprise.server.measurement.MeasurementDataManagerLocal;
import org.rhq.enterprise.server.resource.metadata.test.UpdatePluginMetadataTestBase;
import org.rhq.enterprise.server.scheduler.SchedulerLocal;
import org.rhq.enterprise.server.scheduler.jobs.AlertAvailabilityDurationJob;
+import org.rhq.enterprise.server.test.TransactionCallbackReturnable;
import org.rhq.enterprise.server.util.LookupUtil;
import org.rhq.test.JPAUtils;
import org.rhq.test.TransactionCallbackWithContext;
@@ -428,9 +429,9 @@ public class AlertConditionTest extends UpdatePluginMetadataTestBase {
}
private AlertCondition getAlertConditionWithLogs(final int conditionId) {
- return JPAUtils.executeInTransaction(new TransactionCallbackWithContext<AlertCondition>() {
+ return executeInTransaction(new TransactionCallbackReturnable<AlertCondition>() {
@Override
- public AlertCondition execute(TransactionManager tm, EntityManager em) throws Exception {
+ public AlertCondition execute() throws Exception {
AlertCondition cond = em.find(AlertCondition.class, conditionId);
cond.getConditionLogs().size(); // force the load
return cond;
diff --git a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/core/CoreServerServiceImplTest.java b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/core/CoreServerServiceImplTest.java
index 5992ea1..a4446c1 100644
--- a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/core/CoreServerServiceImplTest.java
+++ b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/core/CoreServerServiceImplTest.java
@@ -31,7 +31,6 @@ import javax.management.ObjectName;
import javax.persistence.Query;
import org.testng.annotations.AfterGroups;
-import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
@@ -165,8 +164,8 @@ public class CoreServerServiceImplTest extends AbstractEJB3Test {
server.setId(serverId);
}
- @AfterMethod
- public void unprepare() throws Exception {
+ @Override
+ public void afterMethod() throws Exception {
// cleanup our test server
LookupUtil.getCloudManager().updateServerMode(new Integer[] { server.getId() }, OperationMode.DOWN);
diff --git a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/group/test/LdapGroupManagerBeanTest.java b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/group/test/LdapGroupManagerBeanTest.java
index 78d23e8..aaa0808 100644
--- a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/group/test/LdapGroupManagerBeanTest.java
+++ b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/group/test/LdapGroupManagerBeanTest.java
@@ -38,9 +38,9 @@ import org.rhq.enterprise.server.resource.group.LdapGroupManagerLocal;
import org.rhq.enterprise.server.system.SystemManagerLocal;
import org.rhq.enterprise.server.test.AbstractEJB3Test;
import org.rhq.enterprise.server.test.TestServerPluginService;
+import org.rhq.enterprise.server.test.TransactionCallback;
import org.rhq.enterprise.server.test.ldap.FakeLdapCtxFactory;
import org.rhq.enterprise.server.util.LookupUtil;
-import org.rhq.test.TransactionCallback;
/**
* Integration tests for methods and operations performed by {@link LdapGroupManagerBean}.
diff --git a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/metadata/MetadataBeanTest.java b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/metadata/MetadataBeanTest.java
index 3748612..755f910 100644
--- a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/metadata/MetadataBeanTest.java
+++ b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/metadata/MetadataBeanTest.java
@@ -53,10 +53,6 @@ public class MetadataBeanTest extends AbstractEJB3Test {
private List<Integer> pluginIds = new ArrayList<Integer>();
- @Override
- protected boolean isDBResetNeeded() {
- return false;
- }
@BeforeGroups(groups = { "plugin.metadata" }, dependsOnGroups = { "integration.ejb3" })
public void beforeGroups() throws Exception {
@@ -79,7 +75,11 @@ public class MetadataBeanTest extends AbstractEJB3Test {
}
@BeforeMethod(groups = { "plugin.metadata" }, dependsOnGroups = { "integration.ejb3" })
- public void beforeMethod() throws Exception {
+ public void before() throws Exception {
+ if (!inContainer()) {
+ return;
+ }
+
TestBundleServerPluginService bundleService = new TestBundleServerPluginService();
prepareCustomServerPluginService(bundleService);
bundleService.startMasterPluginContainerWithoutSchedulingJobs();
@@ -93,7 +93,11 @@ public class MetadataBeanTest extends AbstractEJB3Test {
* however removes the generated plugin files during each test run.
*/
@AfterMethod(alwaysRun = true, groups = { "plugin.metadata" })
- void afterMethod() throws Exception {
+ void after() throws Exception {
+ if (!inContainer()) {
+ return;
+ }
+
unprepareServerPluginService();
unprepareScheduler();
unpreparePluginScannerService();
diff --git a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/metadata/ResourceMetadataManagerBeanTest.java b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/metadata/ResourceMetadataManagerBeanTest.java
index 336e23b..0e142e9 100644
--- a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/metadata/ResourceMetadataManagerBeanTest.java
+++ b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/metadata/ResourceMetadataManagerBeanTest.java
@@ -512,7 +512,7 @@ public class ResourceMetadataManagerBeanTest extends MetadataBeanTest {
// quickly as it is basically just updates the the inventory status to UNINVENTORIED for the
// resources to be deleted.
for (Resource resource : resources) {
- assertEquals("The resource should have been marked for deletion",
+ assertTrue("The resource should have been marked for deletion",
InventoryStatus.UNINVENTORIED == resource.getInventoryStatus());
}
}
diff --git a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/metadata/test/UpdatePluginMetadataTestBase.java b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/metadata/test/UpdatePluginMetadataTestBase.java
index a564aca..ef785fc 100644
--- a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/metadata/test/UpdatePluginMetadataTestBase.java
+++ b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/metadata/test/UpdatePluginMetadataTestBase.java
@@ -28,7 +28,6 @@ import java.util.UUID;
import javax.persistence.EntityManager;
import javax.persistence.NoResultException;
import javax.transaction.Status;
-import javax.transaction.TransactionManager;
import javax.xml.XMLConstants;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.Unmarshaller;
@@ -61,9 +60,8 @@ import org.rhq.enterprise.server.resource.ResourceTypeManagerLocal;
import org.rhq.enterprise.server.resource.metadata.PluginManagerLocal;
import org.rhq.enterprise.server.test.AbstractEJB3Test;
import org.rhq.enterprise.server.test.TestServerCommunicationsService;
+import org.rhq.enterprise.server.test.TransactionCallbackReturnable;
import org.rhq.enterprise.server.util.LookupUtil;
-import org.rhq.test.JPAUtils;
-import org.rhq.test.TransactionCallbackWithContext;
public class UpdatePluginMetadataTestBase extends AbstractEJB3Test {
@@ -425,9 +423,9 @@ public class UpdatePluginMetadataTestBase extends AbstractEJB3Test {
}
protected Resource persistNewResource(final String resourceTypeName) throws Exception {
- return JPAUtils.executeInTransaction(new TransactionCallbackWithContext<Resource>() {
- @Override
- public Resource execute(TransactionManager tm, EntityManager em) throws Exception {
+ return executeInTransaction(new TransactionCallbackReturnable<Resource>() {
+
+ public Resource execute() throws Exception {
ResourceType resourceType = getResourceType(resourceTypeName);
Resource resource = new Resource("reskey" + System.currentTimeMillis(), "resname", resourceType);
resource.setUuid(UUID.randomUUID().toString());
diff --git a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/scheduler/jobs/DataPurgeJobTest.java b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/scheduler/jobs/DataPurgeJobTest.java
index c710706..31d2a87 100644
--- a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/scheduler/jobs/DataPurgeJobTest.java
+++ b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/scheduler/jobs/DataPurgeJobTest.java
@@ -36,8 +36,6 @@ import javax.transaction.SystemException;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.quartz.JobListener;
-import org.testng.annotations.AfterMethod;
-import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import org.rhq.core.domain.alert.Alert;
@@ -97,8 +95,8 @@ public class DataPurgeJobTest extends AbstractEJB3Test {
private int resourceTypeId;
private TestServerPluginService testServerPluginService;
- @BeforeMethod
- public void beforeMethod() throws Throwable {
+ @Override
+ public void beforeMethod() throws Exception {
try {
//we need this because the drift plugins are referenced from the system settings that we use in our tests
testServerPluginService = new TestServerPluginService();
@@ -111,12 +109,12 @@ public class DataPurgeJobTest extends AbstractEJB3Test {
} catch (Throwable t) {
System.err.println("Cannot prepare test: " + t);
t.printStackTrace();
- throw t;
+ throw new RuntimeException(t);
}
}
- @AfterMethod(alwaysRun = true)
- public void afterMethod() throws Throwable {
+ @Override
+ public void afterMethod() throws Exception {
try {
deleteNewResource(newResource);
unprepareForTestAgents();
@@ -125,7 +123,7 @@ public class DataPurgeJobTest extends AbstractEJB3Test {
} catch (Throwable t) {
System.err.println("Cannot unprepare test: " + t);
t.printStackTrace();
- throw t;
+ throw new RuntimeException(t);
}
}
diff --git a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/test/AbstractEJB3Test.java b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/test/AbstractEJB3Test.java
index 11d01a2..4ae4692 100644
--- a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/test/AbstractEJB3Test.java
+++ b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/test/AbstractEJB3Test.java
@@ -1,321 +1,482 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-2008 Red Hat, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
package org.rhq.enterprise.server.test;
-import static org.rhq.test.JPAUtils.clearDB;
-import static org.rhq.test.JPAUtils.lookupEntityManager;
-import static org.rhq.test.JPAUtils.lookupTransactionManager;
-
+import java.io.File;
import java.sql.Connection;
import java.sql.SQLException;
-import java.util.Hashtable;
+import java.util.Collection;
+import java.util.Date;
+import java.util.HashSet;
+import java.util.Iterator;
import java.util.Properties;
+import java.util.regex.Pattern;
import javax.management.MBeanServer;
-import javax.management.MBeanServerFactory;
+import javax.naming.Context;
import javax.naming.InitialContext;
-import javax.naming.NamingException;
import javax.persistence.EntityManager;
+import javax.persistence.EntityManagerFactory;
+import javax.persistence.PersistenceContext;
import javax.transaction.TransactionManager;
-import org.hibernate.SessionFactory;
-import org.hibernate.stat.Statistics;
import org.testng.AssertJUnit;
-import org.testng.annotations.AfterMethod;
-import org.testng.annotations.AfterSuite;
-import org.testng.annotations.BeforeClass;
import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.BeforeSuite;
-import org.jboss.ejb3.embedded.EJB3StandaloneBootstrap;
-import org.jboss.ejb3.embedded.EJB3StandaloneDeployer;
-import org.jboss.mx.util.MBeanServerLocator;
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.test.api.ArquillianResource;
+import org.jboss.arquillian.testng.Arquillian;
+import org.jboss.shrinkwrap.api.ArchivePaths;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.asset.EmptyAsset;
+import org.jboss.shrinkwrap.api.spec.EnterpriseArchive;
+import org.jboss.shrinkwrap.api.spec.JavaArchive;
+import org.jboss.shrinkwrap.resolver.api.DependencyResolvers;
+import org.jboss.shrinkwrap.resolver.api.maven.MavenDependencyResolver;
-import org.rhq.core.db.DatabaseTypeFactory;
-import org.rhq.core.db.PostgresqlDatabaseType;
import org.rhq.core.domain.auth.Subject;
-import org.rhq.core.domain.server.PersistenceUtility;
-import org.rhq.enterprise.server.RHQConstants;
+import org.rhq.core.util.MessageDigestGenerator;
+import org.rhq.core.util.exception.ThrowableUtil;
+import org.rhq.core.util.stream.StreamUtil;
import org.rhq.enterprise.server.auth.SessionManager;
-import org.rhq.enterprise.server.content.ContentSourceManagerBean;
-import org.rhq.enterprise.server.core.comm.ServerCommunicationsServiceMBean;
import org.rhq.enterprise.server.core.plugin.PluginDeploymentScanner;
import org.rhq.enterprise.server.core.plugin.PluginDeploymentScannerMBean;
import org.rhq.enterprise.server.plugin.pc.ServerPluginService;
-import org.rhq.enterprise.server.plugin.pc.ServerPluginServiceMBean;
import org.rhq.enterprise.server.scheduler.SchedulerService;
-import org.rhq.enterprise.server.scheduler.SchedulerServiceMBean;
import org.rhq.enterprise.server.util.LookupUtil;
-import org.rhq.test.JPAUtils;
-import org.rhq.test.TransactionCallback;
-
-/**
- * This is the abstract test base for server jar tests.
- *
- * @author Greg Hinkle
- */
-public abstract class AbstractEJB3Test extends AssertJUnit {
-
- private static EJB3StandaloneDeployer deployer;
- private static Statistics stats;
- @SuppressWarnings("unused")
- private static long start; // see endTest() if you want to output this
- private SchedulerService schedulerService;
- private ServerPluginService serverPluginService;
- private MBeanServer dummyJBossMBeanServer;
- private PluginDeploymentScannerMBean pluginScannerService;
+import org.rhq.test.AssertUtils;
+import org.rhq.test.MatchResult;
+import org.rhq.test.PropertyMatchException;
+import org.rhq.test.PropertyMatcher;
- @BeforeClass
- public void resetDB() throws Exception {
- if (isDBResetNeeded()) {
- clearDB();
- }
- }
+public abstract class AbstractEJB3Test extends Arquillian {
- protected boolean isDBResetNeeded() {
- return true;
- }
+ protected static final String JNDI_RHQDS = "java:jboss/datasources/RHQDS";
- //@BeforeSuite(groups = {"integration.ejb3","PERF"}) // TODO investigate again
- @BeforeSuite(alwaysRun = true)
- public static void startupEmbeddedJboss() throws Exception {
- // The embeddedDeployment property needs to be set for running tests
- // with the embedded container. It is set in the surefire configuration
- // in pom.xml but setting here makes it easier to run tests directly
- // from your IDE.
- //
- // jsanda
- System.setProperty("embeddedDeployment", "true");
+ private SchedulerService schedulerService;
+ private ServerPluginService serverPluginService;
+ //private MBeanServer dummyJBossMBeanServer;
+ private PluginDeploymentScannerMBean pluginScannerService;
- // Setting content location to the tmp dir
- System.setProperty(ContentSourceManagerBean.FILESYSTEM_PROPERTY, System.getProperty("java.io.tmpdir"));
+ @PersistenceContext
+ protected EntityManager em;
- System.out.println("Starting JBoss EJB3 Embedded Container...");
- String deployDir = System.getProperty("deploymentDirectory", "target/classes");
- System.out.println("Loading EJB3 deployments from directory: " + deployDir);
- try {
- EJB3StandaloneBootstrap.boot(null);
- // EJB3StandaloneBootstrap.scanClasspath();
+ @ArquillianResource
+ protected InitialContext initialContext;
- System.err.println("...... embedded container booted....");
+ // We originally deployed the domain jar as a JavaArchive (JAR file). But this ran into problems because
+ // of the dependent 3rd party jars. There isn't an obvious way to deploy the dependent jars of a jar.
+ // Also, AS7 makes it hard to put them in a globally accessibly /lib directory due to
+ // its classloader isolation and module approach. So, we now deploy an EnterpriseArchive (ear)
+ // where the domain jar is deployed as a module and the 3rd party libraries are put in the ear's /lib.
- deployer = EJB3StandaloneBootstrap.createDeployer();
+ @Deployment
+ protected static EnterpriseArchive getBaseDeployment() {
- deployer.setClassLoader(AbstractEJB3Test.class.getClassLoader());
- System.err.println("...... embedded container classloader set....");
+ // depending on the db in use, set up the necessary datasource
+ String dialect = System.getProperty("hibernate.dialect");
+ if (dialect == null) {
+ System.out.println("!!! hibernate.dialect is not set! Assuming you want to test on postgres");
+ dialect = "postgres";
+ }
- deployer.getArchivesByResource().add("META-INF/persistence.xml");
- System.err.println("...... embedded container persistence xml deployed....");
+ String dataSourceXml;
+ if (dialect.toLowerCase().contains("postgres")) {
+ dataSourceXml = "jbossas-postgres-ds.xml";
+ } else {
+ dataSourceXml = "jbossas-oracle-ds.xml";
+ }
- deployer.getArchivesByResource().add("META-INF/ejb-jar.xml");
- System.err.println("...... embedded container ejb-jar xml deployed....");
+ // Create the domain jar which will subsequently be packaged in the ear deployment
+ JavaArchive ejbJar = ShrinkWrap.create(JavaArchive.class, "rhq-core-domain-ejb3.jar") //
+ .addAsManifestResource(dataSourceXml) // the datasource
+ .addAsManifestResource("ejb-jar.xml") // the empty ejb jar descriptor
+ .addAsManifestResource("test-persistence.xml", "persistence.xml") // the test persistence context
+ .addAsManifestResource(EmptyAsset.INSTANCE, ArchivePaths.create("beans.xml") // add CDI injection (needed by arquillian injection)
+ );
+
+ // non-domain RHQ classes in use by domain test classes
+ ejbJar.addClass(ThrowableUtil.class) //
+ .addClass(MessageDigestGenerator.class) //
+ .addClass(StreamUtil.class) //
+ .addClass(AssertUtils.class) //
+ .addClasses(PropertyMatcher.class, MatchResult.class, PropertyMatchException.class);
+
+ // domain classes
+ ejbJar = addClasses(ejbJar, new File("target/classes/org"), null);
+
+ JavaArchive testClassesJar = ShrinkWrap.create(JavaArchive.class, "test-classes.jar");
+ testClassesJar = addClasses(testClassesJar, new File("target/test-classes/org"), null);
+
+ // create test ear
+ EnterpriseArchive ear = ShrinkWrap.create(EnterpriseArchive.class, "test-domain.ear") //
+ .addAsModule(ejbJar) // the domain jar under test
+ .addAsLibrary(testClassesJar) // the actual test classes
+ .setApplicationXML("application.xml"); // the application xml declaring the ejb jar
+
+ // Adding the 3rd party jars is not easy. There were basically two approaches I could think of:
+ //
+ // 1) Use the MavenDependencyResolver to figure out and add all of the test deps and put them in lib
+ //
+ // This immediately ran into trouble as there were way more jars sucked in than were actually necessary.
+ // Furthermore, it included arquillian, shrinkwrap, jboss, etc.. lots of jars that actually caused
+ // issues like locking and other horrible things due, I suppose, to just stepping all over the test env
+ // set up by Arquillian. So, the next step was to try and start excluding the unwanted jars. This was
+ // tedious and difficult and I didn't really get it close to working before giving up and going with
+ // option 2.
+ //
+ // 2) Use the MavenDependencyResolver to locate and pull just the artifacts we need.
+ //
+ // This is annoying because it's basically duplicating the same sort of effort that we already
+ // use maven to do for us. It involves running, failing on NoClassDefFound, fixing it, repeat. It
+ // does pull in necessary transitive deps but sometimes it pulls in unwanted transitive deps. So,
+ // we still end up having to do some exclusion filtering. Since Shrinkwrap has weak and buggy
+ // filtering, we have some homegrown filtering methods below.
+ // TODO: Is there any way to not have to specify the versions for the transitive deps? This is brittle as is.
+
+ //load 3rd party deps explicitly
+ MavenDependencyResolver resolver = DependencyResolvers.use(MavenDependencyResolver.class);
+ resolver.loadMetadataFromPom("pom.xml");
+ Collection<JavaArchive> dependencies = new HashSet<JavaArchive>();
+ dependencies
+ .addAll(resolver.artifact("commons-beanutils:commons-beanutils:1.8.2").resolveAs(JavaArchive.class));
+ dependencies.addAll(resolver.artifact("commons-codec:commons-codec").resolveAs(JavaArchive.class));
+ dependencies.addAll(resolver.artifact("commons-io:commons-io").resolveAs(JavaArchive.class));
+ dependencies.addAll(resolver.artifact("org.unitils:unitils-testng:3.1").resolveAs(JavaArchive.class));
+
+ String[] excludeFilters = { "testng.*jdk" };
+
+ dependencies = exclude(dependencies, excludeFilters);
+ ear = ear.addAsLibraries(dependencies);
+
+ System.out.println("** The Deployment EAR: " + ear.toString(true) + "\n");
+
+ return ear;
+ }
- EJB3StandaloneBootstrap.deployXmlResource("jboss-jms-beans.xml");
- System.err.println("...... embedded container jboss-jms-beans xml deployed....");
+ /**
+ * @param dependencies The current set of deps - THIS IS FILTERED, not copied
+ * @param filters regex filters
+ * @return the filtered set of deps
+ */
+ public static Collection<JavaArchive> exclude(Collection<JavaArchive> dependencies, String... filters) {
- EJB3StandaloneBootstrap.deployXmlResource("rhq-mdb-beans.xml");
- System.err.println("...... embedded container rhq-mdb-beans xml deployed....");
+ for (String filter : filters) {
+ Pattern p = Pattern.compile(filter);
- /*
- * File core = new File(deployDir, "on-core-domain-ejb.ejb3"); if (!core.exists())
- * System.err.println("Deployment directory does not exist: " + core.getAbsolutePath());
- * deployer.getArchives().add(core.toURI().toURL());
- *
- * File server = new File(deployDir, "on-enterprise-server-ejb.ejb3"); if (!server.exists())
- * System.err.println("Deployment directory does not exist: " + server.getAbsolutePath());
- * deployer.getArchives().add(server.toURI().toURL());
- *
- */
+ for (Iterator<JavaArchive> i = dependencies.iterator(); i.hasNext();) {
+ JavaArchive dependency = i.next();
+ if (p.matcher(dependency.getName()).find()) {
+ i.remove();
+ }
+ }
+ }
- //deployer.setKernel(EJB3StandaloneBootstrap.getKernel());
- deployer.create();
- System.err.println("...... deployer created....");
+ return dependencies;
+ }
- deployer.start();
- System.err.println("...... deployer started....");
+ /**
+ * @param dependencies The current set of deps - this is not changed
+ * @param filters regex filters
+ * @return set set of JavaArchives in dependencies that matched an include filter
+ */
+ public static Collection<JavaArchive> include(Collection<JavaArchive> dependencies, String... filters) {
- System.err.println("...... start statistics");
- SessionFactory sessionFactory = PersistenceUtility.getHibernateSession(getEntityManager())
- .getSessionFactory();
- stats = sessionFactory.getStatistics();
- stats.setStatisticsEnabled(true);
+ Collection<JavaArchive> result = new HashSet<JavaArchive>();
- System.err.println("...... embedded container initialized and ready for testing....");
+ for (String filter : filters) {
+ Pattern p = Pattern.compile(filter);
- } catch (Throwable t) {
- // Catch RuntimeExceptions and Errors and dump their stack trace, because Surefire will completely swallow them
- // and throw a cryptic NPE (see http://jira.codehaus.org/browse/SUREFIRE-157)!
- t.printStackTrace();
- throw new RuntimeException(t);
+ for (Iterator<JavaArchive> i = dependencies.iterator(); i.hasNext();) {
+ JavaArchive dependency = i.next();
+ if (p.matcher(dependency.getName()).find()) {
+ result.add(dependency);
+ }
+ }
}
- }
- //@Configuration(groups = "integration.ejb3", afterSuite = true)
- @AfterSuite(alwaysRun = true)
- public static void shutdownEmbeddedJboss() {
- System.out.println("Stopping JBoss EJB3 Embedded Container...");
+ return result;
+ }
- System.err.println("!!! Any errors occurring after this point !!!");
- System.err.println("!!! occurred during embedded server shutdown !!!");
- System.err.println("!!! and are probably not a real problem. !!!");
- if (deployer != null) {
- try {
- deployer.stop();
- deployer.destroy();
- deployer = null;
- } catch (Throwable t) {
- System.err.println("Failed to stop embedded deployer");
- t.printStackTrace(System.err);
+ public static JavaArchive addClasses(JavaArchive archive, File dir, String packageName) {
+
+ packageName = (null == packageName) ? "" + dir.getName() : packageName + "." + dir.getName();
+
+ for (File file : dir.listFiles()) {
+ String fileName = file.getName();
+ if (file.isDirectory()) {
+ archive = addClasses(archive, file, packageName);
+ } else if (fileName.endsWith(".class")) {
+ int dot = fileName.indexOf('.');
+ try {
+ Class<?> clazz = Class.forName(packageName + "." + fileName.substring(0, dot));
+ archive.addClasses(clazz);
+ } catch (Exception e) {
+ System.out.println("WARN: Could not add class:" + e);
+ }
}
}
- EJB3StandaloneBootstrap.shutdown();
+
+ return archive;
}
+ /**
+ * <p>DO NOT OVERRIDE.</p>
+ * <p>DO NOT DEFINE AN @BeforeMethod</p>
+ *
+ * Instead, override {@link #beforeMethod()}. If you must override, for example, if you
+ * need to use special attributes on your annotation, then ensure you protect the code with
+ * and {@link #inContainer()} call.
+ */
@BeforeMethod
- public static void startTest() {
- if (DatabaseTypeFactory.getDefaultDatabaseType() == null) {
- try {
- Connection conn = getConnection();
- DatabaseTypeFactory.setDefaultDatabaseType(DatabaseTypeFactory.getDatabaseType(conn));
- } catch (Exception e) {
- System.err.println("!!! WARNING !!! cannot set default database type, some tests may fail");
- e.printStackTrace();
- }
+ protected void __beforeMethod() throws Exception {
+ // Note that Arquillian calls the testng BeforeMethod twice (as of 1.0.2.Final, once
+ // out of container and once in container. In general the expectation is to execute it
+ // one time, and doing it in container allows for the expected injections and context.
+ if (inContainer()) {
+ beforeMethod();
}
-
- if (stats != null)
- start = stats.getQueryExecutionCount();
- else
- start = 0;
}
- public static Connection getConnection() throws SQLException {
- return LookupUtil.getDataSource().getConnection();
+ /**
+ * <p>DO NOT OVERRIDE.</p>
+ * <p>DO NOT DEFINE AN @AfterMethod</p>
+ *
+ * Instead, override {@link #afterMethod()}.
+ */
+ @BeforeMethod
+ protected void __afterMethod() throws Exception {
+ // currently no special handling necessary
+ afterMethod();
}
- @AfterMethod
- public static void endTest() {
- //System.out.println("Connections used: " + (stats.getQueryExecutionCount() - start));
+ protected boolean inContainer() {
+ // If the injection is done we're running in the container.
+ return (null != initialContext);
}
- public TransactionManager getTransactionManager() {
- return lookupTransactionManager();
+ /**
+ * Override Point! Do not implement a @BeforeMethod, instead override this method.
+ */
+ protected void beforeMethod() throws Exception {
+ // do nothing if we're not overridden
}
- public static EntityManager getEntityManager() {
- return lookupEntityManager();
+ /**
+ * Override Point! Do not implement an @AfterMethod, instead override this method.
+ */
+ protected void afterMethod() throws Exception {
+ // do nothing if we're not overridden
}
- public static InitialContext getInitialContext() {
- Hashtable<String, String> env = new Hashtable<String, String>();
- env.put("java.naming.factory.initial", "org.jnp.interfaces.LocalOnlyContextFactory");
- env.put("java.naming.factory.url.pkgs", "org.jboss.naming:org.jnp.interfaces");
- try {
- return new InitialContext(env);
- } catch (NamingException e) {
- e.printStackTrace();
- throw new RuntimeException("Failed to load initial context", e);
- }
+ protected void startTransaction() throws Exception {
+ getTransactionManager().begin();
}
- public boolean isPostgres() throws Exception {
- return DatabaseTypeFactory.getDatabaseType(getInitialContext(), RHQConstants.DATASOURCE_JNDI_NAME) instanceof PostgresqlDatabaseType;
+ protected void commitTransaction() throws Exception {
+ getTransactionManager().commit();
}
- /**
- * This creates a session for the given user and associates that session with the subject. You can test the security
- * annotations by creating sessions for different users with different permissions.
- *
- * @param subject a JON subject
- * @return the session activated subject, a copy of the subject passed in.
- */
- public Subject createSession(Subject subject) {
- return SessionManager.getInstance().put(subject);
+ protected void rollbackTransaction() throws Exception {
+ getTransactionManager().rollback();
}
- /**
- * Returns an MBeanServer that simulates the JBossAS MBeanServer.
- *
- * @return MBeanServer instance
- */
- public MBeanServer getJBossMBeanServer() {
- if (dummyJBossMBeanServer == null) {
- dummyJBossMBeanServer = MBeanServerFactory.createMBeanServer("jboss");
- MBeanServerLocator.setJBoss(dummyJBossMBeanServer);
+ protected InitialContext getInitialContext() {
+ // may be null if not yet injected (as of 1.0.1.Final, only injected inside @Test)
+ if (null != initialContext) {
+ return initialContext;
}
- return dummyJBossMBeanServer;
- }
+ InitialContext result = null;
- public void releaseJBossMBeanServer() {
- if (dummyJBossMBeanServer != null) {
- MBeanServerFactory.releaseMBeanServer(dummyJBossMBeanServer);
- dummyJBossMBeanServer = null;
+ try {
+ Properties jndiProperties = new Properties();
+ jndiProperties.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.as.naming.InitialContextFactory");
+ result = new InitialContext(jndiProperties);
+
+ } catch (Exception e) {
+ throw new RuntimeException("Failed to get InitialContext", e);
}
+
+ return result;
}
- /**
- * If you need to test round trips from server to agent and back, you first must install the server communications
- * service that houses all the agent clients. Call this method and add your test agent services to the public fields
- * in the returned object.
- *
- * @return the object that will house your test agent service impls and the agent clients.
- *
- * @throws RuntimeException
- */
- public TestServerCommunicationsService prepareForTestAgents() {
+ public TransactionManager getTransactionManager() {
+ TransactionManager result = null;
+
try {
- MBeanServer mbs = getJBossMBeanServer();
- if (mbs.isRegistered(ServerCommunicationsServiceMBean.OBJECT_NAME)) {
- mbs.unregisterMBean(ServerCommunicationsServiceMBean.OBJECT_NAME);
+ result = (TransactionManager) getInitialContext().lookup("java:jboss/TransactionManager");
+ if (null == result) {
+ result = (TransactionManager) getInitialContext().lookup("TransactionManager");
}
- TestServerCommunicationsService testAgentContainer = new TestServerCommunicationsService();
- mbs.registerMBean(testAgentContainer, ServerCommunicationsServiceMBean.OBJECT_NAME);
- return testAgentContainer;
+
} catch (Exception e) {
- throw new RuntimeException(e);
+ throw new RuntimeException("Failed to get TransactionManager", e);
+ }
+
+ return result;
+ }
+
+ protected EntityManager getEntityManager() {
+ // may be null if not yet injected (as of 1.0.1.Final, only injected inside @Test)
+ if (null != em) {
+ return em;
+ }
+
+ EntityManager result = null;
+
+ try {
+ EntityManagerFactory emf = (EntityManagerFactory) getInitialContext().lookup(
+ "java:jboss/RHQEntityManagerFactory");
+ result = emf.createEntityManager();
+
+ } catch (Exception e) {
+ throw new RuntimeException("Failed to get EntityManagerFactory", e);
}
+
+ return result;
}
/**
- * Call this after your tests have finished. You only need to call this if your test previously called
- * {@link #prepareForTestAgents()}.
+ * Equivalent to <pre>executeInTransaction(true, callback)</pre>.
+ * @param callback
*/
- public void unprepareForTestAgents() {
- unprepareForTestAgents(false);
+ protected void executeInTransaction(TransactionCallback callback) {
+ executeInTransaction(true, callback);
}
- public void unprepareForTestAgents(boolean beanOnly) {
+ protected void executeInTransaction(boolean rollback, final TransactionCallback callback) {
+ executeInTransaction(rollback, new TransactionCallbackReturnable<Void>() {
+
+ public Void execute() throws Exception {
+ callback.execute();
+ return null;
+ }});
+ }
+
+ protected <T> T executeInTransaction(TransactionCallbackReturnable<T> callback) {
+ return executeInTransaction(true, callback);
+ }
+
+ protected <T> T executeInTransaction(boolean rollback, TransactionCallbackReturnable<T> callback) {
try {
- if (beanOnly) {
- MBeanServer mbs = getJBossMBeanServer();
- if (mbs.isRegistered(ServerCommunicationsServiceMBean.OBJECT_NAME)) {
- mbs.unregisterMBean(ServerCommunicationsServiceMBean.OBJECT_NAME);
+ startTransaction();
+ T result = callback.execute();
+ return result;
+
+ } catch (Throwable t) {
+ rollback = true;
+ RuntimeException re = new RuntimeException(ThrowableUtil.getAllMessages(t), t);
+ throw re;
+
+ } finally {
+ try {
+ if (!rollback) {
+ commitTransaction();
+ } else {
+ rollbackTransaction();
}
- } else {
- releaseJBossMBeanServer();
+ } catch (Exception e) {
+ throw new RuntimeException("Failed to " + (rollback ? "rollback" : "commit") + " transaction", e);
}
- } catch (Exception e) {
- throw new RuntimeException(e);
}
}
+
+ /* The old AbstractEJB3Test impl extended AssertJUnit. Continue to support the used methods
+ * with various call-thru methods.
+ */
+
+ protected void assertNotNull(Object o) {
+ AssertJUnit.assertNotNull(o);
+ }
+
+ protected void assertNotNull(String msg, Object o) {
+ AssertJUnit.assertNotNull(msg, o);
+ }
+
+ protected void assertNull(Object o) {
+ AssertJUnit.assertNull(o);
+ }
+
+ protected void assertNull(String msg, Object o) {
+ AssertJUnit.assertNull(msg, o);
+ }
+
+ protected void assertFalse(boolean b) {
+ AssertJUnit.assertFalse(b);
+ }
+
+ protected void assertFalse(String msg, boolean b) {
+ AssertJUnit.assertFalse(msg, b);
+ }
+
+ protected void assertTrue(boolean b) {
+ AssertJUnit.assertTrue(b);
+ }
+
+ protected void assertTrue(String msg, boolean b) {
+ AssertJUnit.assertTrue(msg, b);
+ }
+
+ protected void assertEquals(int expected, int actual) {
+ AssertJUnit.assertEquals(expected, actual);
+ }
+
+ protected void assertEquals(String msg, int expected, int actual) {
+ AssertJUnit.assertEquals(msg, expected, actual);
+ }
+
+ protected void assertEquals(long expected, long actual) {
+ AssertJUnit.assertEquals(expected, actual);
+ }
+
+ protected void assertEquals(String msg, long expected, long actual) {
+ AssertJUnit.assertEquals(msg, expected, actual);
+ }
+
+ protected void assertEquals(String expected, String actual) {
+ AssertJUnit.assertEquals(expected, actual);
+ }
+
+ protected void assertEquals(String msg, String expected, String actual) {
+ AssertJUnit.assertEquals(msg, expected, actual);
+ }
+
+ protected void assertEquals(boolean expected, boolean actual) {
+ AssertJUnit.assertEquals(expected, actual);
+ }
+
+ protected void assertEquals(String msg, boolean expected, boolean actual) {
+ AssertJUnit.assertEquals(msg, expected, actual);
+ }
+
+ protected void assertEquals(Object expected, Object actual) {
+ AssertJUnit.assertEquals(expected, actual);
+ }
+
+ protected void assertEquals(String msg, Object expected, Object actual) {
+ AssertJUnit.assertEquals(msg, expected, actual);
+ }
+
+ protected void fail() {
+ AssertJUnit.fail();
+ }
+
+ protected void fail(String message) {
+ AssertJUnit.fail(message);
+ }
+
+ private final long DEFAULT_OFFSET = 50;
+ private long referenceTime = new Date().getTime();
+
+ public Date getAnotherDate() {
+ return getAnotherDate(DEFAULT_OFFSET);
+ }
+
+ public Date getAnotherDate(long offset) {
+ referenceTime += offset;
+ return new Date(referenceTime);
+ }
+
/**
* If you need to test server plugins, you must first prepare the server plugin service.
* After this returns, the caller must explicitly start the PC by using the appropriate API
@@ -327,10 +488,11 @@ public abstract class AbstractEJB3Test extends AssertJUnit {
*/
public void prepareCustomServerPluginService(ServerPluginService testServiceMBean) {
try {
- MBeanServer mbs = getJBossMBeanServer();
- testServiceMBean.start();
- mbs.registerMBean(testServiceMBean, ServerPluginServiceMBean.OBJECT_NAME);
- serverPluginService = testServiceMBean;
+ // TODO: Fix
+ // MBeanServer mbs = getJBossMBeanServer();
+ // testServiceMBean.start();
+ // mbs.registerMBean(testServiceMBean, ServerPluginServiceMBean.OBJECT_NAME);
+ // serverPluginService = testServiceMBean;
return;
} catch (Exception e) {
throw new RuntimeException(e);
@@ -346,16 +508,16 @@ public abstract class AbstractEJB3Test extends AssertJUnit {
serverPluginService.stopMasterPluginContainer();
serverPluginService.stop();
if (beanOnly) {
- MBeanServer mbs = getJBossMBeanServer();
- if (mbs.isRegistered(ServerPluginService.OBJECT_NAME)) {
- getJBossMBeanServer().unregisterMBean(ServerPluginService.OBJECT_NAME);
- }
- if (mbs.isRegistered(ServerPluginServiceMBean.OBJECT_NAME)) {
- getJBossMBeanServer().unregisterMBean(ServerPluginServiceMBean.OBJECT_NAME);
- }
+ // TODO: Fix
+ // if (mbs.isRegistered(ServerPluginService.OBJECT_NAME)) {
+ // getJBossMBeanServer().unregisterMBean(ServerPluginService.OBJECT_NAME);
+ // }
+ // if (mbs.isRegistered(ServerPluginServiceMBean.OBJECT_NAME)) {
+ // getJBossMBeanServer().unregisterMBean(ServerPluginServiceMBean.OBJECT_NAME);
+ // }
} else {
- releaseJBossMBeanServer();
+ // releaseJBossMBeanServer();
}
serverPluginService = null;
}
@@ -377,7 +539,7 @@ public abstract class AbstractEJB3Test extends AssertJUnit {
schedulerService = new SchedulerService();
schedulerService.setQuartzProperties(quartzProps);
schedulerService.start();
- getJBossMBeanServer().registerMBean(schedulerService, SchedulerServiceMBean.SCHEDULER_MBEAN_NAME);
+ // getJBossMBeanServer().registerMBean(schedulerService, SchedulerServiceMBean.SCHEDULER_MBEAN_NAME);
schedulerService.startQuartzScheduler();
return;
} catch (Exception e) {
@@ -394,12 +556,12 @@ public abstract class AbstractEJB3Test extends AssertJUnit {
if (schedulerService != null) {
schedulerService.stop();
if (beanOnly) {
- MBeanServer mbs = getJBossMBeanServer();
- if (mbs.isRegistered(SchedulerServiceMBean.SCHEDULER_MBEAN_NAME)) {
- getJBossMBeanServer().unregisterMBean(SchedulerServiceMBean.SCHEDULER_MBEAN_NAME);
- }
+ // MBeanServer mbs = getJBossMBeanServer();
+ // if (mbs.isRegistered(SchedulerServiceMBean.SCHEDULER_MBEAN_NAME)) {
+ // getJBossMBeanServer().unregisterMBean(SchedulerServiceMBean.SCHEDULER_MBEAN_NAME);
+ // }
} else {
- releaseJBossMBeanServer();
+ // releaseJBossMBeanServer();
}
schedulerService = null;
@@ -419,9 +581,9 @@ public abstract class AbstractEJB3Test extends AssertJUnit {
if (scannerService == null) {
scannerService = new PluginDeploymentScanner();
}
- MBeanServer mbs = getJBossMBeanServer();
- mbs.registerMBean(scannerService, PluginDeploymentScannerMBean.OBJECT_NAME);
- pluginScannerService = scannerService;
+ // MBeanServer mbs = getJBossMBeanServer();
+ // mbs.registerMBean(scannerService, PluginDeploymentScannerMBean.OBJECT_NAME);
+ // pluginScannerService = scannerService;
return;
} catch (Exception e) {
e.printStackTrace();
@@ -437,19 +599,86 @@ public abstract class AbstractEJB3Test extends AssertJUnit {
if (pluginScannerService != null) {
pluginScannerService.stop();
if (beanOnly) {
- MBeanServer mbs = getJBossMBeanServer();
- if (mbs.isRegistered(PluginDeploymentScannerMBean.OBJECT_NAME)) {
- getJBossMBeanServer().unregisterMBean(PluginDeploymentScannerMBean.OBJECT_NAME);
- }
- } else {
- releaseJBossMBeanServer();
+ // MBeanServer mbs = getJBossMBeanServer();
+ // if (mbs.isRegistered(PluginDeploymentScannerMBean.OBJECT_NAME)) {
+ // getJBossMBeanServer().unregisterMBean(PluginDeploymentScannerMBean.OBJECT_NAME);
}
+ } else {
+ // releaseJBossMBeanServer();
+ }
- pluginScannerService = null;
+ pluginScannerService = null;
+ }
+
+ /**
+ * If you need to test round trips from server to agent and back, you first must install the server communications
+ * service that houses all the agent clients. Call this method and add your test agent services to the public fields
+ * in the returned object.
+ *
+ * @return the object that will house your test agent service impls and the agent clients.
+ *
+ * @throws RuntimeException
+ */
+ public TestServerCommunicationsService prepareForTestAgents() {
+ try {
+ // MBeanServer mbs = getJBossMBeanServer();
+ // if (mbs.isRegistered(ServerCommunicationsServiceMBean.OBJECT_NAME)) {
+ // mbs.unregisterMBean(ServerCommunicationsServiceMBean.OBJECT_NAME);
+ // }
+ TestServerCommunicationsService testAgentContainer = new TestServerCommunicationsService();
+ // mbs.registerMBean(testAgentContainer, ServerCommunicationsServiceMBean.OBJECT_NAME);
+ return testAgentContainer;
+ } catch (Exception e) {
+ throw new RuntimeException(e);
}
}
- protected void executeInTransaction(TransactionCallback callback) {
- JPAUtils.executeInTransaction(callback);
+ /**
+ * Call this after your tests have finished. You only need to call this if your test previously called
+ * {@link #prepareForTestAgents()}.
+ */
+ public void unprepareForTestAgents() {
+ unprepareForTestAgents(false);
+ }
+
+ public void unprepareForTestAgents(boolean beanOnly) {
+ try {
+ if (beanOnly) {
+ // MBeanServer mbs = getJBossMBeanServer();
+ // if (mbs.isRegistered(ServerCommunicationsServiceMBean.OBJECT_NAME)) {
+ // mbs.unregisterMBean(ServerCommunicationsServiceMBean.OBJECT_NAME);
+ // }
+ } else {
+ // releaseJBossMBeanServer();
+ }
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ /**
+ * This creates a session for the given user and associates that session with the subject. You can test the security
+ * annotations by creating sessions for different users with different permissions.
+ *
+ * @param subject a JON subject
+ * @return the session activated subject, a copy of the subject passed in.
+ */
+ public Subject createSession(Subject subject) {
+ return SessionManager.getInstance().put(subject);
+ }
+
+ public static Connection getConnection() throws SQLException {
+ return LookupUtil.getDataSource().getConnection();
}
+
+ public MBeanServer getJBossMBeanServer() {
+// if (dummyJBossMBeanServer == null) {
+// dummyJBossMBeanServer = MBeanServerFactory.createMBeanServer("jboss");
+// MBeanServerLocator.setJBoss(dummyJBossMBeanServer);
+// }
+//
+// return dummyJBossMBeanServer;
+ return null;
+ }
+
}
diff --git a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/test/LargeGroupTestBase.java b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/test/LargeGroupTestBase.java
index 1bf07d7..cb7d301 100644
--- a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/test/LargeGroupTestBase.java
+++ b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/test/LargeGroupTestBase.java
@@ -325,8 +325,8 @@ public abstract class LargeGroupTestBase extends AbstractEJB3Test {
System.out.println(" Done.");
// purge the users and role
- JPAUtils.executeInTransaction(new TransactionCallbackWithContext<Object>() {
- public Object execute(TransactionManager tm, EntityManager em) throws Exception {
+ executeInTransaction(new TransactionCallbackReturnable<Object>() {
+ public Object execute() throws Exception {
lge.normalRole = em.getReference(Role.class, lge.normalRole.getId());
lge.normalSubject = em.getReference(Subject.class, lge.normalSubject.getId());
lge.unauthzSubject = em.getReference(Subject.class, lge.unauthzSubject.getId());
@@ -339,8 +339,8 @@ public abstract class LargeGroupTestBase extends AbstractEJB3Test {
if (!keepTypes) {
// purge the resource types
- JPAUtils.executeInTransaction(new TransactionCallbackWithContext<Object>() {
- public Object execute(TransactionManager tm, EntityManager em) throws Exception {
+ executeInTransaction(new TransactionCallbackReturnable<Object>() {
+ public Object execute() throws Exception {
ResourceType pType = em.getReference(ResourceType.class, lge.platformResource.getResourceType()
.getId());
ResourceType sType = em.getReference(ResourceType.class, lge.compatibleGroup.getResourceType()
diff --git a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/test/OldAbstractEJB3Test.java b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/test/OldAbstractEJB3Test.java
new file mode 100644
index 0000000..a8337b7
--- /dev/null
+++ b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/test/OldAbstractEJB3Test.java
@@ -0,0 +1,445 @@
+///*
+// * RHQ Management Platform
+// * Copyright (C) 2005-2008 Red Hat, Inc.
+// * All rights reserved.
+// *
+// * This program is free software; you can redistribute it and/or modify
+// * it under the terms of the GNU General Public License as published by
+// * the Free Software Foundation version 2 of the License.
+// *
+// * This program is distributed in the hope that it will be useful,
+// * but WITHOUT ANY WARRANTY; without even the implied warranty of
+// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// * GNU General Public License for more details.
+// *
+// * You should have received a copy of the GNU General Public License
+// * along with this program; if not, write to the Free Software
+// * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+// */
+package org.rhq.enterprise.server.test;
+
+import org.testng.AssertJUnit;
+
+
+//import static org.rhq.test.JPAUtils.lookupEntityManager;
+//import static org.rhq.test.JPAUtils.lookupTransactionManager;
+//
+//import java.sql.Connection;
+//import java.sql.SQLException;
+//import java.util.Hashtable;
+//import java.util.Properties;
+//
+//import javax.management.MBeanServer;
+//import javax.management.MBeanServerFactory;
+//import javax.naming.InitialContext;
+//import javax.naming.NamingException;
+//import javax.persistence.EntityManager;
+//import javax.transaction.TransactionManager;
+//
+//import org.hibernate.SessionFactory;
+//import org.hibernate.stat.Statistics;
+//import org.testng.AssertJUnit;
+//import org.testng.annotations.AfterMethod;
+//import org.testng.annotations.AfterSuite;
+//import org.testng.annotations.BeforeMethod;
+//import org.testng.annotations.BeforeSuite;
+//
+//import org.jboss.ejb3.embedded.EJB3StandaloneBootstrap;
+//import org.jboss.ejb3.embedded.EJB3StandaloneDeployer;
+//import org.jboss.mx.util.MBeanServerLocator;
+//
+//import org.rhq.core.db.DatabaseTypeFactory;
+//import org.rhq.core.db.PostgresqlDatabaseType;
+//import org.rhq.core.domain.auth.Subject;
+//import org.rhq.core.domain.server.PersistenceUtility;
+//import org.rhq.enterprise.server.RHQConstants;
+//import org.rhq.enterprise.server.auth.SessionManager;
+//import org.rhq.enterprise.server.content.ContentSourceManagerBean;
+//import org.rhq.enterprise.server.core.comm.ServerCommunicationsServiceMBean;
+//import org.rhq.enterprise.server.core.plugin.PluginDeploymentScanner;
+//import org.rhq.enterprise.server.core.plugin.PluginDeploymentScannerMBean;
+//import org.rhq.enterprise.server.plugin.pc.ServerPluginService;
+//import org.rhq.enterprise.server.plugin.pc.ServerPluginServiceMBean;
+//import org.rhq.enterprise.server.scheduler.SchedulerService;
+//import org.rhq.enterprise.server.scheduler.SchedulerServiceMBean;
+//import org.rhq.enterprise.server.util.LookupUtil;
+//
+////
+/////**
+//// * This is the abstract test base for server jar tests.
+//// *
+//// * @author Greg Hinkle
+//// */
+public abstract class OldAbstractEJB3Test extends AssertJUnit {
+ //
+ // private static EJB3StandaloneDeployer deployer;
+ // private static Statistics stats;
+ // @SuppressWarnings("unused")
+ // private static long start; // see endTest() if you want to output this
+ // private SchedulerService schedulerService;
+ // private ServerPluginService serverPluginService;
+ // private MBeanServer dummyJBossMBeanServer;
+ // private PluginDeploymentScannerMBean pluginScannerService;
+ //
+ //
+ // //@BeforeSuite(groups = {"integration.ejb3","PERF"}) // TODO investigate again
+ // @BeforeSuite(alwaysRun = true)
+ // public static void startupEmbeddedJboss() throws Exception {
+ // // The embeddedDeployment property needs to be set for running tests
+ // // with the embedded container. It is set in the surefire configuration
+ // // in pom.xml but setting here makes it easier to run tests directly
+ // // from your IDE.
+ // //
+ // // jsanda
+ // System.setProperty("embeddedDeployment", "true");
+ //
+ // // Setting content location to the tmp dir
+ // System.setProperty(ContentSourceManagerBean.FILESYSTEM_PROPERTY, System.getProperty("java.io.tmpdir"));
+ //
+ // System.out.println("Starting JBoss EJB3 Embedded Container...");
+ // String deployDir = System.getProperty("deploymentDirectory", "target/classes");
+ // System.out.println("Loading EJB3 deployments from directory: " + deployDir);
+ // try {
+ // EJB3StandaloneBootstrap.boot(null);
+ // // EJB3StandaloneBootstrap.scanClasspath();
+ //
+ // System.err.println("...... embedded container booted....");
+ //
+ // deployer = EJB3StandaloneBootstrap.createDeployer();
+ //
+ // deployer.setClassLoader(AbstractEJB3Test.class.getClassLoader());
+ // System.err.println("...... embedded container classloader set....");
+ //
+ // deployer.getArchivesByResource().add("META-INF/persistence.xml");
+ // System.err.println("...... embedded container persistence xml deployed....");
+ //
+ // deployer.getArchivesByResource().add("META-INF/ejb-jar.xml");
+ // System.err.println("...... embedded container ejb-jar xml deployed....");
+ //
+ // EJB3StandaloneBootstrap.deployXmlResource("jboss-jms-beans.xml");
+ // System.err.println("...... embedded container jboss-jms-beans xml deployed....");
+ //
+ // EJB3StandaloneBootstrap.deployXmlResource("rhq-mdb-beans.xml");
+ // System.err.println("...... embedded container rhq-mdb-beans xml deployed....");
+ //
+ // /*
+ // * File core = new File(deployDir, "on-core-domain-ejb.ejb3"); if (!core.exists())
+ // * System.err.println("Deployment directory does not exist: " + core.getAbsolutePath());
+ // * deployer.getArchives().add(core.toURI().toURL());
+ // *
+ // * File server = new File(deployDir, "on-enterprise-server-ejb.ejb3"); if (!server.exists())
+ // * System.err.println("Deployment directory does not exist: " + server.getAbsolutePath());
+ // * deployer.getArchives().add(server.toURI().toURL());
+ // *
+ // */
+ //
+ // //deployer.setKernel(EJB3StandaloneBootstrap.getKernel());
+ // deployer.create();
+ // System.err.println("...... deployer created....");
+ //
+ // deployer.start();
+ // System.err.println("...... deployer started....");
+ //
+ // System.err.println("...... start statistics");
+ // SessionFactory sessionFactory = PersistenceUtility.getHibernateSession(getEntityManager())
+ // .getSessionFactory();
+ // stats = sessionFactory.getStatistics();
+ // stats.setStatisticsEnabled(true);
+ //
+ // System.err.println("...... embedded container initialized and ready for testing....");
+ //
+ // } catch (Throwable t) {
+ // // Catch RuntimeExceptions and Errors and dump their stack trace, because Surefire will completely swallow them
+ // // and throw a cryptic NPE (see http://jira.codehaus.org/browse/SUREFIRE-157)!
+ // t.printStackTrace();
+ // throw new RuntimeException(t);
+ // }
+ // }
+ //
+ // //@Configuration(groups = "integration.ejb3", afterSuite = true)
+ // @AfterSuite(alwaysRun = true)
+ // public static void shutdownEmbeddedJboss() {
+ // System.out.println("Stopping JBoss EJB3 Embedded Container...");
+ //
+ // System.err.println("!!! Any errors occurring after this point !!!");
+ // System.err.println("!!! occurred during embedded server shutdown !!!");
+ // System.err.println("!!! and are probably not a real problem. !!!");
+ // if (deployer != null) {
+ // try {
+ // deployer.stop();
+ // deployer.destroy();
+ // deployer = null;
+ // } catch (Throwable t) {
+ // System.err.println("Failed to stop embedded deployer");
+ // t.printStackTrace(System.err);
+ // }
+ // }
+ // EJB3StandaloneBootstrap.shutdown();
+ // }
+ //
+ // @BeforeMethod
+ // public static void startTest() {
+ // if (DatabaseTypeFactory.getDefaultDatabaseType() == null) {
+ // try {
+ // Connection conn = getConnection();
+ // DatabaseTypeFactory.setDefaultDatabaseType(DatabaseTypeFactory.getDatabaseType(conn));
+ // } catch (Exception e) {
+ // System.err.println("!!! WARNING !!! cannot set default database type, some tests may fail");
+ // e.printStackTrace();
+ // }
+ // }
+ //
+ // if (stats != null)
+ // start = stats.getQueryExecutionCount();
+ // else
+ // start = 0;
+ // }
+ //
+ // public static Connection getConnection() throws SQLException {
+ // return LookupUtil.getDataSource().getConnection();
+ // }
+ //
+ // @AfterMethod
+ // public static void endTest() {
+ // //System.out.println("Connections used: " + (stats.getQueryExecutionCount() - start));
+ // }
+ //
+ // public TransactionManager getTransactionManager() {
+ // return lookupTransactionManager();
+ // }
+ //
+ // public static EntityManager getEntityManager() {
+ // return lookupEntityManager();
+ // }
+ //
+ // public static InitialContext getInitialContext() {
+ // Hashtable<String, String> env = new Hashtable<String, String>();
+ // env.put("java.naming.factory.initial", "org.jnp.interfaces.LocalOnlyContextFactory");
+ // env.put("java.naming.factory.url.pkgs", "org.jboss.naming:org.jnp.interfaces");
+ // try {
+ // return new InitialContext(env);
+ // } catch (NamingException e) {
+ // e.printStackTrace();
+ // throw new RuntimeException("Failed to load initial context", e);
+ // }
+ // }
+ //
+ // public boolean isPostgres() throws Exception {
+ // return DatabaseTypeFactory.getDatabaseType(getInitialContext(), RHQConstants.DATASOURCE_JNDI_NAME) instanceof PostgresqlDatabaseType;
+ // }
+ //
+ // /**
+ // * This creates a session for the given user and associates that session with the subject. You can test the security
+ // * annotations by creating sessions for different users with different permissions.
+ // *
+ // * @param subject a JON subject
+ // * @return the session activated subject, a copy of the subject passed in.
+ // */
+ // public Subject createSession(Subject subject) {
+ // return SessionManager.getInstance().put(subject);
+ // }
+ //
+ // /**
+ // * Returns an MBeanServer that simulates the JBossAS MBeanServer.
+ // *
+ // * @return MBeanServer instance
+ // */
+ // public MBeanServer getJBossMBeanServer() {
+ // if (dummyJBossMBeanServer == null) {
+ // dummyJBossMBeanServer = MBeanServerFactory.createMBeanServer("jboss");
+ // MBeanServerLocator.setJBoss(dummyJBossMBeanServer);
+ // }
+ //
+ // return dummyJBossMBeanServer;
+ // }
+ //
+ // public void releaseJBossMBeanServer() {
+ // if (dummyJBossMBeanServer != null) {
+ // MBeanServerFactory.releaseMBeanServer(dummyJBossMBeanServer);
+ // dummyJBossMBeanServer = null;
+ // }
+ // }
+ //
+ // /**
+ // * If you need to test round trips from server to agent and back, you first must install the server communications
+ // * service that houses all the agent clients. Call this method and add your test agent services to the public fields
+ // * in the returned object.
+ // *
+ // * @return the object that will house your test agent service impls and the agent clients.
+ // *
+ // * @throws RuntimeException
+ // */
+ // public TestServerCommunicationsService prepareForTestAgents() {
+ // try {
+ // MBeanServer mbs = getJBossMBeanServer();
+ // if (mbs.isRegistered(ServerCommunicationsServiceMBean.OBJECT_NAME)) {
+ // mbs.unregisterMBean(ServerCommunicationsServiceMBean.OBJECT_NAME);
+ // }
+ // TestServerCommunicationsService testAgentContainer = new TestServerCommunicationsService();
+ // mbs.registerMBean(testAgentContainer, ServerCommunicationsServiceMBean.OBJECT_NAME);
+ // return testAgentContainer;
+ // } catch (Exception e) {
+ // throw new RuntimeException(e);
+ // }
+ // }
+ //
+ // /**
+ // * Call this after your tests have finished. You only need to call this if your test previously called
+ // * {@link #prepareForTestAgents()}.
+ // */
+ // public void unprepareForTestAgents() {
+ // unprepareForTestAgents(false);
+ // }
+ //
+ // public void unprepareForTestAgents(boolean beanOnly) {
+ // try {
+ // if (beanOnly) {
+ // MBeanServer mbs = getJBossMBeanServer();
+ // if (mbs.isRegistered(ServerCommunicationsServiceMBean.OBJECT_NAME)) {
+ // mbs.unregisterMBean(ServerCommunicationsServiceMBean.OBJECT_NAME);
+ // }
+ // } else {
+ // releaseJBossMBeanServer();
+ // }
+ // } catch (Exception e) {
+ // throw new RuntimeException(e);
+ // }
+ // }
+ //
+ // /**
+ // * If you need to test server plugins, you must first prepare the server plugin service.
+ // * After this returns, the caller must explicitly start the PC by using the appropriate API
+ // * on the given mbean; this method will only start the service, it will NOT start the master PC.
+ // *
+ // * @param testServiceMBean the object that will house your test server plugins
+ // *
+ // * @throws RuntimeException
+ // */
+ // public void prepareCustomServerPluginService(ServerPluginService testServiceMBean) {
+ // try {
+ // MBeanServer mbs = getJBossMBeanServer();
+ // testServiceMBean.start();
+ // mbs.registerMBean(testServiceMBean, ServerPluginServiceMBean.OBJECT_NAME);
+ // serverPluginService = testServiceMBean;
+ // return;
+ // } catch (Exception e) {
+ // throw new RuntimeException(e);
+ // }
+ // }
+ //
+ // public void unprepareServerPluginService() throws Exception {
+ // unprepareServerPluginService(false);
+ // }
+ //
+ // public void unprepareServerPluginService(boolean beanOnly) throws Exception {
+ // if (serverPluginService != null) {
+ // serverPluginService.stopMasterPluginContainer();
+ // serverPluginService.stop();
+ // if (beanOnly) {
+ // MBeanServer mbs = getJBossMBeanServer();
+ // if (mbs.isRegistered(ServerPluginService.OBJECT_NAME)) {
+ // getJBossMBeanServer().unregisterMBean(ServerPluginService.OBJECT_NAME);
+ // }
+ // if (mbs.isRegistered(ServerPluginServiceMBean.OBJECT_NAME)) {
+ // getJBossMBeanServer().unregisterMBean(ServerPluginServiceMBean.OBJECT_NAME);
+ // }
+ //
+ // } else {
+ // releaseJBossMBeanServer();
+ // }
+ // serverPluginService = null;
+ // }
+ // }
+ //
+ // public SchedulerService getSchedulerService() {
+ // return schedulerService;
+ // }
+ //
+ // public void prepareScheduler() {
+ // try {
+ // if (schedulerService != null) {
+ // return;
+ // }
+ //
+ // Properties quartzProps = new Properties();
+ // quartzProps.load(this.getClass().getClassLoader().getResourceAsStream("test-scheduler.properties"));
+ //
+ // schedulerService = new SchedulerService();
+ // schedulerService.setQuartzProperties(quartzProps);
+ // schedulerService.start();
+ // getJBossMBeanServer().registerMBean(schedulerService, SchedulerServiceMBean.SCHEDULER_MBEAN_NAME);
+ // schedulerService.startQuartzScheduler();
+ // return;
+ // } catch (Exception e) {
+ // e.printStackTrace();
+ // throw new RuntimeException(e);
+ // }
+ // }
+ //
+ // public void unprepareScheduler() throws Exception {
+ // unprepareScheduler(false);
+ // }
+ //
+ // public void unprepareScheduler(boolean beanOnly) throws Exception {
+ // if (schedulerService != null) {
+ // schedulerService.stop();
+ // if (beanOnly) {
+ // MBeanServer mbs = getJBossMBeanServer();
+ // if (mbs.isRegistered(SchedulerServiceMBean.SCHEDULER_MBEAN_NAME)) {
+ // getJBossMBeanServer().unregisterMBean(SchedulerServiceMBean.SCHEDULER_MBEAN_NAME);
+ // }
+ // } else {
+ // releaseJBossMBeanServer();
+ // }
+ //
+ // schedulerService = null;
+ // }
+ // }
+ //
+ // public PluginDeploymentScannerMBean getPluginScannerService() {
+ // return pluginScannerService;
+ // }
+ //
+ // protected void preparePluginScannerService() {
+ // preparePluginScannerService(null);
+ // }
+ //
+ // public void preparePluginScannerService(PluginDeploymentScannerMBean scannerService) {
+ // try {
+ // if (scannerService == null) {
+ // scannerService = new PluginDeploymentScanner();
+ // }
+ // MBeanServer mbs = getJBossMBeanServer();
+ // mbs.registerMBean(scannerService, PluginDeploymentScannerMBean.OBJECT_NAME);
+ // pluginScannerService = scannerService;
+ // return;
+ // } catch (Exception e) {
+ // e.printStackTrace();
+ // throw new RuntimeException(e);
+ // }
+ // }
+ //
+ // public void unpreparePluginScannerService() throws Exception {
+ // unpreparePluginScannerService(false);
+ // }
+ //
+ // public void unpreparePluginScannerService(boolean beanOnly) throws Exception {
+ // if (pluginScannerService != null) {
+ // pluginScannerService.stop();
+ // if (beanOnly) {
+ // MBeanServer mbs = getJBossMBeanServer();
+ // if (mbs.isRegistered(PluginDeploymentScannerMBean.OBJECT_NAME)) {
+ // getJBossMBeanServer().unregisterMBean(PluginDeploymentScannerMBean.OBJECT_NAME);
+ // }
+ // } else {
+ // releaseJBossMBeanServer();
+ // }
+ //
+ // pluginScannerService = null;
+ // }
+ // }
+ //
+ // protected void executeInTransaction(TransactionCallback callback) {
+ // executeInTransaction(callback);
+ // }
+}
diff --git a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/test/TransactionCallback.java b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/test/TransactionCallback.java
new file mode 100644
index 0000000..cec66cb
--- /dev/null
+++ b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/test/TransactionCallback.java
@@ -0,0 +1,7 @@
+package org.rhq.enterprise.server.test;
+
+public interface TransactionCallback {
+
+ void execute() throws Exception;
+
+}
diff --git a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/test/TransactionCallbackReturnable.java b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/test/TransactionCallbackReturnable.java
new file mode 100644
index 0000000..cd0389e
--- /dev/null
+++ b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/test/TransactionCallbackReturnable.java
@@ -0,0 +1,7 @@
+package org.rhq.enterprise.server.test;
+
+public interface TransactionCallbackReturnable<T extends Object> {
+
+ T execute() throws Exception;
+
+}
diff --git a/modules/test-utils/src/main/java/org/rhq/test/JPAUtils.java b/modules/test-utils/src/main/java/org/rhq/test/JPAUtils.java
index 8d6d810..5819a1b 100644
--- a/modules/test-utils/src/main/java/org/rhq/test/JPAUtils.java
+++ b/modules/test-utils/src/main/java/org/rhq/test/JPAUtils.java
@@ -131,154 +131,5 @@ public class JPAUtils {
return list.toString();
}
- public static void clearDB() {
- executeInTransaction(new TransactionCallback() {
- @Override
- public void execute() throws Exception {
- EntityManager em = lookupEntityManager();
-
- em.createNativeQuery("delete from jms_subscriptions");
- em.createNativeQuery("delete from jms_roles");
- em.createNativeQuery("delete from jms_users");
- em.createNativeQuery("delete from jms_transactions");
- em.createNativeQuery("delete from jms_messages");
- em.createNativeQuery("delete from rhq_drift_config_map");
- em.createNativeQuery("delete from rhq_drift_template_map");
- em.createNativeQuery("delete from rhq_delete_res_hist");
- em.createNativeQuery("delete from rhq_create_res_hist");
- em.createNativeQuery("delete from rhq_tagging_bundle_dest_map");
- em.createNativeQuery("delete from rhq_tagging_bundle_deploy_map");
- em.createNativeQuery("delete from rhq_tagging_bundle_version_map");
- em.createNativeQuery("delete from rhq_tagging_bundle_map");
- em.createNativeQuery("delete from rhq_bundle_res_dep_hist");
- em.createNativeQuery("delete from rhq_bundle_res_deploy");
- em.createNativeQuery("delete from rhq_bundle_deployment");
- em.createNativeQuery("delete from rhq_bundle_destination");
- em.createNativeQuery("delete from rhq_bundle_file");
- em.createNativeQuery("delete from rhq_bundle_version_repo");
- em.createNativeQuery("delete from rhq_bundle_version");
- em.createNativeQuery("delete from rhq_bundle");
- em.createNativeQuery("delete from rhq_bundle_type");
- em.createNativeQuery("delete from rhq_repo_advisory");
- em.createNativeQuery("delete from rhq_advisory_buglist");
- em.createNativeQuery("delete from rhq_advisory_cve");
- em.createNativeQuery("delete from rhq_cve");
- em.createNativeQuery("delete from rhq_advisory_package");
- em.createNativeQuery("delete from rhq_advisory");
- em.createNativeQuery("delete from rhq_distribution_file");
- em.createNativeQuery("delete from rhq_repo_distribution");
- em.createNativeQuery("delete from rhq_distribution where id not in (1, 2)");
- em.createNativeQuery("delete from rhq_pkg_prd_map");
- em.createNativeQuery("delete from rhq_pkg_ver_content_src_map");
- em.createNativeQuery("delete from rhq_repo_pkg_version_map");
- em.createNativeQuery("delete from rhq_repo_repo_relation_map");
- em.createNativeQuery("delete from rhq_repo_repo_group_map");
- em.createNativeQuery("delete from rhq_repo_content_src_map");
- em.createNativeQuery("delete from rhq_repo_resource_map");
- em.createNativeQuery("delete from rhq_package_inst_step");
- em.createNativeQuery("delete from rhq_repo_sync");
- em.createNativeQuery("delete from rhq_content_src_sync");
- em.createNativeQuery("delete from rhq_installed_pkg_hist");
- em.createNativeQuery("delete from rhq_installed_package");
- em.createNativeQuery("delete from rhq_content_req");
- em.createNativeQuery("delete from rhq_package_version");
- em.createNativeQuery("delete from rhq_package_bits");
- em.createNativeQuery("delete from rhq_package");
- em.createNativeQuery("delete from rhq_package_type");
- em.createNativeQuery("delete from rhq_repo_relation");
- em.createNativeQuery("delete from rhq_repo_relation_type where id not in (1, 2)");
- em.createNativeQuery("delete from rhq_repo");
- em.createNativeQuery("delete from rhq_repo_group");
- em.createNativeQuery("delete from rhq_repo_group_type where id <> 1");
- em.createNativeQuery("delete from rhq_archirtecture where id < 1 and id > 38");
- em.createNativeQuery("delete from rhq_meas_data_num_r14");
- em.createNativeQuery("delete from rhq_meas_data_num_r13");
- em.createNativeQuery("delete from rhq_meas_data_num_r12");
- em.createNativeQuery("delete from rhq_meas_data_num_r11");
- em.createNativeQuery("delete from rhq_meas_data_num_r10");
- em.createNativeQuery("delete from rhq_meas_data_num_r09");
- em.createNativeQuery("delete from rhq_meas_data_num_r08");
- em.createNativeQuery("delete from rhq_meas_data_num_r07");
- em.createNativeQuery("delete from rhq_meas_data_num_r06");
- em.createNativeQuery("delete from rhq_meas_data_num_r05");
- em.createNativeQuery("delete from rhq_meas_data_num_r04");
- em.createNativeQuery("delete from rhq_meas_data_num_r03");
- em.createNativeQuery("delete from rhq_meas_data_num_r02");
- em.createNativeQuery("delete from rhq_meas_data_num_r01");
- em.createNativeQuery("delete from rhq_meas_data_num_r00");
- em.createNativeQuery("delete from rhq_measurement_oob_tmp");
- em.createNativeQuery("delete rhq_measurement_oob");
- em.createNativeQuery("delete rhq_resource_avail");
- em.createNativeQuery("delete from rhq_availability");
- em.createNativeQuery("delete from rhq_calltime_data_value");
- em.createNativeQuery("delete from rhq_calltime_data_key");
- em.createNativeQuery("delete from rhq_measurement_data_trait");
- em.createNativeQuery("delete from rhq_measurement_data_num_1d");
- em.createNativeQuery("delete from rhq_measurement_data_num_6h");
- em.createNativeQuery("delete from rhq_measurement_data_num_1h");
- em.createNativeQuery("delete from rhq_measurement_bline");
- em.createNativeQuery("delete from rhq_measurement_sched");
- em.createNativeQuery("delete from rhq_measurement_def");
- em.createNativeQuery("delete from rhq_plugin");
- em.createNativeQuery("delete from rhq_system_config where id not in (1, 2, 3, 4, 9, 10, 32, 34, 35, 36, 51, 52, 53, 54, 55, 56, 57, 58)");
- em.createNativeQuery("delete from rhq_alert_notification");
- em.createNativeQuery("delete from rhq_alert_condition_log");
- em.createNativeQuery("delete from rhq_alert");
- em.createNativeQuery("delete from rhq_alert_condition");
- em.createNativeQuery("delete from rhq_alert_dampen_event");
- em.createNativeQuery("delete from rhq_alert_definition");
- em.createNativeQuery("delete from rhq_event");
- em.createNativeQuery("delete from rhq_event_source");
- em.createNativeQuery("delete from rhq_event_def");
- em.createNativeQuery("delete from rhq_operation_schedule");
- em.createNativeQuery("delete from rhq_operation_history");
- em.createNativeQuery("delete from rhq_operation_def");
- em.createNativeQuery("delete from rhq_dashboard_portlet");
- em.createNativeQuery("delete from rhq_dashboard");
- em.createNativeQuery("delete from rhq_saved_search");
- em.createNativeQuery("delete from rhq_subject_role_ldap_map");
- em.createNativeQuery("delete from rhq_subject_role_map where id not in (1, 2)");
- em.createNativeQuery("delete from rhq_permission where role_id not in (1, 2)");
- em.createNativeQuery("delete from rhq_role_ldap_group");
- em.createNativeQuery("delete from rhq_role_resource_group_map");
- em.createNativeQuery("delete from rhq_role where id not in (1, 2)");
- em.createNativeQuery("delete from rhq_tagging_res_group_map");
- em.createNativeQuery("delete from rhq_tagging_resource_map");
- em.createNativeQuery("delete from rhq_tagging");
- em.createNativeQuery("delete from rhq_config_update");
- em.createNativeQuery("delete from rhq_config_group_update");
- em.createNativeQuery("delete from rhq_resource_group_res_exp_map");
- em.createNativeQuery("delete from rhq_resource_group_res_imp_map");
- em.createNativeQuery("delete from rhq_resource_group");
- em.createNativeQuery("delete from rhq_group_def");
- em.createNativeQuery("delete from rhq_resource_error");
- em.createNativeQuery("delete from rhq_resource");
- em.createNativeQuery("delete from rhq_prd_ver");
- em.createNativeQuery("delete from rhq_process_scan");
- em.createNativeQuery("delete from rhq_resource_type_parents");
- em.createNativeQuery("delete from rhq_resource_subcat");
- em.createNativeQuery("delete from rhq_resource_type");
- em.createNativeQuery("delete from rhq_subject where id not in (1, 2)");
- em.createNativeQuery("delete from rhq_principal where id <> 2");
- em.createNativeQuery("delete from rhq_failover_details");
- em.createNativeQuery("delete from rhq_failover_list");
- em.createNativeQuery("delete from rhq_partition_details");
- em.createNativeQuery("delete from rhq_partition_event");
- em.createNativeQuery("delete from rhq_agent");
- em.createNativeQuery("delete from rhq_server");
- em.createNativeQuery("delete from rhq_affinity_group");
- em.createNativeQuery("delete from rhq_raw_config");
- em.createNativeQuery("delete from rhq_config_template");
- em.createNativeQuery("delete from rhq_config_property");
- em.createNativeQuery("delete from rhq_config");
- em.createNativeQuery("delete from rhq_config_prop_constr");
- em.createNativeQuery("delete from rhq_conf_prop_def_enum");
- em.createNativeQuery("delete from rhq_config_pd_osrc");
- em.createNativeQuery("delete from rhq_config_prop_def");
- em.createNativeQuery("delete from rhq_config_prop_grp_def");
- em.createNativeQuery("delete from rhq_config_def");
- }
- });
- }
}
commit d59617ace8a18c0c25467f6b87c158c4ee141cd9
Author: Jay Shaughnessy <jshaughn(a)jshaughn.csb>
Date: Mon Oct 22 14:07:03 2012 -0400
more .classpath stuff for new deps
diff --git a/.classpath b/.classpath
index e9ae8a8..5570123 100644
--- a/.classpath
+++ b/.classpath
@@ -1,6 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="modules/common/ant-bundle/src/main/java"/>
+ <classpathentry kind="src" path="modules/enterprise/scripting/javascript/src/main/java"/>
+ <classpathentry kind="src" path="modules/enterprise/scripting/python/src/main/java"/>
+ <classpathentry kind="src" path="modules/enterprise/scripting/python/src/test/java"/>
+ <classpathentry kind="src" path="modules/enterprise/scripting/javascript/src/test/java"/>
<classpathentry kind="src" path="modules/enterprise/gui/installer/src/test/java"/>
<classpathentry kind="src" path="modules/common/jboss-as-dmr-client/src/test/java"/>
<classpathentry kind="src" path="modules/common/jboss-as-dmr-client/src/main/java"/>
@@ -322,5 +326,7 @@
<classpathentry exported="true" kind="var" path="M2_REPO/jboss/jboss-embeddable-ejb3/jboss-ejb3-all/1.0.0.Alpha9/jboss-ejb3-all-1.0.0.Alpha9.jar"/>
<classpathentry exported="true" kind="var" path="JDK_HOME/lib/tools.jar"/>
<classpathentry kind="var" path="M2_REPO/org/jboss/remotingjmx/remoting-jmx/1.0.2.Final/remoting-jmx-1.0.2.Final.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/mozilla/rhino/1.7R4/rhino-1.7R4.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/python/jython-standalone/2.5.2/jython-standalone-2.5.2.jar"/>
<classpathentry kind="output" path="eclipse-classes"/>
</classpath>
commit 33b9581b81fc929c1bec2366010b457f33349464
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Mon Oct 22 11:24:40 2012 -0400
support the ability to restart the server in AS7 admin-only mode (this may be useful in the future when supporting the new AS7 proposed patching mechanism)
diff --git a/modules/common/jboss-as-dmr-client/src/main/java/org/rhq/common/jbossas/client/controller/CoreJBossASClient.java b/modules/common/jboss-as-dmr-client/src/main/java/org/rhq/common/jbossas/client/controller/CoreJBossASClient.java
index 1729f95..3ee36a5 100644
--- a/modules/common/jboss-as-dmr-client/src/main/java/org/rhq/common/jbossas/client/controller/CoreJBossASClient.java
+++ b/modules/common/jboss-as-dmr-client/src/main/java/org/rhq/common/jbossas/client/controller/CoreJBossASClient.java
@@ -180,8 +180,21 @@ public class CoreJBossASClient extends JBossASClient {
* @throws Exception
*/
public void reload() throws Exception {
+ reload(false);
+ }
+
+ /**
+ * Invokes the management "reload" operation which will shut down all the app server services and
+ * restart them again potentially in admin-only mode.
+ * This does not shutdown the JVM itself.
+ *
+ * @param adminOnly if <code>true</code>, reloads the server in admin-only mode
+ *
+ * @throws Exception
+ */
+ public void reload(boolean adminOnly) throws Exception {
final ModelNode request = createRequest("reload", Address.root());
- request.get("admin-only").set(false);
+ request.get("admin-only").set(adminOnly);
final ModelNode response = execute(request);
if (!isSuccess(response)) {
throw new FailureException(response);
11 years, 6 months
[rhq] Branch 'jsanda/cassandra-plugin' - modules/plugins
by snegrea
modules/plugins/cassandra/src/main/java/org/rhq/plugins/cassandra/CassandraNodeComponent.java | 16 -
modules/plugins/cassandra/src/main/java/org/rhq/plugins/cassandra/CassandraUtil.java | 41 +-
modules/plugins/cassandra/src/main/java/org/rhq/plugins/cassandra/ColumnFamilyComponent.java | 133 ++++++++
modules/plugins/cassandra/src/main/java/org/rhq/plugins/cassandra/KeyspaceComponent.java | 51 +++
modules/plugins/cassandra/src/main/java/org/rhq/plugins/cassandra/MetricsDiscoveryComponent.java | 61 ++++
modules/plugins/cassandra/src/main/resources/META-INF/rhq-plugin.xml | 150 ++++++++--
6 files changed, 392 insertions(+), 60 deletions(-)
New commits:
commit 74fd4a6b7ee924619c363193a78a3610af6ce440
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Wed Oct 24 10:45:56 2012 -0500
Add server and internal metrics to the list of metrics.
Add the possibility to restore column families from snapshot.
diff --git a/modules/plugins/cassandra/src/main/java/org/rhq/plugins/cassandra/CassandraNodeComponent.java b/modules/plugins/cassandra/src/main/java/org/rhq/plugins/cassandra/CassandraNodeComponent.java
index dd06f39..1d3e08b 100644
--- a/modules/plugins/cassandra/src/main/java/org/rhq/plugins/cassandra/CassandraNodeComponent.java
+++ b/modules/plugins/cassandra/src/main/java/org/rhq/plugins/cassandra/CassandraNodeComponent.java
@@ -84,18 +84,18 @@ public class CassandraNodeComponent extends JMXServerComponent<ResourceComponent
public OperationResult invokeOperation(String name, Configuration parameters) throws Exception {
if (name.equals("shutdown")) {
- return shutdown(parameters);
+ return shutdownNode();
} else if (name.equals("start")) {
- return start(parameters);
+ return startNode();
} else if (name.equals("restart")) {
- return restart(parameters);
+ return restartNode();
}
return null;
}
@SuppressWarnings("rawtypes")
- private OperationResult shutdown(Configuration params) {
+ protected OperationResult shutdownNode() {
ResourceContext<?> context = getResourceContext();
if (log.isInfoEnabled()) {
@@ -137,7 +137,7 @@ public class CassandraNodeComponent extends JMXServerComponent<ResourceComponent
}
}
- private OperationResult start(Configuration params) {
+ protected OperationResult startNode() {
ResourceContext<?> context = getResourceContext();
Configuration pluginConfig = context.getPluginConfiguration();
String baseDir = pluginConfig.getSimpleValue("baseDir");
@@ -157,11 +157,11 @@ public class CassandraNodeComponent extends JMXServerComponent<ResourceComponent
}
}
- private OperationResult restart(Configuration params) {
- OperationResult result = shutdown(params);
+ protected OperationResult restartNode() {
+ OperationResult result = shutdownNode();
if (result.getErrorMessage() == null) {
- result = start(params);
+ result = startNode();
}
return result;
diff --git a/modules/plugins/cassandra/src/main/java/org/rhq/plugins/cassandra/CassandraUtil.java b/modules/plugins/cassandra/src/main/java/org/rhq/plugins/cassandra/CassandraUtil.java
index a0990d8..5915eed 100644
--- a/modules/plugins/cassandra/src/main/java/org/rhq/plugins/cassandra/CassandraUtil.java
+++ b/modules/plugins/cassandra/src/main/java/org/rhq/plugins/cassandra/CassandraUtil.java
@@ -1,28 +1,27 @@
/*
*
- * * RHQ Management Platform
- * * Copyright (C) 2005-2012 Red Hat, Inc.
- * * All rights reserved.
- * *
- * * This program is free software; you can redistribute it and/or modify
- * * it under the terms of the GNU General Public License, version 2, as
- * * published by the Free Software Foundation, and/or the GNU Lesser
- * * General Public License, version 2.1, also as published by the Free
- * * Software Foundation.
- * *
- * * This program is distributed in the hope that it will be useful,
- * * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * * GNU General Public License and the GNU Lesser General Public License
- * * for more details.
- * *
- * * You should have received a copy of the GNU General Public License
- * * and the GNU Lesser General Public License along with this program;
- * * if not, write to the Free Software Foundation, Inc.,
- * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * RHQ Management Platform
+ * Copyright (C) 2005-2012 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License, version 2, as
+ * published by the Free Software Foundation, and/or the GNU Lesser
+ * General Public License, version 2.1, also as published by the Free
+ * Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License and the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * and the GNU Lesser General Public License along with this program;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
-
package org.rhq.plugins.cassandra;
import java.util.List;
diff --git a/modules/plugins/cassandra/src/main/java/org/rhq/plugins/cassandra/ColumnFamilyComponent.java b/modules/plugins/cassandra/src/main/java/org/rhq/plugins/cassandra/ColumnFamilyComponent.java
index 6371549..845b2fb 100644
--- a/modules/plugins/cassandra/src/main/java/org/rhq/plugins/cassandra/ColumnFamilyComponent.java
+++ b/modules/plugins/cassandra/src/main/java/org/rhq/plugins/cassandra/ColumnFamilyComponent.java
@@ -28,6 +28,9 @@ package org.rhq.plugins.cassandra;
import static org.rhq.core.domain.configuration.ConfigurationUpdateStatus.FAILURE;
import static org.rhq.core.domain.configuration.ConfigurationUpdateStatus.SUCCESS;
import static org.rhq.plugins.cassandra.CassandraUtil.getCluster;
+
+import java.io.File;
+
import me.prettyprint.hector.api.Cluster;
import me.prettyprint.hector.api.ddl.ColumnFamilyDefinition;
import me.prettyprint.hector.api.exceptions.HectorException;
@@ -36,10 +39,14 @@ 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.ConfigurationUpdateReport;
import org.rhq.core.pluginapi.inventory.ResourceContext;
import org.rhq.core.pluginapi.operation.OperationResult;
+import org.rhq.core.util.file.FileUtil;
import org.rhq.plugins.jmx.JMXComponent;
import org.rhq.plugins.jmx.MBeanResourceComponent;
@@ -59,8 +66,8 @@ public class ColumnFamilyComponent extends MBeanResourceComponent<JMXComponent<?
log.debug("Loading resource context for column family " + context.getResourceKey());
}
- ColumnFamilyDefinition cfDef = getColumnFamilyDefinition();
- config.put(new PropertySimple("gc_grace_seconds", cfDef.getGcGraceSeconds()));
+ config.put(new PropertySimple("gc_grace_seconds", this.getColumnFamilyDefinition().getGcGraceSeconds()));
+ config.put(this.getSnapshotsWithDetails());
return config;
}
@@ -76,6 +83,8 @@ public class ColumnFamilyComponent extends MBeanResourceComponent<JMXComponent<?
} else if (name.equals("takeSnapshot")) {
String columnFamilyName = this.getResourceContext().getPluginConfiguration().getSimpleValue("name");
return this.getParentKeyspace().takeSnapshot(parameters, columnFamilyName);
+ } else if (name.equals("restoreSnapshot")){
+ return this.restoreSnapshot(parameters);
}
return super.invokeOperation(name, parameters);
@@ -111,13 +120,127 @@ public class ColumnFamilyComponent extends MBeanResourceComponent<JMXComponent<?
}
report.getConfiguration().remove("gc_grace_seconds");
+ report.getConfiguration().remove("snapshots");
+
super.updateResourceConfiguration(report);
}
+ private PropertyList getSnapshotsWithDetails() {
+ PropertyList listOfSnapshots = new PropertyList("snapshots");
+
+ KeyspaceComponent parentKeyspace = this.getParentKeyspace();
+ PropertyList parentDataFileLocations = parentKeyspace.getKeySpaceDataFileLocations();
+
+ for (Property directory : parentDataFileLocations.getList()) {
+ String directoryName = ((PropertySimple) directory).getStringValue();
+ directoryName += "/" + this.getResourceContext().getPluginConfiguration().getSimpleValue("name");
+ directoryName += "/snapshots";
+
+ File snapshotDirectory = new File(directoryName);
+
+ if (snapshotDirectory.exists()) {
+ File[] files = snapshotDirectory.listFiles();
+
+ for (File individualSnapshot : files) {
+ if (individualSnapshot.isDirectory()) {
+ PropertyMap snapshotDetails = new PropertyMap("snapshot");
+ snapshotDetails.put(new PropertySimple("name", individualSnapshot.getName()));
+ snapshotDetails.put(new PropertySimple("folder", individualSnapshot.getAbsolutePath()));
+ listOfSnapshots.add(snapshotDetails);
+ }
+ }
+ }
+ }
+
+ return listOfSnapshots;
+ }
+
+ private OperationResult restoreSnapshot(Configuration parameters) {
+ OperationResult result = new OperationResult();
+
+ //1. Find the list of snapshots discovered
+ String requestedSnapshotName = parameters.getSimpleValue("snapshotName");
+ PropertyList listOfSnapShots = this.getSnapshotsWithDetails();
+
+ String snapshotDirectoryName = null;
+ for (Property property : listOfSnapShots.getList()) {
+ String snapshotName = ((PropertyMap) property).getSimpleValue("name", null);
+ if (requestedSnapshotName.equals(snapshotName)) {
+ snapshotDirectoryName = ((PropertyMap) property).getSimpleValue("folder", null);
+ break;
+ }
+ }
+
+ //2. Find out if the discovered snapshot still exists on disk
+ if (snapshotDirectoryName == null) {
+ result.setErrorMessage("Restore failed! The snapshot does not exist!");
+ return result;
+ }
+
+ File snapshotDirectory = new File(snapshotDirectoryName);
+ if (!snapshotDirectory.exists() || !snapshotDirectory.isDirectory()) {
+ result.setErrorMessage("Restore failed! The snapshot does not exist on disk!");
+ return result;
+ }
+
+ //3. Shutdown Cassandra
+ CassandraNodeComponent node = this.getParentKeyspace().getCassandraNodeComponent();
+ node.shutdownNode();
+
+ //4. Remove the entire commit log
+ KeyspaceComponent parentKeyspace = this.getParentKeyspace();
+
+ parentKeyspace.clearCommitLog();
+
+ //5. Copy the snapshot files to the column family folders
+ PropertyList parentDataFileLocations = parentKeyspace.getKeySpaceDataFileLocations();
+
+ for (Property dataFileDirectoryProperty : parentDataFileLocations.getList()) {
+ String columnFamilyDirectoryName = ((PropertySimple) dataFileDirectoryProperty).getStringValue();
+ columnFamilyDirectoryName += "/" + this.getResourceContext().getPluginConfiguration().getSimpleValue("name");
+
+ File columnFamilyDirectory = new File(columnFamilyDirectoryName);
+ if(columnFamilyDirectory.exists()){
+ //5.1 Remove existing data files
+ File[] originalColumnFamilyDataFiles = columnFamilyDirectory.listFiles();
+ if (originalColumnFamilyDataFiles != null) {
+ for (File file : originalColumnFamilyDataFiles) {
+ if (file.isFile()) {
+ file.delete();
+ }
+ }
+ }
+
+ //5.2 Copy snapshots files to column family folder
+ File[] filesToBeRestored = snapshotDirectory.listFiles();
+ if (filesToBeRestored != null) {
+ for (File fileToBeRestored : filesToBeRestored) {
+ if (fileToBeRestored.isFile()) {
+ File destinationFile = new File(columnFamilyDirectory, fileToBeRestored.getName());
+ try {
+ FileUtil.copyFile(fileToBeRestored, destinationFile);
+ } catch (Exception e) {
+ result.setErrorMessage("Restore failed! The file copying process failed!");
+ return result;
+ }
+ }
+ }
+ }
+ }
+ }
+
+ //6. Restart Cassandra
+ node.startNode();
+
+ result.setSimpleResult("Snapshot restored succesfully...");
+
+ return result;
+ }
+
private ColumnFamilyDefinition getColumnFamilyDefinition() {
Configuration pluginConfig = this.getResourceContext().getPluginConfiguration();
String cfName = pluginConfig.getSimpleValue("name");
- KeyspaceComponent<?> keyspaceComponent = this.getParentKeyspace();
+ KeyspaceComponent keyspaceComponent = this.getParentKeyspace();
for (ColumnFamilyDefinition cfDef : keyspaceComponent.getKeyspaceDefinition().getCfDefs()) {
if (cfName.equals(cfDef.getName())) {
@@ -128,7 +251,7 @@ public class ColumnFamilyComponent extends MBeanResourceComponent<JMXComponent<?
return null;
}
- private KeyspaceComponent<?> getParentKeyspace() {
- return (KeyspaceComponent<?>) this.getResourceContext().getParentResourceComponent();
+ private KeyspaceComponent getParentKeyspace() {
+ return (KeyspaceComponent) this.getResourceContext().getParentResourceComponent();
}
}
diff --git a/modules/plugins/cassandra/src/main/java/org/rhq/plugins/cassandra/KeyspaceComponent.java b/modules/plugins/cassandra/src/main/java/org/rhq/plugins/cassandra/KeyspaceComponent.java
index d2d6126..5b15ee4 100644
--- a/modules/plugins/cassandra/src/main/java/org/rhq/plugins/cassandra/KeyspaceComponent.java
+++ b/modules/plugins/cassandra/src/main/java/org/rhq/plugins/cassandra/KeyspaceComponent.java
@@ -25,12 +25,14 @@
package org.rhq.plugins.cassandra;
+import java.io.File;
import java.util.Map;
import me.prettyprint.hector.api.ddl.KeyspaceDefinition;
import org.mc4j.ems.connection.EmsConnection;
import org.mc4j.ems.connection.bean.EmsBean;
+import org.mc4j.ems.connection.bean.attribute.EmsAttribute;
import org.mc4j.ems.connection.bean.operation.EmsOperation;
import org.rhq.core.domain.configuration.Configuration;
@@ -49,18 +51,18 @@ import org.rhq.plugins.jmx.JMXComponent;
/**
* @author John Sanda
*/
-public class KeyspaceComponent<T extends ResourceComponent<?>> implements ResourceComponent<T>, ConfigurationFacet,
- JMXComponent<T>, OperationFacet {
+public class KeyspaceComponent implements ResourceComponent<ResourceComponent<?>>, ConfigurationFacet,
+ JMXComponent<ResourceComponent<?>>, OperationFacet {
private static final String STORAGE_SERVICE_BEAN = "org.apache.cassandra.db:type=StorageService";
private static final String COMPACT_OPERATION = "forceTableCompaction";
private static final String REPAIR_OPERATION = "forceTableRepair";
- private ResourceContext<T> context;
+ private ResourceContext<ResourceComponent<?>> context;
@Override
- public void start(ResourceContext<T> context) throws Exception {
+ public void start(ResourceContext<ResourceComponent<?>> context) throws Exception {
this.context = context;
}
@@ -98,6 +100,7 @@ public class KeyspaceComponent<T extends ResourceComponent<?>> implements Resour
list.add(map);
}
config.put(list);
+ config.put(this.getKeySpaceDataFileLocations());
return config;
}
@@ -175,6 +178,46 @@ public class KeyspaceComponent<T extends ResourceComponent<?>> implements Resour
return new OperationResult();
}
+ public PropertyList getKeySpaceDataFileLocations() {
+ EmsBean emsBean = loadBean(STORAGE_SERVICE_BEAN);
+ EmsAttribute attribute = emsBean.getAttribute("AllDataFileLocations");
+
+ PropertyList list = new PropertyList("keyspaceFileLocations");
+ String[] dirs = (String[]) attribute.getValue();
+ for (String dir : dirs) {
+ if (!dir.endsWith("/")) {
+ dir = dir + "/";
+ }
+
+ list.add(new PropertySimple("directory", dir + context.getResourceKey()));
+ }
+
+ return list;
+ }
+
+ public PropertySimple getCommitLogProperty() {
+ EmsBean emsBean = loadBean(STORAGE_SERVICE_BEAN);
+ EmsAttribute attribute = emsBean.getAttribute("CommitLogLocation");
+ return new PropertySimple("CommitLogLocation", attribute.refresh());
+ }
+
+ public boolean clearCommitLog() {
+ PropertySimple commitLogProperty = this.getCommitLogProperty();
+
+ File commitLogFolder = new File(commitLogProperty.getStringValue());
+
+ File[] commitLogFiles = commitLogFolder.listFiles();
+ for (File file : commitLogFiles) {
+ file.delete();
+ }
+
+ return true;
+ }
+
+ public CassandraNodeComponent getCassandraNodeComponent() {
+ return (CassandraNodeComponent) this.context.getParentResourceComponent();
+ }
+
/**
* Loads the bean with the given object name.
*
diff --git a/modules/plugins/cassandra/src/main/java/org/rhq/plugins/cassandra/MetricsDiscoveryComponent.java b/modules/plugins/cassandra/src/main/java/org/rhq/plugins/cassandra/MetricsDiscoveryComponent.java
new file mode 100644
index 0000000..fbd2ef5
--- /dev/null
+++ b/modules/plugins/cassandra/src/main/java/org/rhq/plugins/cassandra/MetricsDiscoveryComponent.java
@@ -0,0 +1,61 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2012 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License, version 2, as
+ * published by the Free Software Foundation, and/or the GNU Lesser
+ * General Public License, version 2.1, also as published by the Free
+ * Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License and the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * and the GNU Lesser General Public License along with this program;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+package org.rhq.plugins.cassandra;
+
+import java.util.Set;
+
+import org.rhq.core.domain.util.StringUtils;
+import org.rhq.core.pluginapi.inventory.DiscoveredResourceDetails;
+import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext;
+import org.rhq.plugins.jmx.JMXComponent;
+import org.rhq.plugins.jmx.MBeanResourceDiscoveryComponent;
+
+/**
+ * @author Stefan Negrea
+ */
+public class MetricsDiscoveryComponent extends MBeanResourceDiscoveryComponent<JMXComponent<?>> {
+
+ public static final String PROPERTY_NAME_MARKER = "nameMarker";
+
+ public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext<JMXComponent<?>> context) {
+ String nameMarker = context.getDefaultPluginConfiguration().getSimpleValue(PROPERTY_NAME_MARKER);
+
+ Set<DiscoveredResourceDetails> discoveredResources = super.discoverResources(context, true);
+
+ String updatedResourceName;
+ int index;
+ for (DiscoveredResourceDetails discoveredResource : discoveredResources) {
+ updatedResourceName = discoveredResource.getResourceName();
+ if ( (index = updatedResourceName.indexOf(nameMarker)) != -1) {
+ updatedResourceName = updatedResourceName.substring(index + nameMarker.length());
+ if (updatedResourceName.length() != 0) {
+ updatedResourceName = StringUtils.deCamelCase(updatedResourceName);
+ discoveredResource.setResourceName(updatedResourceName);
+ }
+ }
+ }
+
+ return discoveredResources;
+ }
+
+}
diff --git a/modules/plugins/cassandra/src/main/resources/META-INF/rhq-plugin.xml b/modules/plugins/cassandra/src/main/resources/META-INF/rhq-plugin.xml
index 6ed9ef4..e3c33d0 100644
--- a/modules/plugins/cassandra/src/main/resources/META-INF/rhq-plugin.xml
+++ b/modules/plugins/cassandra/src/main/resources/META-INF/rhq-plugin.xml
@@ -28,6 +28,8 @@
<subcategories>
<subcategory name="Client Request Metrics" description="Client Request Metrics"/>
+ <subcategory name="Server Request Metrics" description="Server Request Metrics"/>
+ <subcategory name="Internal Server Metrics" description="Server Request Metrics"/>
</subcategories>
<plugin-configuration>
@@ -181,8 +183,8 @@
</plugin-configuration>
<metric property="TotalCommitLogSize" measurementType="trendsup" displayType="summary" description="Size of all commit log segments"/>
- <metric property="PendingTasks" measurementType="dynamic" displayType="detail" description="Number of tasks waiting to be executed"/>
- <metric property="CompletedTasks" measurementType="trendsup" displayType="detail" description="Number of completed tasks"/>
+ <metric property="PendingTasks" measurementType="dynamic" displayType="summary" description="Number of tasks waiting to be executed"/>
+ <metric property="CompletedTasks" measurementType="trendsup" displayType="summary" description="Number of completed tasks"/>
</service>
@@ -260,7 +262,7 @@
</operation>
<metric property="CompletedTasks" measurementType="trendsup" displayType="summary" description="Number of completed compactions since server [re]start"/>
- <metric property="PendingTasks" measurementType="dynamic" displayType="detail" description="Number of tasks waiting to be executed"/>
+ <metric property="PendingTasks" measurementType="dynamic" displayType="summary" description="Number of tasks waiting to be executed"/>
<metric property="TotalBytesCompacted" measurementType="trendsup" displayType="detail" description="Total number of bytes compacted since server [re]start"/>
<metric property="TotalCompactionsCompleted" measurementType="trendsup" displayType="detail" description="Total number of compactions since server [re]start"/>
</service>
@@ -280,17 +282,17 @@
<operation name="invalidateKeyCache" description="Invalidate the key cache."/>
<operation name="invalidateRowCache" description="Invalidate the row cache."/>
- <metric property="KeyCacheHits" measurementType="dynamic" displayType="detail" description="Number of key cache hits"/>
- <metric property="RowCacheHists" measurementType="dynamic" displayType="detail" description="Number of row cache hits"/>
+ <metric property="KeyCacheHits" measurementType="dynamic" displayType="summary" description="Number of key cache hits"/>
+ <metric property="RowCacheHists" measurementType="dynamic" displayType="summary" description="Number of row cache hits"/>
- <metric property="KeyCacheRequests" measurementType="dynamic" displayType="detail" description="Number of key cache requests"/>
- <metric property="RowCacheRequests" measurementType="dynamic" displayType="detail" description="Number of row cache requests"/>
+ <metric property="KeyCacheRequests" measurementType="dynamic" displayType="summary" description="Number of key cache requests"/>
+ <metric property="RowCacheRequests" measurementType="dynamic" displayType="summary" description="Number of row cache requests"/>
- <metric property="KeyCacheRecentHitRate" measurementType="dynamic" displayType="detail" description="Recent key cache hit rate"/>
- <metric property="RowCacheRecentHitRate" measurementType="dynamic" displayType="detail" description="Recent row cache hit rate"/>
+ <metric property="KeyCacheRecentHitRate" measurementType="dynamic" displayType="summary" description="Recent key cache hit rate"/>
+ <metric property="RowCacheRecentHitRate" measurementType="dynamic" displayType="summary" description="Recent row cache hit rate"/>
- <metric property="KeyCacheCapacityInBytes" measurementType="dynamic" displayType="detail" description="Key cache capacity in bytes"/>
- <metric property="RowCacheCapacityInBytes" measurementType="dynamic" displayType="detail" description="Row cache capacity in bytes"/>
+ <metric property="KeyCacheCapacityInBytes" measurementType="dynamic" displayType="summary" description="Key cache capacity in bytes"/>
+ <metric property="RowCacheCapacityInBytes" measurementType="dynamic" displayType="summary" description="Row cache capacity in bytes"/>
<metric property="KeyCacheSize" measurementType="dynamic" displayType="detail" description="Key cache size"/>
<metric property="RowCacheSize" measurementType="dynamic" displayType="detail" description="Row cache size"/>
@@ -344,6 +346,9 @@
<c:simple-property name="strategyOptionValue" type="string" readOnly="true"/>
</c:map-property>
</c:list-property>
+ <c:list-property name="keyspaceFileLocations" readOnly="true" description="List of data file locations">
+ <c:simple-property name="directory" type="string" readOnly="true"/>
+ </c:list-property>
</resource-configuration>
<service name="ColumnFamily"
@@ -393,24 +398,34 @@
<c:simple-property name="operationResult" description="Filenames that contain the given key on this node."/>
</results>
</operation>
+ <operation name="restoreSnapshot" description="Restore the column family from a previously taken snapshot.">
+ <parameters>
+ <c:simple-property name="snapshotName" required="true" type="string" description="Snapshot Name">
+ <c:option-source target="configuration" expression="snapshots:type=ColumnFamily"/>
+ </c:simple-property>
+ </parameters>
+ <results>
+ <c:simple-property name="operationResult" description="Filenames that contain the given key on this node."/>
+ </results>
+ </operation>
- <metric property="CompressionRatio" measurementType="dynamic" displayType="detail" description="Compression Ratio"/>
- <metric property="LiveDiskSpaceUsed" displayName="Live Disk Space Used" measurementType="dynamic" displayType="detail" description="Disk space used by SSTables belonging to this CF"/>
- <metric property="LiveSSTableCount" displayName="Live SS Table Count" measurementType="dynamic" displayType="detail" description="Number of SSTables on disk for this CF"/>
- <metric property="MaxRowSize" measurementType="dynamic" displayType="detail" description="Size of the largest compacted row"/>
- <metric property="MeanRowSize" measurementType="dynamic" displayType="detail" description="Means size of the compacted rows"/>
- <metric property="MemtableColumnsCount" displayName="Memtable Columns Count" measurementType="dynamic" displayType="detail" description="Total number of columns present in the memtable."/>
+ <metric property="CompressionRatio" measurementType="dynamic" displayType="summary" description="Compression Ratio"/>
+ <metric property="LiveDiskSpaceUsed" displayName="Live Disk Space Used" measurementType="dynamic" displayType="summary" description="Disk space used by SSTables belonging to this CF"/>
+ <metric property="LiveSSTableCount" displayName="Live SS Table Count" measurementType="dynamic" displayType="summary" description="Number of SSTables on disk for this CF"/>
+ <metric property="MaxRowSize" measurementType="dynamic" displayType="summary" description="Size of the largest compacted row"/>
+ <metric property="MeanRowSize" measurementType="dynamic" displayType="summary" description="Means size of the compacted rows"/>
+ <metric property="MemtableColumnsCount" displayName="Memtable Columns Count" measurementType="dynamic" displayType="summary" description="Total number of columns present in the memtable."/>
<metric property="MemtableDataSize" displayName="Memtable Data Size" measurementType="dynamic" displayType="detail" description="Total amount of data stored in the memtable, including column related overhead."/>
- <metric property="MemtableSwitchCount" displayName="Memtable Switch Count" measurementType="dynamic" displayType="detail" description="Number of times that a flush has resulted in the memtable being switched out."/>
- <metric property="MinRowSize" measurementType="dynamic" displayType="detail" description="Size of the smallest compacted row"/>
- <metric property="PendingTasks" measurementType="dynamic" displayType="detail" description="Estimated number of tasks pending for this column family"/>
+ <metric property="MemtableSwitchCount" displayName="Memtable Switch Count" measurementType="dynamic" displayType="summary" description="Number of times that a flush has resulted in the memtable being switched out."/>
+ <metric property="MinRowSize" measurementType="dynamic" displayType="summary" description="Size of the smallest compacted row"/>
+ <metric property="PendingTasks" measurementType="dynamic" displayType="summary" description="Estimated number of tasks pending for this column family"/>
<metric property="ReadCount" displayName="Read Count" measurementType="trendsup" displayType="summary" description="Number of read operations since execution start"/>
<metric property="RecentReadLatencyMicros" displayName="Recent Read Latency (in micro seconds)" measurementType="trendsup" displayType="detail" description="Latency of read operations since this metric was last sampled"/>
<metric property="RecentWriteLatencyMicros" displayName="Recent Write Latency (in micro seconds)" measurementType="trendsup" displayType="detail" description="Latency of write operations since this metric was last sampled"/>
- <metric property="TotalDiskSpaceUsed" measurementType="dynamic" displayType="summary" description="Total disk space used by SSTables belonging to this CF, including obsolete ones waiting to be GC'd"/>
+ <metric property="TotalDiskSpaceUsed" measurementType="dynamic" displayType="detail" description="Total disk space used by SSTables belonging to this CF, including obsolete ones waiting to be GC'd"/>
<metric property="TotalReadLatencyMicros" displayName="Total Read Latency (in micro seconds)" measurementType="trendsup" displayType="detail" description="Latency of read operations since execution start"/>
<metric property="TotalWriteLatencyMicros" displayName="Total Write Latency (in micro seconds)" measurementType="trendsup" displayType="detail" description="Latency of write operations since execution start"/>
- <metric property="UnleveledSSTables" measurementType="dynamic" displayType="detail" description="Number of SSTables in L0. Always return 0 if Leveled compaction is not enabled."/>
+ <metric property="UnleveledSSTables" measurementType="dynamic" displayType="summary" description="Number of SSTables in L0. Always return 0 if Leveled compaction is not enabled."/>
<metric property="WriteCount" displayName="Write Count" measurementType="trendsup" displayType="summary" description="Number of write operations since execution start"/>
<resource-configuration>
@@ -422,9 +437,100 @@
<c:simple-property name="CompressionParameters" type="string" required="true" description="Compression parameters"/>
<c:simple-property name="MinimumCompactionThreshold" type="integer" required="true" description="Minimum number of sstables in queue before compaction kicks off."/>
<c:simple-property name="MaximumCompactionThreshold" type="integer" required="true" description="Maximum number of sstables in queue before compaction kicks off."/>
+ <c:list-property name="snapshots" readOnly="true" required="false">
+ <c:map-property name="snapshot" readOnly="true">
+ <c:simple-property name="name" readOnly="true"/>
+ <c:simple-property name="folder" readOnly="true" description="Snapshot Folder"/>
+ </c:map-property>
+ </c:list-property>
</resource-configuration>
</service>
</service>
+
+ <service name="ConfigurableStages"
+ discovery="org.rhq.plugins.cassandra.MetricsDiscoveryComponent"
+ class="org.rhq.plugins.jmx.MBeanResourceComponent"
+ singleton="true"
+ subCategory="Server Request Metrics">
+
+ <plugin-configuration>
+ <c:simple-property name="objectName" readOnly="true" type="string"
+ default="org.apache.cassandra.request:type=MutationStage|org.apache.cassandra.request:type=ReadStage|org.apache.cassandra.request:type=ReplicateOnWriteStage"/>
+ <c:simple-property name="nameMarker" readOnly="true" type="string" default="type=" />
+ </plugin-configuration>
+
+ <metric property="ActiveCount" measurementType="dynamic" displayType="summary" description="Active Count"/>
+ <metric property="CurrentlyBlockedTasks" measurementType="dynamic" displayType="summary" description="Currently Blocked Tasks"/>
+ <metric property="CompletedTasks" measurementType="dynamic" displayType="summary" description="Completed Tasks"/>
+ <metric property="PendingTasks" measurementType="dynamic" displayType="summary" description="Pending Tasks"/>
+ <metric property="TotalBlockedTasks" measurementType="dynamic" displayType="summary" description="Total Blocked Tasks"/>
+
+ <resource-configuration>
+ <c:simple-property name="CorePoolSize" type="integer" required="true" description="Core Pool Size."/>
+ </resource-configuration>
+ </service>
+
+ <service name="EnabledStages"
+ discovery="org.rhq.plugins.cassandra.MetricsDiscoveryComponent"
+ class="org.rhq.plugins.jmx.MBeanResourceComponent"
+ singleton="true"
+ subCategory="Server Request Metrics">
+
+ <plugin-configuration>
+ <c:simple-property name="objectName" readOnly="true" type="string"
+ default="org.apache.cassandra.request:type=ReadRepairStage|org.apache.cassandra.request:type=RequestResponseStage"/>
+ <c:simple-property name="nameMarker" readOnly="true" type="string" default="type=" />
+ </plugin-configuration>
+
+ <metric property="ActiveCount" measurementType="dynamic" displayType="summary" description="Active Count"/>
+ <metric property="CurrentlyBlockedTasks" measurementType="dynamic" displayType="summary" description="Currently Blocked Tasks"/>
+ <metric property="CompletedTasks" measurementType="dynamic" displayType="summary" description="Completed Tasks"/>
+ <metric property="PendingTasks" measurementType="dynamic" displayType="summary" description="Pending Tasks"/>
+ <metric property="TotalBlockedTasks" measurementType="dynamic" displayType="summary" description="Total Blocked Tasks"/>
+ </service>
+
+ <service name="ConfigurableInternalServerMetrics"
+ discovery="org.rhq.plugins.cassandra.MetricsDiscoveryComponent"
+ class="org.rhq.plugins.jmx.MBeanResourceComponent"
+ singleton="true"
+ subCategory="Internal Server Metrics">
+
+ <plugin-configuration>
+ <c:simple-property name="objectName" readOnly="true" type="string"
+ default="org.apache.cassandra.internal:type=AntiEntropySessions"/>
+ <c:simple-property name="nameMarker" readOnly="true" type="string" default="type=" />
+ </plugin-configuration>
+
+ <metric property="ActiveCount" measurementType="dynamic" displayType="summary" description="Active Count"/>
+ <metric property="CurrentlyBlockedTasks" measurementType="dynamic" displayType="summary" description="Currently Blocked Tasks"/>
+ <metric property="CompletedTasks" measurementType="dynamic" displayType="summary" description="Completed Tasks"/>
+ <metric property="PendingTasks" measurementType="dynamic" displayType="summary" description="Pending Tasks"/>
+ <metric property="TotalBlockedTasks" measurementType="dynamic" displayType="summary" description="Total Blocked Tasks"/>
+
+ <resource-configuration>
+ <c:simple-property name="CorePoolSize" type="integer" required="true" description="Core Pool Size."/>
+ </resource-configuration>
+ </service>
+
+ <service name="EnabledInternalServerMetrics"
+ discovery="org.rhq.plugins.cassandra.MetricsDiscoveryComponent"
+ class="org.rhq.plugins.jmx.MBeanResourceComponent"
+ singleton="true"
+ subCategory="Internal Server Metrics">
+
+ <plugin-configuration>
+ <c:simple-property name="objectName" readOnly="true" type="string"
+ default="org.apache.cassandra.internal:type=AntiEntropyStage|org.apache.cassandra.internal:type=FlushWriter|org.apache.cassandra.internal:type=GossipStage|org.apache.cassandra.internal:type=HintedHandoff|org.apache.cassandra.internal:type=InternalResponseStage|org.apache.cassandra.internal:type=MemtablePostFlusher|org.apache.cassandra.internal:type=MigrationStage|org.apache.cassandra.internal:type=MiscStage|org.apache.cassandra.internal:type=StreamStage|org.apache.cassandra.internal:type=commitlog_archiver"/>
+ <c:simple-property name="nameMarker" readOnly="true" type="string" default="type=" />
+ </plugin-configuration>
+
+ <metric property="ActiveCount" measurementType="dynamic" displayType="summary" description="Active Count"/>
+ <metric property="CurrentlyBlockedTasks" measurementType="dynamic" displayType="summary" description="Currently Blocked Tasks"/>
+ <metric property="CompletedTasks" measurementType="dynamic" displayType="summary" description="Completed Tasks"/>
+ <metric property="PendingTasks" measurementType="dynamic" displayType="summary" description="Pending Tasks"/>
+ <metric property="TotalBlockedTasks" measurementType="dynamic" displayType="summary" description="Total Blocked Tasks"/>
+ </service>
+
</server>
</plugin>
\ No newline at end of file
11 years, 6 months
[rhq] Branch 'rhq-on-as7' - modules/common
by mazz
modules/common/jboss-as-dmr-client/src/main/java/org/rhq/common/jbossas/client/controller/DatasourceJBossASClient.java | 26 ++++++----
1 file changed, 18 insertions(+), 8 deletions(-)
New commits:
commit b423892e0a62f0945f2d2d82a3b1f0e9d41c45a0
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Wed Oct 24 11:13:21 2012 -0400
support adding a JDBC driver that does not support XA
diff --git a/modules/common/jboss-as-dmr-client/src/main/java/org/rhq/common/jbossas/client/controller/DatasourceJBossASClient.java b/modules/common/jboss-as-dmr-client/src/main/java/org/rhq/common/jbossas/client/controller/DatasourceJBossASClient.java
index b1f7a98..ab44796 100644
--- a/modules/common/jboss-as-dmr-client/src/main/java/org/rhq/common/jbossas/client/controller/DatasourceJBossASClient.java
+++ b/modules/common/jboss-as-dmr-client/src/main/java/org/rhq/common/jbossas/client/controller/DatasourceJBossASClient.java
@@ -132,18 +132,28 @@ public class DatasourceJBossASClient extends JBossASClient {
* @param name the name of the JDBC driver (this is not the name of the JDBC jar or the module name, it is
* just a convienence name of the JDBC driver configuration).
* @param moduleName the name of the JBossAS module where the JDBC driver is installed
- * @param driverXaClassName the JDBC driver's XA datasource classname
+ * @param driverXaClassName the JDBC driver's XA datasource classname (null if XA is not supported)
*
* @return the request to create the JDBC driver configuration.
*/
public ModelNode createNewJdbcDriverRequest(String name, String moduleName, String driverXaClassName) {
- String dmrTemplate = "" //
- + "{" //
- + "\"driver-module-name\" => \"%s\" " //
- + ", \"driver-xa-datasource-class-name\" => \"%s\" " //
- + "}";
-
- String dmr = String.format(dmrTemplate, moduleName, driverXaClassName);
+ String dmrTemplate;
+ String dmr;
+
+ if (driverXaClassName != null) {
+ dmrTemplate = "" //
+ + "{" //
+ + "\"driver-module-name\" => \"%s\" " //
+ + ", \"driver-xa-datasource-class-name\" => \"%s\" " //
+ + "}";
+ dmr = String.format(dmrTemplate, moduleName, driverXaClassName);
+ } else {
+ dmrTemplate = "" //
+ + "{" //
+ + "\"driver-module-name\" => \"%s\" " //
+ + "}";
+ dmr = String.format(dmrTemplate, moduleName);
+ }
Address addr = Address.root().add(SUBSYSTEM, SUBSYSTEM_DATASOURCES, JDBC_DRIVER, name);
final ModelNode request = ModelNode.fromString(dmr);
11 years, 6 months
[rhq] 3 commits - modules/enterprise modules/helpers
by Heiko W. Rupp
modules/enterprise/server/jar/pom.xml | 4 -
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/GroupHandlerBean.java | 2
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/AlertDefinitionRest.java | 8 ++
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/AlertRest.java | 13 +++
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/AvailabilityRest.java | 8 ++
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/Baseline.java | 8 ++
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/EventRest.java | 3
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/EventSourceRest.java | 3
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/GroupDefinitionRest.java | 11 +++
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/GroupRest.java | 12 +++
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/Link.java | 6 +
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/MetricAggregate.java | 13 +++
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/MetricSchedule.java | 14 ++++
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/NumericDataPoint.java | 7 ++
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/OperationDefinitionRest.java | 7 ++
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/OperationHistoryRest.java | 10 ++
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/OperationRest.java | 14 ++++
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/ResourceWithChildren.java | 7 ++
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/ResourceWithType.java | 15 +++-
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/SimplePropDef.java | 9 ++
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/Status.java | 5 +
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/StringValue.java | 5 +
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/UserRest.java | 10 ++
modules/enterprise/server/plugins/alert-sms/src/main/java/org/rhq/enterprise/server/plugins/alertSms/SmsSender.java | 35 +++++-----
modules/helpers/rest-docs-generator/pom.xml | 2
modules/helpers/rest-docs-generator/src/main/java/org/rhq/helpers/rest_docs_generator/ClassLevelProcessor.java | 15 +++-
26 files changed, 219 insertions(+), 27 deletions(-)
New commits:
commit aba99ed81d4645a1034ed38dea51a02c6d671e98
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Wed Oct 24 15:15:32 2012 +0200
Document the data classes of the REST api.
diff --git a/modules/enterprise/server/jar/pom.xml b/modules/enterprise/server/jar/pom.xml
index dbcaac4..896a352 100644
--- a/modules/enterprise/server/jar/pom.xml
+++ b/modules/enterprise/server/jar/pom.xml
@@ -517,7 +517,7 @@
<dependency>
<groupId>com.wordnik</groupId>
<artifactId>swagger-annotations_2.9.1</artifactId>
- <version>1.1-SNAPSHOT</version>
+ <version>1.1.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.rhq.helpers</groupId>
@@ -925,7 +925,7 @@
<field>namespace</field>
<justification>The namespace changes with every version, so this is definitely an intentional change.</justification>
</difference>
- </ignored>
+ </ignored>
</configuration>
</plugin>
</plugins>
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/GroupHandlerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/GroupHandlerBean.java
index e6f9335..f3bcdff 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/GroupHandlerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/GroupHandlerBean.java
@@ -249,7 +249,7 @@ public class GroupHandlerBean extends AbstractRestBean implements GroupHandlerLo
List<MetricSchedule> schedules = new ArrayList<MetricSchedule>(definitions.size());
for (MeasurementDefinition def : definitions) {
MetricSchedule schedule = new MetricSchedule(def.getId(),def.getName(),def.getDisplayName(),false,def.getDefaultInterval(),
- def.getUnits().getName(),def.getDisplayType().toString());
+ def.getUnits().getName(),def.getDataType().toString());
if (def.getDataType()== DataType.MEASUREMENT) {
UriBuilder uriBuilder = uriInfo.getBaseUriBuilder();
uriBuilder.path("/metric/data/group/{groupId}/{definitionId}");
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/AlertDefinitionRest.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/AlertDefinitionRest.java
index 0719d4a..c7cf98b 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/AlertDefinitionRest.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/AlertDefinitionRest.java
@@ -20,11 +20,14 @@ package org.rhq.enterprise.server.rest.domain;
import javax.xml.bind.annotation.XmlRootElement;
+import com.wordnik.swagger.annotations.ApiClass;
+import com.wordnik.swagger.annotations.ApiProperty;
/**
* Alert Definition
* @author Heiko W. Rupp
*/
+@ApiClass("Representation of an AlertDefinition")
@XmlRootElement
public class AlertDefinitionRest {
@@ -41,6 +44,7 @@ public class AlertDefinitionRest {
this.id = id;
}
+ @ApiProperty("The id of the definition")
public int getId() {
return id;
}
@@ -49,6 +53,7 @@ public class AlertDefinitionRest {
this.id = id;
}
+ @ApiProperty("The name of the definition")
public String getName() {
return name;
}
@@ -57,6 +62,7 @@ public class AlertDefinitionRest {
this.name = name;
}
+ @ApiProperty("Is the definition enabled(=active)?")
public boolean isEnabled() {
return enabled;
}
@@ -65,6 +71,8 @@ public class AlertDefinitionRest {
this.enabled = enabled;
}
+ @ApiProperty(value = "The priority of the definition",
+ allowableValues = "LOW, MEDIUM, HIGH")
public String getPriority() {
return priority;
}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/AlertRest.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/AlertRest.java
index d09f5b8..db44a3b 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/AlertRest.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/AlertRest.java
@@ -24,12 +24,16 @@ import java.util.List;
import javax.xml.bind.annotation.XmlElementRef;
import javax.xml.bind.annotation.XmlRootElement;
+import com.wordnik.swagger.annotations.ApiClass;
+import com.wordnik.swagger.annotations.ApiProperty;
+
import org.jboss.resteasy.links.RESTServiceDiscovery;
/**
* A single alert
* @author Heiko W. Rupp
*/
+@ApiClass(value = "This class represents a single fired alert.")
@XmlRootElement
public class AlertRest {
@@ -61,18 +65,22 @@ public class AlertRest {
this.alertDefinition = alertDefinitionId;
}
+ @ApiProperty("The id of the alert")
public int getId() {
return id;
}
+ @ApiProperty("Name of the alert, taken from the AlertDefinition")
public String getName() {
return name;
}
+ @ApiProperty("AlertDefinition from which the alert was fired")
public AlertDefinitionRest getAlertDefinition() {
return alertDefinition;
}
+ @ApiProperty("Is the definition enabled (=active)?")
public boolean isDefinitionEnabled() {
return definitionEnabled;
}
@@ -81,6 +89,7 @@ public class AlertRest {
this.definitionEnabled = definitionEnabled;
}
+ @ApiProperty("The user that acknowledged the alert (if any)")
public String getAckBy() {
return ackBy;
}
@@ -89,6 +98,7 @@ public class AlertRest {
this.ackBy = ackBy;
}
+ @ApiProperty("Timestamp of the acknowledgement")
public long getAckTime() {
return ackTime;
}
@@ -97,6 +107,7 @@ public class AlertRest {
this.ackTime = ackTime;
}
+ @ApiProperty("Timestamp when the alert has been fired")
public long getAlertTime() {
return alertTime;
}
@@ -105,6 +116,7 @@ public class AlertRest {
this.alertTime = alertTime;
}
+ @ApiProperty("Description of the alert")
public String getDescription() {
return description;
}
@@ -113,6 +125,7 @@ public class AlertRest {
this.description = description;
}
+ @ApiProperty("The resource on which the alert was fired")
public ResourceWithType getResource() {
return resource;
}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/AvailabilityRest.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/AvailabilityRest.java
index 2710660..991f0e4 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/AvailabilityRest.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/AvailabilityRest.java
@@ -22,6 +22,9 @@ import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementRef;
import javax.xml.bind.annotation.XmlRootElement;
+import com.wordnik.swagger.annotations.ApiClass;
+import com.wordnik.swagger.annotations.ApiProperty;
+
import org.jboss.resteasy.links.RESTServiceDiscovery;
import org.rhq.core.domain.measurement.AvailabilityType;
@@ -30,6 +33,7 @@ import org.rhq.core.domain.measurement.AvailabilityType;
* Availability implementation for exposing via REST
* @author Heiko W. Rupp
*/
+@ApiClass("Represents the availability of a resource")
@XmlRootElement(name = "availability")
public class AvailabilityRest {
@@ -55,16 +59,19 @@ public class AvailabilityRest {
this.resourceId = resourceId;
}
+ @ApiProperty("Time since the type is valid")
@XmlElement
public long getSince() {
return since;
}
+ @ApiProperty(value = "Type of availability", allowableValues = "UP, DOWN, DISABLED, UNKNOWN")
@XmlElement
public String getType() {
return type;
}
+ @ApiProperty("Id of the resource that reports the availability")
@XmlElement
public int getResourceId() {
return resourceId;
@@ -82,6 +89,7 @@ public class AvailabilityRest {
this.resourceId = resourceId;
}
+ @ApiProperty("Time until the type is valid. May be null if type is ongoing")
public Long getUntil() {
return until;
}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/Baseline.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/Baseline.java
index d6a4073..69623fb 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/Baseline.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/Baseline.java
@@ -2,10 +2,14 @@ package org.rhq.enterprise.server.rest.domain;
import javax.xml.bind.annotation.XmlRootElement;
+import com.wordnik.swagger.annotations.ApiClass;
+import com.wordnik.swagger.annotations.ApiProperty;
+
/**
* A baseline
* @author Heiko W. Rupp
*/
+@ApiClass("Representation of a metic baseline/-band")
@XmlRootElement
public class Baseline {
@@ -24,6 +28,7 @@ public class Baseline {
this.computeTime = computeTime;
}
+ @ApiProperty("The lower value of the base band")
public double getMin() {
return min;
}
@@ -32,6 +37,7 @@ public class Baseline {
this.min = min;
}
+ @ApiProperty("The higher value of the base band")
public double getMax() {
return max;
}
@@ -40,6 +46,7 @@ public class Baseline {
this.max = max;
}
+ @ApiProperty("The baseline value (i.e. the average of the metrics")
public double getMean() {
return mean;
}
@@ -48,6 +55,7 @@ public class Baseline {
this.mean = mean;
}
+ @ApiProperty("Time this value was computed")
public long getComputeTime() {
return computeTime;
}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/EventRest.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/EventRest.java
index 666b0dc..5657e3c 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/EventRest.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/EventRest.java
@@ -22,13 +22,14 @@ package org.rhq.enterprise.server.rest.domain;
import javax.xml.bind.annotation.XmlRootElement;
import com.wordnik.swagger.annotations.Api;
+import com.wordnik.swagger.annotations.ApiClass;
import com.wordnik.swagger.annotations.ApiProperty;
/**
* An event
* @author Heiko W. Rupp
*/
-@Api("This class represents one event.")
+@ApiClass("This class represents one event.")
@XmlRootElement(name = "event")
public class EventRest {
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/EventSourceRest.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/EventSourceRest.java
index 5cfa3c9..6d121b9 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/EventSourceRest.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/EventSourceRest.java
@@ -22,13 +22,14 @@ package org.rhq.enterprise.server.rest.domain;
import javax.xml.bind.annotation.XmlRootElement;
import com.wordnik.swagger.annotations.Api;
+import com.wordnik.swagger.annotations.ApiClass;
import com.wordnik.swagger.annotations.ApiProperty;
/**
* An EventSource
* @author Heiko W. Rupp
*/
-@Api("This class represents an EventSource - e.g. a logfile.")
+@ApiClass("This class represents an EventSource - e.g. a logfile.")
@XmlRootElement(name="source")
public class EventSourceRest {
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/GroupDefinitionRest.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/GroupDefinitionRest.java
index 93b715c..65573a7 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/GroupDefinitionRest.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/GroupDefinitionRest.java
@@ -25,10 +25,14 @@ import java.util.List;
import javax.xml.bind.annotation.XmlID;
import javax.xml.bind.annotation.XmlRootElement;
+import com.wordnik.swagger.annotations.ApiClass;
+import com.wordnik.swagger.annotations.ApiProperty;
+
/**
* A group definition ("Dyna Group definition")
* @author Heiko W. Rupp
*/
+@ApiClass("One DynaGroup definition")
@XmlRootElement(name="groupDefinition")
public class GroupDefinitionRest {
@@ -51,6 +55,7 @@ public class GroupDefinitionRest {
this.recalcInterval = recalcInterval;
}
+ @ApiProperty("The id of the definition")
public int getId() {
return id;
}
@@ -59,6 +64,7 @@ public class GroupDefinitionRest {
this.id = id;
}
+ @ApiProperty("The name of the definition")
public String getName() {
return name;
}
@@ -67,6 +73,7 @@ public class GroupDefinitionRest {
this.name = name;
}
+ @ApiProperty("A description of the definition")
public String getDescription() {
return description;
}
@@ -75,6 +82,7 @@ public class GroupDefinitionRest {
this.description = description;
}
+ @ApiProperty("Individual lines of the group expression")
public List<String> getExpression() {
return expression;
}
@@ -83,6 +91,7 @@ public class GroupDefinitionRest {
this.expression = expression;
}
+ @ApiProperty("Interval in ms at which the expression should be re-evaluated")
public long getRecalcInterval() {
return recalcInterval;
}
@@ -91,6 +100,7 @@ public class GroupDefinitionRest {
this.recalcInterval = recalcInterval;
}
+ @ApiProperty("List of ids for the groups generated by this group expression")
public List<Integer> getGeneratedGroupIds() {
return generatedGroupIds;
}
@@ -99,6 +109,7 @@ public class GroupDefinitionRest {
this.generatedGroupIds = generatedGroupIds;
}
+ @ApiProperty("Is this definition generating rescursive groups?")
public boolean isRecursive() {
return recursive;
}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/GroupRest.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/GroupRest.java
index c43f911..e0f32e7 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/GroupRest.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/GroupRest.java
@@ -6,12 +6,16 @@ import java.util.List;
import javax.xml.bind.annotation.XmlElementRef;
import javax.xml.bind.annotation.XmlRootElement;
+import com.wordnik.swagger.annotations.ApiClass;
+import com.wordnik.swagger.annotations.ApiProperty;
+
import org.rhq.core.domain.resource.group.GroupCategory;
/**
* Representation of a resource group
* @author Heiko W. Rupp
*/
+@ApiClass("Representation of a resource group")
@XmlRootElement
public class GroupRest {
@@ -34,6 +38,7 @@ public class GroupRest {
this.name = name;
}
+ @ApiProperty("Id of the group")
public int getId() {
return id;
}
@@ -42,6 +47,7 @@ public class GroupRest {
this.id = id;
}
+ @ApiProperty("Name of the group")
public String getName() {
return name;
}
@@ -50,6 +56,7 @@ public class GroupRest {
this.name = name;
}
+ @ApiProperty("ResourceType id for compatible groups")
public Integer getResourceTypeId() {
return resourceTypeId;
}
@@ -58,6 +65,7 @@ public class GroupRest {
this.resourceTypeId = resourceTypeId;
}
+ @ApiProperty("True if the group is recursive (i.e. includes child resources")
public boolean isRecursive() {
return recursive;
}
@@ -66,6 +74,7 @@ public class GroupRest {
this.recursive = recursive;
}
+ @ApiProperty(value="Category of the group. ", allowableValues = "COMPATIBLE, MIXED" )
public GroupCategory getCategory() {
return category;
}
@@ -83,6 +92,7 @@ public class GroupRest {
this.links = links;
}
+ @ApiProperty("Id of a DynaGroup definition if the group was defined by a DynaGroup.")
public int getDynaGroupDefinitionId() {
return dynaGroupDefinitionId;
}
@@ -91,6 +101,7 @@ public class GroupRest {
this.dynaGroupDefinitionId = dynaGroupDefinitionId;
}
+ @ApiProperty("Number of explicitly added resources in the group")
public int getExplicitCount() {
return explicitCount;
}
@@ -99,6 +110,7 @@ public class GroupRest {
this.explicitCount = explicitCount;
}
+ @ApiProperty("Number of resources in the group (explict + children for a recursive group")
public int getImplicitCount() {
return implicitCount;
}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/Link.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/Link.java
index 1936425..3287750 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/Link.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/Link.java
@@ -3,10 +3,14 @@ package org.rhq.enterprise.server.rest.domain;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlRootElement;
+import com.wordnik.swagger.annotations.ApiClass;
+import com.wordnik.swagger.annotations.ApiProperty;
+
/**
* A link between two resources
* @author Heiko W. Rupp
*/
+@ApiClass("Link between two resources")
@XmlRootElement
public class Link {
@@ -22,11 +26,13 @@ public class Link {
}
+ @ApiProperty("Name of the relation")
@XmlAttribute
public String getRel() {
return rel;
}
+ @ApiProperty("Target of the relation")
@XmlAttribute
public String getHref() {
return href;
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/MetricAggregate.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/MetricAggregate.java
index 46605cf..7ad1e50 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/MetricAggregate.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/MetricAggregate.java
@@ -24,10 +24,14 @@ import java.util.List;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
+import com.wordnik.swagger.annotations.ApiClass;
+import com.wordnik.swagger.annotations.ApiProperty;
+
/**
* Metric data that could be used to draw a chart
* @author Heiko W. Rupp
*/
+@ApiClass("An aggregate of metrics data for a given schedule")
@XmlRootElement
public class MetricAggregate {
@@ -55,6 +59,7 @@ public class MetricAggregate {
}
+ @ApiProperty("List of indiviudual data points")
@XmlElement
public List<DataPoint> getDataPoints() {
return dataPoints;
@@ -68,16 +73,19 @@ public class MetricAggregate {
this.dataPoints = dataPoints;
}
+ @ApiProperty("Minimum value for the data")
@XmlElement
public Double getMin() {
return min;
}
+ @ApiProperty("Average value for the data")
@XmlElement
public Double getAvg() {
return avg;
}
+ @ApiProperty("Maximum value for the data")
@XmlElement
public Double getMax() {
return max;
@@ -95,6 +103,7 @@ public class MetricAggregate {
this.max = max;
}
+ @ApiProperty("Number of data points i.e. size of the dataPoints list")
public int getNumDataPoints() {
return numDataPoints;
}
@@ -103,6 +112,7 @@ public class MetricAggregate {
this.numDataPoints = numDataPoints;
}
+ @ApiProperty("Id of the metric")
@XmlElement
public Integer getScheduleId() {
return scheduleId;
@@ -112,6 +122,7 @@ public class MetricAggregate {
this.scheduleId = scheduleId;
}
+ @ApiProperty("Timestamp of the earliest data point in the list")
public long getMinTimeStamp() {
return minTimeStamp;
}
@@ -120,6 +131,7 @@ public class MetricAggregate {
this.minTimeStamp = minTimeStamp;
}
+ @ApiProperty("Timestamp fo the latest data point in the list")
public long getMaxTimeStamp() {
return maxTimeStamp;
}
@@ -128,6 +140,7 @@ public class MetricAggregate {
this.maxTimeStamp = maxTimeStamp;
}
+ @ApiProperty("Determines if this is data for a group")
public boolean isGroup() {
return isGroup;
}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/MetricSchedule.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/MetricSchedule.java
index 30a006b..cd12b04 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/MetricSchedule.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/MetricSchedule.java
@@ -27,12 +27,17 @@ import javax.xml.bind.annotation.XmlID;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;
+import com.wordnik.swagger.annotations.ApiClass;
+import com.wordnik.swagger.annotations.ApiProperty;
+
import org.jboss.resteasy.spi.touri.URITemplate;
/**
* A simple metric schedule
* @author Heiko W. Rupp
*/
+@ApiClass(value = "A single metrics schedule",
+ description = "A scheudle represents the collection interval for a metric and if the collection is enabled")
@XmlRootElement
@URITemplate("/metric/schedule/{id}")
public class MetricSchedule {
@@ -61,6 +66,7 @@ public class MetricSchedule {
this.type = type;
}
+ @ApiProperty("The id of the schedule")
@XmlID
public String getScheduleId() {
return ""+scheduleId;
@@ -70,6 +76,7 @@ public class MetricSchedule {
this.scheduleId = scheduleId;
}
+ @ApiProperty("The name of the metric")
public String getScheduleName() {
return scheduleName;
}
@@ -78,6 +85,7 @@ public class MetricSchedule {
this.scheduleName = scheduleName;
}
+ @ApiProperty("Is the collection enabled?")
public Boolean getEnabled() {
return enabled;
}
@@ -86,6 +94,8 @@ public class MetricSchedule {
this.enabled = enabled;
}
+ @ApiProperty(value = "The collection interval in milliseconds",
+ allowableValues = "A minimum of 30s")
public long getCollectionInterval() {
return collectionInterval;
}
@@ -94,6 +104,7 @@ public class MetricSchedule {
this.collectionInterval = collectionInterval;
}
+ @ApiProperty("The name of the metric as shown in the UI")
public String getDisplayName() {
return displayName;
}
@@ -102,6 +113,7 @@ public class MetricSchedule {
this.displayName = displayName;
}
+ @ApiProperty("The base unit of the metric")
public String getUnit() {
return unit;
}
@@ -110,6 +122,7 @@ public class MetricSchedule {
this.unit = unit;
}
+ @ApiProperty(value ="Type of metric", allowableValues = "MEASUREMENT, TRAIT, COMPLEX, CALLTIME, AVAILABILITY")
public String getType() {
return type;
}
@@ -122,6 +135,7 @@ public class MetricSchedule {
// return String.valueOf(enabled);
// }
+ @ApiProperty("Last modification timestamp of the schedule")
@XmlTransient
public long getMtime() {
return mtime;
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/NumericDataPoint.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/NumericDataPoint.java
index e1ef904..4223fe7 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/NumericDataPoint.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/NumericDataPoint.java
@@ -3,6 +3,9 @@ package org.rhq.enterprise.server.rest.domain;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlRootElement;
+import com.wordnik.swagger.annotations.ApiClass;
+import com.wordnik.swagger.annotations.ApiProperty;
+
/**
* One numerical data point of a schedule.
* This point does not contain the schedule id, as it is expected
@@ -13,6 +16,7 @@ import javax.xml.bind.annotation.XmlRootElement;
*
* @author Heiko W. Rupp
*/
+@ApiClass("One numerical data point of a metric (aka schedule)")
@XmlRootElement
public class NumericDataPoint {
@@ -36,16 +40,19 @@ public class NumericDataPoint {
this.value = value;
}
+ @ApiProperty("The timestamp when the metric was taken")
@XmlAttribute
public long getTimeStamp() {
return timeStamp;
}
+ @ApiProperty("The numerical value")
@XmlAttribute
public Double getValue() {
return value;
}
+ @ApiProperty("The id of the metric")
@XmlAttribute
public int getScheduleId() {
return scheduleId;
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/OperationDefinitionRest.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/OperationDefinitionRest.java
index 06cbbcf..2f5055c 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/OperationDefinitionRest.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/OperationDefinitionRest.java
@@ -8,9 +8,13 @@ import java.util.Map;
import javax.xml.bind.annotation.XmlElementRef;
import javax.xml.bind.annotation.XmlRootElement;
+import com.wordnik.swagger.annotations.ApiClass;
+import com.wordnik.swagger.annotations.ApiProperty;
+
/**
* @author Heiko W. Rupp
*/
+@ApiClass(value = "The template from which operations are created")
@XmlRootElement
public class OperationDefinitionRest {
@@ -22,6 +26,7 @@ public class OperationDefinitionRest {
List<Link> links = new ArrayList<Link>();
List<SimplePropDef> params = new ArrayList<SimplePropDef>();
+ @ApiProperty("Name of the definition")
public String getName() {
return name;
}
@@ -30,6 +35,7 @@ public class OperationDefinitionRest {
this.name = name;
}
+ @ApiProperty("Id of the definition")
public int getId() {
return id;
}
@@ -51,6 +57,7 @@ public class OperationDefinitionRest {
links.add(link);
}
+ @ApiProperty("List of properties for this operation definition")
public List<SimplePropDef> getParams() {
return params;
}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/OperationHistoryRest.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/OperationHistoryRest.java
index 10967df..1731601 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/OperationHistoryRest.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/OperationHistoryRest.java
@@ -25,10 +25,14 @@ import java.util.Map;
import javax.xml.bind.annotation.XmlRootElement;
+import com.wordnik.swagger.annotations.ApiClass;
+import com.wordnik.swagger.annotations.ApiProperty;
+
/**
* An operations history item
* @author Heiko W. Rupp
*/
+@ApiClass(value = "Denotes the outcome of an operation that has been scheduled to run.")
@XmlRootElement
public class OperationHistoryRest {
@@ -42,6 +46,7 @@ public class OperationHistoryRest {
Map<String,Object> result = new HashMap<String, Object>();
List<Link> links = new ArrayList<Link>();
+ @ApiProperty(value = "The status of the history", allowableValues = "In Progress, Cancelled, Failure, Success")
public String getStatus() {
return status;
}
@@ -50,6 +55,7 @@ public class OperationHistoryRest {
this.status = status;
}
+ @ApiProperty("Map with key/value pairs fo the operation result")
public Map<String, Object> getResult() {
return result;
}
@@ -58,6 +64,7 @@ public class OperationHistoryRest {
this.result = result;
}
+ @ApiProperty("Error message if the operation was not successful")
public String getErrorMessage() {
return errorMessage;
}
@@ -74,6 +81,7 @@ public class OperationHistoryRest {
this.links = links;
}
+ @ApiProperty("Name of the operation that was run")
public String getOperationName() {
return operationName;
}
@@ -82,6 +90,7 @@ public class OperationHistoryRest {
this.operationName = operationName;
}
+ @ApiProperty("Name of the resource the operation was run on")
public String getResourceName() {
return resourceName;
}
@@ -98,6 +107,7 @@ public class OperationHistoryRest {
this.lastModified = date;
}
+ @ApiProperty("Job-ID of this history item")
public String getJobId() {
return jobId;
}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/OperationRest.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/OperationRest.java
index 31f51dc..4cd3132 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/OperationRest.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/OperationRest.java
@@ -8,10 +8,17 @@ import java.util.Map;
import javax.xml.bind.annotation.XmlElementRef;
import javax.xml.bind.annotation.XmlRootElement;
+import com.wordnik.swagger.annotations.ApiClass;
+import com.wordnik.swagger.annotations.ApiProperty;
+
/**
* @author Heiko W. Rupp
*/
@XmlRootElement
+@ApiClass(value = "Represents an operation to be scheduled.",
+ description = "You use this object to prepare the operation to be scheduled. " +
+ "The object is derived from an OperationDefinition. When you are ready preparing," +
+ "you need to set 'readyToSubmit' to true.")
public class OperationRest {
int id;
@@ -30,6 +37,7 @@ public class OperationRest {
this.definitionId = definitionId;
}
+ @ApiProperty("Id of the operation schedule")
public int getId() {
return id;
}
@@ -38,6 +46,7 @@ public class OperationRest {
this.id = id;
}
+ @ApiProperty("Name of the operation")
public String getName() {
return name;
}
@@ -46,6 +55,7 @@ public class OperationRest {
this.name = name;
}
+ @ApiProperty("Is this schedule ready to finally be submitted (and thus be scheduled to run)")
public boolean isReadyToSubmit() {
return readyToSubmit;
}
@@ -54,6 +64,7 @@ public class OperationRest {
this.readyToSubmit = readyToSubmit;
}
+ @ApiProperty("The id of the resource the operation should run ")
public int getResourceId() {
return resourceId;
}
@@ -62,6 +73,7 @@ public class OperationRest {
this.resourceId = resourceId;
}
+ @ApiProperty("The id of the operation definition this schedule was created from")
public int getDefinitionId() {
return definitionId;
}
@@ -70,6 +82,8 @@ public class OperationRest {
this.definitionId = definitionId;
}
+ @ApiProperty("A key/value map of parameters. Keys are strings. The map is populated at the time the " +
+ "schedule is created from its definition")
public Map<String, Object> getParams() {
return params;
}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/ResourceWithChildren.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/ResourceWithChildren.java
index 3389493..2f4f699 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/ResourceWithChildren.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/ResourceWithChildren.java
@@ -23,10 +23,14 @@ import java.util.List;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
+import com.wordnik.swagger.annotations.ApiClass;
+import com.wordnik.swagger.annotations.ApiProperty;
+
/**
* A lightweight resource with a list of children
* @author Heiko W. Rupp
*/
+@ApiClass("One resource with its direct child resources")
@XmlRootElement
public class ResourceWithChildren {
@@ -42,16 +46,19 @@ public class ResourceWithChildren {
this.name = name;
}
+ @ApiProperty("Id of the resource")
@XmlElement
public String getId() {
return id;
}
+ @ApiProperty("Name of the resource")
@XmlElement
public String getName() {
return name;
}
+ @ApiProperty("List of child resources")
@XmlElement
public List<ResourceWithChildren> getChildren() {
return children;
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/ResourceWithType.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/ResourceWithType.java
index 10030a9..6b9aace 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/ResourceWithType.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/ResourceWithType.java
@@ -33,17 +33,17 @@ import javax.xml.bind.annotation.XmlElementRef;
import javax.xml.bind.annotation.XmlID;
import javax.xml.bind.annotation.XmlRootElement;
+import com.wordnik.swagger.annotations.ApiClass;
+import com.wordnik.swagger.annotations.ApiProperty;
+
import org.jboss.resteasy.spi.touri.URITemplate;
/**
* A (partial) resource with some type information
* @author Heiko W. Rupp
*/
+@ApiClass("One resource")
@XmlRootElement(name="resource")
-/*
-(a)XmlAccessorType(XmlAccessType.NONE)
-@URITemplate("{id}")
-*/
public class ResourceWithType {
String resourceName;
@@ -67,6 +67,7 @@ public class ResourceWithType {
this.resourceId = id;
}
+ @ApiProperty("Name of the resource")
@XmlElement
public String getResourceName() {
return resourceName;
@@ -76,6 +77,7 @@ public class ResourceWithType {
this.resourceName = resourceName;
}
+ @ApiProperty("ID of the resource")
@XmlID
public String getResourceId() {
return String.valueOf(resourceId);
@@ -85,6 +87,7 @@ public class ResourceWithType {
this.resourceId = resourceId;
}
+ @ApiProperty("Name of the resource type of teh resource")
@XmlElement
public String getTypeName() {
return typeName;
@@ -94,6 +97,7 @@ public class ResourceWithType {
this.typeName = typeName;
}
+ @ApiProperty("Id of the resource type of the resource")
@XmlElement
public Integer getTypeId() {
return typeId;
@@ -103,6 +107,7 @@ public class ResourceWithType {
this.typeId = typeId;
}
+ @ApiProperty("Name of the plugin defining the resource type")
@XmlElement
public String getPluginName() {
return pluginName;
@@ -112,6 +117,7 @@ public class ResourceWithType {
this.pluginName = pluginName;
}
+ @ApiProperty("Id of the parent resource. Can be null if there is no parent (i.e. the category is platform")
public Integer getParentId() {
return parentId;
}
@@ -137,6 +143,7 @@ public class ResourceWithType {
this.ancestry = ancestry;
}
+ @ApiProperty("The ancestry gives the path to the root resource")
public String getAncestry() {
return ancestry;
}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/SimplePropDef.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/SimplePropDef.java
index 08527fd..e4ebe24 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/SimplePropDef.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/SimplePropDef.java
@@ -21,12 +21,16 @@ package org.rhq.enterprise.server.rest.domain;
import javax.xml.bind.annotation.XmlRootElement;
+import com.wordnik.swagger.annotations.ApiClass;
+import com.wordnik.swagger.annotations.ApiProperty;
+
import org.rhq.core.domain.configuration.definition.PropertySimpleType;
/**
* Simple property definition
* @author Heiko W. Rupp
*/
+@ApiClass(value = "A simple property definition", description = "This bean is e.g. used for parameters of operations")
@XmlRootElement
public class SimplePropDef {
@@ -38,6 +42,7 @@ public class SimplePropDef {
public SimplePropDef() {
}
+ @ApiProperty("The name of the property")
public String getName() {
return name;
}
@@ -46,6 +51,7 @@ public class SimplePropDef {
this.name = name;
}
+ @ApiProperty("Indicates if the property is required i.e. has to have a value set")
public boolean isRequired() {
return required;
}
@@ -54,6 +60,8 @@ public class SimplePropDef {
this.required = required;
}
+ @ApiProperty(value = "The type of the property",
+ allowableValues = "STRING, LONG_STRING, PASSWORD, BOOLEAN, INTEGER, LONG, FLOAT, DOUBLE, FILE, DIRECTORY")
public PropertySimpleType getType() {
return type;
}
@@ -62,6 +70,7 @@ public class SimplePropDef {
this.type = type;
}
+ @ApiProperty("The string representation of a default value if defined.")
public String getDefaultValue() {
return defaultValue;
}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/Status.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/Status.java
index dfb64ab..63db3ee 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/Status.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/Status.java
@@ -23,10 +23,14 @@ import java.util.Map;
import javax.xml.bind.annotation.XmlRootElement;
+import com.wordnik.swagger.annotations.ApiClass;
+import com.wordnik.swagger.annotations.ApiProperty;
+
/**
* System status
* @author Heiko W. Rupp
*/
+@ApiClass("Place holder for the system status")
@XmlRootElement
public class Status {
@@ -34,6 +38,7 @@ public class Status {
public Status() {
}
+ @ApiProperty("Contains the status as a map of key/value pairs")
public Map<String, String> getValues() {
return values;
}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/StringValue.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/StringValue.java
index 64ceb70..dde8648 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/StringValue.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/StringValue.java
@@ -2,10 +2,14 @@ package org.rhq.enterprise.server.rest.domain;
import javax.xml.bind.annotation.XmlRootElement;
+import com.wordnik.swagger.annotations.ApiClass;
+import com.wordnik.swagger.annotations.ApiProperty;
+
/**
* Encapsulate a simple string value
* @author Heiko W. Rupp
*/
+@ApiClass("Encapsulates a simple string value")
@XmlRootElement
public class StringValue {
@@ -18,6 +22,7 @@ public class StringValue {
this.value = value;
}
+ @ApiProperty("The actual value")
public String getValue() {
return value;
}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/UserRest.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/UserRest.java
index 4cf9f70..727df3f 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/UserRest.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/UserRest.java
@@ -21,10 +21,14 @@ package org.rhq.enterprise.server.rest.domain;
import javax.xml.bind.annotation.XmlRootElement;
+import com.wordnik.swagger.annotations.ApiClass;
+import com.wordnik.swagger.annotations.ApiProperty;
+
/**
* A user
* @author Heiko W. Rupp
*/
+@ApiClass("Information about a user in RHQ")
@XmlRootElement
public class UserRest {
@@ -43,6 +47,7 @@ public class UserRest {
this.login = login;
}
+ @ApiProperty("The ID of the user")
public int getId() {
return id;
}
@@ -51,6 +56,7 @@ public class UserRest {
this.id = id;
}
+ @ApiProperty("The login name of the user")
public String getLogin() {
return login;
}
@@ -59,6 +65,7 @@ public class UserRest {
this.login = login;
}
+ @ApiProperty("The telephone number of the user")
public String getTel() {
return tel;
}
@@ -67,6 +74,7 @@ public class UserRest {
this.tel = tel;
}
+ @ApiProperty("The email address of the user")
public String getEmail() {
return email;
}
@@ -75,6 +83,7 @@ public class UserRest {
this.email = email;
}
+ @ApiProperty("The first name of the user")
public String getFirstName() {
return firstName;
}
@@ -83,6 +92,7 @@ public class UserRest {
this.firstName = firstName;
}
+ @ApiProperty("The last name of the user")
public String getLastName() {
return lastName;
}
commit b35fce00583384f57400a02409316ca76d440548
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Wed Oct 24 14:10:43 2012 +0200
Make the rest docs generator understand the new @ApiClass annotation.
diff --git a/modules/helpers/rest-docs-generator/pom.xml b/modules/helpers/rest-docs-generator/pom.xml
index 6bf8167..af3374f 100644
--- a/modules/helpers/rest-docs-generator/pom.xml
+++ b/modules/helpers/rest-docs-generator/pom.xml
@@ -146,7 +146,7 @@
<dependency>
<groupId>com.wordnik</groupId>
<artifactId>swagger-annotations_2.9.1</artifactId>
- <version>1.1-SNAPSHOT</version>
+ <version>1.1.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.jboss.resteasy</groupId>
diff --git a/modules/helpers/rest-docs-generator/src/main/java/org/rhq/helpers/rest_docs_generator/ClassLevelProcessor.java b/modules/helpers/rest-docs-generator/src/main/java/org/rhq/helpers/rest_docs_generator/ClassLevelProcessor.java
index 1d6c913..c10dd62 100644
--- a/modules/helpers/rest-docs-generator/src/main/java/org/rhq/helpers/rest_docs_generator/ClassLevelProcessor.java
+++ b/modules/helpers/rest-docs-generator/src/main/java/org/rhq/helpers/rest_docs_generator/ClassLevelProcessor.java
@@ -38,6 +38,7 @@ import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
import com.wordnik.swagger.annotations.Api;
+import com.wordnik.swagger.annotations.ApiClass;
import com.wordnik.swagger.annotations.ApiError;
import com.wordnik.swagger.annotations.ApiErrors;
import com.wordnik.swagger.annotations.ApiOperation;
@@ -170,7 +171,7 @@ public class ClassLevelProcessor extends AbstractProcessor {
log.debug("Looking at " + classElementIn.getQualifiedName().toString());
// Process the data classes
- if (classElementIn.getAnnotation(XmlRootElement.class)!=null) {
+ if (classElementIn.getAnnotation(ApiClass.class)!=null) {
processDataClass(doc, classElementIn, xmlRoot);
return;
}
@@ -367,13 +368,23 @@ public class ClassLevelProcessor extends AbstractProcessor {
Element elem = doc.createElement("data");
xmlRoot.appendChild(elem);
elem.setAttribute("name",classElementIn.getSimpleName().toString());
- Api api = classElementIn.getAnnotation(Api.class);
+ ApiClass api = classElementIn.getAnnotation(ApiClass.class);
if (api!=null) {
elem.setAttribute("abstract",api.value());
if (api.description()!=null && !api.description().isEmpty()) {
elem.setAttribute("description",api.description());
}
}
+ // Determine the name of how the elements of this class are named in the XML / JSON output
+ XmlRootElement rootElement = classElementIn.getAnnotation(XmlRootElement.class);
+ String objectName;
+ if (rootElement!=null) {
+ objectName = rootElement.name();
+ }
+ else {
+ objectName = classElementIn.getSimpleName().toString();
+ }
+ elem.setAttribute("objectName",objectName);
processDataClassProperties(doc, classElementIn, elem);
}
commit b4e1846e8434eab8810fc97ae6c35bcf6e54ecde
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Wed Oct 10 09:00:05 2012 +0200
Follow up with the changes to SenderResult()
diff --git a/modules/enterprise/server/plugins/alert-sms/src/main/java/org/rhq/enterprise/server/plugins/alertSms/SmsSender.java b/modules/enterprise/server/plugins/alert-sms/src/main/java/org/rhq/enterprise/server/plugins/alertSms/SmsSender.java
index a3966be..65bde82 100644
--- a/modules/enterprise/server/plugins/alert-sms/src/main/java/org/rhq/enterprise/server/plugins/alertSms/SmsSender.java
+++ b/modules/enterprise/server/plugins/alert-sms/src/main/java/org/rhq/enterprise/server/plugins/alertSms/SmsSender.java
@@ -1,6 +1,6 @@
/*
* RHQ Management Platform
- * Copyright (C) 2005-2009 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
@@ -43,7 +43,6 @@ import org.jboss.resteasy.client.ClientResponse;
import org.jboss.resteasy.client.core.executors.ApacheHttpClientExecutor;
import org.rhq.core.domain.alert.Alert;
-import org.rhq.core.domain.alert.notification.ResultState;
import org.rhq.core.domain.alert.notification.SenderResult;
import org.rhq.core.domain.configuration.PropertySimple;
import org.rhq.core.domain.resource.Resource;
@@ -58,7 +57,6 @@ import org.rhq.enterprise.server.util.LookupUtil;
public class SmsSender extends AlertSender {
private final Log log = LogFactory.getLog(SmsSender.class);
- private long TWO_MINUTES = 1000L * 60L * 2L;
private static final String DEVGARDEN_SMS_GW = "https://gateway.developer.telekom.com/p3gw-mod-odg-sms/rest";
private static final String DEVGARDEN_SECURE_TOKEN_SERVER = "https://sts.idm.telekom.com/rest-v1/tokens/odg";
private static final String TOKEN_EXPIRY_TIME = "token-expiry-time";
@@ -67,11 +65,13 @@ public class SmsSender extends AlertSender {
@Override
public SenderResult send(Alert alert) {
- String token = null;
+ String token;
try {
token = getToken();
} catch (Exception e) {
- return new SenderResult(ResultState.FAILURE, "Can not obtain token: " + e.getMessage());
+ SenderResult senderResult = new SenderResult();
+ senderResult.addFailureMessage("Can not obtain token: " + e.getMessage());
+ return senderResult;
}
Resource res = alert.getAlertDefinition().getResource();
@@ -87,10 +87,15 @@ public class SmsSender extends AlertSender {
try {
sendAlertSms(token,b.toString());
} catch (Exception e) {
- return new SenderResult(ResultState.FAILURE, "Failed to send SMS: " + e.getMessage());
+ SenderResult senderResult = new SenderResult();
+ senderResult.addFailureMessage("Failed to send SMS: " + e.getMessage());
+ return senderResult;
}
- return new SenderResult(ResultState.SUCCESS, "SMS sent");
+ SenderResult senderResult = new SenderResult();
+ String tel = alertParameters.getSimpleValue("tel",null);
+ senderResult.addSuccessMessage("SMS to " + tel + " sent");
+ return senderResult;
}
/**
@@ -118,15 +123,14 @@ public class SmsSender extends AlertSender {
try {
ClientResponse resp = req.post(String.class);
if (resp.getStatus()==200) {
- System.out.println(resp.getEntity());
+ log.debug(resp.getEntity());
}
else {
- System.out.println("Fehler " + resp.getStatus());
- System.out.println(resp.getEntity());
+ log.warn("Error while sending SMS " + resp.getStatus());
+ log.debug(resp.getEntity());
throw new RuntimeException((String) resp.getEntity());
}
} catch (Exception e) {
- e.printStackTrace(); // TODO: Customise this generated block
throw (e);
}
@@ -146,7 +150,8 @@ public class SmsSender extends AlertSender {
if (tokenTimeProp!=null)
tokenExpTime = tokenTimeProp.getLongValue();
- if (token == null || tokenExpTime == null || tokenExpTime < System.currentTimeMillis() + TWO_MINUTES ) {
+ long TWO_MINUTES = 1000L * 60L * 2L;
+ if (token == null || tokenExpTime == null || tokenExpTime < System.currentTimeMillis() + TWO_MINUTES) {
String userId = preferences.getSimpleValue("login",null);
String password = preferences.getSimpleValue("password",null);
@@ -172,7 +177,7 @@ public class SmsSender extends AlertSender {
ClientResponse resp = request.get(String.class);
// TODO check status
- System.out.println(resp.getStatus());
+ log.debug(resp.getStatus());
String response = (String) resp.getEntity();
BufferedReader reader = new BufferedReader(new StringReader(response));
while (reader.ready()) {
@@ -182,7 +187,7 @@ public class SmsSender extends AlertSender {
break;
}
}
- System.out.println("Token: " + token);
+ log.debug("Token: " + token);
MultivaluedMap<String, List> headers = resp.getHeaders();
List expiresList = headers.get("Expires");
String expires = (String) expiresList.get(0);
@@ -207,7 +212,7 @@ public class SmsSender extends AlertSender {
mgr.mergeConfiguration(preferences);
} catch (Exception e) {
- e.printStackTrace(); // TODO: Customise this generated block
+ log.error("Error while retrieving a token: " + e.getMessage());
throw e;
}
}
11 years, 6 months
[rhq] modules/core modules/enterprise
by John Sanda
modules/core/domain/src/main/java/org/rhq/core/domain/resource/ResourceType.java | 3 -
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/discovery/DeletedResourceTypeFilter.java | 24 ++++++++-
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/discovery/DiscoveryBossBean.java | 13 ++++-
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/discovery/DiscoveryServerServiceImpl.java | 6 ++
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/discovery/InventoryReportFilter.java | 9 ---
modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/discovery/DeletedResourceTypeFilterTest.java | 26 +++++-----
6 files changed, 57 insertions(+), 24 deletions(-)
New commits:
commit c5c722c853ca0d99d30dda4c9b7c50dee6476640
Author: John Sanda <jsanda(a)redhat.com>
Date: Mon Oct 22 17:09:41 2012 -0400
[BZ 869015] Add more detail logging when handling inventory report with stale types
This commit contains a few changes:
* Add logging in DiscoveryBossBean when inventory report contains deleted types
There is detailed log statements that include both the deleted resource types
as well as the agent sending the report.
* Remove ERROR log statement from DiscoveryServerServiceImpl
No need to log the exception since it is not an error. We just want to throw
the exception back to the agent so it knows to resync its plugins.
* Revert ResourceType.toString
Not sure why but in commit bb2b881045 was changed. The version prior to that
commit was already concise yet detailed and specific. I have reverted back
to that version.
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/ResourceType.java b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/ResourceType.java
index bf36ee0..ee2586d 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/ResourceType.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/ResourceType.java
@@ -906,7 +906,8 @@ public class ResourceType implements Serializable, Comparable<ResourceType> {
@Override
public String toString() {
- return "{" + this.plugin + "}" + this.name;
+ return "ResourceType[id=" + this.id + ", name=" + this.name + ", plugin=" + this.plugin +
+ ", category=" + this.category + "]";
}
}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/discovery/DeletedResourceTypeFilter.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/discovery/DeletedResourceTypeFilter.java
index 42106ae..c2371bd 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/discovery/DeletedResourceTypeFilter.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/discovery/DeletedResourceTypeFilter.java
@@ -15,7 +15,7 @@ import org.rhq.enterprise.server.auth.SubjectManagerLocal;
import org.rhq.enterprise.server.resource.ResourceTypeManagerLocal;
import org.rhq.enterprise.server.resource.metadata.PluginManagerLocal;
-public class DeletedResourceTypeFilter implements InventoryReportFilter {
+public class DeletedResourceTypeFilter {
private SubjectManagerLocal subjectMgr;
@@ -77,6 +77,28 @@ public class DeletedResourceTypeFilter implements InventoryReportFilter {
return true;
}
+ public Set<ResourceType> apply(InventoryReport report) {
+ Set<ResourceType> resourceTypes = getResourceTypes(report.getAddedRoots());
+ Set<ResourceType> staleTypes = new HashSet<ResourceType>();
+
+ for (ResourceType type : resourceTypes) {
+ // We check two things to determine whether a report should be rejected. First we check
+ // that the plugin from which the type comes is installed. We check that the plugin is
+ // installed as opposed to checking that it is deleted because the plugin could also
+ // be purged in which case checking against deleted plugins wouldn't catch it. Secondly,
+ // we check to see if the type is a deleted type. Here we check against deleted types
+ // instead of installed types because the number of deleted types at any given time
+ // should be much smaller than the number of installed types, resulting in faster look
+ // ups. If we have a stale type in the report and that type has already been purged from
+ // the database, it will get flagged by the check against installed plugins.
+ if (!installedPlugins.contains(type.getPlugin()) ||
+ deletedTypes.contains(type.getName() + "::" + type.getPlugin())) {
+ staleTypes.add(type);
+ }
+ }
+ return staleTypes;
+ }
+
private Set<ResourceType> getResourceTypes(Set<Resource> resources) {
Set<ResourceType> types = new HashSet<ResourceType>();
for (Resource resource : resources) {
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/discovery/DiscoveryBossBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/discovery/DiscoveryBossBean.java
index 2511d28..ded24ce 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/discovery/DiscoveryBossBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/discovery/DiscoveryBossBean.java
@@ -139,8 +139,17 @@ public class DiscoveryBossBean implements DiscoveryBossLocal, DiscoveryBossRemot
public ResourceSyncInfo mergeInventoryReport(InventoryReport report) throws InvalidInventoryReportException {
validateInventoryReport(report);
- InventoryReportFilter filter = new DeletedResourceTypeFilter(subjectManager, resourceTypeManager, pluginManager);
- if (!filter.accept(report)) {
+ DeletedResourceTypeFilter filter = new DeletedResourceTypeFilter(subjectManager, resourceTypeManager, pluginManager);
+ Set<ResourceType> deletedTypes = filter.apply(report);
+
+ if (!deletedTypes.isEmpty()) {
+ if (log.isDebugEnabled()) {
+ log.debug("The inventory report from " + report.getAgent() + " with added roots " +
+ report.getAddedRoots() + " contains these deleted resource types " + deletedTypes);
+ } else {
+ log.info("The inventory report from " + report.getAgent() + " contains these deleted resource types " +
+ deletedTypes);
+ }
throw new StaleTypeException("The report contains one or more resource types that have been marked for "
+ "deletion.");
}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/discovery/DiscoveryServerServiceImpl.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/discovery/DiscoveryServerServiceImpl.java
index 153144a..75d97f7 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/discovery/DiscoveryServerServiceImpl.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/discovery/DiscoveryServerServiceImpl.java
@@ -73,6 +73,12 @@ public class DiscoveryServerServiceImpl implements DiscoveryServerService {
ResourceSyncInfo syncInfo;
try {
syncInfo = discoveryBoss.mergeInventoryReport(report);
+ } catch (StaleTypeException e) {
+ // There is no need to log this exception as it is part of a normal work flow
+ // that occurs as a result of a user deleting a plugin. DiscoveryBossBean
+ // already logs a message about the stale types that can be useful for
+ // debugging; so, we just need to propagate the exception to the agent.
+ throw e;
} catch (InvalidInventoryReportException e) {
Agent agent = report.getAgent();
if (log.isDebugEnabled()) {
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/discovery/InventoryReportFilter.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/discovery/InventoryReportFilter.java
deleted file mode 100644
index 78ac3e1..0000000
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/discovery/InventoryReportFilter.java
+++ /dev/null
@@ -1,9 +0,0 @@
-package org.rhq.enterprise.server.discovery;
-
-import org.rhq.core.clientapi.server.discovery.InventoryReport;
-
-public interface InventoryReportFilter {
-
- boolean accept(InventoryReport report);
-
-}
diff --git a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/discovery/DeletedResourceTypeFilterTest.java b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/discovery/DeletedResourceTypeFilterTest.java
index 1c3dc7d..c0ac4a1 100644
--- a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/discovery/DeletedResourceTypeFilterTest.java
+++ b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/discovery/DeletedResourceTypeFilterTest.java
@@ -1,5 +1,9 @@
package org.rhq.enterprise.server.discovery;
+import static org.rhq.test.AssertUtils.assertCollectionEqualsNoOrder;
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertTrue;
+
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
@@ -7,19 +11,17 @@ import java.util.List;
import java.util.Set;
import org.jmock.Expectations;
-
-import org.rhq.core.domain.plugin.Plugin;
-import org.rhq.core.domain.resource.Resource;
-import org.rhq.core.domain.resource.ResourceCategory;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import org.rhq.core.clientapi.server.discovery.InventoryReport;
import org.rhq.core.domain.auth.Subject;
import org.rhq.core.domain.criteria.ResourceTypeCriteria;
+import org.rhq.core.domain.plugin.Plugin;
import org.rhq.core.domain.resource.Agent;
-import org.rhq.core.domain.shared.ResourceBuilder;
+import org.rhq.core.domain.resource.Resource;
import org.rhq.core.domain.resource.ResourceType;
+import org.rhq.core.domain.shared.ResourceBuilder;
import org.rhq.core.domain.shared.ResourceTypeBuilder;
import org.rhq.core.domain.util.PageList;
import org.rhq.enterprise.server.auth.SubjectManagerLocal;
@@ -27,8 +29,6 @@ import org.rhq.enterprise.server.resource.ResourceTypeManagerLocal;
import org.rhq.enterprise.server.resource.metadata.PluginManagerLocal;
import org.rhq.test.JMockTest;
-import static org.testng.Assert.*;
-
public class DeletedResourceTypeFilterTest extends JMockTest {
SubjectManagerLocal subjectMgr;
@@ -74,8 +74,9 @@ public class DeletedResourceTypeFilterTest extends JMockTest {
filter = new DeletedResourceTypeFilter(subjectMgr, resourceTypeMgr, pluginMgr);
- assertTrue(filter.accept(report), "Expected report to be accepted when it does not contain any deleted " +
- "resource types");
+ Set<ResourceType> staleTypes = filter.apply(report);
+ assertTrue(staleTypes.isEmpty(), "Expected filter to return empty set when report does not contain any " +
+ "deleted resource types, but filter returned " + staleTypes);
}
@Test
@@ -119,8 +120,10 @@ public class DeletedResourceTypeFilterTest extends JMockTest {
}});
filter = new DeletedResourceTypeFilter(subjectMgr, resourceTypeMgr, pluginMgr);
+ Set<ResourceType> staleTypes = filter.apply(report);
- assertFalse(filter.accept(report), "Expected report to be rejected since it contains deleted resource types");
+ assertCollectionEqualsNoOrder(staleTypes, deletedTypes, "Expected report to be rejected since it contains " +
+ "deleted resource types");
}
@Test
@@ -157,7 +160,8 @@ public class DeletedResourceTypeFilterTest extends JMockTest {
filter = new DeletedResourceTypeFilter(subjectMgr, resourceTypeMgr, pluginMgr);
- assertFalse(filter.accept(report), "Expected report to be rejected since it contains a deleted plugin");
+ assertFalse(filter.apply(report).isEmpty(), "Expected filter to return non-empty since it contains a deleted " +
+ "plugin but empty set was returned");
}
InventoryReport createReport() {
11 years, 6 months