Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
df8e6b8f
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看板
提交
df8e6b8f
编写于
12月 03, 2014
作者:
S
sjiang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
8065764: javax/management/monitor/CounterMonitorTest.java hangs
Reviewed-by: jbachorik, dfuchs
上级
9871ad68
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
34 addition
and
12 deletion
+34
-12
test/javax/management/monitor/CounterMonitorTest.java
test/javax/management/monitor/CounterMonitorTest.java
+34
-12
未找到文件。
test/javax/management/monitor/CounterMonitorTest.java
浏览文件 @
df8e6b8f
/*
* Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2004,
2014,
Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
...
...
@@ -26,7 +26,7 @@
* @bug 4981829
* @summary Test that the counter monitor, when running in difference mode,
* emits a notification every time the threshold is exceeded.
* @author Luis-Miguel Alventosa
* @author Luis-Miguel Alventosa
, Shanliang JIANG
* @run clean CounterMonitorTest
* @run build CounterMonitorTest
* @run main CounterMonitorTest
...
...
@@ -50,23 +50,31 @@ public class CounterMonitorTest implements NotificationListener {
private
boolean
notifyFlag
=
true
;
// granularity period
private
int
granularityperiod
=
50
0
;
private
int
granularityperiod
=
1
0
;
//
counter values
private
int
[]
values
=
new
int
[]
{
4
,
6
,
9
,
11
}
;
//
derived gauge
private
volatile
int
derivedGauge
=
2
;
// flag to notify that a message has been received
private
volatile
boolean
messageReceived
=
false
;
private
volatile
Object
observedValue
=
null
;
// MBean class
public
class
StdObservedObject
implements
StdObservedObjectMBean
{
public
Object
getNbObjects
()
{
echo
(
">>> StdObservedObject.getNbObjects: "
+
count
);
synchronized
(
CounterMonitorTest
.
class
)
{
observedValue
=
count
;
CounterMonitorTest
.
class
.
notifyAll
();
}
return
count
;
}
public
void
setNbObjects
(
Object
n
)
{
echo
(
">>> StdObservedObject.setNbObjects: "
+
n
);
count
=
n
;
}
private
Object
count
=
null
;
private
volatile
Object
count
=
null
;
}
// MBean interface
...
...
@@ -166,18 +174,18 @@ public class CounterMonitorTest implements NotificationListener {
Attribute
attrib
=
new
Attribute
(
"NbObjects"
,
data
);
server
.
setAttribute
(
stdObsObjName
,
attrib
);
// Wait for granularity period (multiplied by 2 for sure)
//
Thread
.
sleep
(
granularityperiod
*
2
);
waitObservation
(
data
);
// Loop through the values
//
for
(
int
i
=
0
;
i
<
values
.
length
;
i
++)
{
data
=
new
Integer
(
values
[
i
]);
echo
(
">>> Set data = "
+
data
.
intValue
());
while
(
derivedGauge
++
<
10
)
{
System
.
out
.
print
(
">>> Set data from "
+
data
.
intValue
());
data
=
new
Integer
(
data
.
intValue
()
+
derivedGauge
);
echo
(
" to "
+
data
.
intValue
());
attrib
=
new
Attribute
(
"NbObjects"
,
data
);
server
.
setAttribute
(
stdObsObjName
,
attrib
);
waitObservation
(
data
);
echo
(
"\tdoWait in Counter Monitor"
);
doWait
();
...
...
@@ -214,6 +222,20 @@ public class CounterMonitorTest implements NotificationListener {
}
}
private
void
waitObservation
(
Object
value
)
{
synchronized
(
CounterMonitorTest
.
class
)
{
while
(
value
!=
observedValue
)
{
try
{
CounterMonitorTest
.
class
.
wait
();
}
catch
(
InterruptedException
e
)
{
System
.
err
.
println
(
"Got unexpected exception: "
+
e
);
e
.
printStackTrace
();
break
;
}
}
}
}
/*
* Print message
*/
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录