Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
dc24e449
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看板
提交
dc24e449
编写于
3月 12, 2009
作者:
D
dfuchs
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
6661448: Make the SNMP agent optional when OPENJDK=true and IMPORT_BINARY_PLUGS=false
Reviewed-by: mchung, ohair
上级
5392a6dc
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
268 addition
and
25 deletion
+268
-25
make/com/sun/jmx/Makefile
make/com/sun/jmx/Makefile
+9
-1
make/java/management/Makefile
make/java/management/Makefile
+2
-0
make/javax/management/Makefile
make/javax/management/Makefile
+1
-0
make/sun/management/Makefile
make/sun/management/Makefile
+10
-1
src/share/classes/sun/management/Agent.java
src/share/classes/sun/management/Agent.java
+35
-3
test/com/sun/jmx/snmp/SnmpOidHashCode.java
test/com/sun/jmx/snmp/SnmpOidHashCode.java
+70
-4
test/com/sun/jmx/snmp/TimeTicksWrapping.java
test/com/sun/jmx/snmp/TimeTicksWrapping.java
+141
-16
未找到文件。
make/com/sun/jmx/Makefile
浏览文件 @
dc24e449
...
...
@@ -41,7 +41,15 @@ include $(BUILDDIR)/common/Defs.gmk
# Note : some targets are double colon rules and some single colon rules
# within common included gmk files : that is why the following for loop
# has been duplicated.
SUBDIRS
=
snmp
# When building the openjdk, build snmp only if importing binary plugs,
ifdef
OPENJDK
ifeq
($(IMPORT_BINARY_PLUGS),true)
SUBDIRS
=
snmp
endif
else
SUBDIRS
=
snmp
endif
all build
:
$
(
SUBDIRS-loop
)
...
...
make/java/management/Makefile
浏览文件 @
dc24e449
...
...
@@ -46,6 +46,8 @@ include $(BUILDDIR)/common/Mapfile-vers.gmk
#
include
FILES_c.gmk
# We don't need snmp here.
AUTO_JAVA_PRUNE
=
snmp
AUTO_FILES_JAVA_DIRS
=
java/lang/management com/sun/management sun/management
include
Exportedfiles.gmk
...
...
make/javax/management/Makefile
浏览文件 @
dc24e449
...
...
@@ -35,6 +35,7 @@ include $(BUILDDIR)/common/Defs.gmk
#
# Files to compile
#
AUTO_JAVA_PRUNE
=
snmp
AUTO_FILES_JAVA_DIRS
=
javax/management com/sun/jmx com/sun/management/jmx
#
...
...
make/sun/management/Makefile
浏览文件 @
dc24e449
...
...
@@ -35,7 +35,16 @@ MGMT_LIB_SRC = $(SHARE_SRC)/lib/management
all build
::
properties aclfile jmxremotefiles
SUBDIRS
=
snmp jmxremote
# When building the openjdk, build snmp only if importing binary plugs,
ifdef
OPENJDK
ifeq
($(IMPORT_BINARY_PLUGS),true)
SUBDIRS
=
snmp
endif
else
SUBDIRS
=
snmp
endif
SUBDIRS
+=
jmxremote
all build clean clobber
::
$
(
SUBDIRS-loop
)
...
...
src/share/classes/sun/management/Agent.java
浏览文件 @
dc24e449
...
...
@@ -31,9 +31,9 @@ import java.io.FileInputStream;
import
java.io.BufferedInputStream
;
import
java.io.FileNotFoundException
;
import
java.io.IOException
;
import
java.lang.reflect.InvocationTargetException
;
import
java.text.MessageFormat
;
import
java.util.Properties
;
import
java.util.Enumeration
;
import
java.util.ResourceBundle
;
import
java.util.MissingResourceException
;
import
java.lang.management.ManagementFactory
;
...
...
@@ -41,7 +41,6 @@ import java.lang.reflect.Method;
import
javax.management.remote.JMXConnectorServer
;
import
sun.management.snmp.AdaptorBootstrap
;
import
sun.management.jmxremote.ConnectorBootstrap
;
import
static
sun
.
management
.
AgentConfigurationError
.*;
import
sun.misc.VMSupport
;
...
...
@@ -69,6 +68,9 @@ public class Agent {
private
static
final
String
LOCAL_CONNECTOR_ADDRESS_PROP
=
"com.sun.management.jmxremote.localConnectorAddress"
;
private
static
final
String
SNMP_ADAPTOR_BOOTSTRAP_CLASS_NAME
=
"sun.management.snmp.AdaptorBootstrap"
;
// invoked by -javaagent or -Dcom.sun.management.agent.class
public
static
void
premain
(
String
args
)
throws
Exception
{
agentmain
(
args
);
...
...
@@ -128,7 +130,7 @@ public class Agent {
try
{
if
(
snmpPort
!=
null
)
{
AdaptorBootstrap
.
initialize
(
snmpPort
,
props
);
loadSnmpAgent
(
snmpPort
,
props
);
}
/*
...
...
@@ -204,6 +206,36 @@ public class Agent {
return
mgmtProps
;
}
private
static
void
loadSnmpAgent
(
String
snmpPort
,
Properties
props
)
{
try
{
// invoke the following through reflection:
// AdaptorBootstrap.initialize(snmpPort, props);
final
Class
<?>
adaptorClass
=
Class
.
forName
(
SNMP_ADAPTOR_BOOTSTRAP_CLASS_NAME
,
true
,
null
);
final
Method
initializeMethod
=
adaptorClass
.
getMethod
(
"initialize"
,
String
.
class
,
Properties
.
class
);
initializeMethod
.
invoke
(
null
,
snmpPort
,
props
);
}
catch
(
ClassNotFoundException
x
)
{
// The SNMP packages are not present: throws an exception.
throw
new
UnsupportedOperationException
(
"Unsupported management property: "
+
SNMP_PORT
,
x
);
}
catch
(
NoSuchMethodException
x
)
{
// should not happen...
throw
new
UnsupportedOperationException
(
"Unsupported management property: "
+
SNMP_PORT
,
x
);
}
catch
(
InvocationTargetException
x
)
{
final
Throwable
cause
=
x
.
getCause
();
if
(
cause
instanceof
RuntimeException
)
throw
(
RuntimeException
)
cause
;
else
if
(
cause
instanceof
Error
)
throw
(
Error
)
cause
;
// should not happen...
throw
new
UnsupportedOperationException
(
"Unsupported management property: "
+
SNMP_PORT
,
cause
);
}
catch
(
IllegalAccessException
x
)
{
// should not happen...
throw
new
UnsupportedOperationException
(
"Unsupported management property: "
+
SNMP_PORT
,
x
);
}
}
// read config file and initialize the properties
private
static
void
readConfiguration
(
String
fname
,
Properties
p
)
{
if
(
fname
==
null
)
{
...
...
test/com/sun/jmx/snmp/SnmpOidHashCode.java
浏览文件 @
dc24e449
/*
* Copyright 2003 Sun Microsystems, Inc. All Rights Reserved.
* Copyright 2003
-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
...
...
@@ -28,7 +28,8 @@
* @build SnmpOidHashCode
* @run main SnmpOidHashCode
*/
import
com.sun.jmx.snmp.SnmpOid
;
import
java.lang.reflect.Constructor
;
import
java.lang.reflect.InvocationTargetException
;
public
class
SnmpOidHashCode
{
public
static
final
String
[]
oids
=
{
...
...
@@ -57,16 +58,81 @@ public class SnmpOidHashCode {
".39."
+
0xFFFFFFFF
L
};
// We use an SnmpOidBuilder in order to adapt this test case to a
// configuration where the SNMP packages are not present in rt.jar.
//
public
static
final
class
SnmpOidBuilder
{
public
static
final
String
SNMP_OID_CLASS_NAME
=
"com.sun.jmx.snmp.SnmpOid"
;
private
static
final
Class
<?>
SNMP_OID_CLASS
;
private
static
final
Constructor
<?>
SNMP_OID_CTOR
;
static
{
Class
<?>
snmpOidClass
;
try
{
snmpOidClass
=
Class
.
forName
(
SNMP_OID_CLASS_NAME
,
true
,
null
);
}
catch
(
ClassNotFoundException
x
)
{
snmpOidClass
=
null
;
System
.
err
.
println
(
"WARNING: can't load "
+
SNMP_OID_CLASS_NAME
);
}
catch
(
NoClassDefFoundError
x
)
{
snmpOidClass
=
null
;
System
.
err
.
println
(
"WARNING: can't load "
+
SNMP_OID_CLASS_NAME
);
}
SNMP_OID_CLASS
=
snmpOidClass
;
if
(
SNMP_OID_CLASS
!=
null
)
{
try
{
SNMP_OID_CTOR
=
snmpOidClass
.
getConstructor
(
String
.
class
);
}
catch
(
Exception
x
)
{
throw
new
ExceptionInInitializerError
(
x
);
}
}
else
{
SNMP_OID_CTOR
=
null
;
}
}
public
static
boolean
isSnmpPresent
()
{
System
.
out
.
println
(
SnmpOidHashCode
.
class
.
getName
()+
": Testing for SNMP Packages..."
);
return
SNMP_OID_CLASS
!=
null
;
}
public
static
Object
newSnmpOid
(
String
oid
)
throws
InstantiationException
,
IllegalAccessException
,
InvocationTargetException
{
return
SNMP_OID_CTOR
.
newInstance
(
oid
);
}
}
private
static
Object
newSnmpOid
(
String
oid
)
throws
Exception
{
try
{
return
SnmpOidBuilder
.
newSnmpOid
(
oid
);
}
catch
(
InvocationTargetException
x
)
{
final
Throwable
cause
=
x
.
getCause
();
if
(
cause
instanceof
Exception
)
throw
(
Exception
)
cause
;
if
(
cause
instanceof
Error
)
throw
(
Error
)
cause
;
throw
x
;
}
}
public
static
void
main
(
String
args
[])
{
if
(!
SnmpOidBuilder
.
isSnmpPresent
())
{
System
.
err
.
println
(
"WARNING: "
+
SnmpOidBuilder
.
SNMP_OID_CLASS_NAME
+
" not present."
);
System
.
err
.
println
(
SnmpOidHashCode
.
class
.
getName
()+
": test skipped."
);
return
;
}
try
{
int
errCount
=
0
;
int
collisions
=
0
;
for
(
int
i
=
0
;
i
<
oids
.
length
;
i
++)
{
System
.
out
.
println
(
"Testing "
+
oids
[
i
]);
final
SnmpOid
o1
=
new
SnmpOid
(
oids
[
i
]);
final
Object
o1
=
new
SnmpOid
(
oids
[
i
]);
final
int
startCount
=
errCount
;
for
(
int
j
=
0
;
j
<
oids
.
length
;
j
++)
{
final
SnmpOid
o2
=
new
SnmpOid
(
oids
[
j
]);
final
Object
o2
=
new
SnmpOid
(
oids
[
j
]);
if
(
o1
.
equals
(
o2
))
{
if
(!(
oids
[
i
].
equals
(
oids
[
j
])))
{
System
.
err
.
println
(
"OIDs differ but "
+
...
...
test/com/sun/jmx/snmp/TimeTicksWrapping.java
浏览文件 @
dc24e449
/*
* Copyright 2003 Sun Microsystems, Inc. All Rights Reserved.
* Copyright 2003
-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
...
...
@@ -29,33 +29,158 @@
* @build TimeTicksWrapping
* @run main TimeTicksWrapping
*/
import
com.sun.jmx.snmp.SnmpTimeticks
;
import
com.sun.jmx.snmp.SnmpUnsignedInt
;
import
java.lang.reflect.Constructor
;
import
java.lang.reflect.InvocationTargetException
;
import
java.lang.reflect.Method
;
public
class
TimeTicksWrapping
{
// We use an SnmpTimeticksBuilder in order to adapt this test case to a
// configuration where the SNMP packages are not present in rt.jar.
//
public
static
final
class
SnmpTimeticksBuilder
{
public
static
final
long
MAX_VALUE
=
0x0ffffffff
L
;
public
static
final
String
SNMP_TIME_TICKS_CLASS_NAME
=
"com.sun.jmx.snmp.SnmpTimeticks"
;
private
static
final
Class
<?>
SNMP_TIME_TICKS_CLASS
;
private
static
final
Constructor
<?>
SNMP_long_CTOR
;
private
static
final
Constructor
<?>
SNMP_LONG_CTOR
;
private
static
final
Method
SNMP_LONG_VALUE
;
static
{
Class
<?>
snmpTimeTicksClass
;
try
{
snmpTimeTicksClass
=
Class
.
forName
(
SNMP_TIME_TICKS_CLASS_NAME
,
true
,
null
);
}
catch
(
ClassNotFoundException
x
)
{
snmpTimeTicksClass
=
null
;
System
.
err
.
println
(
"WARNING: can't load "
+
SNMP_TIME_TICKS_CLASS_NAME
);
}
catch
(
NoClassDefFoundError
x
)
{
snmpTimeTicksClass
=
null
;
System
.
err
.
println
(
"WARNING: can't load "
+
SNMP_TIME_TICKS_CLASS_NAME
);
}
SNMP_TIME_TICKS_CLASS
=
snmpTimeTicksClass
;
if
(
SNMP_TIME_TICKS_CLASS
!=
null
)
{
try
{
SNMP_long_CTOR
=
SNMP_TIME_TICKS_CLASS
.
getConstructor
(
long
.
class
);
}
catch
(
Exception
x
)
{
throw
new
ExceptionInInitializerError
(
x
);
}
}
else
{
SNMP_long_CTOR
=
null
;
}
if
(
SNMP_TIME_TICKS_CLASS
!=
null
)
{
try
{
SNMP_LONG_CTOR
=
SNMP_TIME_TICKS_CLASS
.
getConstructor
(
Long
.
class
);
}
catch
(
Exception
x
)
{
throw
new
ExceptionInInitializerError
(
x
);
}
}
else
{
SNMP_LONG_CTOR
=
null
;
}
if
(
SNMP_TIME_TICKS_CLASS
!=
null
)
{
try
{
SNMP_LONG_VALUE
=
SNMP_TIME_TICKS_CLASS
.
getMethod
(
"longValue"
);
}
catch
(
Exception
x
)
{
throw
new
ExceptionInInitializerError
(
x
);
}
}
else
{
SNMP_LONG_VALUE
=
null
;
}
}
private
final
Object
timeticks
;
public
SnmpTimeticksBuilder
(
long
ticks
)
throws
Exception
{
timeticks
=
newSnmpTimeticks
(
ticks
);
}
public
SnmpTimeticksBuilder
(
Long
ticks
)
throws
Exception
{
timeticks
=
newSnmpTimeticks
(
ticks
);
}
public
long
longValue
()
throws
Exception
{
return
longValue
(
timeticks
);
}
public
static
boolean
isSnmpPresent
()
{
System
.
out
.
println
(
TimeTicksWrapping
.
class
.
getName
()+
": Testing for SNMP Packages..."
);
return
SNMP_TIME_TICKS_CLASS
!=
null
;
}
private
static
Object
newSnmpTimeticks
(
long
time
)
throws
Exception
{
try
{
return
SNMP_long_CTOR
.
newInstance
(
time
);
}
catch
(
InvocationTargetException
x
)
{
final
Throwable
cause
=
x
.
getCause
();
if
(
cause
instanceof
Exception
)
throw
(
Exception
)
cause
;
if
(
cause
instanceof
Error
)
throw
(
Error
)
cause
;
throw
x
;
}
}
private
static
Object
newSnmpTimeticks
(
Long
time
)
throws
Exception
{
try
{
return
SNMP_LONG_CTOR
.
newInstance
(
time
);
}
catch
(
InvocationTargetException
x
)
{
final
Throwable
cause
=
x
.
getCause
();
if
(
cause
instanceof
Exception
)
throw
(
Exception
)
cause
;
if
(
cause
instanceof
Error
)
throw
(
Error
)
cause
;
throw
x
;
}
}
private
static
long
longValue
(
Object
o
)
throws
Exception
{
try
{
return
((
Long
)
SNMP_LONG_VALUE
.
invoke
(
o
)).
longValue
();
}
catch
(
InvocationTargetException
x
)
{
final
Throwable
cause
=
x
.
getCause
();
if
(
cause
instanceof
Exception
)
throw
(
Exception
)
cause
;
if
(
cause
instanceof
Error
)
throw
(
Error
)
cause
;
throw
x
;
}
}
}
public
static
final
long
[]
oks
=
{
0L
,
1L
,
(
long
)
Integer
.
MAX_VALUE
,
(
long
)
Integer
.
MAX_VALUE
*
2
,
(
long
)
Integer
.
MAX_VALUE
*
2
+
1L
,
(
long
)
Integer
.
MAX_VALUE
*
2
+
2L
,
(
long
)
Integer
.
MAX_VALUE
*
3
,
Snmp
UnsignedInt
.
MAX_VALUE
,
SnmpUnsignedInt
.
MAX_VALUE
+
1L
,
Snmp
UnsignedInt
.
MAX_VALUE
*
3
-
1L
,
Long
.
MAX_VALUE
Snmp
TimeticksBuilder
.
MAX_VALUE
,
SnmpTimeticksBuilder
.
MAX_VALUE
+
1L
,
Snmp
TimeticksBuilder
.
MAX_VALUE
*
3
-
1L
,
Long
.
MAX_VALUE
};
public
static
final
long
[]
kos
=
{
-
1L
,
(
long
)
Integer
.
MIN_VALUE
,
(
long
)
Integer
.
MIN_VALUE
*
2
,
(
long
)
Integer
.
MIN_VALUE
*
2
-
1L
,
(
long
)
Integer
.
MIN_VALUE
*
3
,
-
Snmp
UnsignedInt
.
MAX_VALUE
,
-(
SnmpUnsignedInt
.
MAX_VALUE
+
1L
),
-(
Snmp
UnsignedInt
.
MAX_VALUE
*
3
-
1L
),
Long
.
MIN_VALUE
-
Snmp
TimeticksBuilder
.
MAX_VALUE
,
-(
SnmpTimeticksBuilder
.
MAX_VALUE
+
1L
),
-(
Snmp
TimeticksBuilder
.
MAX_VALUE
*
3
-
1L
),
Long
.
MIN_VALUE
};
public
static
void
main
(
String
args
[])
{
if
(!
SnmpTimeticksBuilder
.
isSnmpPresent
())
{
System
.
err
.
println
(
"WARNING: "
+
SnmpTimeticksBuilder
.
SNMP_TIME_TICKS_CLASS_NAME
+
" not present."
);
System
.
err
.
println
(
TimeTicksWrapping
.
class
.
getName
()+
": test skipped."
);
return
;
}
try
{
SnmpTimeticks
t
;
SnmpTimeticks
Builder
t
=
null
;
for
(
int
i
=
0
;
i
<
oks
.
length
;
i
++)
{
final
long
t1
,
t2
,
t3
;
t1
=
(
new
SnmpTimeticks
(
oks
[
i
])).
longValue
();
t2
=
(
new
SnmpTimeticks
(
new
Long
(
oks
[
i
]))).
longValue
();
t1
=
(
new
SnmpTimeticks
Builder
(
oks
[
i
])).
longValue
();
t2
=
(
new
SnmpTimeticks
Builder
(
new
Long
(
oks
[
i
]))).
longValue
();
t3
=
oks
[
i
]%
0x0100000000
L
;
if
(
t1
!=
t3
)
throw
new
Exception
(
"Value should have wrapped: "
+
...
...
@@ -64,16 +189,16 @@ public class TimeTicksWrapping {
throw
new
Exception
(
"Value should have wrapped: "
+
"Long("
+
oks
[
i
]+
") expected: "
+
t3
);
if
(
t1
>
Snmp
UnsignedInt
.
MAX_VALUE
)
if
(
t1
>
Snmp
TimeticksBuilder
.
MAX_VALUE
)
throw
new
Exception
(
"Value should have wrapped "
+
"for "
+
oks
[
i
]
+
": "
+
t1
+
" exceeds max: "
+
Snmp
UnsignedInt
.
MAX_VALUE
);
if
(
t2
>
Snmp
UnsignedInt
.
MAX_VALUE
)
Snmp
TimeticksBuilder
.
MAX_VALUE
);
if
(
t2
>
Snmp
TimeticksBuilder
.
MAX_VALUE
)
throw
new
Exception
(
"Value should have wrapped "
+
"for "
+
oks
[
i
]
+
": "
+
t2
+
" exceeds max: "
+
Snmp
UnsignedInt
.
MAX_VALUE
);
Snmp
TimeticksBuilder
.
MAX_VALUE
);
if
(
t1
<
0
)
throw
new
Exception
(
"Value should have wrapped: "
+
...
...
@@ -90,14 +215,14 @@ public class TimeTicksWrapping {
for
(
int
i
=
0
;
i
<
kos
.
length
;
i
++)
{
try
{
t
=
new
SnmpTimeticks
(
kos
[
i
]);
t
=
new
SnmpTimeticks
Builder
(
kos
[
i
]);
throw
new
Exception
(
"Value should have been rejected: "
+
kos
[
i
]);
}
catch
(
IllegalArgumentException
x
)
{
// OK!
}
try
{
t
=
new
SnmpTimeticks
(
new
Long
(
kos
[
i
]));
t
=
new
SnmpTimeticks
Builder
(
new
Long
(
kos
[
i
]));
throw
new
Exception
(
"Value should have been rejected: "
+
"Long("
+
kos
[
i
]+
")"
);
}
catch
(
IllegalArgumentException
x
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录