Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
e2227d90
D
dragonwell8_jdk
项目概览
openanolis
/
dragonwell8_jdk
通知
4
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
dragonwell8_jdk
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
e2227d90
编写于
11月 12, 2013
作者:
E
egahlin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
6543856: MonitorVmStartTerminate.sh fails intermittently
Reviewed-by: sla, dholmes
上级
44aebaa3
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
154 addition
and
175 deletion
+154
-175
test/sun/jvmstat/monitor/MonitoredVm/MonitorVmStartTerminate.java
.../jvmstat/monitor/MonitoredVm/MonitorVmStartTerminate.java
+154
-173
test/sun/jvmstat/monitor/MonitoredVm/MonitorVmStartTerminate.sh
...un/jvmstat/monitor/MonitoredVm/MonitorVmStartTerminate.sh
+0
-1
test/sun/jvmstat/testlibrary/JavaProcess.java
test/sun/jvmstat/testlibrary/JavaProcess.java
+0
-1
未找到文件。
test/sun/jvmstat/monitor/MonitoredVm/MonitorVmStartTerminate.java
浏览文件 @
e2227d90
...
@@ -21,6 +21,7 @@
...
@@ -21,6 +21,7 @@
* questions.
* questions.
*/
*/
import
java.util.concurrent.CountDownLatch
;
import
java.util.regex.*
;
import
java.util.regex.*
;
import
java.util.*
;
import
java.util.*
;
import
java.net.URISyntaxException
;
import
java.net.URISyntaxException
;
...
@@ -33,8 +34,6 @@ public class MonitorVmStartTerminate {
...
@@ -33,8 +34,6 @@ public class MonitorVmStartTerminate {
private
static
final
int
SLEEPERS
=
10
;
private
static
final
int
SLEEPERS
=
10
;
private
static
final
int
SLEEPTIME
=
5000
;
// sleep time for a sleeper
private
static
final
int
SLEEPTIME
=
5000
;
// sleep time for a sleeper
private
static
final
int
EXECINTERVAL
=
3000
;
// wait time between exec's
private
static
final
int
EXECINTERVAL
=
3000
;
// wait time between exec's
private
static
final
int
JOINTIME
=
(
SLEEPERS
*
EXECINTERVAL
)
+
SLEEPTIME
*
2
;
public
static
void
main
(
String
args
[])
throws
Exception
{
public
static
void
main
(
String
args
[])
throws
Exception
{
...
@@ -46,7 +45,8 @@ public class MonitorVmStartTerminate {
...
@@ -46,7 +45,8 @@ public class MonitorVmStartTerminate {
MonitoredHost
host
=
MonitoredHost
.
getMonitoredHost
(
"localhost"
);
MonitoredHost
host
=
MonitoredHost
.
getMonitoredHost
(
"localhost"
);
host
.
setInterval
(
200
);
host
.
setInterval
(
200
);
SleeperListener
listener
=
new
SleeperListener
(
host
,
sleeperPattern
);
Matcher
matcher
=
Pattern
.
compile
(
sleeperPattern
).
matcher
(
""
);
SleeperListener
listener
=
new
SleeperListener
(
host
,
matcher
,
SLEEPERS
);
host
.
addHostListener
(
listener
);
host
.
addHostListener
(
listener
);
SleeperStarter
ss
=
new
SleeperStarter
(
SLEEPERS
,
EXECINTERVAL
,
SleeperStarter
ss
=
new
SleeperStarter
(
SLEEPERS
,
EXECINTERVAL
,
...
@@ -56,47 +56,40 @@ public class MonitorVmStartTerminate {
...
@@ -56,47 +56,40 @@ public class MonitorVmStartTerminate {
System
.
out
.
println
(
"Waiting for "
System
.
out
.
println
(
"Waiting for "
+
SLEEPERS
+
" sleepers to terminate"
);
+
SLEEPERS
+
" sleepers to terminate"
);
try
{
try
{
ss
.
join
(
JOINTIME
);
ss
.
join
();
}
catch
(
InterruptedException
e
)
{
}
catch
(
InterruptedException
e
)
{
System
.
err
.
printl
n
(
"Timed out waiting for sleepers"
);
throw
new
Exceptio
n
(
"Timed out waiting for sleepers"
);
}
}
listener
.
waitForSleepersToStart
();
if
(
listener
.
getStarted
()
!=
SLEEPERS
)
{
listener
.
waitForSleepersToTerminate
();
throw
new
RuntimeException
(
"Too few sleepers started: "
+
" started = "
+
listener
.
getStarted
()
+
" SLEEPERS = "
+
SLEEPERS
);
}
if
(
listener
.
getStarted
()
!=
listener
.
getTerminated
())
{
throw
new
RuntimeException
(
"Started count != terminated count: "
+
" started = "
+
listener
.
getStarted
()
+
" terminated = "
+
listener
.
getTerminated
());
}
}
}
}
class
SleeperListener
implements
HostListener
{
public
static
class
SleeperListener
implements
HostListener
{
private
static
final
boolean
DEBUG
=
false
;
int
started
;
private
final
List
<
Integer
>
targets
=
new
ArrayList
<>()
;
int
terminated
;
private
final
CountDownLatch
terminateLatch
;
MonitoredHost
host
;
private
final
CountDownLatch
startLatch
;
Matcher
patternMatcher
;
private
final
MonitoredHost
host
;
ArrayList
targets
;
private
final
Matcher
patternMatcher
;
public
SleeperListener
(
MonitoredHost
host
,
String
sleeperPattern
)
{
public
SleeperListener
(
MonitoredHost
host
,
Matcher
matcher
,
int
count
)
{
this
.
host
=
host
;
this
.
host
=
host
;
Pattern
pattern
=
Pattern
.
compile
(
sleeperPattern
)
;
this
.
patternMatcher
=
matcher
;
patternMatcher
=
pattern
.
matcher
(
""
);
this
.
terminateLatch
=
new
CountDownLatch
(
count
);
targets
=
new
ArrayList
(
);
this
.
startLatch
=
new
CountDownLatch
(
count
);
}
}
private
void
printList
(
Iterator
i
,
String
msg
)
{
public
void
waitForSleepersToTerminate
()
throws
InterruptedException
{
terminateLatch
.
await
();
}
public
void
waitForSleepersToStart
()
throws
InterruptedException
{
startLatch
.
await
();
}
private
void
printList
(
Set
<
Integer
>
list
,
String
msg
)
{
System
.
out
.
println
(
msg
+
":"
);
System
.
out
.
println
(
msg
+
":"
);
while
(
i
.
hasNext
())
{
for
(
Integer
lvmid
:
list
)
{
Integer
lvmid
=
(
Integer
)
i
.
next
();
try
{
try
{
VmIdentifier
vmid
=
new
VmIdentifier
(
"//"
+
lvmid
.
intValue
());
VmIdentifier
vmid
=
new
VmIdentifier
(
"//"
+
lvmid
.
intValue
());
MonitoredVm
target
=
host
.
getMonitoredVm
(
vmid
);
MonitoredVm
target
=
host
.
getMonitoredVm
(
vmid
);
...
@@ -119,11 +112,10 @@ class SleeperListener implements HostListener {
...
@@ -119,11 +112,10 @@ class SleeperListener implements HostListener {
}
}
private
int
addStarted
(
Iterator
i
)
{
private
int
addStarted
(
Set
<
Integer
>
started
)
{
int
found
=
0
;
int
found
=
0
;
while
(
i
.
hasNext
()
)
{
for
(
Integer
lvmid
:
started
)
{
try
{
try
{
Integer
lvmid
=
(
Integer
)
i
.
next
();
VmIdentifier
vmid
=
new
VmIdentifier
(
"//"
+
lvmid
.
intValue
());
VmIdentifier
vmid
=
new
VmIdentifier
(
"//"
+
lvmid
.
intValue
());
MonitoredVm
target
=
host
.
getMonitoredVm
(
vmid
);
MonitoredVm
target
=
host
.
getMonitoredVm
(
vmid
);
...
@@ -154,10 +146,9 @@ class SleeperListener implements HostListener {
...
@@ -154,10 +146,9 @@ class SleeperListener implements HostListener {
return
found
;
return
found
;
}
}
private
int
removeTerminated
(
Iterator
i
)
{
private
int
removeTerminated
(
Set
<
Integer
>
terminated
)
{
int
found
=
0
;
int
found
=
0
;
while
(
i
.
hasNext
())
{
for
(
Integer
lvmid
:
terminated
)
{
Integer
lvmid
=
(
Integer
)
i
.
next
();
/*
/*
* we don't attempt to attach to the target here as it's
* we don't attempt to attach to the target here as it's
* now dead and has no jvmstat share memory file. Just see
* now dead and has no jvmstat share memory file. Just see
...
@@ -178,40 +169,32 @@ class SleeperListener implements HostListener {
...
@@ -178,40 +169,32 @@ class SleeperListener implements HostListener {
return
found
;
return
found
;
}
}
public
synchronized
int
getStarted
()
{
@SuppressWarnings
(
"unchecked"
)
return
started
;
}
public
synchronized
int
getTerminated
()
{
return
terminated
;
}
public
void
vmStatusChanged
(
VmStatusChangeEvent
ev
)
{
public
void
vmStatusChanged
(
VmStatusChangeEvent
ev
)
{
if
(
DEBUG
)
{
printList
(
ev
.
getActive
(),
"Active"
);
printList
(
ev
.
getActive
().
iterator
(),
"Active"
);
printList
(
ev
.
getStarted
(),
"Started"
);
printList
(
ev
.
getStarted
().
iterator
(),
"Started"
);
printList
(
ev
.
getTerminated
(),
"Terminated"
);
printList
(
ev
.
getTerminated
().
iterator
(),
"Terminated"
);
}
int
recentlyStarted
=
addStarted
(
ev
.
getStarted
().
iterator
());
int
recentlyStarted
=
addStarted
(
ev
.
getStarted
());
int
recentlyTerminated
=
removeTerminated
(
int
recentlyTerminated
=
removeTerminated
(
ev
.
getTerminated
());
ev
.
getTerminated
().
iterator
());
synchronized
(
this
)
{
for
(
int
i
=
0
;
i
<
recentlyTerminated
;
i
++)
{
started
+=
recentlyStarted
;
terminateLatch
.
countDown
();
terminated
+=
recentlyTerminated
;
}
for
(
int
i
=
0
;
i
<
recentlyStarted
;
i
++)
{
startLatch
.
countDown
();
}
}
}
}
public
void
disconnected
(
HostEvent
ev
)
{
public
void
disconnected
(
HostEvent
ev
)
{
}
}
}
}
class
SleeperStarter
extends
Thread
{
public
static
class
SleeperStarter
extends
Thread
{
JavaProcess
[]
processes
;
private
final
JavaProcess
[]
processes
;
int
execInterval
;
private
final
int
execInterval
;
String
args
;
private
final
String
args
;
public
SleeperStarter
(
int
sleepers
,
int
execInterval
,
String
args
)
{
public
SleeperStarter
(
int
sleepers
,
int
execInterval
,
String
args
)
{
this
.
execInterval
=
execInterval
;
this
.
execInterval
=
execInterval
;
...
@@ -221,9 +204,9 @@ class SleeperStarter extends Thread {
...
@@ -221,9 +204,9 @@ class SleeperStarter extends Thread {
private
synchronized
int
active
()
{
private
synchronized
int
active
()
{
int
active
=
processes
.
length
;
int
active
=
processes
.
length
;
for
(
int
i
=
0
;
i
<
processes
.
length
;
i
++
)
{
for
(
JavaProcess
jp
:
processes
)
{
try
{
try
{
int
exitValue
=
processes
[
i
]
.
exitValue
();
jp
.
exitValue
();
active
--;
active
--;
}
catch
(
IllegalThreadStateException
e
)
{
}
catch
(
IllegalThreadStateException
e
)
{
// process hasn't exited yet
// process hasn't exited yet
...
@@ -259,9 +242,7 @@ class SleeperStarter extends Thread {
...
@@ -259,9 +242,7 @@ class SleeperStarter extends Thread {
// spin waiting for the processes to terminate
// spin waiting for the processes to terminate
while
(
active
()
>
0
)
;
while
(
active
()
>
0
)
;
}
// give final termination event a change to propogate to
// the HostListener
try
{
Thread
.
sleep
(
2000
);
}
catch
(
InterruptedException
ignore
)
{
}
}
}
}
}
test/sun/jvmstat/monitor/MonitoredVm/MonitorVmStartTerminate.sh
浏览文件 @
e2227d90
...
@@ -23,7 +23,6 @@
...
@@ -23,7 +23,6 @@
#
#
# @test
# @test
# @ignore until 6543856 is fixed
# @bug 4990825
# @bug 4990825
# @summary attach to external but local JVM processes
# @summary attach to external but local JVM processes
# @library ../../testlibrary
# @library ../../testlibrary
...
...
test/sun/jvmstat/testlibrary/JavaProcess.java
浏览文件 @
e2227d90
...
@@ -26,7 +26,6 @@
...
@@ -26,7 +26,6 @@
*/
*/
import
java.io.*
;
import
java.io.*
;
import
java.util.Properties
;
public
class
JavaProcess
{
public
class
JavaProcess
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录