Permalink
Browse files

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.
  • Loading branch information...
1 parent b8d8b81 commit dfb7507a27761f7e409243ea3bc7f79c941b61bd @cnauroth committed Aug 17, 2011
Showing with 13 additions and 1 deletion.
  1. +13 −1 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)

0 comments on commit dfb7507

Please sign in to comment.