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.
*