use of org.apache.cassandra.config.Config.DiskFailurePolicy in project cassandra by apache.
the class OutOfSpaceTest method testFlushUnwriteableDie.
@Test
public void testFlushUnwriteableDie() throws Throwable {
makeTable();
KillerForTests killerForTests = new KillerForTests();
JVMStabilityInspector.Killer originalKiller = JVMStabilityInspector.replaceKiller(killerForTests);
DiskFailurePolicy oldPolicy = DatabaseDescriptor.getDiskFailurePolicy();
try (Closeable c = Util.markDirectoriesUnwriteable(getCurrentColumnFamilyStore())) {
DatabaseDescriptor.setDiskFailurePolicy(DiskFailurePolicy.die);
flushAndExpectError();
Assert.assertTrue(killerForTests.wasKilled());
//only killed quietly on startup failure
Assert.assertFalse(killerForTests.wasKilledQuietly());
} finally {
DatabaseDescriptor.setDiskFailurePolicy(oldPolicy);
JVMStabilityInspector.replaceKiller(originalKiller);
}
}
use of org.apache.cassandra.config.Config.DiskFailurePolicy in project cassandra by apache.
the class OutOfSpaceTest method testFlushUnwriteableStop.
@Test
public void testFlushUnwriteableStop() throws Throwable {
makeTable();
DiskFailurePolicy oldPolicy = DatabaseDescriptor.getDiskFailurePolicy();
try (Closeable c = Util.markDirectoriesUnwriteable(getCurrentColumnFamilyStore())) {
DatabaseDescriptor.setDiskFailurePolicy(DiskFailurePolicy.stop);
flushAndExpectError();
Assert.assertFalse(Gossiper.instance.isEnabled());
} finally {
DatabaseDescriptor.setDiskFailurePolicy(oldPolicy);
}
}
use of org.apache.cassandra.config.Config.DiskFailurePolicy in project cassandra by apache.
the class DirectoriesTest method testDiskFailurePolicy_best_effort.
@Test
public void testDiskFailurePolicy_best_effort() {
DiskFailurePolicy origPolicy = DatabaseDescriptor.getDiskFailurePolicy();
try {
DatabaseDescriptor.setDiskFailurePolicy(DiskFailurePolicy.best_effort);
// Fake a Directory creation failure
if (Directories.dataDirectories.length > 0) {
String[] path = new String[] { KS, "bad" };
File dir = new File(Directories.dataDirectories[0].location, StringUtils.join(path, File.separator));
FileUtils.handleFSError(new FSWriteError(new IOException("Unable to create directory " + dir), dir));
}
for (DataDirectory dd : Directories.dataDirectories) {
File file = new File(dd.location, new File(KS, "bad").getPath());
assertTrue(BlacklistedDirectories.isUnwritable(file));
}
} finally {
DatabaseDescriptor.setDiskFailurePolicy(origPolicy);
}
}
use of org.apache.cassandra.config.Config.DiskFailurePolicy in project cassandra by apache.
the class CommitLogTest method testUnwriteableFlushRecovery.
public void testUnwriteableFlushRecovery() throws ExecutionException, InterruptedException, IOException {
CommitLog.instance.resetUnsafe(true);
ColumnFamilyStore cfs = Keyspace.open(KEYSPACE1).getColumnFamilyStore(STANDARD1);
DiskFailurePolicy oldPolicy = DatabaseDescriptor.getDiskFailurePolicy();
try {
DatabaseDescriptor.setDiskFailurePolicy(DiskFailurePolicy.ignore);
for (int i = 0; i < 5; i++) {
new RowUpdateBuilder(cfs.metadata(), 0, "k").clustering("c" + i).add("val", ByteBuffer.allocate(100)).build().apply();
if (i == 2) {
try (Closeable c = Util.markDirectoriesUnwriteable(cfs)) {
cfs.forceBlockingFlush();
} catch (Throwable t) {
// expected. Cause (after some wrappings) should be a write error
while (!(t instanceof FSWriteError)) t = t.getCause();
}
} else
cfs.forceBlockingFlush();
}
} finally {
DatabaseDescriptor.setDiskFailurePolicy(oldPolicy);
}
CommitLog.instance.sync();
System.setProperty("cassandra.replayList", KEYSPACE1 + "." + STANDARD1);
// Currently we don't attempt to re-flush a memtable that failed, thus make sure data is replayed by commitlog.
// If retries work subsequent flushes should clear up error and this should change to expect 0.
Assert.assertEquals(1, CommitLog.instance.resetUnsafe(false));
}
use of org.apache.cassandra.config.Config.DiskFailurePolicy in project cassandra by apache.
the class OutOfSpaceTest method testFlushUnwriteableIgnore.
@Test
public void testFlushUnwriteableIgnore() throws Throwable {
makeTable();
DiskFailurePolicy oldPolicy = DatabaseDescriptor.getDiskFailurePolicy();
try (Closeable c = Util.markDirectoriesUnwriteable(getCurrentColumnFamilyStore())) {
DatabaseDescriptor.setDiskFailurePolicy(DiskFailurePolicy.ignore);
flushAndExpectError();
} finally {
DatabaseDescriptor.setDiskFailurePolicy(oldPolicy);
}
// Next flush should succeed.
flush();
}
Aggregations