Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
ea710513
提交
ea710513
authored
3月 30, 2018
作者:
andrei
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
just removed useless throw Exception etc. to make IDE happy
上级
e9cebe85
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
27 行增加
和
33 行删除
+27
-33
TestConcurrent.java
h2/src/test/org/h2/test/store/TestConcurrent.java
+27
-33
没有找到文件。
h2/src/test/org/h2/test/store/TestConcurrent.java
浏览文件 @
ea710513
...
@@ -41,7 +41,13 @@ public class TestConcurrent extends TestMVStore {
...
@@ -41,7 +41,13 @@ public class TestConcurrent extends TestMVStore {
* @param a ignored
* @param a ignored
*/
*/
public
static
void
main
(
String
...
a
)
throws
Exception
{
public
static
void
main
(
String
...
a
)
throws
Exception
{
TestBase
.
createCaller
().
init
().
test
();
TestBase
init
=
TestBase
.
createCaller
().
init
();
init
.
config
.
memory
=
true
;
init
.
config
.
multiThreaded
=
true
;
for
(
int
i
=
0
;
i
<
1000
;
i
++)
{
System
.
out
.
println
(
"Pass #"
+
i
);
init
.
test
();
}
}
}
@Override
@Override
...
@@ -64,7 +70,7 @@ public class TestConcurrent extends TestMVStore {
...
@@ -64,7 +70,7 @@ public class TestConcurrent extends TestMVStore {
testConcurrentRead
();
testConcurrentRead
();
}
}
private
void
testInterruptReopen
()
throws
Exception
{
private
void
testInterruptReopen
()
{
String
fileName
=
"retry:nio:"
+
getBaseDir
()
+
"/"
+
getTestName
();
String
fileName
=
"retry:nio:"
+
getBaseDir
()
+
"/"
+
getTestName
();
FileUtils
.
delete
(
fileName
);
FileUtils
.
delete
(
fileName
);
final
MVStore
s
=
new
MVStore
.
Builder
().
final
MVStore
s
=
new
MVStore
.
Builder
().
...
@@ -95,7 +101,7 @@ public class TestConcurrent extends TestMVStore {
...
@@ -95,7 +101,7 @@ public class TestConcurrent extends TestMVStore {
}
}
}
}
private
void
testConcurrentSaveCompact
()
throws
Exception
{
private
void
testConcurrentSaveCompact
()
{
String
fileName
=
"memFS:"
+
getTestName
();
String
fileName
=
"memFS:"
+
getTestName
();
FileUtils
.
delete
(
fileName
);
FileUtils
.
delete
(
fileName
);
final
MVStore
s
=
new
MVStore
.
Builder
().
final
MVStore
s
=
new
MVStore
.
Builder
().
...
@@ -107,7 +113,7 @@ public class TestConcurrent extends TestMVStore {
...
@@ -107,7 +113,7 @@ public class TestConcurrent extends TestMVStore {
final
MVMap
<
Integer
,
Integer
>
dataMap
=
s
.
openMap
(
"data"
);
final
MVMap
<
Integer
,
Integer
>
dataMap
=
s
.
openMap
(
"data"
);
Task
task
=
new
Task
()
{
Task
task
=
new
Task
()
{
@Override
@Override
public
void
call
()
throws
Exception
{
public
void
call
()
{
int
i
=
0
;
int
i
=
0
;
while
(!
stop
)
{
while
(!
stop
)
{
s
.
compact
(
100
,
1024
*
1024
);
s
.
compact
(
100
,
1024
*
1024
);
...
@@ -152,7 +158,7 @@ public class TestConcurrent extends TestMVStore {
...
@@ -152,7 +158,7 @@ public class TestConcurrent extends TestMVStore {
for
(
int
i
=
0
;
i
<
tasks
.
length
;
i
++)
{
for
(
int
i
=
0
;
i
<
tasks
.
length
;
i
++)
{
tasks
[
i
]
=
new
Task
()
{
tasks
[
i
]
=
new
Task
()
{
@Override
@Override
public
void
call
()
throws
Exception
{
public
void
call
()
{
Random
r
=
new
Random
();
Random
r
=
new
Random
();
WriteBuffer
buff
=
new
WriteBuffer
();
WriteBuffer
buff
=
new
WriteBuffer
();
while
(!
stop
)
{
while
(!
stop
)
{
...
@@ -198,7 +204,7 @@ public class TestConcurrent extends TestMVStore {
...
@@ -198,7 +204,7 @@ public class TestConcurrent extends TestMVStore {
s
.
setAutoCommitDelay
(
1
);
s
.
setAutoCommitDelay
(
1
);
Task
task
=
new
Task
()
{
Task
task
=
new
Task
()
{
@Override
@Override
public
void
call
()
throws
Exception
{
public
void
call
()
{
while
(!
stop
)
{
while
(!
stop
)
{
s
.
compact
(
100
,
1024
*
1024
);
s
.
compact
(
100
,
1024
*
1024
);
}
}
...
@@ -210,7 +216,7 @@ public class TestConcurrent extends TestMVStore {
...
@@ -210,7 +216,7 @@ public class TestConcurrent extends TestMVStore {
final
AtomicInteger
counter
=
new
AtomicInteger
();
final
AtomicInteger
counter
=
new
AtomicInteger
();
Task
task2
=
new
Task
()
{
Task
task2
=
new
Task
()
{
@Override
@Override
public
void
call
()
throws
Exception
{
public
void
call
()
{
while
(!
stop
)
{
while
(!
stop
)
{
int
i
=
counter
.
getAndIncrement
();
int
i
=
counter
.
getAndIncrement
();
dataMap
.
put
(
i
,
i
*
10
);
dataMap
.
put
(
i
,
i
*
10
);
...
@@ -247,7 +253,7 @@ public class TestConcurrent extends TestMVStore {
...
@@ -247,7 +253,7 @@ public class TestConcurrent extends TestMVStore {
}
}
Task
task
=
new
Task
()
{
Task
task
=
new
Task
()
{
@Override
@Override
public
void
call
()
throws
Exception
{
public
void
call
()
{
int
i
=
0
;
int
i
=
0
;
while
(!
stop
)
{
while
(!
stop
)
{
map
.
put
(
i
%
100
,
i
%
100
);
map
.
put
(
i
%
100
,
i
%
100
);
...
@@ -281,7 +287,7 @@ public class TestConcurrent extends TestMVStore {
...
@@ -281,7 +287,7 @@ public class TestConcurrent extends TestMVStore {
try
{
try
{
Task
task
=
new
Task
()
{
Task
task
=
new
Task
()
{
@Override
@Override
public
void
call
()
throws
Exception
{
public
void
call
()
{
while
(!
stop
)
{
while
(!
stop
)
{
s
.
compact
(
100
,
1024
*
1024
);
s
.
compact
(
100
,
1024
*
1024
);
}
}
...
@@ -290,7 +296,7 @@ public class TestConcurrent extends TestMVStore {
...
@@ -290,7 +296,7 @@ public class TestConcurrent extends TestMVStore {
task
.
execute
();
task
.
execute
();
Task
task2
=
new
Task
()
{
Task
task2
=
new
Task
()
{
@Override
@Override
public
void
call
()
throws
Exception
{
public
void
call
()
{
while
(!
stop
)
{
while
(!
stop
)
{
s
.
compact
(
100
,
1024
*
1024
);
s
.
compact
(
100
,
1024
*
1024
);
}
}
...
@@ -323,7 +329,7 @@ public class TestConcurrent extends TestMVStore {
...
@@ -323,7 +329,7 @@ public class TestConcurrent extends TestMVStore {
m
.
put
(
1
,
1
);
m
.
put
(
1
,
1
);
Task
task
=
new
Task
()
{
Task
task
=
new
Task
()
{
@Override
@Override
public
void
call
()
throws
Exception
{
public
void
call
()
{
while
(!
stop
)
{
while
(!
stop
)
{
m
.
put
(
1
,
1
);
m
.
put
(
1
,
1
);
s
.
commit
();
s
.
commit
();
...
@@ -386,7 +392,7 @@ public class TestConcurrent extends TestMVStore {
...
@@ -386,7 +392,7 @@ public class TestConcurrent extends TestMVStore {
final
AtomicInteger
counter
=
new
AtomicInteger
();
final
AtomicInteger
counter
=
new
AtomicInteger
();
Task
task
=
new
Task
()
{
Task
task
=
new
Task
()
{
@Override
@Override
public
void
call
()
throws
Exception
{
public
void
call
()
{
while
(!
stop
)
{
while
(!
stop
)
{
int
x
=
counter
.
getAndIncrement
();
int
x
=
counter
.
getAndIncrement
();
if
(
x
>=
count
)
{
if
(
x
>=
count
)
{
...
@@ -451,7 +457,7 @@ public class TestConcurrent extends TestMVStore {
...
@@ -451,7 +457,7 @@ public class TestConcurrent extends TestMVStore {
final
AtomicInteger
counter
=
new
AtomicInteger
();
final
AtomicInteger
counter
=
new
AtomicInteger
();
Task
task
=
new
Task
()
{
Task
task
=
new
Task
()
{
@Override
@Override
public
void
call
()
throws
Exception
{
public
void
call
()
{
while
(!
stop
)
{
while
(!
stop
)
{
counter
.
incrementAndGet
();
counter
.
incrementAndGet
();
s
.
commit
();
s
.
commit
();
...
@@ -483,7 +489,7 @@ public class TestConcurrent extends TestMVStore {
...
@@ -483,7 +489,7 @@ public class TestConcurrent extends TestMVStore {
final
AtomicInteger
counter
=
new
AtomicInteger
();
final
AtomicInteger
counter
=
new
AtomicInteger
();
Task
task
=
new
Task
()
{
Task
task
=
new
Task
()
{
@Override
@Override
public
void
call
()
throws
Exception
{
public
void
call
()
{
while
(!
stop
)
{
while
(!
stop
)
{
s
.
setStoreVersion
(
counter
.
incrementAndGet
());
s
.
setStoreVersion
(
counter
.
incrementAndGet
());
s
.
commit
();
s
.
commit
();
...
@@ -499,7 +505,7 @@ public class TestConcurrent extends TestMVStore {
...
@@ -499,7 +505,7 @@ public class TestConcurrent extends TestMVStore {
// sometimes closing works, in which case
// sometimes closing works, in which case
// storing must fail at some point (not necessarily
// storing must fail at some point (not necessarily
// immediately)
// immediately)
for
(
int
x
=
counter
.
get
(),
y
=
x
;
x
<=
y
+
2
;
x
++)
{
for
(
int
x
=
counter
.
get
(),
y
=
x
+
2
;
x
<=
y
;
x
++)
{
Thread
.
sleep
(
1
);
Thread
.
sleep
(
1
);
}
}
Exception
e
=
task
.
getException
();
Exception
e
=
task
.
getException
();
...
@@ -529,7 +535,7 @@ public class TestConcurrent extends TestMVStore {
...
@@ -529,7 +535,7 @@ public class TestConcurrent extends TestMVStore {
final
Random
rand
=
new
Random
(
1
);
final
Random
rand
=
new
Random
(
1
);
Task
task
=
new
Task
()
{
Task
task
=
new
Task
()
{
@Override
@Override
public
void
call
()
throws
Exception
{
public
void
call
()
{
try
{
try
{
while
(!
stop
)
{
while
(!
stop
)
{
if
(
rand
.
nextBoolean
())
{
if
(
rand
.
nextBoolean
())
{
...
@@ -651,7 +657,7 @@ public class TestConcurrent extends TestMVStore {
...
@@ -651,7 +657,7 @@ public class TestConcurrent extends TestMVStore {
final
Random
r
=
new
Random
();
final
Random
r
=
new
Random
();
Task
task
=
new
Task
()
{
Task
task
=
new
Task
()
{
@Override
@Override
public
void
call
()
throws
Exception
{
public
void
call
()
{
while
(!
stop
)
{
while
(!
stop
)
{
int
x
=
r
.
nextInt
(
len
);
int
x
=
r
.
nextInt
(
len
);
if
(
r
.
nextBoolean
())
{
if
(
r
.
nextBoolean
())
{
...
@@ -704,7 +710,7 @@ public class TestConcurrent extends TestMVStore {
...
@@ -704,7 +710,7 @@ public class TestConcurrent extends TestMVStore {
final
Random
rand
=
new
Random
(
1
);
final
Random
rand
=
new
Random
(
1
);
Task
task
=
new
Task
()
{
Task
task
=
new
Task
()
{
@Override
@Override
public
void
call
()
throws
Exception
{
public
void
call
()
{
while
(!
stop
)
{
while
(!
stop
)
{
try
{
try
{
if
(
rand
.
nextBoolean
())
{
if
(
rand
.
nextBoolean
())
{
...
@@ -715,13 +721,7 @@ public class TestConcurrent extends TestMVStore {
...
@@ -715,13 +721,7 @@ public class TestConcurrent extends TestMVStore {
m
.
get
(
rand
.
nextInt
(
size
));
m
.
get
(
rand
.
nextInt
(
size
));
}
catch
(
ConcurrentModificationException
e
)
{
}
catch
(
ConcurrentModificationException
e
)
{
detected
.
incrementAndGet
();
detected
.
incrementAndGet
();
}
catch
(
NegativeArraySizeException
e
)
{
}
catch
(
NegativeArraySizeException
|
ArrayIndexOutOfBoundsException
|
IllegalArgumentException
|
NullPointerException
e
)
{
notDetected
.
incrementAndGet
();
}
catch
(
ArrayIndexOutOfBoundsException
e
)
{
notDetected
.
incrementAndGet
();
}
catch
(
IllegalArgumentException
e
)
{
notDetected
.
incrementAndGet
();
}
catch
(
NullPointerException
e
)
{
notDetected
.
incrementAndGet
();
notDetected
.
incrementAndGet
();
}
}
}
}
...
@@ -741,13 +741,7 @@ public class TestConcurrent extends TestMVStore {
...
@@ -741,13 +741,7 @@ public class TestConcurrent extends TestMVStore {
m
.
get
(
rand
.
nextInt
(
size
));
m
.
get
(
rand
.
nextInt
(
size
));
}
catch
(
ConcurrentModificationException
e
)
{
}
catch
(
ConcurrentModificationException
e
)
{
detected
.
incrementAndGet
();
detected
.
incrementAndGet
();
}
catch
(
NegativeArraySizeException
e
)
{
}
catch
(
NegativeArraySizeException
|
ArrayIndexOutOfBoundsException
|
IllegalArgumentException
|
NullPointerException
e
)
{
notDetected
.
incrementAndGet
();
}
catch
(
ArrayIndexOutOfBoundsException
e
)
{
notDetected
.
incrementAndGet
();
}
catch
(
IllegalArgumentException
e
)
{
notDetected
.
incrementAndGet
();
}
catch
(
NullPointerException
e
)
{
notDetected
.
incrementAndGet
();
notDetected
.
incrementAndGet
();
}
}
}
}
...
@@ -771,7 +765,7 @@ public class TestConcurrent extends TestMVStore {
...
@@ -771,7 +765,7 @@ public class TestConcurrent extends TestMVStore {
s
.
commit
();
s
.
commit
();
Task
task
=
new
Task
()
{
Task
task
=
new
Task
()
{
@Override
@Override
public
void
call
()
throws
Exception
{
public
void
call
()
{
while
(!
stop
)
{
while
(!
stop
)
{
long
v
=
s
.
getCurrentVersion
()
-
1
;
long
v
=
s
.
getCurrentVersion
()
-
1
;
Map
<
Integer
,
Integer
>
old
=
m
.
openVersion
(
v
);
Map
<
Integer
,
Integer
>
old
=
m
.
openVersion
(
v
);
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论