提交 ad3f0cf7 authored 作者: Thomas Mueller's avatar Thomas Mueller

A new file system implementation that re-opens the file if it was closed due to…

A new file system implementation that re-opens the file if it was closed due to the application calling Thread.interrupt(). File name prefix "retry:". Please note it is strongly recommended to avoid calling Thread.interrupt; this is a problem for various libraries, including Apache Lucene.
上级 072ab2ee
......@@ -50,6 +50,7 @@ public class TestConcurrent extends TestMVStore {
FileUtils.createDirectories(getBaseDir());
FileUtils.deleteRecursive("memFS:", false);
testInterruptReopen();
testConcurrentSaveCompact();
testConcurrentDataType();
testConcurrentAutoCommitAndChange();
......@@ -65,6 +66,37 @@ public class TestConcurrent extends TestMVStore {
testConcurrentWrite();
testConcurrentRead();
}
private void testInterruptReopen() throws Exception {
String fileName = "retry:nio:" + getBaseDir() + "/testInterruptReopen.h3";
FileUtils.delete(fileName);
final MVStore s = new MVStore.Builder().
fileName(fileName).
cacheSize(0).
open();
final Thread mainThread = Thread.currentThread();
Task task = new Task() {
@Override
public void call() throws Exception {
while (!stop) {
mainThread.interrupt();
Thread.sleep(10);
}
}
};
try {
MVMap<Integer, byte[]> map = s.openMap("data");
task.execute();
for (int i = 0; i < 1000 && !task.isFinished(); i++) {
map.get(i % 1000);
map.put(i % 1000, new byte[1024]);
s.commit();
}
} finally {
task.get();
s.close();
}
}
private void testConcurrentSaveCompact() throws Exception {
String fileName = "memFS:testConcurrentSaveCompact";
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论