/
CleanupHelper.java
39 lines (34 loc) · 1.23 KB
/
CleanupHelper.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package org.apache.cassandra;
import java.io.File;
import org.junit.BeforeClass;
import org.apache.cassandra.config.DatabaseDescriptor;
import org.apache.cassandra.db.ColumnFamilyStore;
import org.apache.cassandra.db.CommitLog;
import org.apache.cassandra.db.Table;
public class CleanupHelper
{
@BeforeClass
public static void cleanup()
{
// we clean the fs twice, once to start with (so old data files don't get stored by anything static if this is the first run)
// and once after flushing stuff (to try to clean things out if it is not.) part #2 seems to be less than perfect.
String[] directoryNames = {
DatabaseDescriptor.getBootstrapFileLocation(),
DatabaseDescriptor.getLogFileLocation(),
DatabaseDescriptor.getDataFileLocation(),
DatabaseDescriptor.getMetadataDirectory(),
};
for (String dirName : directoryNames)
{
File dir = new File(dirName);
if (!dir.exists())
{
throw new RuntimeException("No such directory: " + dir.getAbsolutePath());
}
for (File f : dir.listFiles())
{
f.delete();
}
}
}
}