modules/common/cassandra-installer/src/main/java/org/rhq/storage/installer/StorageInstaller.java
| 9 +-
modules/plugins/rhq-storage/src/main/java/org/rhq/plugins/storage/StorageNodeConfigDelegate.java
| 39 +++++++---
modules/plugins/rhq-storage/src/test/java/org/rhq/plugins/storage/StorageNodeConfigDelegateTest.java
| 35 +++++++-
3 files changed, 66 insertions(+), 17 deletions(-)
New commits:
commit 68d4c3d2c3c5eb67c09cde41ac78f77f6b32ec33
Author: John Sanda <jsanda(a)redhat.com>
Date: Mon Jul 15 10:34:28 2013 -0400
[BZ 984433] revert changes for empty directory check
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 386cda7..9a6a1c0 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
@@ -55,7 +55,6 @@ import org.apache.commons.cli.PosixParser;
import org.apache.commons.exec.DefaultExecutor;
import org.apache.commons.exec.Executor;
import org.apache.commons.exec.PumpStreamHandler;
-import org.apache.commons.io.FileUtils;
import org.apache.commons.io.output.NullOutputStream;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -450,7 +449,13 @@ public class StorageInstaller {
}
private boolean isDirectoryEmpty(File dir) {
- return FileUtils.sizeOf(dir) == 0;
+ // TODO need to check subdirectories
+ if (dir.isDirectory()) {
+ File[] files = dir.listFiles();
+ return (files == null || files.length == 0);
+ } else {
+ return true;
+ }
}
private int getPort(CommandLine cmdLine, String option, int defaultValue) {
commit 0bc81e9df0976365252b5ca11795b25d78172ec4
Author: John Sanda <jsanda(a)redhat.com>
Date: Mon Jul 15 10:13:35 2013 -0400
check that properties are set before trying to update them
diff --git
a/modules/plugins/rhq-storage/src/main/java/org/rhq/plugins/storage/StorageNodeConfigDelegate.java
b/modules/plugins/rhq-storage/src/main/java/org/rhq/plugins/storage/StorageNodeConfigDelegate.java
index e82f290..c87d2ac 100644
---
a/modules/plugins/rhq-storage/src/main/java/org/rhq/plugins/storage/StorageNodeConfigDelegate.java
+++
b/modules/plugins/rhq-storage/src/main/java/org/rhq/plugins/storage/StorageNodeConfigDelegate.java
@@ -68,19 +68,36 @@ public class StorageNodeConfigDelegate implements ConfigurationFacet
{
Configuration config = configurationUpdateReport.getConfiguration();
- // We want min and max heap to be the same
- properties.setProperty("heap_min", "-Xms" +
config.getSimpleValue("maxHeapSize"));
- properties.setProperty("heap_max", "-Xmx" +
config.getSimpleValue("maxHeapSize"));
- properties.setProperty("heap_new", "-Xmn" +
config.getSimpleValue("heapNewSize"));
- properties.setProperty("thread_stack_size", "-Xss" +
config.getSimpleValue("threadStackSize"));
-
- if (config.getSimple("heapDumpOnOOMError").getBooleanValue()) {
- properties.setProperty("heap_dump_on_OOMError",
"-XX:+HeapDumpOnOutOfMemoryError");
- } else {
- properties.setProperty("heap_dump_on_OOMError", "");
+ String maxHeapSize = config.getSimpleValue("maxHeapSize");
+ if (!StringUtil.isEmpty(maxHeapSize)) {
+ // We want min and max heap to be the same
+ properties.setProperty("heap_min", "-Xms" +
maxHeapSize);
+ properties.setProperty("heap_max", "-Xmx" +
maxHeapSize);
}
- properties.setProperty("heap_dump_dir",
config.getSimpleValue("heapDumpDir"));
+ String heapNewSize = config.getSimpleValue("heapNewSize");
+ if (!StringUtil.isEmpty(heapNewSize)) {
+ properties.setProperty("heap_new", "-Xmn" +
heapNewSize);
+ }
+
+ String threadStackSize = config.getSimpleValue("threadStackSize");
+ if (!StringUtil.isEmpty(threadStackSize)) {
+ properties.setProperty("thread_stack_size", "-Xss" +
threadStackSize);
+ }
+
+ PropertySimple heapDumpOnOMMError =
config.getSimple("heapDumpOnOOMError");
+ if (heapDumpOnOMMError != null) {
+ if (heapDumpOnOMMError.getBooleanValue()) {
+ properties.setProperty("heap_dump_on_OOMError",
"-XX:+HeapDumpOnOutOfMemoryError");
+ } else {
+ properties.setProperty("heap_dump_on_OOMError",
"");
+ }
+ }
+
+ String heapDumpDir = config.getSimpleValue("heapDumpDir");
+ if (!StringUtil.isEmpty(heapDumpDir)) {
+ properties.setProperty("heap_dump_dir", heapDumpDir);
+ }
propertiesUpdater.update(properties);
diff --git
a/modules/plugins/rhq-storage/src/test/java/org/rhq/plugins/storage/StorageNodeConfigDelegateTest.java
b/modules/plugins/rhq-storage/src/test/java/org/rhq/plugins/storage/StorageNodeConfigDelegateTest.java
index 5c5f089..ee34f43 100644
---
a/modules/plugins/rhq-storage/src/test/java/org/rhq/plugins/storage/StorageNodeConfigDelegateTest.java
+++
b/modules/plugins/rhq-storage/src/test/java/org/rhq/plugins/storage/StorageNodeConfigDelegateTest.java
@@ -23,10 +23,13 @@ public class StorageNodeConfigDelegateTest {
private File basedir;
+ private StorageNodeConfigDelegate configDelegate;
+
@BeforeMethod
public void initDirs(Method test) throws Exception {
File dir = new File(getClass().getResource(".").toURI());
basedir = new File(dir, getClass().getSimpleName() + "/" +
test.getName());
+ configDelegate = new StorageNodeConfigDelegate(basedir);
}
@@ -34,7 +37,6 @@ public class StorageNodeConfigDelegateTest {
public void loadValidConfig() throws Exception {
createDefaultConfig();
- StorageNodeConfigDelegate configDelegate = new
StorageNodeConfigDelegate(basedir);
Configuration config = configDelegate.loadResourceConfiguration();
assertEquals(config.getSimpleValue("minHeapSize"), "512M",
"Failed to load property [minHeapSize]");
@@ -60,11 +62,9 @@ public class StorageNodeConfigDelegateTest {
ConfigurationUpdateReport report = new ConfigurationUpdateReport(config);
- StorageNodeConfigDelegate configDelegate = new
StorageNodeConfigDelegate(basedir);
configDelegate.updateResourceConfiguration(report);
- Properties properties = new Properties();
- properties.load(new FileInputStream(new File(confDir(),
"cassandra-jvm.properties")));
+ Properties properties = loadCassandraJvmProps();
assertEquals(properties.getProperty("heap_min"), "-Xms1024M",
"Failed to update property [minHeapSize]");
assertEquals(properties.getProperty("heap_max"), "-Xmx1024M",
"Failed to update property [maxHeapSize]");
@@ -77,6 +77,25 @@ public class StorageNodeConfigDelegateTest {
"Failed to update property [heap_dump_dir]");
}
+ @Test
+ public void minHeapSizeShouldBeTheSameAsMaxHeapSize() throws Exception {
+ createDefaultConfig();
+
+ Configuration config = new Configuration();
+ config.put(new PropertySimple("minHeapSize", "512M"));
+ config.put(new PropertySimple("maxHeapSize", "768M"));
+
+ ConfigurationUpdateReport report = new ConfigurationUpdateReport(config);
+
+ configDelegate.updateResourceConfiguration(report);
+
+ Properties properties = loadCassandraJvmProps();
+
+ assertEquals(properties.getProperty("heap_max"), "-Xmx768M",
"Failed to update property [maxHeapSize]");
+ assertEquals(properties.getProperty("heap_min"), "-Xms768M",
"Failed to update property [maxHeapSize]. It " +
+ "should be the same as [maxHeapSize].");
+ }
+
private void createDefaultConfig() throws IOException {
Properties properties = new Properties();
properties.setProperty("heap_min", "-Xms512M");
@@ -84,10 +103,18 @@ public class StorageNodeConfigDelegateTest {
properties.setProperty("heap_new", "-Xmn128M");
properties.setProperty("thread_stack_size", "-Xss180k");
properties.setProperty("heap_dump_on_OOMError",
"-XX:+HeapDumpOnOutOfMemoryError");
+ properties.setProperty("heap_dump_dir", binDir().getAbsolutePath());
properties.store(new FileOutputStream(new File(confDir(),
"cassandra-jvm.properties")), "");
}
+ private Properties loadCassandraJvmProps() throws Exception {
+ Properties properties = new Properties();
+ properties.load(new FileInputStream(new File(confDir(),
"cassandra-jvm.properties")));
+
+ return properties;
+ }
+
private File confDir() {
return mkdirIfNecessary(basedir, "conf");
}