modules/common/cassandra-ccm/cassandra-ccm-core/src/main/java/org/rhq/cassandra/UnmanagedDeployer.java
| 17
modules/common/cassandra-installer/pom.xml
| 174 ++++++++++
modules/common/cassandra-installer/src/main/java/org/rhq/cassandra/installer/CassandraInstaller.java
| 153 ++++++++
modules/common/pom.xml
| 1
4 files changed, 328 insertions(+), 17 deletions(-)
New commits:
commit ce678b6298aea507b9443ba3e7a3341b95f9f920
Author: John Sanda <jsanda(a)redhat.com>
Date: Wed Jan 30 21:48:48 2013 -0500
add a reminder for updating rhq-server.properties
diff --git
a/modules/common/cassandra-installer/src/main/java/org/rhq/cassandra/installer/CassandraInstaller.java
b/modules/common/cassandra-installer/src/main/java/org/rhq/cassandra/installer/CassandraInstaller.java
index 368071a..8794c4d 100644
---
a/modules/common/cassandra-installer/src/main/java/org/rhq/cassandra/installer/CassandraInstaller.java
+++
b/modules/common/cassandra-installer/src/main/java/org/rhq/cassandra/installer/CassandraInstaller.java
@@ -107,6 +107,7 @@ public class CassandraInstaller {
UnmanagedDeployer deployer = new UnmanagedDeployer();
deployer.unpackBundle();
deployer.deploy(options, 1);
+ System.out.println(getInstallationSummary(options));
deployer.cleanUpBundle();
}
}
@@ -125,6 +126,17 @@ public class CassandraInstaller {
return options;
}
+ public String getInstallationSummary(DeploymentOptions options) {
+ return "\n" +
+ "Installation Summary:\n" +
+ "Finished installing Cassandra in " + options.getBasedir() +
"\n\n" +
+ "IMPORTANT - remember to update the rhq.cassandra.seeds property in
rhq-server.properties with the " +
+ "following:\n" +
+ "\thostname: " + options.getListenAddress() + "\n" +
+ "\tthrift port: " + options.getRpcPort() + "\n" +
+ "\tcql port: " + options.getNativeTransportPort();
+ }
+
public static void main(String[] args) throws Exception {
System.out.println("Running Cassandra installer...");
CassandraInstaller installer = new CassandraInstaller();
commit 7329251321d53ccec536ea6eb1b391a5a3e70308
Author: John Sanda <jsanda(a)redhat.com>
Date: Wed Jan 30 21:37:38 2013 -0500
initial commit for cassandra-installer module
This is a first pass at a stand alone installer. The goal right now is to have
something in place so that QE can start testing.
diff --git
a/modules/common/cassandra-ccm/cassandra-ccm-core/src/main/java/org/rhq/cassandra/UnmanagedDeployer.java
b/modules/common/cassandra-ccm/cassandra-ccm-core/src/main/java/org/rhq/cassandra/UnmanagedDeployer.java
index 1668afa..7eabb86 100644
---
a/modules/common/cassandra-ccm/cassandra-ccm-core/src/main/java/org/rhq/cassandra/UnmanagedDeployer.java
+++
b/modules/common/cassandra-ccm/cassandra-ccm-core/src/main/java/org/rhq/cassandra/UnmanagedDeployer.java
@@ -58,19 +58,6 @@ public class UnmanagedDeployer {
private File bundleDir;
- public void setDeploymentOptions(DeploymentOptions deploymentOptions) {
- this.deploymentOptions = deploymentOptions;
- }
-
- public String getCassandraHosts() {
- StringBuilder hosts = new StringBuilder();
- for (int i = 0; i < deploymentOptions.getNumNodes(); ++i) {
- hosts.append(getLocalIPAddress(i + 1)).append(":9160,");
- }
- hosts.deleteCharAt(hosts.length() - 1);
- return hosts.toString();
- }
-
public void unpackBundle() throws CassandraException {
try {
File bundleZipFile = unpackBundleZipFile();
@@ -145,8 +132,4 @@ public class UnmanagedDeployer {
return bundleDir;
}
- private String getLocalIPAddress(int i) {
- return "127.0.0." + i;
- }
-
}
diff --git a/modules/common/cassandra-installer/pom.xml
b/modules/common/cassandra-installer/pom.xml
new file mode 100644
index 0000000..bf85e56
--- /dev/null
+++ b/modules/common/cassandra-installer/pom.xml
@@ -0,0 +1,174 @@
+<project
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.rhq</groupId>
+ <artifactId>rhq-common-parent</artifactId>
+ <version>4.6.0-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>rhq-cassandra-installer</artifactId>
+ <name>RHQ Cassandra Installer</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>rhq-cassandra-ccm-core</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>commons-cli</groupId>
+ <artifactId>commons-cli</artifactId>
+ <version>1.2</version>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-jar-plugin</artifactId>
+ <!--<configuration>-->
+ <!--<archive>-->
+ <!--<manifest>-->
+
<!--<mainClass>org.rhq.cassandra.installer.Main</mainClass>-->
+ <!--<addClasspath>true</addClasspath>-->
+ <!--<classpathPrefix>lib/</classpathPrefix>-->
+ <!--</manifest>-->
+ <!--</archive>-->
+ <!--</configuration>-->
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-assembly-plugin</artifactId>
+ <version>2.2-beta-4</version>
+ <configuration>
+ <descriptorRefs>
+ <descriptorRef>jar-with-dependencies</descriptorRef>
+ </descriptorRefs>
+ <archive>
+ <manifest>
+
<mainClass>org.rhq.cassandra.installer.CassandraInstaller</mainClass>
+ </manifest>
+ </archive>
+ </configuration>
+ <executions>
+ <execution>
+ <phase>package</phase>
+ <goals>
+ <goal>single</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <!--<plugin>-->
+ <!--<artifactId>maven-dependency-plugin</artifactId>-->
+ <!--<executions>-->
+ <!--<execution>-->
+ <!--<id>copy-deps</id>-->
+ <!--<phase>prepare-package</phase>-->
+ <!--<goals>-->
+ <!--<goal>copy</goal>-->
+ <!--</goals>-->
+ <!--<configuration>-->
+
<!--<outputDirectory>${project.build.outputDirectory}/lib</outputDirectory>-->
+ <!--<artifactItems>-->
+ <!--<artifactItem>-->
+ <!--<groupId>${project.groupId}</groupId>-->
+
<!--<artifactId>rhq-cassandra-ccm-core</artifactId>-->
+ <!--</artifactItem>-->
+ <!--<artifactItem>-->
+ <!--<groupId>${project.groupId}</groupId>-->
+
<!--<artifactId>rhq-ant-bundle-common</artifactId>-->
+ <!--<version>${project.version}</version>-->
+ <!--</artifactItem>-->
+ <!--<artifactItem>-->
+ <!--<groupId>${project.groupId}</groupId>-->
+ <!--<artifactId>rhq-core-util</artifactId>-->
+ <!--<version>${project.version}</version>-->
+ <!--</artifactItem>-->
+ <!--<artifactItem>-->
+ <!--<groupId>jdom</groupId>-->
+ <!--<artifactId>jdom</artifactId>-->
+ <!--<version>1.0</version>-->
+ <!--</artifactItem>-->
+ <!--<artifactItem>-->
+ <!--<groupId>i18nlog</groupId>-->
+ <!--<artifactId>i18nlog</artifactId>-->
+ <!--<version>1.0.10</version>-->
+ <!--</artifactItem>-->
+ <!--<artifactItem>-->
+ <!--<groupId>${project.groupId}</groupId>-->
+
<!--<artifactId>rhq-core-native-system</artifactId>-->
+ <!--<version>${project.version}</version>-->
+ <!--</artifactItem>-->
+ <!--<artifactItem>-->
+ <!--<groupId>org.apache.ant</groupId>-->
+ <!--<artifactId>ant</artifactId>-->
+ <!--<version>1.8.0</version>-->
+ <!--</artifactItem>-->
+ <!--<artifactItem>-->
+ <!--<groupId>org.apache.ant</groupId>-->
+ <!--<artifactId>ant-launcher</artifactId>-->
+ <!--<version>1.8.0</version>-->
+ <!--</artifactItem>-->
+ <!--<artifactItem>-->
+ <!--<groupId>org.apache.ant</groupId>-->
+ <!--<artifactId>ant-nodeps</artifactId>-->
+ <!--<version>1.8.0</version>-->
+ <!--</artifactItem>-->
+ <!--<artifactItem>-->
+ <!--<groupId>ant-contrib</groupId>-->
+ <!--<artifactId>ant-contrib</artifactId>-->
+ <!--<version>1.0b3</version>-->
+ <!--</artifactItem>-->
+ <!--<artifactItem>-->
+ <!--<groupId>${project.groupId}</groupId>-->
+ <!--<artifactId>rhq-core-plugin-api</artifactId>-->
+ <!--<version>${project.version}</version>-->
+ <!--</artifactItem>-->
+ <!--<artifactItem>-->
+ <!--<groupId>org.apache.cassandra</groupId>-->
+ <!--<artifactId>cassandra-thrift</artifactId>-->
+ <!--<version>${cassandra.version}</version>-->
+ <!--</artifactItem>-->
+ <!--<artifactItem>-->
+ <!--<groupId>org.slf4j</groupId>-->
+ <!--<artifactId>slf4j-api</artifactId>-->
+ <!--<version>1.7.2</version>-->
+ <!--</artifactItem>-->
+ <!--<artifactItem>-->
+ <!--<groupId>${project.groupId}</groupId>-->
+ <!--<artifactId>rhq-core-domain</artifactId>-->
+ <!--<version>${project.version}</version>-->
+ <!--</artifactItem>-->
+ <!--<artifactItem>-->
+ <!--<groupId>commons-lang</groupId>-->
+ <!--<artifactId>commons-lang</artifactId>-->
+ <!--<version>2.4</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>-->
+ <!--<artifactItem>-->
+ <!--<groupId>commons-codec</groupId>-->
+ <!--<artifactId>commons-codec</artifactId>-->
+ <!--<version>1.3</version>-->
+ <!--</artifactItem>-->
+ <!--</artifactItems>-->
+ <!--</configuration>-->
+ <!--</execution>-->
+ <!--</executions>-->
+ <!--</plugin>-->
+ </plugins>
+ </build>
+</project>
diff --git
a/modules/common/cassandra-installer/src/main/java/org/rhq/cassandra/installer/CassandraInstaller.java
b/modules/common/cassandra-installer/src/main/java/org/rhq/cassandra/installer/CassandraInstaller.java
new file mode 100644
index 0000000..368071a
--- /dev/null
+++
b/modules/common/cassandra-installer/src/main/java/org/rhq/cassandra/installer/CassandraInstaller.java
@@ -0,0 +1,141 @@
+/*
+ *
+ * * 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.installer;
+
+import java.io.File;
+import java.net.InetAddress;
+
+import org.apache.commons.cli.CommandLine;
+import org.apache.commons.cli.CommandLineParser;
+import org.apache.commons.cli.HelpFormatter;
+import org.apache.commons.cli.Option;
+import org.apache.commons.cli.Options;
+import org.apache.commons.cli.ParseException;
+import org.apache.commons.cli.PosixParser;
+
+import org.rhq.cassandra.DeploymentOptions;
+import org.rhq.cassandra.UnmanagedDeployer;
+
+/**
+ * @author John Sanda
+ */
+public class CassandraInstaller {
+
+ private Options options;
+
+ public CassandraInstaller() {
+ Option hostname = new Option("n", "hostname", true, "The
hostname or IP address on which the node will listen for " +
+ "requests. If not specified, defaults to the value returned by
InetAddress.getLocalHost().getHostName().");
+ hostname.setArgName("HOSTNAME");
+
+ Option dir = new Option("d", "dir", true, "The
directory in which to install Cassandra. Defaults to the " +
+ "current working directory");
+ dir.setArgName("INSTALL_DIR");
+
+ Option seeds = new Option("s", "seeds", true, "A
comma-delimited list of hostnames or IP addresses that " +
+ "serve as contact points. Nodes use this list to find each other and to
learn the cluster topology. " +
+ "It does not need to specify all nodes in the cluster. Defaults to this
nodes hostname.");
+ seeds.setArgName("SEEDS");
+
+ options = new Options()
+ .addOption(new Option("h", "help", false, "Show this
message."))
+ .addOption(hostname)
+ .addOption(dir)
+ .addOption(seeds);
+ }
+
+ public void run(CommandLine cmdLine) throws Exception {
+ if (cmdLine.hasOption("h")) {
+ printUsage();
+ } else {
+ DeploymentOptions options = new DeploymentOptions();
+
+ File basedir;
+ if (cmdLine.hasOption("d")) {
+ basedir = new File(cmdLine.getOptionValue("d"));
+ } else {
+ basedir = new File(System.getProperty("user.dir"));
+ }
+ options.setBasedir(basedir.getAbsolutePath());
+
+ String hostname;
+ if (cmdLine.hasOption("n")) {
+ hostname = cmdLine.getOptionValue("n");
+ } else {
+ hostname = InetAddress.getLocalHost().getHostName();
+ }
+ options.setListenAddress(hostname);
+ options.setRpcAddress(hostname);
+
+ String seeds;
+ if (cmdLine.hasOption("s")) {
+ seeds = cmdLine.getOptionValue("s");
+ } else {
+ seeds = hostname;
+ }
+ options.setSeeds(seeds);
+
+ options.setCommitLogDir(new File(basedir,
"commit_log").getAbsolutePath());
+ options.setSavedCachesDir(new File(basedir,
"saved_caches").getAbsolutePath());
+ options.setDataDir(new File(basedir, "data").getAbsolutePath());
+ options.setLogDir(new File(basedir, "logs").getAbsolutePath());
+ options.load();
+
+ UnmanagedDeployer deployer = new UnmanagedDeployer();
+ deployer.unpackBundle();
+ deployer.deploy(options, 1);
+ deployer.cleanUpBundle();
+ }
+ }
+
+ public void printUsage() {
+ Options options = getOptions();
+ HelpFormatter helpFormatter = new HelpFormatter();
+ String header = "\nInstalls RHQ metrics database.\n\n";
+ String syntax = "java -jar rhq-cassandra-installer.jar [options]";
+
+ helpFormatter.setNewLine("\n");
+ helpFormatter.printHelp(syntax, header, options, null);
+ }
+
+ public Options getOptions() {
+ return options;
+ }
+
+ public static void main(String[] args) throws Exception {
+ System.out.println("Running Cassandra installer...");
+ CassandraInstaller installer = new CassandraInstaller();
+ try {
+ CommandLineParser parser = new PosixParser();
+ CommandLine cmdLine = parser.parse(installer.getOptions(), args);
+ installer.run(cmdLine);
+ return;
+ } catch (ParseException e) {
+ installer.printUsage();
+ }
+ }
+
+}
diff --git a/modules/common/pom.xml b/modules/common/pom.xml
index f131ccf..cc557b8 100644
--- a/modules/common/pom.xml
+++ b/modules/common/pom.xml
@@ -33,5 +33,6 @@
<module>cassandra-auth</module>
<module>cassandra-schema</module>
<module>cassandra-ccm</module>
+ <module>cassandra-installer</module>
</modules>
</project>