use of com.twitter.distributedlog.namespace.DistributedLogNamespace in project distributedlog by twitter.
the class TestLogSegmentsZK method testCompleteLogSegmentConflicts.
@Test(timeout = 60000)
public void testCompleteLogSegmentConflicts() throws Exception {
URI uri = createURI();
String streamName = testName.getMethodName();
DistributedLogConfiguration conf = new DistributedLogConfiguration().setLockTimeout(99999).setOutputBufferSize(0).setImmediateFlushEnabled(true).setEnableLedgerAllocatorPool(true).setLedgerAllocatorPoolName("test");
DistributedLogNamespace namespace = DistributedLogNamespaceBuilder.newBuilder().conf(conf).uri(uri).build();
namespace.createLog(streamName);
DistributedLogManager dlm1 = namespace.openLog(streamName);
DistributedLogManager dlm2 = namespace.openLog(streamName);
// dlm1 is writing
BKSyncLogWriter out1 = (BKSyncLogWriter) dlm1.startLogSegmentNonPartitioned();
out1.write(DLMTestUtil.getLogRecordInstance(1));
// before out1 complete, out2 is in on recovery
// it completed the log segments which bump the version of /ledgers znode
BKAsyncLogWriter out2 = (BKAsyncLogWriter) dlm2.startAsyncLogSegmentNonPartitioned();
try {
out1.closeAndComplete();
fail("Should fail closeAndComplete since other people already completed it.");
} catch (IOException ioe) {
}
}
Aggregations