Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
23d1ac39
提交
23d1ac39
authored
11月 16, 2010
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
JMX (the Java management extension) is now supported. Issue 253.
上级
d93418ea
显示空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
15 行增加
和
9 行删除
+15
-9
DatabaseInfo.java
h2/src/main/org/h2/jmx/DatabaseInfo.java
+13
-7
TestJmx.java
h2/src/test/org/h2/test/unit/TestJmx.java
+2
-2
没有找到文件。
h2/src/main/org/h2/jmx/DatabaseInfo.java
浏览文件 @
23d1ac39
...
@@ -9,6 +9,7 @@ package org.h2.jmx;
...
@@ -9,6 +9,7 @@ package org.h2.jmx;
import
java.lang.management.ManagementFactory
;
import
java.lang.management.ManagementFactory
;
import
java.sql.Timestamp
;
import
java.sql.Timestamp
;
import
java.util.Hashtable
;
import
java.util.Map
;
import
java.util.Map
;
import
java.util.TreeMap
;
import
java.util.TreeMap
;
import
javax.management.JMException
;
import
javax.management.JMException
;
...
@@ -46,12 +47,17 @@ public class DatabaseInfo implements DatabaseInfoMBean {
...
@@ -46,12 +47,17 @@ public class DatabaseInfo implements DatabaseInfoMBean {
* Returns a JMX new ObjectName instance.
* Returns a JMX new ObjectName instance.
*
*
* @param name name of the MBean
* @param name name of the MBean
* @param path the path
* @return a new ObjectName instance
* @return a new ObjectName instance
* @throws JMException if the ObjectName could not be created
* @throws JMException if the ObjectName could not be created
*/
*/
private
static
ObjectName
getObjectName
(
String
name
)
throws
JMException
{
private
static
ObjectName
getObjectName
(
String
name
,
String
path
)
throws
JMException
{
name
=
name
.
replace
(
':'
,
'_'
);
name
=
name
.
replace
(
':'
,
'_'
);
return
new
ObjectName
(
"org.h2"
,
"name"
,
name
);
path
=
path
.
replace
(
':'
,
'_'
);
Hashtable
<
String
,
String
>
map
=
new
Hashtable
<
String
,
String
>();
map
.
put
(
"name"
,
name
);
map
.
put
(
"path"
,
path
);
return
new
ObjectName
(
"org.h2"
,
map
);
}
}
/**
/**
...
@@ -61,12 +67,12 @@ public class DatabaseInfo implements DatabaseInfoMBean {
...
@@ -61,12 +67,12 @@ public class DatabaseInfo implements DatabaseInfoMBean {
* @param database database
* @param database database
*/
*/
public
static
void
registerMBean
(
ConnectionInfo
connectionInfo
,
Database
database
)
throws
JMException
{
public
static
void
registerMBean
(
ConnectionInfo
connectionInfo
,
Database
database
)
throws
JMException
{
String
name
=
connectionInfo
.
getName
();
String
path
=
connectionInfo
.
getName
();
if
(!
MBEANS
.
containsKey
(
name
))
{
if
(!
MBEANS
.
containsKey
(
path
))
{
MBeanServer
mbeanServer
=
ManagementFactory
.
getPlatformMBeanServer
();
MBeanServer
mbeanServer
=
ManagementFactory
.
getPlatformMBeanServer
();
String
mbeanName
=
database
.
getShortName
()
+
" ("
+
name
+
")"
;
String
name
=
database
.
getShortName
()
;
ObjectName
mbeanObjectName
=
getObjectName
(
mbeanName
);
ObjectName
mbeanObjectName
=
getObjectName
(
name
,
path
);
MBEANS
.
put
(
name
,
mbeanObjectName
);
MBEANS
.
put
(
path
,
mbeanObjectName
);
DatabaseInfo
info
=
new
DatabaseInfo
(
database
);
DatabaseInfo
info
=
new
DatabaseInfo
(
database
);
Object
mbean
=
new
DocumentedMBean
(
info
,
DatabaseInfoMBean
.
class
);
Object
mbean
=
new
DocumentedMBean
(
info
,
DatabaseInfoMBean
.
class
);
mbeanServer
.
registerMBean
(
mbean
,
mbeanObjectName
);
mbeanServer
.
registerMBean
(
mbean
,
mbeanObjectName
);
...
...
h2/src/test/org/h2/test/unit/TestJmx.java
浏览文件 @
23d1ac39
...
@@ -48,7 +48,7 @@ public class TestJmx extends TestBase {
...
@@ -48,7 +48,7 @@ public class TestJmx extends TestBase {
conn
=
getConnection
(
"mem:jmx;jmx=true"
);
conn
=
getConnection
(
"mem:jmx;jmx=true"
);
stat
=
conn
.
createStatement
();
stat
=
conn
.
createStatement
();
name
=
new
ObjectName
(
"org.h2
"
,
"name"
,
"JMX (mem_jmx)
"
);
name
=
new
ObjectName
(
"org.h2
:name=JMX,path=mem_jmx
"
);
info
=
mbeanServer
.
getMBeanInfo
(
name
);
info
=
mbeanServer
.
getMBeanInfo
(
name
);
assertEquals
(
"0"
,
mbeanServer
.
getAttribute
(
name
,
"CacheSizeMax"
).
toString
());
assertEquals
(
"0"
,
mbeanServer
.
getAttribute
(
name
,
"CacheSizeMax"
).
toString
());
// cache size is ignored for in-memory databases
// cache size is ignored for in-memory databases
...
@@ -103,7 +103,7 @@ public class TestJmx extends TestBase {
...
@@ -103,7 +103,7 @@ public class TestJmx extends TestBase {
conn
=
getConnection
(
"jmx;jmx=true"
);
conn
=
getConnection
(
"jmx;jmx=true"
);
stat
=
conn
.
createStatement
();
stat
=
conn
.
createStatement
();
name
=
new
ObjectName
(
"org.h2
"
,
"name"
,
"JMX
*"
);
name
=
new
ObjectName
(
"org.h2
:name=JMX,
*"
);
Set
<
ObjectName
>
set
=
mbeanServer
.
queryNames
(
name
,
null
);
Set
<
ObjectName
>
set
=
mbeanServer
.
queryNames
(
name
,
null
);
name
=
set
.
iterator
().
next
();
name
=
set
.
iterator
().
next
();
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论