Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
d61be971
提交
d61be971
authored
7月 09, 2013
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Automated build improvements.
上级
1cba07fa
显示空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
167 行增加
和
34 行删除
+167
-34
SelfDestructor.java
h2/src/test/org/h2/test/utils/SelfDestructor.java
+38
-31
UploadBuild.java
h2/src/tools/org/h2/build/doc/UploadBuild.java
+3
-3
JavaProcessKiller.java
h2/src/tools/org/h2/dev/util/JavaProcessKiller.java
+126
-0
没有找到文件。
h2/src/test/org/h2/test/utils/SelfDestructor.java
浏览文件 @
d61be971
...
@@ -48,6 +48,7 @@ public class SelfDestructor extends Thread {
...
@@ -48,6 +48,7 @@ public class SelfDestructor extends Thread {
// ignore
// ignore
}
}
}
}
try
{
String
time
=
new
Timestamp
(
System
.
currentTimeMillis
()).
toString
();
String
time
=
new
Timestamp
(
System
.
currentTimeMillis
()).
toString
();
System
.
out
.
println
(
time
+
" Killing the process after "
+
minutes
+
" minute(s)"
);
System
.
out
.
println
(
time
+
" Killing the process after "
+
minutes
+
" minute(s)"
);
try
{
try
{
...
@@ -88,7 +89,13 @@ public class SelfDestructor extends Thread {
...
@@ -88,7 +89,13 @@ public class SelfDestructor extends Thread {
// ignore
// ignore
}
}
System
.
out
.
println
(
"Killing the process now"
);
System
.
out
.
println
(
"Killing the process now"
);
}
catch
(
Throwable
t
)
{
try
{
t
.
printStackTrace
(
System
.
out
);
}
catch
(
Throwable
t2
)
{
// ignore (out of memory)
}
}
Runtime
.
getRuntime
().
halt
(
1
);
Runtime
.
getRuntime
().
halt
(
1
);
}
}
};
};
...
...
h2/src/tools/org/h2/build/doc/UploadBuild.java
浏览文件 @
d61be971
...
@@ -112,12 +112,12 @@ public class UploadBuild {
...
@@ -112,12 +112,12 @@ public class UploadBuild {
int
end
=
testOutput
.
indexOf
(
"<br />"
,
idx
);
int
end
=
testOutput
.
indexOf
(
"<br />"
,
idx
);
if
(
end
>=
0
)
{
if
(
end
>=
0
)
{
String
result
=
testOutput
.
substring
(
idx
+
"Statements per second: "
.
length
(),
end
);
String
result
=
testOutput
.
substring
(
idx
+
"Statements per second: "
.
length
(),
end
);
now
+=
"
("
+
result
+
" op/s)
"
;
now
+=
"
"
+
result
+
" op/s
"
;
}
}
}
}
String
sql
=
"insert into item(title, issued, desc) values('Build "
+
now
+
String
sql
=
"insert into item(title, issued, desc) values('Build "
+
now
+
(
error
?
"
(FAILED)
"
:
""
)
+
(
error
?
"
FAILED
"
:
""
)
+
(
coverageFailed
?
"
(COVERAGE)
"
:
""
)
+
(
coverageFailed
?
"
COVERAGE
"
:
""
)
+
"', '"
+
ts
+
"', '<a href=\"http://www.h2database.com/html/testOutput.html\">Output</a>"
+
"', '"
+
ts
+
"', '<a href=\"http://www.h2database.com/html/testOutput.html\">Output</a>"
+
" - <a href=\"http://www.h2database.com/coverage/overview.html\">Coverage</a>"
+
" - <a href=\"http://www.h2database.com/coverage/overview.html\">Coverage</a>"
+
" - <a href=\"http://www.h2database.com/automated/h2-latest.jar\">Jar</a>');\n"
;
" - <a href=\"http://www.h2database.com/automated/h2-latest.jar\">Jar</a>');\n"
;
...
...
h2/src/tools/org/h2/dev/util/JavaProcessKiller.java
0 → 100644
浏览文件 @
d61be971
/*
* Copyright 2004-2013 H2 Group. Multiple-Licensed under the H2 License,
* Version 1.0, and under the Eclipse Public License, Version 1.0
* (http://h2database.com/html/license.html).
* Initial Developer: H2 Group
*/
package
org
.
h2
.
dev
.
util
;
import
java.io.ByteArrayOutputStream
;
import
java.io.InputStream
;
import
java.io.OutputStream
;
import
java.util.Map.Entry
;
import
java.util.TreeMap
;
/**
* Allows to kill a certain Java process.
*/
public
class
JavaProcessKiller
{
/**
* Kill a certain Java process. The JDK (jps) needs to be in the path.
*
* @param args the Java process name as listed by jps -l. If not set the
* Java processes are listed
*/
public
static
void
main
(
String
...
args
)
{
new
JavaProcessKiller
().
run
(
args
);
}
private
void
run
(
String
...
args
)
{
TreeMap
<
Integer
,
String
>
map
=
getProcesses
();
System
.
out
.
println
(
"Processes:"
);
System
.
out
.
println
(
map
);
if
(
args
.
length
==
0
)
{
System
.
out
.
println
(
"Kill a Java process"
);
System
.
out
.
println
(
"Usage: java "
+
getClass
().
getName
()
+
" <name>"
);
return
;
}
String
processName
=
args
[
0
];
int
killCount
=
0
;
for
(
Entry
<
Integer
,
String
>
e
:
map
.
entrySet
())
{
String
name
=
e
.
getValue
();
if
(
name
.
equals
(
processName
))
{
int
pid
=
e
.
getKey
();
System
.
out
.
println
(
"Killing pid "
+
pid
+
"..."
);
// Windows
try
{
exec
(
"taskkill"
,
"/pid"
,
""
+
pid
,
"/f"
);
}
catch
(
Exception
e2
)
{
// ignore
}
// Unix
try
{
exec
(
"kill"
,
"-9"
,
""
+
pid
);
}
catch
(
Exception
e2
)
{
// ignore
}
System
.
out
.
println
(
"done."
);
killCount
++;
}
}
if
(
killCount
==
0
)
{
System
.
out
.
println
(
"Process "
+
processName
+
" not found"
);
}
map
=
getProcesses
();
System
.
out
.
println
(
"Processes now:"
);
System
.
out
.
println
(
map
);
}
private
static
TreeMap
<
Integer
,
String
>
getProcesses
()
{
String
processList
=
exec
(
"jps"
,
"-l"
);
String
[]
processes
=
processList
.
split
(
"\n"
);
TreeMap
<
Integer
,
String
>
map
=
new
TreeMap
<
Integer
,
String
>();
for
(
int
i
=
0
;
i
<
processes
.
length
;
i
++)
{
String
p
=
processes
[
i
].
trim
();
int
idx
=
p
.
indexOf
(
' '
);
if
(
idx
>
0
)
{
int
pid
=
Integer
.
parseInt
(
p
.
substring
(
0
,
idx
));
String
n
=
p
.
substring
(
idx
+
1
);
map
.
put
(
pid
,
n
);
}
}
return
map
;
}
private
static
String
exec
(
String
...
args
)
{
ByteArrayOutputStream
err
=
new
ByteArrayOutputStream
();
ByteArrayOutputStream
out
=
new
ByteArrayOutputStream
();
try
{
Process
p
=
Runtime
.
getRuntime
().
exec
(
args
);
copyInThread
(
p
.
getInputStream
(),
out
);
copyInThread
(
p
.
getErrorStream
(),
err
);
p
.
waitFor
();
String
e
=
new
String
(
err
.
toByteArray
(),
"UTF-8"
);
if
(
e
.
length
()
>
0
)
{
throw
new
RuntimeException
(
e
);
}
String
output
=
new
String
(
out
.
toByteArray
(),
"UTF-8"
);
return
output
;
}
catch
(
Exception
e
)
{
throw
new
RuntimeException
(
e
);
}
}
private
static
void
copyInThread
(
final
InputStream
in
,
final
OutputStream
out
)
{
new
Thread
(
"Profiler stream copy"
)
{
@Override
public
void
run
()
{
byte
[]
buffer
=
new
byte
[
4096
];
try
{
while
(
true
)
{
int
len
=
in
.
read
(
buffer
,
0
,
buffer
.
length
);
if
(
len
<
0
)
{
break
;
}
out
.
write
(
buffer
,
0
,
len
);
}
}
catch
(
Exception
e
)
{
throw
new
RuntimeException
(
e
);
}
}
}.
run
();
}
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论