modules/common/cassandra-installer/pom.xml
| 6 +
modules/common/cassandra-installer/src/main/java/org/rhq/storage/installer/StorageInstaller.java
| 39 +++++-----
modules/common/cassandra-installer/src/main/resources/module/main/module.xml
| 1
modules/common/cassandra-util/src/main/java/org/rhq/cassandra/util/ConfigEditor.java
| 11 ++
modules/enterprise/server/appserver/src/main/scripts/rhq-container.build.xml
| 2
5 files changed, 39 insertions(+), 20 deletions(-)
New commits:
commit 3a36720ad018a3e48532bf50650d6dbb065de695
Author: John Sanda <jsanda(a)redhat.com>
Date: Fri Aug 30 11:47:00 2013 -0400
set the rhq.storage.gossip-port during installation/upgrade
diff --git a/modules/common/cassandra-installer/pom.xml
b/modules/common/cassandra-installer/pom.xml
index 4492e70..4c737fc 100644
--- a/modules/common/cassandra-installer/pom.xml
+++ b/modules/common/cassandra-installer/pom.xml
@@ -24,6 +24,12 @@
</dependency>
<dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>rhq-cassandra-util</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
<groupId>commons-cli</groupId>
<artifactId>commons-cli</artifactId>
<version>1.2</version>
diff --git
a/modules/common/cassandra-installer/src/main/java/org/rhq/storage/installer/StorageInstaller.java
b/modules/common/cassandra-installer/src/main/java/org/rhq/storage/installer/StorageInstaller.java
index de13f5c..243620f 100644
---
a/modules/common/cassandra-installer/src/main/java/org/rhq/storage/installer/StorageInstaller.java
+++
b/modules/common/cassandra-installer/src/main/java/org/rhq/storage/installer/StorageInstaller.java
@@ -60,11 +60,11 @@ import org.apache.commons.exec.PumpStreamHandler;
import org.apache.commons.io.output.NullOutputStream;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.yaml.snakeyaml.Yaml;
import org.rhq.cassandra.Deployer;
import org.rhq.cassandra.DeploymentOptions;
import org.rhq.cassandra.DeploymentOptionsFactory;
+import org.rhq.cassandra.util.ConfigEditor;
import org.rhq.core.util.PropertiesFileUpdate;
import org.rhq.core.util.StringUtil;
import org.rhq.core.util.exception.ThrowableUtil;
@@ -107,7 +107,7 @@ public class StorageInstaller {
private int defaultNativeTransportPort = 9142;
- private int storagePort = 7100;
+ private int defaultStoragePort = 7100;
private int sslStoragePort = 7101;
@@ -151,7 +151,7 @@ public class StorageInstaller {
nativeTransportPortOption.setArgName("PORT");
Option storagePortOption = new Option(null, "storage-port", true,
"The port on which to listen for requests "
- + " from other nodes. Defaults to " + storagePort);
+ + " from other nodes. Defaults to " + defaultStoragePort);
storagePortOption.setArgName("PORT");
Option sslStoragePortOption = new Option(null, "ssl-storage-port",
true, "The port on which to listen for "
@@ -218,6 +218,8 @@ public class StorageInstaller {
String hostname;
int jmxPort;
+ int nativeTransportPort;
+ int storagePort;
File logFile = new File(logDir, "rhq-storage.log");
if (cmdLine.hasOption("upgrade")) {
@@ -283,15 +285,13 @@ public class StorageInstaller {
replaceFile(internodeAuthConfFile, new File(newConfDir,
internodeAuthConfFile.getName()));
}
- log.info("Finished installing RHQ Storage Node.");
-
- log.info("Updating rhq-server.properties...");
File yamlFile = new File(newConfDir, "cassandra.yaml");
+ ConfigEditor yamlEditor = new ConfigEditor(yamlFile);
+ yamlEditor.load();
- Yaml yaml = new Yaml();
- Map<String, Object> config = (Map<String, Object>)
yaml.load(new FileInputStream(yamlFile));
-
- hostname = (String) config.get("listen_address");
+ hostname = yamlEditor.getListenAddress();
+ nativeTransportPort = yamlEditor.getNativeTransportPort();
+ storagePort = yamlEditor.getStoragePort();
} else {
if (cmdLine.hasOption("dir")) {
File basedir = new File(cmdLine.getOptionValue("dir"));
@@ -342,7 +342,8 @@ public class StorageInstaller {
}
jmxPort = getPort(cmdLine, "jmx-port", defaultJmxPort);
- int nativeTransportPort = getPort(cmdLine, "client-port",
defaultNativeTransportPort);
+ nativeTransportPort = getPort(cmdLine, "client-port",
defaultNativeTransportPort);
+ storagePort = getPort(cmdLine, "storage-port",
defaultStoragePort);
deploymentOptions.setCommitLogDir(commitLogDir);
deploymentOptions.setDataDir(dataDir);
@@ -352,7 +353,7 @@ public class StorageInstaller {
deploymentOptions.setRpcPort(rpcPort);
deploymentOptions.setJmxPort(jmxPort);
deploymentOptions.setNativeTransportPort(nativeTransportPort);
- deploymentOptions.setStoragePort(getPort(cmdLine,
"storage-port", storagePort));
+ deploymentOptions.setStoragePort(storagePort);
deploymentOptions.setSslStoragePort(getPort(cmdLine,
"ssl-storage-port", sslStoragePort));
// The out of box default for native_transport_max_threads is 128. We
default
@@ -395,14 +396,16 @@ public class StorageInstaller {
Set<InetAddress> addresses = new HashSet<InetAddress>();
addresses.add(InetAddress.getByName(hostname));
deployer.updateStorageAuthConf(addresses);
+ }
- log.info("Finished installing RHQ Storage Node.");
+ PropertiesFileUpdate serverPropertiesUpdater = getServerProperties();
+ log.info("Updating rhq-server.properties...");
+ Properties properties = new Properties();
+ properties.setProperty("rhq.storage.nodes", hostname);
+ properties.setProperty("rhq.storage.cql-port",
Integer.toString(nativeTransportPort));
+ properties.setProperty("rhq.storage.gossip-port",
Integer.toString(storagePort));
- PropertiesFileUpdate serverPropertiesUpdater = getServerProperties();
- log.info("Updating rhq-server.properties...");
- serverPropertiesUpdater.update("rhq.storage.nodes", hostname);
- serverPropertiesUpdater.update("rhq.storage.cql-port",
nativeTransportPort + "");
- }
+ serverPropertiesUpdater.update(properties);
boolean startNode =
Boolean.parseBoolean(cmdLine.getOptionValue("start", "true"));
if (startNode) {
diff --git a/modules/common/cassandra-installer/src/main/resources/module/main/module.xml
b/modules/common/cassandra-installer/src/main/resources/module/main/module.xml
index bf66025..3e10262 100644
--- a/modules/common/cassandra-installer/src/main/resources/module/main/module.xml
+++ b/modules/common/cassandra-installer/src/main/resources/module/main/module.xml
@@ -7,6 +7,7 @@
<resource-root path="${project.build.finalName}.jar"/>
<resource-root
path="rhq-cassandra-ccm-core-${project.version}.jar"/>
<resource-root path="rhq-core-util-${project.version}.jar"/>
+ <resource-root path="rhq-cassandra-util-${project.version}.jar"/>
<resource-root path="snakeyaml-${cassandra.snakeyaml.version}.jar"/>
</resources>
diff --git
a/modules/common/cassandra-util/src/main/java/org/rhq/cassandra/util/ConfigEditor.java
b/modules/common/cassandra-util/src/main/java/org/rhq/cassandra/util/ConfigEditor.java
index 42e531f..1d727c9 100644
---
a/modules/common/cassandra-util/src/main/java/org/rhq/cassandra/util/ConfigEditor.java
+++
b/modules/common/cassandra-util/src/main/java/org/rhq/cassandra/util/ConfigEditor.java
@@ -32,14 +32,23 @@ public class ConfigEditor {
}
public void load() {
+ FileInputStream inputStream = null;
try {
DumperOptions options = new DumperOptions();
options.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK);
yaml = new Yaml(options);
- config = (Map) yaml.load(new FileInputStream(configFile));
+ inputStream = new FileInputStream(configFile);
+ config = (Map) yaml.load(inputStream);
createBackup();
} catch (FileNotFoundException e) {
throw new ConfigEditorException("Failed to load " + configFile,
e);
+ } finally {
+ if (inputStream != null) {
+ try {
+ inputStream.close();
+ } catch (IOException e) {
+ }
+ }
}
}
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 566a0c9..2bc16a7 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
@@ -694,7 +694,7 @@ rhq.storage.nodes=
# Both properties are required.
#
rhq.storage.cql-port=${rhq.cassandra.native-transport-port}
-rhq.storage.gossip-port=${rhq.cassandra.native-transport-port}
+rhq.storage.gossip-port=${rhq.cassandra.storage-port}
# If enabled data sent to and from storage nodes will be compressed using
# snappy (
https://code.google.com/p/snappy) compression. Note that this is an