use of org.apache.distributedlog.lock.LockClosedException in project bookkeeper by apache.
the class TestAsyncReaderLock method testReaderLockFutureCancelledWhileWaiting.
@Test(timeout = 60000)
public void testReaderLockFutureCancelledWhileWaiting() throws Exception {
String name = runtime.getMethodName();
DistributedLogManager dlm0 = createNewDLM(conf, name);
BKAsyncLogWriter writer = (BKAsyncLogWriter) (dlm0.startAsyncLogSegmentNonPartitioned());
writer.write(DLMTestUtil.getLogRecordInstance(1L));
writer.write(DLMTestUtil.getLogRecordInstance(2L));
writer.closeAndComplete();
DistributedLogManager dlm1 = createNewDLM(conf, name);
CompletableFuture<AsyncLogReader> futureReader1 = dlm1.getAsyncLogReaderWithLock(DLSN.InitialDLSN);
AsyncLogReader reader1 = Utils.ioResult(futureReader1);
DistributedLogManager dlm2 = createNewDLM(conf, name);
CompletableFuture<AsyncLogReader> futureReader2 = dlm2.getAsyncLogReaderWithLock(DLSN.InitialDLSN);
try {
futureReader2.cancel(true);
Utils.ioResult(futureReader2);
fail("Should fail getting log reader as it is cancelled");
} catch (CancellationException ce) {
} catch (LockClosedException ex) {
} catch (LockCancelledException ex) {
} catch (OwnershipAcquireFailedException oafe) {
}
futureReader2 = dlm2.getAsyncLogReaderWithLock(DLSN.InitialDLSN);
Utils.close(reader1);
Utils.ioResult(futureReader2);
dlm0.close();
dlm1.close();
dlm2.close();
}
use of org.apache.distributedlog.lock.LockClosedException in project bookkeeper by apache.
the class TestAsyncReaderLock method testReaderLockDlmClosed.
@Test(timeout = 60000)
public void testReaderLockDlmClosed() throws Exception {
String name = runtime.getMethodName();
DistributedLogManager dlm0 = createNewDLM(conf, name);
BKAsyncLogWriter writer = (BKAsyncLogWriter) (dlm0.startAsyncLogSegmentNonPartitioned());
writer.write(DLMTestUtil.getLogRecordInstance(1L));
writer.write(DLMTestUtil.getLogRecordInstance(2L));
writer.closeAndComplete();
DistributedLogManager dlm1 = createNewDLM(conf, name);
CompletableFuture<AsyncLogReader> futureReader1 = dlm1.getAsyncLogReaderWithLock(DLSN.InitialDLSN);
AsyncLogReader reader1 = Utils.ioResult(futureReader1);
BKDistributedLogManager dlm2 = (BKDistributedLogManager) createNewDLM(conf, name);
CompletableFuture<AsyncLogReader> futureReader2 = dlm2.getAsyncLogReaderWithLock(DLSN.InitialDLSN);
dlm2.close();
try {
Utils.ioResult(futureReader2);
fail("should have thrown exception!");
} catch (CancellationException ce) {
} catch (LockClosedException ex) {
} catch (LockCancelledException ex) {
}
Utils.close(reader1);
dlm0.close();
dlm1.close();
}
Aggregations