use of org.apache.distributedlog.lock.ZKDistributedLock in project bookkeeper by apache.
the class TestBKLogSegmentWriter method testNondurableWriteAfterWriterIsClosed.
/**
* Non durable write should fail if writer is closed.
*
* @throws Exception
*/
@Test(timeout = 60000)
public void testNondurableWriteAfterWriterIsClosed() throws Exception {
DistributedLogConfiguration confLocal = newLocalConf();
confLocal.setImmediateFlushEnabled(false);
confLocal.setOutputBufferSize(Integer.MAX_VALUE);
confLocal.setPeriodicFlushFrequencyMilliSeconds(0);
confLocal.setDurableWriteEnabled(false);
ZKDistributedLock lock = createLock("/test/lock-" + runtime.getMethodName(), zkc, true);
BKLogSegmentWriter writer = createLogSegmentWriter(confLocal, 0L, -1L, lock);
// close the writer
closeWriterAndLock(writer, lock);
Utils.ioResult(writer.asyncClose());
try {
Utils.ioResult(writer.asyncWrite(DLMTestUtil.getLogRecordInstance(1)));
fail("Should fail the write if the writer is closed");
} catch (WriteException we) {
// expected
}
}
Aggregations