[rhq] Branch 'feature/cassandra-backend' - modules/common modules/enterprise
by John Sanda
modules/common/cassandra-schema/src/main/java/org/rhq/cassandra/schema/SchemaManager.java | 12 ++
modules/enterprise/server/appserver/src/main/scripts/rhq-container.build.xml | 32 -------
modules/enterprise/server/installer/pom.xml | 6 +
modules/enterprise/server/installer/src/main/java/org/rhq/enterprise/server/installer/InstallerServiceImpl.java | 37 ++++++++-
modules/enterprise/server/installer/src/main/java/org/rhq/enterprise/server/installer/ServerInstallUtil.java | 41 ----------
5 files changed, 54 insertions(+), 74 deletions(-)
New commits:
commit e184c7f8004d62cadbe9447eb3ec63c49486c64b
Author: John Sanda <jsanda(a)redhat.com>
Date: Fri Dec 14 16:47:31 2012 -0500
Updating installer logic to be consistent with what we do for the RDBMS
This commit adds logic to support the rhq.autoinstall.database property like we
already do for the RDBMS. Also remove the Cassandra data source module from the
container build.
diff --git a/modules/common/cassandra-schema/src/main/java/org/rhq/cassandra/schema/SchemaManager.java b/modules/common/cassandra-schema/src/main/java/org/rhq/cassandra/schema/SchemaManager.java
index 77a3b30..ecc6a5f 100644
--- a/modules/common/cassandra-schema/src/main/java/org/rhq/cassandra/schema/SchemaManager.java
+++ b/modules/common/cassandra-schema/src/main/java/org/rhq/cassandra/schema/SchemaManager.java
@@ -83,6 +83,14 @@ public class SchemaManager {
}
}
+ public void dropSchema() {
+ try {
+ session.execute("DROP KEYSPACE rhq");
+ } catch (NoHostAvailableException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
public boolean schemaExists() {
try {
String cql = "SELECT keyspace_name FROM schema_keyspaces WHERE keyspace_name = 'rhq'";
@@ -102,6 +110,10 @@ public class SchemaManager {
}
}
+ public void shutdown() {
+ session.getCluster().shutdown();
+ }
+
private void runLiquibase(Database database) {
try {
ClassLoaderResourceAccessor resourceAccessor = new ClassLoaderResourceAccessor();
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 2ed5f96..4bb37fb 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
@@ -186,38 +186,6 @@
</module>
]]></echo>
- <echo>Adding Cassandra JDBC module to ${jboss.modules.dir}...</echo>
- <copy file="${settings.localRepository}/org/apache-extras/cassandra-jdbc/cassandra-jdbc/${cassandra.jdbc.version}/cassandra-jdbc-${cassandra.jdbc.version}.jar"
- toDir="${jboss.modules.dir}/org/apache-extras/cassandra-jdbc/main" failonerror="false" verbose="true"/>
- <copy file="${settings.localRepository}/org/apache/cassandra/cassandra-clientutil/${cassandra.version}/cassandra-clientutil-${cassandra.version}.jar"
- toDir="${jboss.modules.dir}/org/apache-extras/cassandra-jdbc/main" failonerror="false" verbose="true"/>
- <copy file="${settings.localRepository}/org/apache/cassandra/cassandra-thrift/${cassandra.version}/cassandra-thrift-${cassandra.version}.jar"
- toDir="${jboss.modules.dir}/org/apache-extras/cassandra-jdbc/main" failonerror="false" verbose="true"/>
- <copy file="${settings.localRepository}/org/apache/thrift/libthrift/${cassandra.thrift.version}/libthrift-${cassandra.thrift.version}.jar"
- toDir="${jboss.modules.dir}/org/apache-extras/cassandra-jdbc/main" failonerror="false" verbose="true"/>
- <copy file="${settings.localRepository}/com/google/guava/guava/${cassandra.jdbc.guava.version}/guava-${cassandra.jdbc.guava.version}.jar"
- 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"?>
-<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.version}.jar"/>
- <resource-root path="jsr305-${cassandra.jdbc.jsr305.version}.jar"/>
- <resource-root path="guava-${cassandra.jdbc.guava.version}.jar"/>
- </resources>
-
- <dependencies>
- <module name="org.slf4j"/>
- <module name="org.apache.commons.lang"/>
- </dependencies>
-</module>
-]]>
- </echo>
-
<copy file="${settings.localRepository}/postgresql/postgresql/${postgresql.version}/postgresql-${postgresql.version}.jar"
toDir="${jboss.modules.dir}/org/rhq/postgres/main" verbose="true" />
<echo file="${jboss.modules.dir}/org/rhq/postgres/main/module.xml"><![CDATA[<?xml version="1.0" encoding="UTF-8"?>
diff --git a/modules/enterprise/server/installer/pom.xml b/modules/enterprise/server/installer/pom.xml
index 266da75..defb78e 100644
--- a/modules/enterprise/server/installer/pom.xml
+++ b/modules/enterprise/server/installer/pom.xml
@@ -85,6 +85,12 @@
<artifactId>i18nlog</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.jboss.spec.javax.annotation</groupId>
+ <artifactId>jboss-annotations-api_1.1_spec</artifactId>
+ <scope>provided</scope>
+ </dependency>
+
<!-- test deps -->
<dependency>
<groupId>org.mockito</groupId>
diff --git a/modules/enterprise/server/installer/src/main/java/org/rhq/enterprise/server/installer/InstallerServiceImpl.java b/modules/enterprise/server/installer/src/main/java/org/rhq/enterprise/server/installer/InstallerServiceImpl.java
index 6e32e89..a8cc8df 100644
--- a/modules/enterprise/server/installer/src/main/java/org/rhq/enterprise/server/installer/InstallerServiceImpl.java
+++ b/modules/enterprise/server/installer/src/main/java/org/rhq/enterprise/server/installer/InstallerServiceImpl.java
@@ -33,6 +33,7 @@ import org.apache.commons.logging.LogFactory;
import org.jboss.as.controller.client.ModelControllerClient;
+import org.rhq.cassandra.schema.SchemaManager;
import org.rhq.common.jbossas.client.controller.CoreJBossASClient;
import org.rhq.common.jbossas.client.controller.DeploymentJBossASClient;
import org.rhq.common.jbossas.client.controller.WebJBossASClient;
@@ -366,7 +367,6 @@ public class InstallerServiceImpl implements InstallerService {
log("Database schema exists - it will now be updated.");
ServerInstallUtil.upgradeExistingDatabaseSchema(serverProperties, serverDetails,
clearTextDbPassword, getLogDir());
- ServerInstallUtil.installOrUpdateCassandraSchema(serverProperties);
}
} else {
log("Database schema does not yet exist - it will now be created.");
@@ -380,6 +380,33 @@ public class InstallerServiceImpl implements InstallerService {
throw new Exception("Could not complete the database schema installation", e);
}
+ SchemaManager cassandraSchemaManager = null;
+ try {
+ cassandraSchemaManager = createCassandraSchemaManager(serverProperties);
+ if (ExistingSchemaOption.SKIP != existingSchemaOptionEnum) {
+ if (cassandraSchemaManager.schemaExists()) {
+ if (ExistingSchemaOption.OVERWRITE == existingSchemaOptionEnum) {
+ log("Cassandra schema exists but installer was told to overwrite it - a new schema will be " +
+ "created now.");
+ cassandraSchemaManager.dropSchema();
+ cassandraSchemaManager.createSchema();
+
+ }
+ log("Updating Cassandra schema.");
+ cassandraSchemaManager.updateSchema();
+ } else {
+ cassandraSchemaManager.createSchema();
+ cassandraSchemaManager.updateSchema();
+ }
+ } else {
+ log("Ignoring Cassandra schema - installer will assume it exists and is already up-to-date.");
+ }
+ } catch (Exception e) {
+ throw new Exception("Could not complete Cassandra schema installation.", e);
+ } finally {
+ cassandraSchemaManager.shutdown();
+ }
+
// ensure the server info is up to date and stored in the DB
ServerInstallUtil.storeServerDetails(serverProperties, clearTextDbPassword, serverDetails);
@@ -987,4 +1014,12 @@ public class InstallerServiceImpl implements InstallerService {
safeClose(mcc);
}
}
+
+ private SchemaManager createCassandraSchemaManager(HashMap<String, String> serverProps) {
+ String[] hosts = serverProps.get("rhq.cassandra.cluster.seeds").split(",");
+ String username = serverProps.get("rhq.cassandra.username");
+ String password = serverProps.get("rhq.cassandra.password");
+
+ return new SchemaManager(username, password, hosts);
+ }
}
diff --git a/modules/enterprise/server/installer/src/main/java/org/rhq/enterprise/server/installer/ServerInstallUtil.java b/modules/enterprise/server/installer/src/main/java/org/rhq/enterprise/server/installer/ServerInstallUtil.java
index 794c482..531bfa6 100644
--- a/modules/enterprise/server/installer/src/main/java/org/rhq/enterprise/server/installer/ServerInstallUtil.java
+++ b/modules/enterprise/server/installer/src/main/java/org/rhq/enterprise/server/installer/ServerInstallUtil.java
@@ -46,7 +46,6 @@ import org.apache.tools.ant.helper.ProjectHelper2;
import org.jboss.as.controller.client.ModelControllerClient;
import org.jboss.dmr.ModelNode;
-import org.rhq.cassandra.schema.SchemaManager;
import org.rhq.common.jbossas.client.controller.Address;
import org.rhq.common.jbossas.client.controller.CoreJBossASClient;
import org.rhq.common.jbossas.client.controller.DatasourceJBossASClient;
@@ -131,12 +130,10 @@ 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";
@@ -403,8 +400,6 @@ 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", 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
@@ -465,13 +460,6 @@ 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
}
-
-// 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");
-// }
}
/**
@@ -497,8 +485,6 @@ 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");
final DatasourceJBossASClient client = new DatasourceJBossASClient(mcc);
@@ -552,21 +538,6 @@ 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);
@@ -1055,18 +1026,6 @@ public class ServerInstallUtil {
return;
}
- public static void installOrUpdateCassandraSchema(HashMap<String, String> props) {
- String[] hosts = props.get("rhq.cassandra.cluster.seeds").split(",");
- String username = props.get("rhq.cassandra.username");
- String password = props.get("rhq.cassandra.password");
-
- SchemaManager schemaManager = new SchemaManager(username, password, hosts);
- if (!schemaManager.schemaExists()) {
- schemaManager.createSchema();
- }
- schemaManager.updateSchema();
- }
-
/**
* Given a server property value string, returns true if it is not specified.
*
11 years, 5 months
[rhq] Branch 'feature/cassandra-backend' - 4 commits - modules/common modules/enterprise
by John Sanda
modules/common/cassandra-common/pom.xml | 6
modules/common/cassandra-common/src/main/java/org/rhq/cassandra/BootstrapDeployer.java | 92 -----
modules/common/cassandra-schema/pom.xml | 6
modules/common/cassandra-schema/src/main/java/org/rhq/cassandra/schema/SchemaManager.java | 129 +++++++
modules/enterprise/server/appserver/src/main/scripts/rhq-container.build.xml | 24 -
modules/enterprise/server/installer/pom.xml | 162 ++++++++++
modules/enterprise/server/installer/src/main/java/org/rhq/enterprise/server/installer/InstallerServiceImpl.java | 1
modules/enterprise/server/installer/src/main/java/org/rhq/enterprise/server/installer/ServerInstallUtil.java | 59 ++-
modules/enterprise/server/installer/src/main/resources/module/main/module.xml | 23 +
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cassandra/CassandraClusterManagerBean.java | 8
10 files changed, 380 insertions(+), 130 deletions(-)
New commits:
commit ef64ac9986d58c171ebac30e1ddb894c10ec5255
Author: John Sanda <jsanda(a)redhat.com>
Date: Fri Dec 14 14:06:41 2012 -0500
first cut at integrating cassandra into new installer
This is the first of what will be several commits for integrating with the new
installer. The installer build has been updated so that we now deploy all of
the cassandra-related dependencies in the installer module. For now version
strings are hard coded because I am hoping that a number of these dependencies
will go away once I open a pull request against the datastax driver.
This commit also includes an initial update to the installer code to call
SchemaManager to create the schema (if necessary) and then apply any schema
updates via liquibase.
diff --git a/modules/enterprise/server/installer/pom.xml b/modules/enterprise/server/installer/pom.xml
index a1b2dab..266da75 100644
--- a/modules/enterprise/server/installer/pom.xml
+++ b/modules/enterprise/server/installer/pom.xml
@@ -49,6 +49,12 @@
<version>${project.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.rhq</groupId>
+ <artifactId>rhq-cassandra-schema</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
<dependency>
<groupId>gnu-getopt</groupId>
<artifactId>getopt</artifactId>
@@ -148,6 +154,162 @@
<groupId>i18nlog</groupId>
<artifactId>i18nlog</artifactId>
</artifactItem>
+ <artifactItem>
+ <groupId>org.rhq</groupId>
+ <artifactId>rhq-cassandra-schema</artifactId>
+ </artifactItem>
+ <artifactItem>
+ <groupId>com.datastax.cassandra</groupId>
+ <artifactId>cassandra-driver-core</artifactId>
+ <version>0.1.0-SNAPSHOT</version>
+ </artifactItem>
+ <!-- start cassandra-driver-core deps -->
+ <artifactItem>
+ <groupId>org.apache.cassandra</groupId>
+ <artifactId>cassandra-all</artifactId>
+ <version>${cassandra.version}</version>
+ </artifactItem>
+ <artifactItem>
+ <groupId>org.apache.cassandra</groupId>
+ <artifactId>cassandra-thrift</artifactId>
+ <version>${cassandra.version}</version>
+ </artifactItem>
+ <artifactItem>
+ <groupId>io.netty</groupId>
+ <artifactId>netty</artifactId>
+ <version>3.5.9.Final</version>
+ </artifactItem>
+ <artifactItem>
+ <groupId>com.google.guava</groupId>
+ <artifactId>guava</artifactId>
+ <version>12.0</version>
+ </artifactItem>
+ <artifactItem>
+ <groupId>com.google.code.findbugs</groupId>
+ <artifactId>jsr305</artifactId>
+ <version>1.3.9</version>
+ </artifactItem>
+ <!--<artifactItem>-->
+ <!--<groupId>commons-lang</groupId>-->
+ <!--<artifactId>commons-lang</artifactId>-->
+ <!--<version>2.4</version>-->
+ <!--</artifactItem>-->
+ <artifactItem>
+ <groupId>org.apache.httpcomponents</groupId>
+ <artifactId>httpclient</artifactId>
+ <version>4.0.1</version>
+ </artifactItem>
+ <artifactItem>
+ <groupId>org.apache.httpcomponents</groupId>
+ <artifactId>httpcore</artifactId>
+ <version>4.0.1</version>
+ </artifactItem>
+ <artifactItem>
+ <groupId>org.codehaus.jackson</groupId>
+ <artifactId>jackson-core-asl</artifactId>
+ <version>1.4.0</version>
+ </artifactItem>
+ <artifactItem>
+ <groupId>com.yammer.metrics</groupId>
+ <artifactId>metrics-core</artifactId>
+ <version>2.2.0</version>
+ </artifactItem>
+ <artifactItem>
+ <groupId>org.xerial.snappy</groupId>
+ <artifactId>snappy-java</artifactId>
+ <version>1.0.4.1</version>
+ </artifactItem>
+ <artifactItem>
+ <groupId>com.ning</groupId>
+ <artifactId>compress-lzf</artifactId>
+ <version>0.8.4</version>
+ </artifactItem>
+ <artifactItem>
+ <groupId>commons-cli</groupId>
+ <artifactId>commons-cli</artifactId>
+ <version>1.1</version>
+ </artifactItem>
+ <artifactItem>
+ <groupId>commons-codec</groupId>
+ <artifactId>commons-codec</artifactId>
+ <version>1.2</version>
+ </artifactItem>
+ <artifactItem>
+ <groupId>com.googlecode.concurrentlinkedhashmap</groupId>
+ <artifactId>concurrentlinkedhashmap-lru</artifactId>
+ <version>1.3</version>
+ </artifactItem>
+ <artifactItem>
+ <groupId>org.antlr</groupId>
+ <artifactId>antlr</artifactId>
+ <version>3.2</version>
+ </artifactItem>
+ <artifactItem>
+ <groupId>org.antlr</groupId>
+ <artifactId>antlr-runtime</artifactId>
+ <version>3.2</version>
+ </artifactItem>
+ <artifactItem>
+ <groupId>org.antlr</groupId>
+ <artifactId>stringtemplate</artifactId>
+ <version>3.2</version>
+ </artifactItem>
+ <artifactItem>
+ <groupId>org.codehaus.jackson</groupId>
+ <artifactId>jackson-mapper-asl</artifactId>
+ <version>1.4.0</version>
+ </artifactItem>
+ <artifactItem>
+ <groupId>com.googlecode.json-simple</groupId>
+ <artifactId>json-simple</artifactId>
+ <version>1.1</version>
+ </artifactItem>
+ <artifactItem>
+ <groupId>com.github.stephenc.high-scale-lib</groupId>
+ <artifactId>high-scale-lib</artifactId>
+ <version>1.1.2</version>
+ </artifactItem>
+ <artifactItem>
+ <groupId>edu.stanford.ppl</groupId>
+ <artifactId>snaptree</artifactId>
+ <version>0.1</version>
+ </artifactItem>
+ <artifactItem>
+ <groupId>com.github.stephenc</groupId>
+ <artifactId>jamm</artifactId>
+ <version>0.2.5</version>
+ </artifactItem>
+ <artifactItem>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-log4j12</artifactId>
+ <version>1.6.6</version>
+ </artifactItem>
+ <artifactItem>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ <version>1.7.2</version>
+ </artifactItem>
+ <artifactItem>
+ <groupId>org.apache.thrift</groupId>
+ <artifactId>libthrift</artifactId>
+ <version>0.7.0</version>
+ </artifactItem>
+ <!-- end cassandra-driver-core deps -->
+ <artifactItem>
+ <groupId>org.liquibase</groupId>
+ <artifactId>liquibase-core</artifactId>
+ <version>3.0.0-SNAPSHOT</version>
+ </artifactItem>
+ <artifactItem>
+ <groupId>org.apache-extras.cassandra-jdbc</groupId>
+ <artifactId>cassandra-jdbc</artifactId>
+ <version>1.2.0-SNAPSHOT</version>
+ </artifactItem>
+ <artifactItem>
+ <groupId>cassandra-liquibase-ext</groupId>
+ <artifactId>cassandra-liquibase-ext</artifactId>
+ <version>0.1.0-SNAPSHOT</version>
+ </artifactItem>
</artifactItems>
<outputDirectory>${project.build.directory}/installer-deps</outputDirectory>
</configuration>
diff --git a/modules/enterprise/server/installer/src/main/java/org/rhq/enterprise/server/installer/InstallerServiceImpl.java b/modules/enterprise/server/installer/src/main/java/org/rhq/enterprise/server/installer/InstallerServiceImpl.java
index 589efca..6e32e89 100644
--- a/modules/enterprise/server/installer/src/main/java/org/rhq/enterprise/server/installer/InstallerServiceImpl.java
+++ b/modules/enterprise/server/installer/src/main/java/org/rhq/enterprise/server/installer/InstallerServiceImpl.java
@@ -366,6 +366,7 @@ public class InstallerServiceImpl implements InstallerService {
log("Database schema exists - it will now be updated.");
ServerInstallUtil.upgradeExistingDatabaseSchema(serverProperties, serverDetails,
clearTextDbPassword, getLogDir());
+ ServerInstallUtil.installOrUpdateCassandraSchema(serverProperties);
}
} else {
log("Database schema does not yet exist - it will now be created.");
diff --git a/modules/enterprise/server/installer/src/main/java/org/rhq/enterprise/server/installer/ServerInstallUtil.java b/modules/enterprise/server/installer/src/main/java/org/rhq/enterprise/server/installer/ServerInstallUtil.java
index 49b3e32..794c482 100644
--- a/modules/enterprise/server/installer/src/main/java/org/rhq/enterprise/server/installer/ServerInstallUtil.java
+++ b/modules/enterprise/server/installer/src/main/java/org/rhq/enterprise/server/installer/ServerInstallUtil.java
@@ -46,6 +46,7 @@ import org.apache.tools.ant.helper.ProjectHelper2;
import org.jboss.as.controller.client.ModelControllerClient;
import org.jboss.dmr.ModelNode;
+import org.rhq.cassandra.schema.SchemaManager;
import org.rhq.common.jbossas.client.controller.Address;
import org.rhq.common.jbossas.client.controller.CoreJBossASClient;
import org.rhq.common.jbossas.client.controller.DatasourceJBossASClient;
@@ -402,8 +403,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", null);
+// final ModelNode cassandraDriverRequest = client.createNewJdbcDriverRequest(JDBC_DRIVER_CASSANDRA,
+// "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
@@ -465,12 +466,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");
- }
+// 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");
+// }
}
/**
@@ -496,7 +497,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);
+// createNewDatasources_Cassandra(mcc);
LOG.info("Created datasources");
@@ -551,20 +552,20 @@ 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_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);
@@ -1054,6 +1055,18 @@ public class ServerInstallUtil {
return;
}
+ public static void installOrUpdateCassandraSchema(HashMap<String, String> props) {
+ String[] hosts = props.get("rhq.cassandra.cluster.seeds").split(",");
+ String username = props.get("rhq.cassandra.username");
+ String password = props.get("rhq.cassandra.password");
+
+ SchemaManager schemaManager = new SchemaManager(username, password, hosts);
+ if (!schemaManager.schemaExists()) {
+ schemaManager.createSchema();
+ }
+ schemaManager.updateSchema();
+ }
+
/**
* Given a server property value string, returns true if it is not specified.
*
diff --git a/modules/enterprise/server/installer/src/main/resources/module/main/module.xml b/modules/enterprise/server/installer/src/main/resources/module/main/module.xml
index 4358c6b..98b4d87 100644
--- a/modules/enterprise/server/installer/src/main/resources/module/main/module.xml
+++ b/modules/enterprise/server/installer/src/main/resources/module/main/module.xml
@@ -13,6 +13,29 @@
<resource-root path="ant-${ant.version}.jar"/>
<resource-root path="ant-launcher-${ant.version}.jar"/>
<resource-root path="i18nlog-${i18nlog.version}.jar"/>
+ <resource-root path="rhq-cassandra-schema-${project.version}.jar"/>
+ <!-- begin rhq-cassandra-schema dependencies -->
+ <!--
+ cassandra-driver-core declares a lot of dependencies, many of which
+ are very likely not needed. For now I am only declaring those
+ dependencies that are known to be needed. They are known to be needed
+ because excluding them results in a ClassNotFoundException.
+ -->
+ <resource-root path="cassandra-driver-core-0.1.0-SNAPSHOT.jar"/>
+ <resource-root path="slf4j-api-1.7.2.jar"/>
+ <resource-root path="slf4j-log4j12-1.6.6.jar"/>
+ <resource-root path="netty-3.5.9.Final.jar"/>
+ <resource-root path="cassandra-all-1.2.0-beta3.jar"/>
+ <resource-root path="metrics-core-2.2.0.jar"/>
+ <resource-root path="guava-12.0.jar"/>
+ <resource-root path="cassandra-thrift-1.2.0-beta3.jar"/>
+ <resource-root path="libthrift-0.7.0.jar"/>
+ <resource-root path="jackson-mapper-asl-1.4.0.jar"/>
+ <resource-root path="jackson-core-asl-1.4.0.jar"/>
+ <!-- end rhq-cassandra-schema dependencies -->
+ <resource-root path="liquibase-core-3.0.0-SNAPSHOT.jar"/>
+ <resource-root path="cassandra-jdbc-1.2.0-SNAPSHOT.jar"/>
+ <resource-root path="cassandra-liquibase-ext-0.1.0-SNAPSHOT.jar"/>
</resources>
<dependencies>
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 13ec6a6..6fc8419 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
@@ -149,7 +149,13 @@ public class CassandraClusterManagerBean implements CassandraClusterManagerLocal
log.warn("Failed to update rhq.cassandra.cluster.seeds property in " + serverProperties, e);
}
- deployer.deploy();
+ // Commenting out the call to deploy as this was here only to support dev
+ // environments. Now that the new AS 7 installer is in place, the embedded
+ // cluster will be deployed during the auto installation that happens with the
+ // dev-container and a separate script will be made available for managing the
+ // embedded cluster.
+ //
+ //deployer.deploy();
} else {
seeds = System.getProperty("rhq.cassandra.cluster.seeds");
commit 1a1c1d464ae1c03728b4e454ae2e18f0b9d9729c
Author: John Sanda <jsanda(a)redhat.com>
Date: Fri Dec 14 14:05:22 2012 -0500
fixing indentation
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 bb4fce6..2ed5f96 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
@@ -693,18 +693,18 @@ 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>
- <replace file="${project.build.outputDirectory}/bin/rhq-server.sh">
- <replacefilter>
- <replacetoken># START SERVER</replacetoken>
- <replacevalue><![CDATA[export RHQ_SERVER_HOME; ${RHQ_SERVER_HOME}/bin/rhq-autoinstall.sh &]]></replacevalue>
- </replacefilter>
- </replace>
- <replace file="${project.build.outputDirectory}/bin/rhq-server.bat">
- <replacefilter>
- <replacetoken>rem START SERVER</replacetoken>
- <replacevalue><![CDATA[start /B %RHQ_SERVER_HOME%\bin\rhq-autoinstall.bat]]></replacevalue>
- </replacefilter>
- </replace>
+ <replace file="${project.build.outputDirectory}/bin/rhq-server.sh">
+ <replacefilter>
+ <replacetoken># START SERVER</replacetoken>
+ <replacevalue><![CDATA[export RHQ_SERVER_HOME; ${RHQ_SERVER_HOME}/bin/rhq-autoinstall.sh &]]></replacevalue>
+ </replacefilter>
+ </replace>
+ <replace file="${project.build.outputDirectory}/bin/rhq-server.bat">
+ <replacefilter>
+ <replacetoken>rem START SERVER</replacetoken>
+ <replacevalue><![CDATA[start /B %RHQ_SERVER_HOME%\bin\rhq-autoinstall.bat]]></replacevalue>
+ </replacefilter>
+ </replace>
</target>
<!-- The prepare-release target must be run AFTER the resources:resources goal has executed. -->
commit d66242e848d997003b84b1710ef434cdd4f66043
Author: John Sanda <jsanda(a)redhat.com>
Date: Fri Dec 14 14:03:45 2012 -0500
removing dependency on the cassandra-schema module
Schema install/update logic has been removed from BootstrapDeployer and moved
into the class SchemaManager which is in cassandra-schema.
diff --git a/modules/common/cassandra-common/pom.xml b/modules/common/cassandra-common/pom.xml
index 9004786..78d25bf 100644
--- a/modules/common/cassandra-common/pom.xml
+++ b/modules/common/cassandra-common/pom.xml
@@ -32,12 +32,6 @@
<dependency>
<groupId>${project.groupId}</groupId>
- <artifactId>rhq-cassandra-schema</artifactId>
- <version>${project.version}</version>
- </dependency>
-
- <dependency>
- <groupId>${project.groupId}</groupId>
<artifactId>rhq-core-plugin-api</artifactId>
<version>${project.version}</version>
</dependency>
diff --git a/modules/common/cassandra-common/src/main/java/org/rhq/cassandra/BootstrapDeployer.java b/modules/common/cassandra-common/src/main/java/org/rhq/cassandra/BootstrapDeployer.java
index 3cca747..ed8e578 100644
--- a/modules/common/cassandra-common/src/main/java/org/rhq/cassandra/BootstrapDeployer.java
+++ b/modules/common/cassandra-common/src/main/java/org/rhq/cassandra/BootstrapDeployer.java
@@ -53,12 +53,6 @@ import org.rhq.core.util.ZipUtil;
import org.rhq.core.util.file.FileUtil;
import org.rhq.core.util.stream.StreamUtil;
-import liquibase.Liquibase;
-import liquibase.database.Database;
-import liquibase.exception.DatabaseException;
-import liquibase.integration.commandline.CommandLineUtils;
-import liquibase.resource.ClassLoaderResourceAccessor;
-
/**
* @author John Sanda
*/
@@ -134,10 +128,10 @@ public class BootstrapDeployer {
doLocalDeploy(props, bundleDir);
startNode(nodeBasedir);
- if (i == 0) {
- waitForNodeToStart(10, address);
- updateSchema(nodeBasedir, address, 9160);
- }
+// if (i == 0) {
+// waitForNodeToStart(10, address);
+// updateSchema(nodeBasedir, address, 9160);
+// }
}
FileUtil.writeFile(new ByteArrayInputStream(new byte[] {0}), installedMarker);
} catch (IOException e) {
@@ -212,84 +206,6 @@ public class BootstrapDeployer {
" tries");
}
- private void updateSchema(File basedir, String host, int port) throws CassandraException {
-// File binDir = new File(basedir, "bin");
-// File script = new File(binDir, "cqlsh");
-// SystemInfo systemInfo = SystemInfoFactory.createSystemInfo();
-//
-// File dbsetupFile = null;
-// try {
-// dbsetupFile = File.createTempFile("dbsetup.cql", null);
-// InputStream inputStream = getClass().getResourceAsStream("/dbsetup.cql");
-// FileOutputStream outputStream = new FileOutputStream(dbsetupFile);
-// StreamUtil.copy(inputStream, outputStream);
-// } catch (IOException e) {
-// throw new CassandraException("Failed to load schema update script", e);
-// }
-// ProcessExecution cliExe = ProcessExecutionUtility.createProcessExecution(script);
-// cliExe.setWaitForCompletion(30000L);
-// cliExe.setCaptureOutput(true);
-// cliExe.setArguments(asList("-3", "--debug", "-u", "rhqadmin", "-p", "rhqadmin", "-f",
-// dbsetupFile.getAbsolutePath()));
-//
-// ProcessExecutionResults results = systemInfo.executeProcess(cliExe);
-// String output = results.getCapturedOutput();
- createSchema(basedir);
- runLiquibase(host);
- }
-
- private void createSchema(File basedir) throws CassandraException {
- File binDir = new File(basedir, "bin");
- File script = new File(binDir, "cqlsh");
- SystemInfo systemInfo = SystemInfoFactory.createSystemInfo();
-
- File dbsetupFile = null;
- try {
- dbsetupFile = File.createTempFile("dbsetup.cql", null);
- InputStream inputStream = getClass().getResourceAsStream("/create_keyspace.cql");
- FileOutputStream outputStream = new FileOutputStream(dbsetupFile);
- StreamUtil.copy(inputStream, outputStream);
- } catch (IOException e) {
- throw new CassandraException("Failed to load schema update script", e);
- }
- ProcessExecution cliExe = ProcessExecutionUtility.createProcessExecution(script);
- cliExe.setWaitForCompletion(30000L);
- cliExe.setCaptureOutput(true);
- cliExe.setArguments(asList("-3", "--debug", "-u", "rhqadmin", "-p", "rhqadmin", "-f",
- dbsetupFile.getAbsolutePath()));
-
- ProcessExecutionResults results = systemInfo.executeProcess(cliExe);
- }
-
- private void runLiquibase(String host) throws CassandraException {
- try {
- Database database = createDatabase(host);
-
-// URL url = getClass().getResource("/changelog.xml");
-// File changeLog = new File(url.toURI());
-
- ClassLoaderResourceAccessor resourceAccessor = new ClassLoaderResourceAccessor();
-
- Liquibase liquibase = new Liquibase("changelog.xml", resourceAccessor, database);
- liquibase.update(null);
- } catch (Exception e) {
- throw new CassandraException(e);
- }
- }
-
- private Database createDatabase(String host) throws DatabaseException {
- String url = "jdbc:cassandra://" + host + ":9160/system?version=3.0.0";
- String username = deploymentOptions.getUsername();
- String password = deploymentOptions.getPassword();
- String driver = "org.apache.cassandra.cql.jdbc.CassandraDriver";
- String databaseClass = "liquibase.database.ext.CassandraDatabase";
- String defaultCatalog = null;
- String defaultSchema = "rhq";
-
- return CommandLineUtils.createDatabaseObject(getClass().getClassLoader(), url, username, password, driver,
- null, defaultSchema, databaseClass, null);
- }
-
private File unpackBundleZipFile() throws IOException {
InputStream bundleInputStream = getClass().getResourceAsStream("/cassandra-bundle.zip");
File bundleZipFile = File.createTempFile("cassandra-bundle.zip", null);
commit 010f0c33a123937357153e9587af1757cb3e7e96
Author: John Sanda <jsanda(a)redhat.com>
Date: Fri Dec 14 13:58:50 2012 -0500
Initial commit for SchemaManager
SchemaManager handles creating and installing the schema. Most of the work is
delegated to Liquibase. Previously the work was done in BootstrapDeployer
which lives in the cassandra-common module. We only need to run Liquibase
in the installer and deploying it in the EAR causes problems with CDI due the
JSF libraries conflict in portal-war. The logic has been pulled out of
BootstrapDeployer and is now only used in the installer.
diff --git a/modules/common/cassandra-schema/pom.xml b/modules/common/cassandra-schema/pom.xml
index 5ebe633..660fadf 100644
--- a/modules/common/cassandra-schema/pom.xml
+++ b/modules/common/cassandra-schema/pom.xml
@@ -14,6 +14,12 @@
<dependencies>
<dependency>
+ <groupId>com.datastax.cassandra</groupId>
+ <artifactId>cassandra-driver-core</artifactId>
+ <version>0.1.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
<groupId>org.liquibase</groupId>
<artifactId>liquibase-core</artifactId>
<version>3.0.0-SNAPSHOT</version>
diff --git a/modules/common/cassandra-schema/src/main/java/org/rhq/cassandra/schema/SchemaManager.java b/modules/common/cassandra-schema/src/main/java/org/rhq/cassandra/schema/SchemaManager.java
new file mode 100644
index 0000000..77a3b30
--- /dev/null
+++ b/modules/common/cassandra-schema/src/main/java/org/rhq/cassandra/schema/SchemaManager.java
@@ -0,0 +1,129 @@
+/*
+ *
+ * * 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.cassandra.schema;
+
+import com.datastax.driver.core.Cluster;
+import com.datastax.driver.core.ResultSet;
+import com.datastax.driver.core.Session;
+import com.datastax.driver.core.SimpleAuthInfoProvider;
+import com.datastax.driver.core.exceptions.NoHostAvailableException;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import liquibase.Liquibase;
+import liquibase.database.Database;
+import liquibase.exception.DatabaseException;
+import liquibase.integration.commandline.CommandLineUtils;
+import liquibase.resource.ClassLoaderResourceAccessor;
+
+/**
+ * @author John Sanda
+ */
+public class SchemaManager {
+
+ private final Log log = LogFactory.getLog(SchemaManager.class);
+
+ private Session session;
+
+ private String username;
+
+ private String password;
+
+ private String[] hosts;
+
+ public SchemaManager(String username, String password, String... hosts) {
+ try {
+ this.username = username;
+ this.password = password;
+ this.hosts = hosts;
+
+ SimpleAuthInfoProvider authInfoProvider = new SimpleAuthInfoProvider();
+ authInfoProvider.add("username", "rhqadmin").add("password", "rhqadmin");
+
+ Cluster cluster = Cluster.builder()
+ .addContactPoints("127.0.0.1", "127.0.0.2")
+ .withAuthInfoProvider(authInfoProvider)
+ .build();
+ session = cluster.connect("system");
+ } catch (NoHostAvailableException e) {
+ throw new RuntimeException("Unable create session.", e);
+ }
+ }
+
+ public void createSchema() {
+ try {
+ String cql = "CREATE KEYSPACE rhq WITH replication = {'class': 'SimpleStrategy', 'replication_factor': 1};";
+ session.execute(cql);
+ } catch (NoHostAvailableException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ public boolean schemaExists() {
+ try {
+ String cql = "SELECT keyspace_name FROM schema_keyspaces WHERE keyspace_name = 'rhq'";
+ ResultSet resultSet = session.execute(cql);
+ return !resultSet.fetchAll().isEmpty();
+ } catch (NoHostAvailableException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ public void updateSchema() {
+ try {
+ Database database = createDatabase(hosts[0]);
+ runLiquibase(database);
+ } catch (DatabaseException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ private void runLiquibase(Database database) {
+ try {
+ ClassLoaderResourceAccessor resourceAccessor = new ClassLoaderResourceAccessor();
+
+ Liquibase liquibase = new Liquibase("changelog.xml", resourceAccessor, database);
+ liquibase.update(null);
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ private Database createDatabase(String host) throws DatabaseException {
+ String url = "jdbc:cassandra://" + host + ":9160/system?version=3.0.0";
+ String driver = "org.apache.cassandra.cql.jdbc.CassandraDriver";
+ String databaseClass = "liquibase.database.ext.CassandraDatabase";
+ String defaultCatalog = null;
+ String defaultSchema = "rhq";
+
+ log.debug("Cassandra JDBC URL: " + url);
+
+ return CommandLineUtils.createDatabaseObject(getClass().getClassLoader(), url, username, password, driver,
+ null, defaultSchema, databaseClass, null);
+ }
+
+}
11 years, 5 months
[rhq] modules/plugins
by Simeon Pinder
modules/plugins/tomcat/src/main/java/org/jboss/on/plugins/tomcat/TomcatUserDatabaseComponent.java | 3 +++
1 file changed, 3 insertions(+)
New commits:
commit bd0cba4c258ef0f6884ce1465e744e0d37acc9a9
Author: Remy Maucherat <rmaucher(a)redhat.com>
Date: Fri Dec 14 11:53:16 2012 -0500
[BZ 865459] adding support for adding users for tomcat 7 UserDatabase.
diff --git a/modules/plugins/tomcat/src/main/java/org/jboss/on/plugins/tomcat/TomcatUserDatabaseComponent.java b/modules/plugins/tomcat/src/main/java/org/jboss/on/plugins/tomcat/TomcatUserDatabaseComponent.java
index bb13097..23a20e1 100644
--- a/modules/plugins/tomcat/src/main/java/org/jboss/on/plugins/tomcat/TomcatUserDatabaseComponent.java
+++ b/modules/plugins/tomcat/src/main/java/org/jboss/on/plugins/tomcat/TomcatUserDatabaseComponent.java
@@ -47,6 +47,7 @@ public class TomcatUserDatabaseComponent extends MBeanResourceComponent<TomcatSe
try {
if (TomcatGroupComponent.RESOURCE_TYPE_NAME.equals(resourceTypeName)) {
name = report.getResourceConfiguration().getSimple("groupname").getStringValue();
+ report.getResourceConfiguration().remove(TomcatGroupComponent.CONFIG_ROLES);
objectName = String.format("Users:type=Group,groupname=\"%s\",database=UserDatabase", name);
operation = "createGroup";
} else if (TomcatRoleComponent.RESOURCE_TYPE_NAME.equals(resourceTypeName)) {
@@ -55,6 +56,8 @@ public class TomcatUserDatabaseComponent extends MBeanResourceComponent<TomcatSe
operation = "createRole";
} else if (TomcatUserComponent.RESOURCE_TYPE_NAME.equals(resourceTypeName)) {
name = report.getResourceConfiguration().getSimple("username").getStringValue();
+ report.getResourceConfiguration().remove(TomcatUserComponent.CONFIG_ROLES);
+ report.getResourceConfiguration().remove(TomcatUserComponent.CONFIG_GROUPS);
objectName = String.format("Users:type=User,username=\"%s\",database=UserDatabase", name);
operation = "createUser";
} else {
11 years, 5 months
[rhq] modules/common
by Jiri Kremser
modules/common/ant-bundle/src/main/java/org/rhq/bundle/ant/type/SystemServiceType.java | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
New commits:
commit 49a48ea47dde77506b48bb1c699dd6aab0ab8a20
Author: Jirka Kremser <jkremser(a)redhat.com>
Date: Fri Dec 14 14:50:57 2012 +0100
[BZ 886287 - NullPointerException when another exception should have been thrown] quick fix, lazy evaluation of Java should ensure the prevention of throwing NPE
diff --git a/modules/common/ant-bundle/src/main/java/org/rhq/bundle/ant/type/SystemServiceType.java b/modules/common/ant-bundle/src/main/java/org/rhq/bundle/ant/type/SystemServiceType.java
index 6521d2e..006e1e4 100644
--- a/modules/common/ant-bundle/src/main/java/org/rhq/bundle/ant/type/SystemServiceType.java
+++ b/modules/common/ant-bundle/src/main/java/org/rhq/bundle/ant/type/SystemServiceType.java
@@ -87,14 +87,14 @@ public class SystemServiceType extends AbstractBundleType {
}
public void init() throws BuildException {
- if (!OS_NAME.equals("Linux") || !REDHAT_RELEASE_FILE.exists()) {
+ if (!"Linux".equals(OS_NAME) || !REDHAT_RELEASE_FILE.exists()) {
throw new BuildException("The system-service element is only supported on Red Hat Linux systems.");
}
if (!this.scriptFile.exists() || this.scriptFile.isDirectory()) {
throw new BuildException("The 'scriptFile' attribute must be set to the path of an existing regular file.");
}
- if (this.configFile != null && !this.configFile.exists() || this.configFile.isDirectory()) {
+ if (this.configFile != null && (!this.configFile.exists() || this.configFile.isDirectory())) {
throw new BuildException("The 'configFile' attribute must be set to the path of an existing regular file.");
}
}
11 years, 5 months
[rhq] modules/enterprise
by Jay Shaughnessy
modules/enterprise/server/itests-2/pom.xml | 19 +++++++++++++++----
1 file changed, 15 insertions(+), 4 deletions(-)
New commits:
commit 3b27674c0810da01bd7d4031f5f3ea852b62e538
Author: Jay Shaughnessy <jshaughn(a)jshaughn.csb>
Date: Thu Dec 13 20:27:06 2012 -0500
Add test dep to ensure the oracle driver can be found when testing against oracle.
diff --git a/modules/enterprise/server/itests-2/pom.xml b/modules/enterprise/server/itests-2/pom.xml
index ba7dd7e..407dc0b 100644
--- a/modules/enterprise/server/itests-2/pom.xml
+++ b/modules/enterprise/server/itests-2/pom.xml
@@ -26,10 +26,10 @@
<jboss.vm.args>-Xmx700m -XX:MaxPermSize=200m -Djava.security.manager
-Djava.security.policy==${jboss.unzip.location}/security.policy</jboss.vm.args>
<jboss.vm.args.debug></jboss.vm.args.debug> <!-- -Ditest.debug can override this, see below -->
- <!-- These properties guide which datasources are used for integration tests. Only one should be true.
- The default is Postgres, specify -Pitest.oracle to use Oracle -->
- <skip.postgres>false</skip.postgres>
- <skip.oracle>true</skip.oracle>
+ <!-- These properties guide which datasources are used for integration tests. Only one should be true.
+ The default is Postgres, specify -Pitest.oracle to use Oracle -->
+ <skip.postgres>false</skip.postgres>
+ <skip.oracle>true</skip.oracle>
</properties>
<dependencies>
@@ -683,6 +683,17 @@
<skip.postgres>true</skip.postgres>
<skip.oracle>false</skip.oracle>
</properties>
+
+ <dependencies>
+ <!-- The provided scope in the root pom is not sufficient, we need this fo shrinkwrap to resolve
+ dependency and add the jar to the deployment. -->
+ <dependency>
+ <groupId>com.oracle</groupId>
+ <artifactId>ojdbc6</artifactId>
+ <version>${ojdbc6.version}</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
</profile>
<profile>
11 years, 5 months
[rhq] modules/core
by Jay Shaughnessy
modules/core/dbutils/pom.xml | 11 +++++++++++
1 file changed, 11 insertions(+)
New commits:
commit 8dbf3bd0b887c1b371f11394112755a714fa9e2b
Author: Jay Shaughnessy <jshaughn(a)jshaughn.csb>
Date: Thu Dec 13 17:12:57 2012 -0500
Make sure oracle driver dependency is in place for -Ddbreset
diff --git a/modules/core/dbutils/pom.xml b/modules/core/dbutils/pom.xml
index c8fef74..aa9a2ce 100644
--- a/modules/core/dbutils/pom.xml
+++ b/modules/core/dbutils/pom.xml
@@ -435,6 +435,17 @@
<profile>
<id>ojdbc-driver</id>
+ <dependencies>
+ <!-- The provided scope in the root pom is not sufficient, we need this
+ dependency for dbreset, if it is used. -->
+ <dependency>
+ <groupId>com.oracle</groupId>
+ <artifactId>ojdbc6</artifactId>
+ <version>${ojdbc6.version}</version>
+ <scope>compile</scope>
+ </dependency>
+ </dependencies>
+
<!-- TODO: defer to root pom version when we can agree on a version -->
<build>
<plugins>
11 years, 5 months
[rhq] Branch 'feature/cassandra-backend' - modules/core modules/enterprise
by snegrea
modules/core/domain/src/main/java/org/rhq/core/domain/measurement/MeasurementBaseline.java | 100 ---------
modules/core/domain/src/test/java/org/rhq/core/domain/measurement/test/MeasurementBaselineTest.java | 54 +++++
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/MeasurementBaselineManagerBean.java | 108 +---------
modules/enterprise/server/server-metrics/src/main/java/org/rhq/server/metrics/MetricBaselineCalculator.java | 67 ++++++
4 files changed, 146 insertions(+), 183 deletions(-)
New commits:
commit 211ca70a03647ccdc99bb8f22f3a296beb52320b
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Thu Dec 13 16:00:43 2012 -0600
Move baseline calculation away from SQL db. The baselines will continue to be stored and retrieved from SQL but the data for the calculation will have to come from new metrics storage system. Also removed most of the references to the old way of calculating baselines.
Cassandra integration is still to be added.
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/measurement/MeasurementBaseline.java b/modules/core/domain/src/main/java/org/rhq/core/domain/measurement/MeasurementBaseline.java
index 4df256b..7b3e4a7 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/measurement/MeasurementBaseline.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/measurement/MeasurementBaseline.java
@@ -42,49 +42,9 @@ import javax.persistence.Table;
@Entity
@NamedQueries( {
- // Unfortunately, hibernate is broken after 3.2.0.rc4 - we can't process these insert/delete HQL queries.
- // http://opensource.atlassian.com/projects/hibernate/browse/HHH-2833
- // Instead, take these HQLs, plug into Eclipse Hibernate Tool and look at the generated native SQL.
- // Take those native queries (for each supported database) and create native queries here.
- // Can't use NamedNativeQuery either, hibernate doesn't support that.
-
- // update: RHQ-716 proved that this still isn't working, even with a version of Hibernate containing a fix
- // for HHH-2833. Basically, CURRENT_TIMESTAMP returns a timestamp data type, but computeTime field expects
- // a long. this incompatibility forces the query analysis to bomb at compile time. this issue could have been
- // by-passed if Hibernate allows binding parameters in the select list, but that is disallowed as well.
- /*
- @NamedQuery(name = MeasurementBaseline.QUERY_CALC_FIRST_AUTOBASELINE, query = "" //
- + " INSERT INTO MeasurementBaseline (baselineMin,baselineMax,baselineMean,computeTime,scheduleId) "
- + " SELECT min(d.min) AS baselineMin, "
- + " max(d.max) AS baselineMax, "
- + " avg(d.value) AS baselineMean, "
- + " CURRENT_TIMESTAMP AS currentTime, "
- + " d.id.scheduleId AS scheduleId "
- + " FROM MeasurementDataNumeric1H d "
- + " JOIN d.schedule s "
- + " LEFT JOIN s.baseline b "
- + " WHERE s.definition.numericType = 0 "
- + " AND b.id IS NULL "
- + " AND d.id.timestamp BETWEEN :startTime AND :endTime "
- + " GROUP BY d.id.scheduleId "
- + " HAVING d.id.scheduleId IN (SELECT d1.id.scheduleId "
- + " FROM MeasurementDataNumeric1H d1 "
- + " WHERE d1.id.timestamp <= :startTime) "),
- @NamedQuery(name = MeasurementBaseline.QUERY_DELETE_EXISTING_AUTOBASELINES, query = "" //
- + " DELETE MeasurementBaseline AS doomed WHERE doomed.scheduleId IN "
- + "( "
- + " SELECT d.id.scheduleId AS scheduleId "
- + " FROM MeasurementDataNumeric1H d "
- + " JOIN d.schedule s "
- + " LEFT JOIN s.baseline b "
- + " WHERE b.id IS NOT NULL "
- + " AND d.id.timestamp BETWEEN :startTime AND :endTime "
- + " AND b.userEntered = FALSE "
- + " GROUP BY d.id.scheduleId "
- + " HAVING d.id.scheduleId IN (SELECT d1.id.scheduleId "
- + " FROM MeasurementDataNumeric1H d1 "
- + " WHERE d1.id.timestamp <= :startTime) " + ") "),
- */
+ @NamedQuery(name = MeasurementBaseline.QUERY_FIND_MEASUREMENT_SCHEDULES_WITHOUT_AUTOBASELINES, query = "SELECT schedule.id FROM MeasurementSchedule schedule "
+ + "WHERE schedule.definition.numericType = 0 AND "
+ + "schedule.id NOT IN (SELECT scheduleId FROM MeasurementBaseline)"),
@NamedQuery(name = MeasurementBaseline.QUERY_FIND_BY_RESOURCE, query = "SELECT mb FROM MeasurementBaseline mb WHERE mb.schedule.resource.id = :resourceId"),
@NamedQuery(name = MeasurementBaseline.QUERY_FIND_BY_RESOURCE_IDS_AND_DEF_IDS, query = "SELECT mb FROM MeasurementBaseline mb "
+ "WHERE mb.schedule.resource.id IN (:resourceIds) AND mb.schedule.definition.id IN (:definitionIds)"),
@@ -112,9 +72,8 @@ public class MeasurementBaseline implements Serializable {
public static final String QUERY_DELETE_BY_RESOURCES = "MeasurementBaseline.deleteByResources";
public static final String QUERY_CALC_FIRST_AUTOBASELINE = "MeasurementBaseline.calcFirstAutoBaseline";
public static final String QUERY_DELETE_EXISTING_AUTOBASELINES = "MeasurementBaseline.deleteExistingAutoBaseline";
+ public static final String QUERY_FIND_MEASUREMENT_SCHEDULES_WITHOUT_AUTOBASELINES = "MeasurementBaseline.findMetricSchedulesWithoutAutoBaselines";
public static final String NATIVE_QUERY_CALC_FIRST_AUTOBASELINE_POSTGRES;
- public static final String NATIVE_QUERY_CALC_FIRST_AUTOBASELINE_ORACLE;
- public static final String NATIVE_QUERY_CALC_FIRST_AUTOBASELINE_SQLSERVER;
static {
/*
@@ -131,7 +90,7 @@ public class MeasurementBaseline implements Serializable {
+ " FROM RHQ_MEASUREMENT_DATA_NUM_1H data1h " // baselines are 1H data statistics
+ " INNER JOIN RHQ_MEASUREMENT_SCHED sched " // baselines are aggregates of schedules
+ " ON data1h.SCHEDULE_ID = sched.id " //
- + " INNER JOIN RHQ_MEASUREMENT_DEF def " // only compute off of dynamic types
+ + " INNER JOIN RHQ_MEASUREMENT_DEF def " // only compute off of dynamic types
+ " ON sched.definition = def.id " //
+ "LEFT OUTER JOIN RHQ_MEASUREMENT_BLINE bline " // we want null entries on purpose
+ " ON sched.id = bline.SCHEDULE_ID " //
@@ -144,55 +103,6 @@ public class MeasurementBaseline implements Serializable {
+ " FROM RHQ_MEASUREMENT_DATA_NUM_1H mdata " //
+ " WHERE mdata.TIME_STAMP <= ? ) " // ?4=startTime
+ " LIMIT 100000 "; // batch at most 100K inserts at a time to shrink the xtn size
-
- NATIVE_QUERY_CALC_FIRST_AUTOBASELINE_ORACLE = "" //
- + " INSERT INTO RHQ_MEASUREMENT_BLINE ( id, BL_MIN, BL_MAX, BL_MEAN, BL_COMPUTE_TIME, SCHEDULE_ID ) "
- + " SELECT RHQ_MEASUREMENT_BLINE_ID_SEQ.nextval, " //
- + " blMin, blMax, blAvg, coTime, schId "
- + " FROM ( SELECT MIN(data1h.minvalue) AS blMin, " //
- + " MAX(data1h.maxvalue) AS blMax, " //
- + " AVG(data1h.value) AS blAvg, " //
- + " ? as coTime, " // ?1=computeTime
- + " data1h.SCHEDULE_ID as schId " //
- + " FROM RHQ_MEASUREMENT_DATA_NUM_1H data1h " // baselines are 1H data statistics
- + " INNER JOIN RHQ_MEASUREMENT_SCHED sched " // baselines are aggregates of schedules
- + " ON data1h.SCHEDULE_ID = sched.id " //
- + " INNER JOIN RHQ_MEASUREMENT_DEF def " // only compute off of dynamic types
- + " ON sched.definition = def.id " //
- + " LEFT OUTER JOIN RHQ_MEASUREMENT_BLINE bline " // we want null entries on purpose
- + " ON sched.id = bline.SCHEDULE_ID " //
- + " WHERE ( def.numeric_type = 0 ) " // only dynamics (NumericType.DYNAMIC)
- + " AND ( bline.id IS NULL ) " // no baseline means it was deleted or never calculated
- + " AND ( data1h.TIME_STAMP BETWEEN ? AND ? ) " // ?2=startTime, ?3=endTime
- + " AND ROWNUM < 100001 " // batch at most 100K inserts at a time to shrink the xtn size
- + " GROUP BY data1h.SCHEDULE_ID " // baselines are aggregates per schedule
- // but only calculate baselines for schedules where we have data that fills (startTime, endTime)
- + " HAVING data1h.SCHEDULE_ID in ( SELECT distinct (mdata.SCHEDULE_ID) " //
- + " FROM RHQ_MEASUREMENT_DATA_NUM_1H mdata "
- + " WHERE mdata.TIME_STAMP <= ? ) ) "; // ?4=startTime
-
- NATIVE_QUERY_CALC_FIRST_AUTOBASELINE_SQLSERVER = "" //
- + " INSERT INTO RHQ_MEASUREMENT_BLINE ( BL_MIN, BL_MAX, BL_MEAN, BL_COMPUTE_TIME, SCHEDULE_ID ) "
- + " SELECT MIN(data1h.minvalue) AS blMin, " //
- + " MAX(data1h.maxvalue) AS blMax, " //
- + " AVG(data1h.value) AS blAvg, " //
- + " ? as coTime, " // ?1=computeTime
- + " data1h.SCHEDULE_ID as schId " //
- + " FROM RHQ_MEASUREMENT_DATA_NUM_1H data1h " // baselines are 1H data statistics
- + " INNER JOIN RHQ_MEASUREMENT_SCHED sched " // baselines are aggregates of schedules
- + " ON data1h.SCHEDULE_ID = sched.id " //
- + " INNER JOIN RHQ_MEASUREMENT_DEF def " // only compute off of dynamic types
- + " ON sched.definition = def.id " //
- + "LEFT OUTER JOIN RHQ_MEASUREMENT_BLINE bline " // we want null entries on purpose
- + " ON sched.id = bline.SCHEDULE_ID " //
- + " WHERE ( def.numeric_type = 0 ) " // only dynamics (NumericType.DYNAMIC)
- + " AND ( bline.id IS NULL ) " // no baseline means it was deleted or never calculated
- + " AND ( data1h.TIME_STAMP BETWEEN ? AND ? ) " // ?2=startTime, ?3=endTime
- + " GROUP BY data1h.SCHEDULE_ID " // baselines are aggregates per schedule
- // but only calculate baselines for schedules where we have data that fills (startTime, endTime)
- + " HAVING data1h.SCHEDULE_ID in ( SELECT distinct (mdata.SCHEDULE_ID) " //
- + " FROM RHQ_MEASUREMENT_DATA_NUM_1H mdata "
- + " WHERE mdata.TIME_STAMP <= ? ) "; // ?4=startTime
}
private static final long serialVersionUID = 1L;
@GeneratedValue(strategy = GenerationType.AUTO, generator = "MEAS_BL_GEN")
diff --git a/modules/core/domain/src/test/java/org/rhq/core/domain/measurement/test/MeasurementBaselineTest.java b/modules/core/domain/src/test/java/org/rhq/core/domain/measurement/test/MeasurementBaselineTest.java
new file mode 100644
index 0000000..57d45e0
--- /dev/null
+++ b/modules/core/domain/src/test/java/org/rhq/core/domain/measurement/test/MeasurementBaselineTest.java
@@ -0,0 +1,54 @@
+ /*
+ * 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, 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.core.domain.measurement.test;
+
+import java.util.List;
+
+import javax.persistence.EntityManager;
+import javax.persistence.Query;
+
+import org.testng.annotations.Test;
+
+import org.rhq.core.domain.measurement.MeasurementBaseline;
+import org.rhq.core.domain.test.AbstractEJB3Test;
+
+/**
+ * Tests for MeasurementBaseline entity
+ *
+ * @author Stefan Negrea
+ */
+@Test(groups = "integration.ejb3")
+public class MeasurementBaselineTest extends AbstractEJB3Test {
+
+ @Test
+ public void testSelectQuery() throws Exception {
+ EntityManager entityManager = getEntityManager();
+ Query query = entityManager
+ .createNamedQuery(MeasurementBaseline.QUERY_FIND_MEASUREMENT_SCHEDULES_WITHOUT_AUTOBASELINES);
+ List<String> rows = query.getResultList();
+ System.out.println("----------------------------------------------------------------------------");
+ System.out.println(rows.size());
+ System.out.println(rows);
+ System.out.println("----------------------------------------------------------------------------");
+ }
+}
\ No newline at end of file
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/MeasurementBaselineManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/MeasurementBaselineManagerBean.java
index 1d64102..4dee6fa 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/MeasurementBaselineManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/MeasurementBaselineManagerBean.java
@@ -18,8 +18,6 @@
*/
package org.rhq.enterprise.server.measurement;
-import java.sql.Connection;
-import java.sql.PreparedStatement;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
@@ -37,12 +35,6 @@ import javax.sql.DataSource;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.rhq.core.db.DatabaseType;
-import org.rhq.core.db.DatabaseTypeFactory;
-import org.rhq.core.db.H2DatabaseType;
-import org.rhq.core.db.OracleDatabaseType;
-import org.rhq.core.db.PostgresqlDatabaseType;
-import org.rhq.core.db.SQLServerDatabaseType;
import org.rhq.core.domain.auth.Subject;
import org.rhq.core.domain.authz.Permission;
import org.rhq.core.domain.measurement.MeasurementBaseline;
@@ -58,6 +50,7 @@ import org.rhq.enterprise.server.cloud.StatusManagerLocal;
import org.rhq.enterprise.server.measurement.instrumentation.MeasurementMonitor;
import org.rhq.enterprise.server.resource.ResourceManagerLocal;
import org.rhq.enterprise.server.system.SystemManagerLocal;
+import org.rhq.server.metrics.MetricBaselineCalculator;
/**
* A manager for {@link MeasurementBaseline}s.
@@ -95,6 +88,7 @@ public class MeasurementBaselineManagerBean implements MeasurementBaselineManage
private ResourceManagerLocal resourceManager;
private final Log log = LogFactory.getLog(MeasurementBaselineManagerBean.class);
+ private static final int BASELINE_PROCESSING_LIMIT = 50000;
@TransactionAttribute(TransactionAttributeType.NEVER)
public void calculateAutoBaselines() {
@@ -194,7 +188,7 @@ public class MeasurementBaselineManagerBean implements MeasurementBaselineManage
int inserted = measurementBaselineManager._calculateAutoBaselinesINSERT(amountOfData);
totalInserted += inserted;
// since we're batch 100K inserts at a time, we're done if we didn't have that many to insert
- if (inserted < 100000) {
+ if (inserted < BASELINE_PROCESSING_LIMIT) {
break;
}
}
@@ -213,7 +207,6 @@ public class MeasurementBaselineManagerBean implements MeasurementBaselineManage
}
@TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
- //@TransactionTimeout( 60 * 60 )
public int _calculateAutoBaselinesDELETE(long olderThanTime) throws Exception {
Query query = entityManager.createNamedQuery(MeasurementBaseline.QUERY_DELETE_BY_COMPUTE_TIME);
query.setParameter("timestamp", olderThanTime);
@@ -221,92 +214,31 @@ public class MeasurementBaselineManagerBean implements MeasurementBaselineManage
return rowsAffected;
}
+ @SuppressWarnings("unchecked")
@TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
- //@TransactionTimeout( 60 * 60 )
public int _calculateAutoBaselinesINSERT(long amountOfData) throws Exception {
- long now = System.currentTimeMillis();
- long computeTime = now;
- long endTime = now;
+ long endTime = System.currentTimeMillis();
long startTime = endTime - amountOfData;
- Connection conn = null;
- PreparedStatement insertQuery = null;
-
- try {
- // calculate the baselines for schedules that have no baseline yet (or were just deleted)
- // do everything via JDBC - our perf testing shows that we hit entity cache locking timeouts
- // when the entity manager performs native queries under heavy load
- conn = dataSource.getConnection();
- DatabaseType dbType = DatabaseTypeFactory.getDatabaseType(conn);
-
- if (dbType instanceof PostgresqlDatabaseType || dbType instanceof H2DatabaseType) {
- insertQuery = conn.prepareStatement(MeasurementBaseline.NATIVE_QUERY_CALC_FIRST_AUTOBASELINE_POSTGRES);
- insertQuery.setLong(1, computeTime);
- insertQuery.setLong(2, startTime);
- insertQuery.setLong(3, endTime);
- insertQuery.setLong(4, startTime);
- } else if (dbType instanceof OracleDatabaseType) {
- insertQuery = conn.prepareStatement(MeasurementBaseline.NATIVE_QUERY_CALC_FIRST_AUTOBASELINE_ORACLE);
- insertQuery.setLong(1, computeTime);
- insertQuery.setLong(2, startTime);
- insertQuery.setLong(3, endTime);
- insertQuery.setLong(4, startTime);
- } else if (dbType instanceof SQLServerDatabaseType) {
- insertQuery = conn.prepareStatement(MeasurementBaseline.NATIVE_QUERY_CALC_FIRST_AUTOBASELINE_SQLSERVER);
- insertQuery.setLong(1, computeTime);
- insertQuery.setLong(2, startTime);
- insertQuery.setLong(3, endTime);
- insertQuery.setLong(4, startTime);
- } else {
- throw new IllegalArgumentException("Unknown database type, can't continue: " + dbType);
- }
+ //1. Find dynamic schedule ids that do not have baseline calculated
+ Query query = this.entityManager
+ .createNamedQuery(MeasurementBaseline.QUERY_FIND_MEASUREMENT_SCHEDULES_WITHOUT_AUTOBASELINES);
+ query.setMaxResults(BASELINE_PROCESSING_LIMIT);
+ List<String> scheduleIdsWithoutBaselines = query.getResultList();
- int inserted = insertQuery.executeUpdate();
- return inserted;
- } finally {
- if (insertQuery != null) {
- try {
- insertQuery.close();
- } catch (Exception e) {
- }
- }
+ //2. calculate the baselines based metrics data
+ MetricBaselineCalculator baselineCalculator = new MetricBaselineCalculator();
+ List<MeasurementBaseline> results = baselineCalculator.calculateBaselines(scheduleIdsWithoutBaselines,
+ startTime, endTime);
- if (conn != null) {
- try {
- conn.close();
- } catch (Exception e) {
- }
- }
+ //3. persist all calculated baselines to SQL db
+ for (Object result : results) {
+ entityManager.persist(result);
}
- }
-
- @SuppressWarnings("unused")
- @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
- //@TransactionTimeout( 60 * 60 )
- private int _calculateAutoBaselinesDELETE_HQL(long startTime, long endTime) throws Exception {
- Query query = entityManager.createNamedQuery(MeasurementBaseline.QUERY_DELETE_EXISTING_AUTOBASELINES);
-
- query.setParameter("startTime", startTime);
- query.setParameter("endTime", endTime);
-
- int rowsModified = query.executeUpdate();
-
- return rowsModified;
- }
-
- @SuppressWarnings("unused")
- @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
- //@TransactionTimeout( 60 * 60 )
- private int _calculateAutoBaselinesINSERT_HQL(long startTime, long endTime, long computeTime) throws Exception {
- Query query = entityManager.createNamedQuery(MeasurementBaseline.QUERY_CALC_FIRST_AUTOBASELINE);
-
- //query.setParameter("computeTime", computeTime);
- query.setParameter("startTime", startTime);
- query.setParameter("endTime", endTime);
-
- int rowsModified = query.executeUpdate();
+ entityManager.flush();
- return rowsModified;
+ //4. return the number of schedule ids initially retrieved for calculation
+ return scheduleIdsWithoutBaselines.size();
}
/**
diff --git a/modules/enterprise/server/server-metrics/src/main/java/org/rhq/server/metrics/MetricBaselineCalculator.java b/modules/enterprise/server/server-metrics/src/main/java/org/rhq/server/metrics/MetricBaselineCalculator.java
new file mode 100644
index 0000000..67853e3
--- /dev/null
+++ b/modules/enterprise/server/server-metrics/src/main/java/org/rhq/server/metrics/MetricBaselineCalculator.java
@@ -0,0 +1,67 @@
+/*
+ *
+ * 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.server.metrics;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Random;
+
+import org.rhq.core.domain.measurement.MeasurementBaseline;
+
+/**
+ * @author Stefan Negrea
+ */
+public class MetricBaselineCalculator {
+
+ public List<MeasurementBaseline> calculateBaselines(List<String> scheduleIds, long startTime, long endTime) {
+ List<MeasurementBaseline> calculatedBaselines = new ArrayList<MeasurementBaseline>();
+
+ MeasurementBaseline measurementBaseline;
+ for (String scheduleId : scheduleIds) {
+ //TODO: do processing to find the actual baseline for this schedule id
+ //!use data from Cassandra!
+
+ //for now just return a values
+ measurementBaseline = this.generateRandomBaseline();
+
+ if (measurementBaseline != null) {
+ calculatedBaselines.add(measurementBaseline);
+ }
+ }
+
+ return calculatedBaselines;
+ }
+
+ private MeasurementBaseline generateRandomBaseline() {
+ Random random = new Random(12345);
+
+ MeasurementBaseline randomBaseline = new MeasurementBaseline();
+ randomBaseline.setMax(random.nextDouble() * 1000);
+ randomBaseline.setMin(random.nextDouble() * 1000);
+ randomBaseline.setMean(random.nextDouble() * 1000);
+
+ return new MeasurementBaseline();
+ }
+}
11 years, 5 months
[rhq] modules/enterprise modules/test-utils
by Jay Shaughnessy
modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/measurement/MeasurementDataManagerBeanTest.java | 10 +-
modules/test-utils/src/main/java/org/rhq/test/AssertUtils.java | 41 ++++++++--
modules/test-utils/src/main/java/org/rhq/test/PropertyMatcher.java | 22 ++++-
3 files changed, 61 insertions(+), 12 deletions(-)
New commits:
commit d5a7ec0bed4d88493a5213ea0a43a9cda0f60610
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Thu Dec 13 16:12:49 2012 -0500
Add ability to specify Double comparison tolerances in our matcher test utils.
Hopefully this will handle the minor roundoff errors that are sinking some
some tests. When we move to cassandra we may be able to remove these tolerances from
the tests, given more precision in our math.
diff --git a/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/measurement/MeasurementDataManagerBeanTest.java b/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/measurement/MeasurementDataManagerBeanTest.java
index e87bff2..9e8b4e3 100644
--- a/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/measurement/MeasurementDataManagerBeanTest.java
+++ b/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/measurement/MeasurementDataManagerBeanTest.java
@@ -169,9 +169,9 @@ public class MeasurementDataManagerBeanTest extends AbstractEJB3Test {
buckets.get(29), Double.NaN, Double.NaN, Double.NaN);
assertPropertiesMatch("The data for bucket 0 does not match the expected values.", expectedBucket0Data,
- actualData.get(0));
+ actualData.get(0), 0.0001D);
assertPropertiesMatch("The data for bucket 59 does not match the expected values.", expectedBucket59Data,
- actualData.get(59));
+ actualData.get(59), 0.0001D);
assertPropertiesMatch("The data for bucket 29 does not match the expected values.", expectedBucket29Data,
actualData.get(29));
}
@@ -206,7 +206,7 @@ public class MeasurementDataManagerBeanTest extends AbstractEJB3Test {
MeasurementAggregate expected = new MeasurementAggregate(1.1, divide((1.1 + 2.2 + 3.3 + 4.4 + 5.5 + 6.6), 6),
6.6);
- AssertUtils.assertPropertiesMatch(expected, actual, "Aggregate does not match");
+ AssertUtils.assertPropertiesMatch("Aggregate does not match", expected, actual, 0.0001D);
}
@Test(enabled = ENABLED)
@@ -242,9 +242,9 @@ public class MeasurementDataManagerBeanTest extends AbstractEJB3Test {
buckets.get(59), divide((5.0 + 5.0 + 3.0), 3), 9.0, 2.0);
assertPropertiesMatch("The data for bucket 0 does not match the expected values.", expectedBucket0Data,
- actualData.get(0));
+ actualData.get(0), 0.0001D);
assertPropertiesMatch("The data for bucket 59 does not match the expected values.", expectedBucket59Data,
- actualData.get(59));
+ actualData.get(59), 0.0001D);
}
private void createInventory() throws Exception {
diff --git a/modules/test-utils/src/main/java/org/rhq/test/AssertUtils.java b/modules/test-utils/src/main/java/org/rhq/test/AssertUtils.java
index 7524fc8..50c1212 100644
--- a/modules/test-utils/src/main/java/org/rhq/test/AssertUtils.java
+++ b/modules/test-utils/src/main/java/org/rhq/test/AssertUtils.java
@@ -23,14 +23,14 @@
package org.rhq.test;
+import static org.testng.Assert.assertNotNull;
+import static org.testng.Assert.assertTrue;
+
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
-import static org.testng.Assert.assertNotNull;
-import static org.testng.Assert.assertTrue;
-
public class AssertUtils {
/**
@@ -44,7 +44,7 @@ public class AssertUtils {
* @param <T> The type of the objects to be compared
*/
public static <T> void assertPropertiesMatch(T expected, T actual, String msg) {
- assertPropertiesMatch(msg, expected, actual, Collections.<String>emptyList());
+ assertPropertiesMatch(msg, expected, actual, null, Collections.<String> emptyList());
}
/**
@@ -55,7 +55,20 @@ public class AssertUtils {
* @param <T> The type of the objects to be compared.
*/
public static <T> void assertPropertiesMatch(String msg, T expected, T actual, String... ignoredProperties) {
- assertPropertiesMatch(msg, expected, actual, Arrays.asList(ignoredProperties));
+ assertPropertiesMatch(msg, expected, actual, null, Arrays.asList(ignoredProperties));
+ }
+
+ /**
+ * @param msg An error message
+ * @param expected The expected object to compare against. Should be non-null.
+ * @param actual The actual object to be compared. Should be non-null.
+ * @param ignoredProperties A list of property names to exclude from comparison.
+ * @param maxDifference When matching doubles, the max roundoff difference still considered equal. If null Double.equals() is used.
+ * @param <T> The type of the objects to be compared.
+ */
+ public static <T> void assertPropertiesMatch(String msg, T expected, T actual, Double maxDifference,
+ String... ignoredProperties) {
+ assertPropertiesMatch(msg, expected, actual, maxDifference, Arrays.asList(ignoredProperties));
}
/**
@@ -70,12 +83,30 @@ public class AssertUtils {
* @param <T> The type of the objects to be compared.
*/
public static <T> void assertPropertiesMatch(String msg, T expected, T actual, List<String> ignoredProperties) {
+ assertPropertiesMatch(msg, expected, actual, null, ignoredProperties);
+ }
+
+ /**
+ * Verifies that all public, accessible properties of the two objects are equal, excluding those specified in the
+ * <code>ignoredProperties</code> argument. This method might be used when you want to compare two objects without
+ * using their <code>equals()</code> methods or when they do not implement <code>equals</code>.
+ *
+ * @param msg An error message
+ * @param expected The expected object to compare against. Should be non-null.
+ * @param actual The actual object to be compared. Should be non-null.
+ * @param maxDifference When matching doubles, the max roundoff difference still considered equal. If null Double.equals() is used.
+ * @param ignoredProperties A list of property names to exclude from comparison.
+ * @param <T> The type of the objects to be compared.
+ */
+ public static <T> void assertPropertiesMatch(String msg, T expected, T actual, Double maxDifference,
+ List<String> ignoredProperties) {
assertNotNull(expected, "Expected object should not be null");
assertNotNull(actual, "Actual object should not be null");
PropertyMatcher<T> matcher = new PropertyMatcher<T>();
matcher.setExpected(expected);
matcher.setActual(actual);
+ matcher.setMaxDifference(maxDifference);
matcher.setIgnoredProperties(ignoredProperties);
MatchResult result = matcher.execute();
diff --git a/modules/test-utils/src/main/java/org/rhq/test/PropertyMatcher.java b/modules/test-utils/src/main/java/org/rhq/test/PropertyMatcher.java
index 8d9b3cc..7f07c2d 100644
--- a/modules/test-utils/src/main/java/org/rhq/test/PropertyMatcher.java
+++ b/modules/test-utils/src/main/java/org/rhq/test/PropertyMatcher.java
@@ -23,14 +23,14 @@
package org.rhq.test;
-import org.apache.commons.beanutils.PropertyUtils;
-
import java.lang.reflect.InvocationTargetException;
import java.util.Collection;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
+import org.apache.commons.beanutils.PropertyUtils;
+
public class PropertyMatcher<T> {
private T expected;
@@ -39,6 +39,8 @@ public class PropertyMatcher<T> {
private Set<String> ignoredProperties = new HashSet<String>();
+ private Double maxDifference;
+
public void setExpected(T expected) {
this.expected = expected;
}
@@ -51,6 +53,10 @@ public class PropertyMatcher<T> {
this.ignoredProperties.addAll(ignoredProperties);
}
+ public void setMaxDifference(Double maxDifference) {
+ this.maxDifference = maxDifference;
+ }
+
public MatchResult execute() {
try {
Map<String, ?> expectedProps = PropertyUtils.describe(expected);
@@ -96,6 +102,18 @@ public class PropertyMatcher<T> {
if (expected == null && actual != null) {
return false;
}
+
+ if (maxDifference != null && expected instanceof Double) {
+ boolean result = expected.equals(actual);
+ if (!result) {
+ Double dExpected = (Double) expected;
+ Double dActual = (Double) actual;
+ Double diff = Math.abs(dExpected - dActual);
+ result = ((!diff.isNaN()) && (!diff.isInfinite()) && (diff < maxDifference));
+ }
+ return result;
+ }
+
return expected.equals(actual);
}
}
11 years, 5 months
[rhq] Branch 'feature/cassandra-backend' - 5 commits - modules/core modules/enterprise
by snegrea
modules/core/dbutils/pom.xml | 8
modules/core/domain/pom.xml | 45 -
modules/enterprise/server/itests-2/pom.xml | 19
modules/enterprise/server/jar/pom.xml | 13
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/auth/SessionManager.java | 8
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/naming/AccessCheckingInitialContextFactoryBuilder.java | 63 +-
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/naming/NamingHack.java | 2
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/sync/ExportingInputStream.java | 15
modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/naming/DecoratingInvocationHandlerTest.java | 2
modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/sync/test/ExportingInputStreamTest.java | 260 +++++++++-
10 files changed, 325 insertions(+), 110 deletions(-)
New commits:
commit ed5920e6ae433e37a1c8fa2bec94280724f314dd
Merge: 441379d 165b4f5
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Thu Dec 13 13:19:24 2012 -0600
Merge branch 'master' into feature/cassandra-backend
commit 165b4f583ca08f6a7c20ebcdaad7fe7f43508b90
Author: Jay Shaughnessy <jshaughn(a)jshaughn.csb>
Date: Thu Dec 13 13:18:09 2012 -0500
Fix an issue where the domain and server itests needed one of
-Ppostgres or -Poracle to be defined. Now it will default to
postgres unless -Pitest.oracle is set.
Also, removed some ojdbc-driver profile declarations that were
redundant with what is already defined in the root pom and should
be inherited.
diff --git a/modules/core/dbutils/pom.xml b/modules/core/dbutils/pom.xml
index c110636..c8fef74 100644
--- a/modules/core/dbutils/pom.xml
+++ b/modules/core/dbutils/pom.xml
@@ -435,13 +435,7 @@
<profile>
<id>ojdbc-driver</id>
- <dependencies>
- <dependency>
- <groupId>com.oracle</groupId>
- <artifactId>ojdbc6</artifactId>
- <version>${ojdbc6.version}</version>
- </dependency>
- </dependencies>
+ <!-- TODO: defer to root pom version when we can agree on a version -->
<build>
<plugins>
<plugin>
diff --git a/modules/core/domain/pom.xml b/modules/core/domain/pom.xml
index cb7699b..23d5fe0 100644
--- a/modules/core/domain/pom.xml
+++ b/modules/core/domain/pom.xml
@@ -18,6 +18,10 @@
<jboss.zip>${settings.localRepository}/org/jboss/as/jboss-as-dist/${jboss.version}/jboss-as-dist-${jboss.version}.zip</jboss.zip>
<jboss.unzip.location>${basedir}/target/jboss-as-${jboss.version}</jboss.unzip.location>
<rhq.internal>false</rhq.internal>
+ <!-- These properties guide which datasources are used for integration tests. Only one should be true.
+ The default is Postgres, specify -Pitest.oracle to use Oracle -->
+ <skip.postgres>false</skip.postgres>
+ <skip.oracle>true</skip.oracle>
</properties>
@@ -542,18 +546,14 @@
</build>
- <profiles>
-
- <!-- if you want to test on oracle, this can pull down the oracle jdbc driver that is needed -->
- <profile>
- <id>ojdbc-driver</id>
- <dependencies>
- <dependency>
- <groupId>com.oracle</groupId>
- <artifactId>ojdbc6</artifactId>
- <version>${ojdbc6.version}</version>
- </dependency>
- </dependencies>
+ <profiles>
+ <!-- If testing against oracle, override the default property settings -->
+ <profile>
+ <id>itest.oracle</id>
+ <properties>
+ <skip.postgres>true</skip.postgres>
+ <skip.oracle>false</skip.oracle>
+ </properties>
</profile>
<profile>
@@ -669,26 +669,7 @@
</plugins>
</build>
</profile>
-
- <profile>
- <id>postgres</id>
- <activation>
- <activeByDefault>true</activeByDefault>
- </activation>
- <properties>
- <skip.postgres>false</skip.postgres>
- <skip.oracle>true</skip.oracle>
- </properties>
- </profile>
-
- <profile>
- <id>oracle</id>
- <properties>
- <skip.postgres>true</skip.postgres>
- <skip.oracle>false</skip.oracle>
- </properties>
- </profile>
-
+
<profile>
<id>itest.debug</id>
<activation>
diff --git a/modules/enterprise/server/itests-2/pom.xml b/modules/enterprise/server/itests-2/pom.xml
index 01b377f..ba7dd7e 100644
--- a/modules/enterprise/server/itests-2/pom.xml
+++ b/modules/enterprise/server/itests-2/pom.xml
@@ -26,6 +26,10 @@
<jboss.vm.args>-Xmx700m -XX:MaxPermSize=200m -Djava.security.manager
-Djava.security.policy==${jboss.unzip.location}/security.policy</jboss.vm.args>
<jboss.vm.args.debug></jboss.vm.args.debug> <!-- -Ditest.debug can override this, see below -->
+ <!-- These properties guide which datasources are used for integration tests. Only one should be true.
+ The default is Postgres, specify -Pitest.oracle to use Oracle -->
+ <skip.postgres>false</skip.postgres>
+ <skip.oracle>true</skip.oracle>
</properties>
<dependencies>
@@ -672,19 +676,9 @@
</build>
<profiles>
+ <!-- If testing against oracle, override the default property settings -->
<profile>
- <id>postgres</id>
- <activation>
- <activeByDefault>true</activeByDefault>
- </activation>
- <properties>
- <skip.postgres>false</skip.postgres>
- <skip.oracle>true</skip.oracle>
- </properties>
- </profile>
-
- <profile>
- <id>oracle</id>
+ <id>itest.oracle</id>
<properties>
<skip.postgres>true</skip.postgres>
<skip.oracle>false</skip.oracle>
diff --git a/modules/enterprise/server/jar/pom.xml b/modules/enterprise/server/jar/pom.xml
index 98a7895..2033a2c 100644
--- a/modules/enterprise/server/jar/pom.xml
+++ b/modules/enterprise/server/jar/pom.xml
@@ -694,19 +694,6 @@
</build>
</profile>
- <!-- if you want to test on oracle, this can pull down the oracle jdbc driver that is needed -->
- <profile>
- <id>ojdbc-driver</id>
- <dependencies>
- <dependency>
- <groupId>com.oracle</groupId>
- <artifactId>ojdbc6</artifactId>
- <version>${ojdbc6.version}</version>
- </dependency>
- </dependencies>
- </profile>
-
-
<profile>
<id>dev</id>
commit e794a376e030ff34e237afcb9b4994768e489cd8
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Thu Dec 13 17:27:45 2012 +0100
Fixed the ExportingInputStream to correctly define the XML namespaces
(and thus work under woodstox, which is the XML streaming provider in AS7).
Re-enabled the SynchronizationManagerBeanTest.
diff --git a/modules/enterprise/server/itests-2/pom.xml b/modules/enterprise/server/itests-2/pom.xml
index f58396a..01b377f 100644
--- a/modules/enterprise/server/itests-2/pom.xml
+++ b/modules/enterprise/server/itests-2/pom.xml
@@ -656,7 +656,6 @@
<excludes>
<!-- NOTE: PERF GROUP AND SOME CLASSES EXCLUDED (SEE BZ 874696) -->
<exclude>**/LdapGroupManagerBeanTest.java</exclude>
- <exclude>**/SynchronizationManagerBeanTest.java</exclude>
<exclude>org/rhq/**/performance/**/*.java</exclude>
<!-- exclude the db tests which are not expected to run in this suite -->
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/sync/ExportingInputStream.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/sync/ExportingInputStream.java
index 19734f6..eae8d7d 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/sync/ExportingInputStream.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/sync/ExportingInputStream.java
@@ -34,7 +34,6 @@ import java.util.zip.GZIPOutputStream;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Marshaller;
-import javax.xml.namespace.NamespaceContext;
import javax.xml.stream.XMLOutputFactory;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamWriter;
@@ -238,19 +237,15 @@ public class ExportingInputStream extends InputStream {
*/
private void exportPrologue(XMLStreamWriter wrt) throws XMLStreamException {
wrt.setDefaultNamespace(SynchronizationConstants.EXPORT_NAMESPACE);
- wrt.setPrefix(SynchronizationConstants.EXPORT_NAMESPACE_PREFIX, SynchronizationConstants.EXPORT_NAMESPACE);
- wrt.setPrefix(SynchronizationConstants.CONFIGURATION_INSTANCE_NAMESPACE_PREFIX, SynchronizationConstants.CONFIGURATION_INSTANCE_NAMESPACE);
- wrt.setPrefix(SynchronizationConstants.CONFIGURATION_NAMESPACE_PREFIX, SynchronizationConstants.CONFIGURATION_NAMESPACE);
-
- NamespaceContext nsContext = SynchronizationConstants.createConfigurationExportNamespaceContext();
-
- wrt.setNamespaceContext(nsContext);
wrt.writeStartDocument();
wrt.writeStartElement(SynchronizationConstants.EXPORT_NAMESPACE, SynchronizationConstants.CONFIGURATION_EXPORT_ELEMENT);
- wrt.writeNamespace(SynchronizationConstants.CONFIGURATION_INSTANCE_NAMESPACE_PREFIX, ConfigurationInstanceDescriptorUtil.NS_CONFIGURATION_INSTANCE);
- wrt.writeNamespace(SynchronizationConstants.CONFIGURATION_NAMESPACE_PREFIX, SynchronizationConstants.CONFIGURATION_NAMESPACE);
+ wrt.writeNamespace(SynchronizationConstants.CONFIGURATION_INSTANCE_NAMESPACE_PREFIX,
+ ConfigurationInstanceDescriptorUtil.NS_CONFIGURATION_INSTANCE);
+ wrt.writeNamespace(SynchronizationConstants.CONFIGURATION_NAMESPACE_PREFIX,
+ SynchronizationConstants.CONFIGURATION_NAMESPACE);
+
writeValidators(wrt);
}
diff --git a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/sync/test/ExportingInputStreamTest.java b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/sync/test/ExportingInputStreamTest.java
index 6d56969..db6393e 100644
--- a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/sync/test/ExportingInputStreamTest.java
+++ b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/sync/test/ExportingInputStreamTest.java
@@ -28,6 +28,8 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
+import java.nio.charset.Charset;
+import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
@@ -36,9 +38,19 @@ import java.util.List;
import java.util.Set;
import javax.persistence.EntityManager;
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBException;
+import javax.xml.bind.Unmarshaller;
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamConstants;
import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -56,12 +68,14 @@ import org.rhq.core.domain.sync.ExporterMessages;
import org.rhq.enterprise.server.sync.ExportReader;
import org.rhq.enterprise.server.sync.ExportWriter;
import org.rhq.enterprise.server.sync.ExportingInputStream;
+import org.rhq.enterprise.server.sync.ImportException;
import org.rhq.enterprise.server.sync.NoSingleEntity;
import org.rhq.enterprise.server.sync.SynchronizationConstants;
import org.rhq.enterprise.server.sync.Synchronizer;
import org.rhq.enterprise.server.sync.exporters.AbstractDelegatingExportingIterator;
import org.rhq.enterprise.server.sync.exporters.Exporter;
import org.rhq.enterprise.server.sync.exporters.ExportingIterator;
+import org.rhq.enterprise.server.sync.exporters.JAXBExportingIterator;
import org.rhq.enterprise.server.sync.importers.ExportedEntityMatcher;
import org.rhq.enterprise.server.sync.importers.Importer;
import org.rhq.enterprise.server.sync.validators.ConsistencyValidator;
@@ -90,7 +104,9 @@ public class ExportingInputStreamTest extends JMockTest {
}
public void export(ExportWriter output) throws XMLStreamException {
- output.writeCData(getCurrent().toString());
+ output.writeStartElement("datum");
+ output.writeCharacters(getCurrent().toString());
+ output.writeEndElement();
}
public String getNotes() {
@@ -191,6 +207,140 @@ public class ExportingInputStreamTest extends JMockTest {
}
}
+ public static class Entity {
+ public int value;
+
+ public Entity(int value) {
+ this.value = value;
+ }
+ }
+
+ @XmlRootElement(name = "exported-entity")
+ @XmlAccessorType(XmlAccessType.FIELD)
+ public static class ExportedEntity {
+
+ @XmlAttribute
+ public int property;
+ }
+
+ public static class JAXBExporter implements Exporter<Entity, ExportedEntity> {
+
+ private static class JAXBIterator extends JAXBExportingIterator<ExportedEntity, Entity> {
+
+ public JAXBIterator(java.util.Iterator<Entity> sourceIterator) {
+ super(sourceIterator, ExportedEntity.class);
+ }
+
+ @Override
+ protected ExportedEntity convert(Entity object) {
+ ExportedEntity ret = new ExportedEntity();
+ ret.property = object.value;
+
+ return ret;
+ }
+
+ @Override
+ public String getNotes() {
+ return null;
+ }
+ }
+
+ @Override
+ public ExportingIterator<ExportedEntity> getExportingIterator() {
+ List<Entity> data = new ArrayList<Entity>();
+ for(int i = 0; i < 4; ++i) {
+ data.add(new Entity(i));
+ }
+
+ return new JAXBIterator(data.iterator());
+ }
+
+ @Override
+ public String getNotes() {
+ return null;
+ }
+
+ }
+
+ public static class JAXBImporter implements Importer<Entity, ExportedEntity> {
+
+ private Unmarshaller unmarshaller;
+ {
+ try {
+ JAXBContext context = JAXBContext.newInstance(ExportedEntity.class);
+ unmarshaller = context.createUnmarshaller();
+ } catch (JAXBException e) {
+ throw new IllegalStateException(e);
+ }
+ }
+
+ @Override
+ public ConfigurationDefinition getImportConfigurationDefinition() {
+ return null;
+ }
+
+ @Override
+ public void configure(Configuration importConfiguration) {
+ }
+
+ @Override
+ public ExportedEntityMatcher<Entity, ExportedEntity> getExportedEntityMatcher() {
+ return new ExportedEntityMatcher<Entity, ExportedEntity>() {
+ @Override
+ public Entity findMatch(ExportedEntity object) {
+ return new Entity(object.property);
+ }
+ };
+ }
+
+ @Override
+ public Set<EntityValidator<ExportedEntity>> getEntityValidators() {
+ return Collections.emptySet();
+ }
+
+ @Override
+ public void update(Entity entity, ExportedEntity exportedEntity) throws Exception {
+ entity.value = exportedEntity.property;
+ }
+
+ @Override
+ public ExportedEntity unmarshallExportedEntity(ExportReader reader) throws XMLStreamException {
+ try {
+ return (ExportedEntity) unmarshaller.unmarshal(reader);
+ } catch (JAXBException e) {
+ throw new XMLStreamException(e);
+ }
+ }
+
+ @Override
+ public String finishImport() throws Exception {
+ return null;
+ }
+
+ }
+
+ public static class JAXBSynchronizer implements Synchronizer<Entity, ExportedEntity> {
+
+ @Override
+ public void initialize(Subject subject, EntityManager entityManager) {
+ }
+
+ @Override
+ public Exporter<Entity, ExportedEntity> getExporter() {
+ return new JAXBExporter();
+ }
+
+ @Override
+ public Importer<Entity, ExportedEntity> getImporter() {
+ return new JAXBImporter();
+ }
+
+ @Override
+ public Set<ConsistencyValidator> getRequiredValidators() {
+ return Collections.emptySet();
+ }
+
+ }
public void testSucessfulExport() throws Exception {
List<String> list1 = Arrays.asList("a", "b", "c");
@@ -203,11 +353,11 @@ public class ExportingInputStreamTest extends JMockTest {
InputStream export = new ExportingInputStream(exporters, new HashMap<String, ExporterMessages>(), 1024, false);
-// String exportContents = readAll(new InputStreamReader(export, "UTF-8"));
-//
-// LOG.info("Export contents:\n" + exportContents);
-//
-// export = new ByteArrayInputStream(exportContents.getBytes("UTF-8"));
+ String exportContents = readAll(new InputStreamReader(export, "UTF-8"));
+
+ LOG.info("Export contents:\n" + exportContents);
+
+ export = new ByteArrayInputStream(exportContents.getBytes("UTF-8"));
DocumentBuilder bld = DocumentBuilderFactory.newInstance().newDocumentBuilder();
@@ -264,16 +414,108 @@ public class ExportingInputStreamTest extends JMockTest {
Node data = getDirectChildByTagName(entityElement, SynchronizationConstants.DATA_ELEMENT);
assertNotNull(data, "Could not find data element in the entity.");
- String dataText = ((Element)data).getTextContent();
+ Node datum = getDirectChildByTagName(data, "datum");
+ assertNotNull(datum, "Could not find the exported datum element containing the actual data.");
+
+ String datumText = ((Element) datum).getTextContent();
notesText = ((Element)note).getTextContent();
- assertEquals(notesText, ListToStringExporter.NOTE_PREFIX + dataText, "Unexpected discrepancy between data and notes in the export.");
+ assertEquals(notesText, ListToStringExporter.NOTE_PREFIX + datumText,
+ "Unexpected discrepancy between data and notes in the export.");
}
++elementIndex;
}
}
+ @Test
+ public void testJAXBHandled() throws Exception {
+ JAXBSynchronizer sync = new JAXBSynchronizer();
+
+ Set<Synchronizer<?, ?>>syncs = this.<Synchronizer<?, ?>> asSet(sync);
+
+ InputStream export = new ExportingInputStream(syncs, new HashMap<String, ExporterMessages>(), 1024, false);
+
+ String exportContents = readAll(new InputStreamReader(export, "UTF-8"));
+
+ XMLStreamReader rdr = XMLInputFactory.newInstance().createXMLStreamReader(
+ new ByteArrayInputStream(exportContents.getBytes(Charset.forName("UTF-8"))));
+
+ try {
+ while (rdr.hasNext()) {
+ switch (rdr.next()) {
+ case XMLStreamReader.START_ELEMENT:
+ String tagName = rdr.getName().getLocalPart();
+ if (SynchronizationConstants.ENTITIES_EXPORT_ELEMENT.equals(tagName)) {
+ try {
+ importSingle(rdr);
+ } catch (Exception e) {
+ //fail fast on the import errors... This runs in a single transaction
+ //so all imports done so far will get rolled-back.
+ //(Even if we change our minds later and run a transaction per importer
+ //we should fail fast to prevent further damage due to possible
+ //constraint violations in the db, etc.)
+ throw new ImportException("Import failed.", e);
+ }
+ }
+ break;
+ }
+ }
+ } finally {
+ rdr.close();
+ }
+ }
+
+ private <E, X> void importSingle(XMLStreamReader rdr)
+ throws Exception {
+ String synchronizerClassName = rdr.getAttributeValue(null, SynchronizationConstants.ID_ATTRIBUTE);
+
+ @SuppressWarnings("unchecked")
+ Synchronizer<E, X> synchronizer = instantiate(synchronizerClassName, Synchronizer.class,
+ "The synchronizer denoted in the export file ('%s') does not implement the importer interface. This should not happen.");
+
+ Importer<E, X> importer = synchronizer.getImporter();
+
+ ExportedEntityMatcher<E, X> matcher = importer.getExportedEntityMatcher();
+
+ //the passed in configuration has precedence over the default one inlined in
+ //the config file.
+ while (rdr.hasNext()) {
+ boolean bailout = false;
+ switch (rdr.next()) {
+ case XMLStreamConstants.START_ELEMENT:
+ if (SynchronizationConstants.DATA_ELEMENT.equals(rdr.getName().getLocalPart())) {
+
+ rdr.nextTag();
+ X exportedEntity = importer.unmarshallExportedEntity(new ExportReader(rdr));
+ E entity = matcher == null ? null : matcher.findMatch(exportedEntity);
+ importer.update(entity, exportedEntity);
+ }
+ break;
+ case XMLStreamConstants.END_ELEMENT:
+ if (SynchronizationConstants.ENTITIES_EXPORT_ELEMENT.equals(rdr.getName().getLocalPart())) {
+ bailout = true;
+ }
+ }
+
+ if (bailout) {
+ break;
+ }
+ }
+ }
+
+ private <T> T instantiate(String className, Class<T> desiredClass, String notAssignableErrorMessage)
+ throws InstantiationException, IllegalAccessException, ClassNotFoundException {
+ Class<?> cls = Class.forName(className);
+ if (!desiredClass.isAssignableFrom(cls)) {
+ throw new IllegalStateException(String.format(notAssignableErrorMessage, className, desiredClass.getName()));
+ }
+
+ Object instance = cls.newInstance();
+
+ return desiredClass.cast(instance);
+ }
+
@Test(expectedExceptions = IOException.class)
public void testExceptionHandling_Exporter_getExportingIterator() throws Exception {
final Exporter<?, ?> failingExporter = context.mock(Exporter.class);
@@ -452,7 +694,7 @@ public class ExportingInputStreamTest extends JMockTest {
return n;
}
}
-
+
return null;
}
}
commit b62fb191a178d06fe48b47b2508fd4cb0aa039ca
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Thu Dec 13 16:15:00 2012 +0100
Modified the access checking JNDI lookup wrappers to take into account
the slightly different behavior needed when there was originally no
initial context factory builder or if there originally was some.
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/naming/AccessCheckingInitialContextFactoryBuilder.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/naming/AccessCheckingInitialContextFactoryBuilder.java
index 9681014..52addaa 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/naming/AccessCheckingInitialContextFactoryBuilder.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/naming/AccessCheckingInitialContextFactoryBuilder.java
@@ -32,6 +32,7 @@ import java.util.EnumMap;
import java.util.Enumeration;
import java.util.HashSet;
import java.util.Hashtable;
+import java.util.List;
import java.util.Set;
import javax.naming.Context;
@@ -138,7 +139,7 @@ public class AccessCheckingInitialContextFactoryBuilder implements InitialContex
}
private enum FactoryType {
- ACCESS_CHECKING {
+ ACCESS_CHECKING_URL_PREFERRING {
@Override
public InitialContextFactory wrap(InitialContextFactory factory) {
@@ -158,15 +159,34 @@ public class AccessCheckingInitialContextFactoryBuilder implements InitialContex
return new DecoratingInitialContextFactory(factory, pickers);
}
+ },
+ ACCESS_CHECKING {
+
+ @Override
+ public InitialContextFactory wrap(InitialContextFactory factory) {
+ ArrayList<DecoratorPicker<Context, ContextDecorator>> pickers = new ArrayList<DecoratorPicker<Context, ContextDecorator>>();
+ pickers.add(getAccessCheckingDecoratorPicker());
+
+ return new DecoratingInitialContextFactory(factory, pickers);
+ }
+ },
+ PASS_THROUGH {
+
+ @Override
+ public InitialContextFactory wrap(InitialContextFactory factory) {
+ List<DecoratorPicker<Context, ContextDecorator>> pickers = Collections.emptyList();
+
+ return new DecoratingInitialContextFactory(factory, pickers);
+ }
};
public abstract InitialContextFactory wrap(InitialContextFactory factory);
- public static FactoryType detect(Hashtable<?, ?> environment) {
+ public static FactoryType detect(Hashtable<?, ?> environment, boolean pretendNoFactoryBuilder) {
String providerUrl = (String) environment.get(Context.PROVIDER_URL);
if (providerUrl == null) {
- return ACCESS_CHECKING;
+ return pretendNoFactoryBuilder ? ACCESS_CHECKING_URL_PREFERRING : ACCESS_CHECKING;
} else {
try {
URI uri = new URI(providerUrl);
@@ -175,9 +195,9 @@ public class AccessCheckingInitialContextFactoryBuilder implements InitialContex
//check if we are accessing the RHQ server through some remoting
//interface.
if (uri.getPort() == JNP_PORT && SERVER_BIND_IPS.contains(providerHost)) {
- return ACCESS_CHECKING;
+ return pretendNoFactoryBuilder ? ACCESS_CHECKING_URL_PREFERRING : ACCESS_CHECKING;
} else {
- return URL_PREFERRING;
+ return pretendNoFactoryBuilder ? URL_PREFERRING : PASS_THROUGH;
}
} catch (URISyntaxException e) {
if (LOG.isDebugEnabled()) {
@@ -185,7 +205,7 @@ public class AccessCheckingInitialContextFactoryBuilder implements InitialContex
+ Context.PROVIDER_URL
+ " is not a valid URI. Falling back to using the access checking wrapper.", e);
}
- return ACCESS_CHECKING;
+ return pretendNoFactoryBuilder ? ACCESS_CHECKING_URL_PREFERRING : ACCESS_CHECKING;
} catch (UnknownHostException e) {
//let the factory deal with the unknown host...
//this most probably shouldn't be secured because localhost addresses
@@ -195,7 +215,7 @@ public class AccessCheckingInitialContextFactoryBuilder implements InitialContex
+ Context.PROVIDER_URL
+ " is not resolvable. Falling back to using the URL preferring wrapper.", e);
}
- return URL_PREFERRING;
+ return pretendNoFactoryBuilder ? URL_PREFERRING : PASS_THROUGH;
}
}
}
@@ -219,15 +239,19 @@ public class AccessCheckingInitialContextFactoryBuilder implements InitialContex
FactoryType.class);
private final String defaultFactoryClassName;
-
+ private final boolean pretendNoFactoryBuilder;
+
/**
* @param defaultFactory the default factory to use if none can be deduced from the environment. If null, an attempt
* is made to obtain the default InitialContextFactory of JBoss AS (which may fail depending on the classloading
* "situation").
+ * @param pretendNoFactoryBuilder true if the naming contexts should pretend as if there was no initial context
+ * factory builder installed. This is to support environments as AS4, where there really was no builder initially
+ * and the lookup relied on that fact.
*
* @throws NamingException
*/
- public AccessCheckingInitialContextFactoryBuilder(InitialContextFactory defaultFactory) throws NamingException {
+ public AccessCheckingInitialContextFactoryBuilder(InitialContextFactory defaultFactory, final boolean pretendNoFactoryBuilder) throws NamingException {
if (defaultFactory == null) {
defaultFactory = getJbossDefaultInitialContextFactory();
}
@@ -237,21 +261,22 @@ public class AccessCheckingInitialContextFactoryBuilder implements InitialContex
for (FactoryType ft : FactoryType.values()) {
typeDefaults.put(ft, ft.wrap(defaultFactory));
}
+
+ this.pretendNoFactoryBuilder = pretendNoFactoryBuilder;
+
+ this.defaultFactory = new InitialContextFactory() {
+ public Context getInitialContext(Hashtable<?, ?> environment) throws NamingException {
+ return typeDefaults.get(FactoryType.detect(environment, pretendNoFactoryBuilder)).getInitialContext(
+ environment);
+ }
+ };
}
/**
* This is the default initial context factory that is returned when no other is
* configured using the environment variables.
- * <p>
- * It uses {@link NamingContextFactory} as the underlying mechanism - the same
- * as the default configuration in JBoss 4.
*/
- private final InitialContextFactory defaultFactory = new InitialContextFactory() {
- public Context getInitialContext(Hashtable<?, ?> environment) throws NamingException {
- return typeDefaults.get(FactoryType.detect(environment)).getInitialContext(
- environment);
- }
- };
+ private final InitialContextFactory defaultFactory;
/**
* Create a InitialContext factory. If the environment does not override the factory class it will use the
@@ -273,7 +298,7 @@ public class AccessCheckingInitialContextFactoryBuilder implements InitialContex
try {
final Class<?> factoryClass = Class.forName(factoryClassName, true, classLoader);
InitialContextFactory configuredFactory = (InitialContextFactory) factoryClass.newInstance();
- return FactoryType.detect(environment).wrap(configuredFactory);
+ return FactoryType.detect(environment, pretendNoFactoryBuilder).wrap(configuredFactory);
} catch (Exception e) {
NamingException ne = new NamingException("Failed instantiate InitialContextFactory "
+ factoryClassName
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/naming/NamingHack.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/naming/NamingHack.java
index f21322f..a4173ca 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/naming/NamingHack.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/naming/NamingHack.java
@@ -79,7 +79,7 @@ public class NamingHack {
}
NamingManager.setInitialContextFactoryBuilder(new AccessCheckingInitialContextFactoryBuilder(
- defaultFactory));
+ defaultFactory, originalBuilder == null));
} catch (Exception e) {
LOG.error("Failed to install a custom initial context factory builder. RHQ installation is unsecure!",
e);
diff --git a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/naming/DecoratingInvocationHandlerTest.java b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/naming/DecoratingInvocationHandlerTest.java
index c92cc42..a5daa9f 100644
--- a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/naming/DecoratingInvocationHandlerTest.java
+++ b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/naming/DecoratingInvocationHandlerTest.java
@@ -106,7 +106,7 @@ public class DecoratingInvocationHandlerTest {
@BeforeClass
public void setBuilder() throws Exception {
NamingManager.setInitialContextFactoryBuilder(new AccessCheckingInitialContextFactoryBuilder(
- new org.jboss.as.naming.InitialContextFactory()));
+ new org.jboss.as.naming.InitialContextFactory(), false));
}
public void testSimpleDispatch() throws Exception {
commit 3f1149427123c1bbafdb8596e87b776f84b59d54
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Wed Dec 12 16:59:22 2012 +0100
Recovering from the merge of commit 2ce8b7aa063a56840090ed553f47b6e3a0ba7845.
The SessionManager should do the security checks, we've got JNDI security
working.
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/auth/SessionManager.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/auth/SessionManager.java
index ccffd37..c2b8270 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/auth/SessionManager.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/auth/SessionManager.java
@@ -45,8 +45,7 @@ import org.rhq.enterprise.server.util.LookupUtil;
*/
public final class SessionManager {
- // TODO JNDI
- // private static final AllowRhqServerInternalsAccessPermission ACCESS_PERMISSION = new AllowRhqServerInternalsAccessPermission();
+ private static final AllowRhqServerInternalsAccessPermission ACCESS_PERMISSION = new AllowRhqServerInternalsAccessPermission();
/**
* Our source for random session IDs.
@@ -278,8 +277,7 @@ public final class SessionManager {
}
private static void checkPermission() {
- // TODO JNDI
- // SecurityManager sm = System.getSecurityManager();
- // if (sm != null) sm.checkPermission(ACCESS_PERMISSION);
+ SecurityManager sm = System.getSecurityManager();
+ if (sm != null) sm.checkPermission(ACCESS_PERMISSION);
}
}
\ No newline at end of file
11 years, 5 months
[rhq] Branch 'feature/cassandra-backend' - modules/enterprise
by John Sanda
modules/enterprise/server/appserver/src/main/scripts/rhq-container.build.xml | 37 +++++++++-
1 file changed, 36 insertions(+), 1 deletion(-)
New commits:
commit 441379dd21e6b35b129dee236fe265eebe68f0b4
Author: John Sanda <jsanda(a)redhat.com>
Date: Thu Dec 13 14:12:50 2012 -0500
fixing bad merge and adding cassandra dev properties
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 f405089..bb4fce6 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
@@ -607,6 +607,7 @@ rhq.sync.endpoint-address=false
# etc. The server does however persist content for text files or any other
# files that are not known binary types.
#rhq.server.drift.store-binary-content=${rhq.server.drift.store-binary-content}
+
#############################################
# Cassandra cluster configuration settings
#############################################
@@ -668,8 +669,42 @@ rhq.casandra.native-transport-max-threads=${rhq.casandra.native-transport-max-th
<copy todir="${project.build.outputDirectory}" verbose="true">
<fileset dir="src/main/dev-resources" />
</copy>
+ <loadproperties>
+ <zipentry zipfile="${settings.localRepository}/org/rhq/rhq-cassandra-common/${project.version}/rhq-cassandra-common-${project.version}.jar"
+ name="cassandra.properties"/>
+ </loadproperties>
<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>
+ <echo file="${project.build.outputDirectory}/bin/rhq-server.properties" append="true">
+rhq.server.agent-update.nonstrict-version-check=true
+
+# 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=${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>
+ <replace file="${project.build.outputDirectory}/bin/rhq-server.sh">
+ <replacefilter>
+ <replacetoken># START SERVER</replacetoken>
+ <replacevalue><![CDATA[export RHQ_SERVER_HOME; ${RHQ_SERVER_HOME}/bin/rhq-autoinstall.sh &]]></replacevalue>
+ </replacefilter>
+ </replace>
+ <replace file="${project.build.outputDirectory}/bin/rhq-server.bat">
+ <replacefilter>
+ <replacetoken>rem START SERVER</replacetoken>
+ <replacevalue><![CDATA[start /B %RHQ_SERVER_HOME%\bin\rhq-autoinstall.bat]]></replacevalue>
+ </replacefilter>
+ </replace>
</target>
<!-- The prepare-release target must be run AFTER the resources:resources goal has executed. -->
11 years, 5 months