Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Add stopServer method to CassandraUtils.java. This is useful in scenario #121

Merged
merged 1 commit into from

2 participants

@cnauroth

This change adds a stopServer method to CassandraUtils.java. Before this change, there was no way for client code to access the CassandraDaemon that was started by a call to CassandraUtils.startupServer and guarantee a graceful shutdown.

I found this problematic for automated integration tests running on Windows. We need to delete the /tmp/cassandra-data directory between test suite runs to guarantee a clean slate. On Windows, Cassandra would hold a file lock on the commit log, preventing the test suite from deleting it. With this new method in place, a test suite can call CassandraUtils.stopServer, wait for a graceful shutdown of Cassandra, and then delete /tmp/cassandra-data without lock contention.

Thanks,
--Chris

@cnauroth cnauroth Add stopServer method to CassandraUtils.java. This is useful in scena…
…rios where the client code must guarantee a clean exit of Cassandra, such as in test suites.
dfb7507
@tjake tjake merged commit 60ce47c into tjake:solandra
@tjake
Owner

thx!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Aug 17, 2011
  1. @cnauroth

    Add stopServer method to CassandraUtils.java. This is useful in scena…

    cnauroth authored
    …rios where the client code must guarantee a clean exit of Cassandra, such as in test suites.
This page is out of date. Refresh to see the latest.
Showing with 13 additions and 1 deletion.
  1. +13 −1 src/lucandra/CassandraUtils.java
View
14 src/lucandra/CassandraUtils.java
@@ -188,6 +188,8 @@
private static boolean cassandraStarted = false;
+ private static CassandraDaemon daemon = null;
+
public static String fakeToken = String.valueOf(System.nanoTime());
public static synchronized void setStartup()
@@ -250,7 +252,7 @@ public static synchronized void startupServer() throws IOException
System.setProperty("cassandra-foreground", "1");
- final CassandraDaemon daemon = new CassandraDaemon();
+ daemon = new CassandraDaemon();
try
{
@@ -284,6 +286,16 @@ public void run()
}
}
+ public static synchronized void stopServer()
+ {
+ if (!cassandraStarted)
+ return;
+
+ daemon.deactivate();
+ daemon = null;
+ cassandraStarted = false;
+ }
+
public static void createCassandraSchema() throws IOException
{
if (!cassandraStarted)
Something went wrong with that request. Please try again.