Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
c449e27f
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看板
提交
c449e27f
编写于
11月 14, 2008
作者:
D
dfuchs
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
6683213: CounterMonitor's derived Gauge badly initialized
Reviewed-by: emcmanus
上级
e58b993b
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
277 addition
and
2 deletion
+277
-2
src/share/classes/javax/management/monitor/CounterMonitor.java
...hare/classes/javax/management/monitor/CounterMonitor.java
+3
-0
src/share/classes/javax/management/monitor/GaugeMonitor.java
src/share/classes/javax/management/monitor/GaugeMonitor.java
+3
-0
src/share/classes/javax/management/monitor/Monitor.java
src/share/classes/javax/management/monitor/Monitor.java
+1
-2
test/javax/management/monitor/DerivedGaugeMonitorTest.java
test/javax/management/monitor/DerivedGaugeMonitorTest.java
+270
-0
未找到文件。
src/share/classes/javax/management/monitor/CounterMonitor.java
浏览文件 @
c449e27f
...
@@ -265,6 +265,7 @@ public class CounterMonitor extends Monitor implements CounterMonitorMBean {
...
@@ -265,6 +265,7 @@ public class CounterMonitor extends Monitor implements CounterMonitorMBean {
* @return The derived gauge of the specified object.
* @return The derived gauge of the specified object.
*
*
*/
*/
@Override
public
synchronized
Number
getDerivedGauge
(
ObjectName
object
)
{
public
synchronized
Number
getDerivedGauge
(
ObjectName
object
)
{
return
(
Number
)
super
.
getDerivedGauge
(
object
);
return
(
Number
)
super
.
getDerivedGauge
(
object
);
}
}
...
@@ -280,6 +281,7 @@ public class CounterMonitor extends Monitor implements CounterMonitorMBean {
...
@@ -280,6 +281,7 @@ public class CounterMonitor extends Monitor implements CounterMonitorMBean {
* @return The derived gauge timestamp of the specified object.
* @return The derived gauge timestamp of the specified object.
*
*
*/
*/
@Override
public
synchronized
long
getDerivedGaugeTimeStamp
(
ObjectName
object
)
{
public
synchronized
long
getDerivedGaugeTimeStamp
(
ObjectName
object
)
{
return
super
.
getDerivedGaugeTimeStamp
(
object
);
return
super
.
getDerivedGaugeTimeStamp
(
object
);
}
}
...
@@ -595,6 +597,7 @@ public class CounterMonitor extends Monitor implements CounterMonitorMBean {
...
@@ -595,6 +597,7 @@ public class CounterMonitor extends Monitor implements CounterMonitorMBean {
* name of the Java class of the notification and the notification
* name of the Java class of the notification and the notification
* types sent by the counter monitor.
* types sent by the counter monitor.
*/
*/
@Override
public
MBeanNotificationInfo
[]
getNotificationInfo
()
{
public
MBeanNotificationInfo
[]
getNotificationInfo
()
{
return
notifsInfo
;
return
notifsInfo
;
}
}
...
...
src/share/classes/javax/management/monitor/GaugeMonitor.java
浏览文件 @
c449e27f
...
@@ -258,6 +258,7 @@ public class GaugeMonitor extends Monitor implements GaugeMonitorMBean {
...
@@ -258,6 +258,7 @@ public class GaugeMonitor extends Monitor implements GaugeMonitorMBean {
* @return The derived gauge of the specified object.
* @return The derived gauge of the specified object.
*
*
*/
*/
@Override
public
synchronized
Number
getDerivedGauge
(
ObjectName
object
)
{
public
synchronized
Number
getDerivedGauge
(
ObjectName
object
)
{
return
(
Number
)
super
.
getDerivedGauge
(
object
);
return
(
Number
)
super
.
getDerivedGauge
(
object
);
}
}
...
@@ -273,6 +274,7 @@ public class GaugeMonitor extends Monitor implements GaugeMonitorMBean {
...
@@ -273,6 +274,7 @@ public class GaugeMonitor extends Monitor implements GaugeMonitorMBean {
* @return The derived gauge timestamp of the specified object.
* @return The derived gauge timestamp of the specified object.
*
*
*/
*/
@Override
public
synchronized
long
getDerivedGaugeTimeStamp
(
ObjectName
object
)
{
public
synchronized
long
getDerivedGaugeTimeStamp
(
ObjectName
object
)
{
return
super
.
getDerivedGaugeTimeStamp
(
object
);
return
super
.
getDerivedGaugeTimeStamp
(
object
);
}
}
...
@@ -477,6 +479,7 @@ public class GaugeMonitor extends Monitor implements GaugeMonitorMBean {
...
@@ -477,6 +479,7 @@ public class GaugeMonitor extends Monitor implements GaugeMonitorMBean {
* name of the Java class of the notification and the notification
* name of the Java class of the notification and the notification
* types sent by the gauge monitor.
* types sent by the gauge monitor.
*/
*/
@Override
public
MBeanNotificationInfo
[]
getNotificationInfo
()
{
public
MBeanNotificationInfo
[]
getNotificationInfo
()
{
return
notifsInfo
;
return
notifsInfo
;
}
}
...
...
src/share/classes/javax/management/monitor/Monitor.java
浏览文件 @
c449e27f
...
@@ -34,7 +34,6 @@ import java.security.AccessController;
...
@@ -34,7 +34,6 @@ import java.security.AccessController;
import
java.security.PrivilegedAction
;
import
java.security.PrivilegedAction
;
import
java.util.List
;
import
java.util.List
;
import
java.util.concurrent.CopyOnWriteArrayList
;
import
java.util.concurrent.CopyOnWriteArrayList
;
import
java.util.concurrent.ExecutorService
;
import
java.util.concurrent.Executors
;
import
java.util.concurrent.Executors
;
import
java.util.concurrent.Future
;
import
java.util.concurrent.Future
;
import
java.util.concurrent.LinkedBlockingQueue
;
import
java.util.concurrent.LinkedBlockingQueue
;
...
@@ -517,7 +516,7 @@ public abstract class Monitor
...
@@ -517,7 +516,7 @@ public abstract class Monitor
//
//
ObservedObject
o
=
createObservedObject
(
object
);
ObservedObject
o
=
createObservedObject
(
object
);
o
.
setAlreadyNotified
(
RESET_FLAGS_ALREADY_NOTIFIED
);
o
.
setAlreadyNotified
(
RESET_FLAGS_ALREADY_NOTIFIED
);
o
.
setDerivedGauge
(
null
);
o
.
setDerivedGauge
(
INTEGER_ZERO
);
o
.
setDerivedGaugeTimeStamp
(
System
.
currentTimeMillis
());
o
.
setDerivedGaugeTimeStamp
(
System
.
currentTimeMillis
());
observedObjects
.
add
(
o
);
observedObjects
.
add
(
o
);
...
...
test/javax/management/monitor/DerivedGaugeMonitorTest.java
0 → 100644
浏览文件 @
c449e27f
/*
* Copyright 2008 Sun Microsystems, Inc. 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
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
/*
* @test
* @bug 6683213
* @summary Test that the initial derived gauge is (Integer)0
* @author Daniel Fuchs
* @run clean DerivedGaugeMonitorTest
* @run build DerivedGaugeMonitorTest
* @run main DerivedGaugeMonitorTest
*/
import
java.io.Serializable
;
import
java.util.concurrent.CountDownLatch
;
import
java.util.concurrent.TimeUnit
;
import
javax.management.MBeanServer
;
import
javax.management.MBeanServerFactory
;
import
javax.management.ObjectName
;
import
javax.management.monitor.CounterMonitor
;
import
javax.management.monitor.GaugeMonitor
;
public
class
DerivedGaugeMonitorTest
{
public
static
interface
Things
{
public
long
getALong
();
public
int
getAnInt
();
public
double
getADouble
();
public
short
getAShort
();
public
byte
getAByte
();
public
float
getAFloat
();
}
public
static
interface
MyMBean
extends
Things
{
public
Things
getAThing
();
}
public
static
class
MyThings
implements
Things
,
Serializable
{
private
static
final
long
serialVersionUID
=
-
4333982919572564126L
;
private
volatile
long
along
=
0
;
private
volatile
int
anint
=
0
;
private
volatile
short
ashort
=
0
;
private
volatile
byte
abyte
=
0
;
private
volatile
float
afloat
=
0
;
private
volatile
double
adouble
=
0
;
private
volatile
transient
boolean
mutable
;
public
MyThings
()
{
this
(
false
);
}
protected
MyThings
(
boolean
mutable
)
{
this
.
mutable
=
mutable
;
}
public
long
getALong
()
{
return
mutable
?
along
++:
along
;
}
public
int
getAnInt
()
{
return
mutable
?
anint
++:
anint
;
}
public
double
getADouble
()
{
return
mutable
?
adouble
++:
adouble
;
}
public
short
getAShort
()
{
return
mutable
?
ashort
++:
ashort
;
}
public
byte
getAByte
()
{
return
mutable
?
abyte
++:
abyte
;
}
public
float
getAFloat
()
{
return
mutable
?
afloat
++:
afloat
;
}
@Override
public
Object
clone
()
throws
CloneNotSupportedException
{
final
MyThings
other
=
(
MyThings
)
super
.
clone
();
other
.
mutable
=
false
;
return
other
;
}
}
public
static
class
My
implements
MyMBean
{
public
final
CountDownLatch
cdl
=
new
CountDownLatch
(
6
);
private
final
MyThings
things
=
new
MyThings
(
true
);
private
volatile
int
count
=
0
;
public
Things
getAThing
()
{
count
++;
cdl
.
countDown
();
try
{
return
(
Things
)
things
.
clone
();
}
catch
(
CloneNotSupportedException
ex
)
{
return
null
;
}
}
public
long
getALong
()
{
count
++;
cdl
.
countDown
();
return
things
.
getALong
();
}
public
int
getAnInt
()
{
count
++;
cdl
.
countDown
();
return
things
.
getAnInt
();
}
public
double
getADouble
()
{
count
++;
cdl
.
countDown
();
return
things
.
getADouble
();
}
public
short
getAShort
()
{
count
++;
cdl
.
countDown
();
return
things
.
getAShort
();
}
public
byte
getAByte
()
{
count
++;
cdl
.
countDown
();
return
things
.
getAByte
();
}
public
float
getAFloat
()
{
count
++;
cdl
.
countDown
();
return
things
.
getAFloat
();
}
}
public
static
String
[]
attributes
=
{
"AByte"
,
"AShort"
,
"AnInt"
,
"ALong"
,
"AFloat"
,
"ADouble"
};
public
static
String
[]
things
=
{
"AThing.AByte"
,
"AThing.AShort"
,
"AThing.AnInt"
,
"AThing.ALong"
,
"AThing.AFloat"
,
"AThing.ADouble"
};
public
static
void
check
(
String
attr
,
MBeanServer
server
,
ObjectName
mon
,
ObjectName
mbean
)
throws
Exception
{
final
Object
obj
=
server
.
getAttribute
(
mon
,
"DerivedGauge"
);
check
(
attr
,
server
,
mon
,
mbean
,
obj
);
}
public
static
void
check
(
String
attr
,
MBeanServer
server
,
ObjectName
mon
,
ObjectName
mbean
,
Object
obj
)
throws
Exception
{
if
(
obj
==
null
)
throw
new
Exception
(
"Derived gauge for: "
+
attr
+
" ["
+
mon
+
", "
+
mbean
+
"] is null!"
);
if
(!
Integer
.
valueOf
(
0
).
equals
(
obj
))
throw
new
Exception
(
"Derived gauge for: "
+
attr
+
" ["
+
mon
+
", "
+
mbean
+
"] is "
+
obj
);
}
public
static
void
check
(
String
attr
,
MBeanServer
server
,
ObjectName
mon
,
ObjectName
mbean
,
long
start
)
throws
Exception
{
final
Object
obj
=
server
.
getAttribute
(
mon
,
"DerivedGauge"
);
final
long
now
=
System
.
currentTimeMillis
();
final
long
gran
=
(
Long
)
server
.
getAttribute
(
mon
,
"GranularityPeriod"
);
if
(
now
>
start
+
2
*
gran
)
{
throw
new
Exception
(
attr
+
": Can't verify test case: "
+
"granularity period expired!"
);
}
check
(
attr
,
server
,
mon
,
mbean
,
obj
);
}
public
static
void
test
(
String
attr
)
throws
Exception
{
System
.
err
.
println
(
"Testing "
+
attr
);
final
MBeanServer
server
=
MBeanServerFactory
.
createMBeanServer
();
final
ObjectName
mbean
=
new
ObjectName
(
"ugly:type=cr.p"
);
final
My
my
=
new
My
();
final
GaugeMonitor
mon2
=
new
GaugeMonitor
();
final
ObjectName
mon2n
=
new
ObjectName
(
"mon1:type=GaugeMonitor"
);
final
CounterMonitor
mon1
=
new
CounterMonitor
();
final
ObjectName
mon1n
=
new
ObjectName
(
"mon2:type=CounterMonitor"
);
server
.
registerMBean
(
my
,
mbean
);
server
.
registerMBean
(
mon1
,
mon1n
);
server
.
registerMBean
(
mon2
,
mon2n
);
mon1
.
addObservedObject
(
mbean
);
mon1
.
setGranularityPeriod
(
60000
);
// 60 sec...
mon1
.
setObservedAttribute
(
attr
);
mon1
.
setDifferenceMode
(
true
);
check
(
attr
,
server
,
mon1n
,
mbean
);
mon2
.
addObservedObject
(
mbean
);
mon2
.
setGranularityPeriod
(
60000
);
// 60 sec...
mon2
.
setObservedAttribute
(
attr
);
mon2
.
setDifferenceMode
(
true
);
check
(
attr
,
server
,
mon2n
,
mbean
);
final
long
approxStart
=
System
.
currentTimeMillis
();
mon1
.
start
();
mon2
.
start
();
try
{
check
(
attr
,
server
,
mon1n
,
mbean
,
approxStart
);
check
(
attr
,
server
,
mon2n
,
mbean
,
approxStart
);
check
(
attr
,
server
,
mon1n
,
mbean
,
approxStart
);
check
(
attr
,
server
,
mon2n
,
mbean
,
approxStart
);
mon1
.
setGranularityPeriod
(
5
);
mon2
.
setGranularityPeriod
(
5
);
my
.
cdl
.
await
(
1000
,
TimeUnit
.
MILLISECONDS
);
if
(
my
.
cdl
.
getCount
()
>
0
)
throw
new
Exception
(
attr
+
": Count down not reached!"
);
// just check that we don't get an exception now...
System
.
err
.
println
(
attr
+
": ["
+
mon1n
+
"] DerivedGauge is now "
+
server
.
getAttribute
(
mon1n
,
"DerivedGauge"
));
System
.
err
.
println
(
attr
+
": ["
+
mon2n
+
"] DerivedGauge is now "
+
server
.
getAttribute
(
mon2n
,
"DerivedGauge"
));
}
finally
{
try
{
mon1
.
stop
();}
catch
(
Exception
x
)
{}
try
{
mon2
.
stop
();}
catch
(
Exception
x
)
{}
}
}
public
static
void
main
(
String
[]
args
)
throws
Exception
{
for
(
String
attr:
attributes
)
{
test
(
attr
);
}
for
(
String
attr:
things
)
{
test
(
attr
);
}
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录