Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
d42b9406
提交
d42b9406
authored
16 年前
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
In-memory databases can now run inside the Google App Engine.
上级
9b21163b
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
43 行增加
和
25 行删除
+43
-25
Database.java
h2/src/main/org/h2/engine/Database.java
+3
-1
WriterThread.java
h2/src/main/org/h2/store/WriterThread.java
+4
-3
RandomUtils.java
h2/src/main/org/h2/util/RandomUtils.java
+36
-21
没有找到文件。
h2/src/main/org/h2/engine/Database.java
浏览文件 @
d42b9406
...
...
@@ -222,8 +222,8 @@ public class Database implements DataHandler {
try
{
open
(
traceLevelFile
,
traceLevelSystemOut
);
if
(
closeAtVmShutdown
)
{
closeOnExit
=
new
DatabaseCloser
(
this
,
0
,
true
);
try
{
closeOnExit
=
new
DatabaseCloser
(
this
,
0
,
true
);
Runtime
.
getRuntime
().
addShutdownHook
(
closeOnExit
);
}
catch
(
IllegalStateException
e
)
{
// shutdown in progress - just don't register the handler
...
...
@@ -231,6 +231,8 @@ public class Database implements DataHandler {
// database at shutdown time)
}
catch
(
SecurityException
e
)
{
// applets may not do that - ignore
// Google App Engine doesn't allow
// to instantiate classes that extend Thread
}
}
}
catch
(
Throwable
e
)
{
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/store/WriterThread.java
浏览文件 @
d42b9406
...
...
@@ -25,7 +25,7 @@ import org.h2.util.ObjectArray;
* The writer thread is responsible to flush the transaction log file from time
* to time.
*/
public
class
WriterThread
extends
Thread
{
public
class
WriterThread
implements
Runnable
{
/**
* The reference to the database.
...
...
@@ -74,11 +74,12 @@ public class WriterThread extends Thread {
* @return the writer thread object
*/
public
static
WriterThread
create
(
Database
database
,
int
writeDelay
)
{
WriterThread
thread
=
new
WriterThread
(
database
,
writeDelay
);
WriterThread
writer
=
new
WriterThread
(
database
,
writeDelay
);
Thread
thread
=
new
Thread
(
writer
);
thread
.
setName
(
"H2 Log Writer "
+
database
.
getShortName
());
thread
.
setDaemon
(
true
);
thread
.
start
();
return
thread
;
return
writer
;
}
private
LogSystem
getLog
()
{
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/util/RandomUtils.java
浏览文件 @
d42b9406
...
...
@@ -10,7 +10,6 @@ import java.io.ByteArrayOutputStream;
import
java.io.DataOutputStream
;
import
java.io.IOException
;
import
java.lang.reflect.Method
;
import
java.net.InetAddress
;
import
java.security.NoSuchAlgorithmException
;
import
java.security.SecureRandom
;
import
java.util.Random
;
...
...
@@ -65,24 +64,31 @@ public class RandomUtils {
}
}
};
Thread
t
=
new
Thread
(
runnable
);
// let the process terminate even if generating the seed is really slow
t
.
setDaemon
(
true
);
t
.
start
();
Thread
.
yield
();
try
{
// normally, generateSeed takes less than 200 ms
t
.
join
(
400
);
}
catch
(
InterruptedException
e
)
{
warn
(
"InterruptedException"
,
e
);
}
if
(!
seeded
)
{
byte
[]
seed
=
generateAlternativeSeed
();
// this never reduces randomness
synchronized
(
cachedSecureRandom
)
{
cachedSecureRandom
.
setSeed
(
seed
);
Thread
t
=
new
Thread
(
runnable
);
// let the process terminate even if generating the seed is really slow
t
.
setDaemon
(
true
);
t
.
start
();
Thread
.
yield
();
try
{
// normally, generateSeed takes less than 200 ms
t
.
join
(
400
);
}
catch
(
InterruptedException
e
)
{
warn
(
"InterruptedException"
,
e
);
}
if
(!
seeded
)
{
byte
[]
seed
=
generateAlternativeSeed
();
// this never reduces randomness
synchronized
(
cachedSecureRandom
)
{
cachedSecureRandom
.
setSeed
(
seed
);
}
}
}
catch
(
SecurityException
e
)
{
// workaround for the Google App Engine: don't use a thread
runnable
.
run
();
generateAlternativeSeed
();
}
}
catch
(
NoSuchAlgorithmException
e
)
{
warn
(
"SecureRandom"
,
e
);
cachedSecureRandom
=
new
SecureRandom
();
...
...
@@ -125,18 +131,27 @@ public class RandomUtils {
// host name and ip addresses (if any)
try
{
String
hostName
=
InetAddress
.
getLocalHost
().
getHostName
();
// workaround for the Google App Engine: don't use InetAddress
Class
inetAddressClass
=
Class
.
forName
(
"java.net.InetAddress"
);
Object
localHost
=
inetAddressClass
.
getMethod
(
"getLocalHost"
,
new
Class
[
0
]).
invoke
(
null
,
new
Object
[
0
]);
String
hostName
=
inetAddressClass
.
getMethod
(
"getHostName"
,
new
Class
[
0
]).
invoke
(
localHost
,
new
Object
[
0
]).
toString
();
out
.
writeUTF
(
hostName
);
InetAddress
[]
list
=
InetAddress
.
getAllByName
(
hostName
);
Object
[]
list
=
(
Object
[])
inetAddressClass
.
getMethod
(
"getAllByName"
,
new
Class
[]
{
String
.
class
})
.
invoke
(
null
,
new
Object
[]
{
hostName
});
Method
getAddress
=
inetAddressClass
.
getMethod
(
"getAddress"
,
new
Class
[
0
]);
for
(
int
i
=
0
;
i
<
list
.
length
;
i
++)
{
out
.
write
(
list
[
i
].
getAddress
(
));
out
.
write
(
(
byte
[])
getAddress
.
invoke
(
list
[
i
],
new
Object
[
0
]
));
}
}
catch
(
Exception
e
)
{
}
catch
(
Throwable
e
)
{
// on some system, InetAddress is not supported
// on some system, InetAddress.getLocalHost() doesn't work
// for some reason (incorrect configuration)
}
// timing (a second thread is already running)
// timing (a second thread is already running
usually
)
for
(
int
j
=
0
;
j
<
16
;
j
++)
{
int
i
=
0
;
long
end
=
System
.
currentTimeMillis
();
...
...
This diff is collapsed.
Click to expand it.
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论