From 327a2b950e556118f943906220e9a5a5b5f77eb3 Mon Sep 17 00:00:00 2001 From: Aled Sage Date: Fri, 31 Oct 2014 14:36:08 +0000 Subject: [PATCH] Fix Cassandra v2 - roll back to 2.0.9 - let bin/cassandra write pid, rather than us writing pid --- .../cassandra/CassandraNodeSshDriver.java | 22 ++++++++++++++----- .../CassandraNodeIntegrationTest.java | 9 +++++++- 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/software/nosql/src/main/java/brooklyn/entity/nosql/cassandra/CassandraNodeSshDriver.java b/software/nosql/src/main/java/brooklyn/entity/nosql/cassandra/CassandraNodeSshDriver.java index 65ed4a621e..9a54c8a577 100644 --- a/software/nosql/src/main/java/brooklyn/entity/nosql/cassandra/CassandraNodeSshDriver.java +++ b/software/nosql/src/main/java/brooklyn/entity/nosql/cassandra/CassandraNodeSshDriver.java @@ -117,10 +117,14 @@ protected String getDefaultUnpackedDirectoryName() { return "apache-cassandra-"+getVersion(); } + protected boolean isV2() { + String version = getVersion(); + return version.startsWith("2."); + } + @Override public boolean installJava() { - String version = getVersion(); - if (version.startsWith("2.")) { + if (isV2()) { return checkForAndInstallJava7or8(); } else { return super.installJava(); @@ -292,12 +296,14 @@ public void launch() { } try { - newScript(MutableMap.of(USE_PID_FILE, getPidFile()), LAUNCHING) + // Relies on `bin/cassandra -p `, rather than us writing pid file ourselves. + newScript(MutableMap.of(USE_PID_FILE, false), LAUNCHING) .body.append( // log the date to attempt to debug occasional http://wiki.apache.org/cassandra/FAQ#schema_disagreement // (can be caused by machines out of synch time-wise; but in our case it seems to be caused by other things!) "echo date on cassandra server `hostname` when launching is `date`", - launchEssentialCommand()) + launchEssentialCommand(), + "echo after essential command") .execute(); if (!isClustered()) { InputStream creationScript = DatastoreMixins.getDatabaseCreationScript(entity); @@ -337,7 +343,13 @@ protected List getCassandraAncestors() { } protected String launchEssentialCommand() { - return String.format("nohup ./bin/cassandra -p %s > ./cassandra-console.log 2>&1 &", getPidFile()); + if (isV2()) { + return String.format("./bin/cassandra -p %s > ./cassandra-console.log 2>&1", getPidFile()); + } else { + // TODO Could probably get rid of the nohup here, as script does equivalent itself + // with `exec ... <&- &` + return String.format("nohup ./bin/cassandra -p %s > ./cassandra-console.log 2>&1 &", getPidFile()); + } } public String getPidFile() { return Os.mergePathsUnix(getRunDir(), "cassandra.pid"); } diff --git a/software/nosql/src/test/java/brooklyn/entity/nosql/cassandra/CassandraNodeIntegrationTest.java b/software/nosql/src/test/java/brooklyn/entity/nosql/cassandra/CassandraNodeIntegrationTest.java index 9c3989c1c9..06686dd4c8 100644 --- a/software/nosql/src/test/java/brooklyn/entity/nosql/cassandra/CassandraNodeIntegrationTest.java +++ b/software/nosql/src/test/java/brooklyn/entity/nosql/cassandra/CassandraNodeIntegrationTest.java @@ -83,7 +83,14 @@ public void testConnection() throws Exception { */ @Test(groups = "Integration") public void testCassandraVersion2() throws Exception { - String version = "2.0.11"; + // TODO In v2.0.10, the bin/cassandra script changed to add an additional check for JMX connectivity. + // This causes cassandera script to hang for us (presumably due to the CLASSPATH/JVM_OPTS we're passing + // in, regarding JMX agent). + // See: + // - https://issues.apache.org/jira/browse/CASSANDRA-7254 + // - https://github.com/apache/cassandra/blame/trunk/bin/cassandra#L211-216 + + String version = "2.0.9"; String majorMinorVersion = "2.0"; cassandra = app.createAndManageChild(EntitySpec.create(CassandraNode.class)