Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
doujutun3207
flink
提交
53630da0
F
flink
项目概览
doujutun3207
/
flink
与 Fork 源项目一致
从无法访问的项目Fork
通知
24
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
F
flink
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
53630da0
编写于
6月 29, 2016
作者:
Z
zentol
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[hotfix][metrics] Harden JMXAvailability test
上级
123be227
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
10 addition
and
13 deletion
+10
-13
flink-core/src/main/java/org/apache/flink/metrics/reporter/JMXReporter.java
...n/java/org/apache/flink/metrics/reporter/JMXReporter.java
+6
-0
flink-core/src/test/java/org/apache/flink/metrics/reporter/JMXReporterTest.java
...va/org/apache/flink/metrics/reporter/JMXReporterTest.java
+4
-13
未找到文件。
flink-core/src/main/java/org/apache/flink/metrics/reporter/JMXReporter.java
浏览文件 @
53630da0
...
...
@@ -125,6 +125,10 @@ public class JMXReporter implements MetricReporter {
}
}
}
public
int
getPort
()
{
return
jmxServer
.
port
;
}
// ------------------------------------------------------------------------
// adding / removing metrics
...
...
@@ -415,6 +419,7 @@ public class JMXReporter implements MetricReporter {
private
static
class
JMXServer
{
private
Registry
rmiRegistry
;
private
JMXConnectorServer
connector
;
private
int
port
;
public
void
start
(
int
port
)
throws
IOException
{
if
(
rmiRegistry
!=
null
&&
connector
!=
null
)
{
...
...
@@ -423,6 +428,7 @@ public class JMXReporter implements MetricReporter {
}
startRmiRegistry
(
port
);
startJmxService
(
port
);
this
.
port
=
port
;
}
/**
...
...
flink-core/src/test/java/org/apache/flink/metrics/reporter/JMXReporterTest.java
浏览文件 @
53630da0
...
...
@@ -38,7 +38,6 @@ import javax.management.remote.JMXConnectorFactory;
import
javax.management.remote.JMXServiceURL
;
import
java.lang.management.ManagementFactory
;
import
static
org
.
apache
.
flink
.
metrics
.
MetricRegistry
.
KEY_METRICS_JMX_PORT
;
import
static
org
.
apache
.
flink
.
metrics
.
MetricRegistry
.
KEY_METRICS_REPORTER_CLASS
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
...
...
@@ -137,16 +136,8 @@ public class JMXReporterTest extends TestLogger {
JMXReporter
rep1
=
new
JMXReporter
();
JMXReporter
rep2
=
new
JMXReporter
();
int
port1
=
9010
;
int
port2
=
9011
;
Configuration
cfg1
=
new
Configuration
();
cfg1
.
setString
(
KEY_METRICS_JMX_PORT
,
String
.
valueOf
(
port1
));
Configuration
cfg2
=
new
Configuration
();
cfg2
.
setString
(
KEY_METRICS_JMX_PORT
,
String
.
valueOf
(
port2
));
rep1
.
open
(
cfg1
);
rep2
.
open
(
cfg2
);
rep1
.
open
(
new
Configuration
());
rep2
.
open
(
new
Configuration
());
rep1
.
notifyOfAddedMetric
(
new
Gauge
<
Integer
>()
{
@Override
...
...
@@ -165,7 +156,7 @@ public class JMXReporterTest extends TestLogger {
ObjectName
objectName1
=
new
ObjectName
(
JMXReporter
.
generateJmxName
(
"rep1"
,
mg
.
getScopeComponents
()));
ObjectName
objectName2
=
new
ObjectName
(
JMXReporter
.
generateJmxName
(
"rep2"
,
mg
.
getScopeComponents
()));
JMXServiceURL
url1
=
new
JMXServiceURL
(
"service:jmx:rmi://localhost:"
+
port1
+
"/jndi/rmi://localhost:"
+
port1
+
"/jmxrmi"
);
JMXServiceURL
url1
=
new
JMXServiceURL
(
"service:jmx:rmi://localhost:"
+
rep1
.
getPort
()
+
"/jndi/rmi://localhost:"
+
rep1
.
getPort
()
+
"/jmxrmi"
);
JMXConnector
jmxCon1
=
JMXConnectorFactory
.
connect
(
url1
);
MBeanServerConnection
mCon1
=
jmxCon1
.
getMBeanServerConnection
();
...
...
@@ -177,7 +168,7 @@ public class JMXReporterTest extends TestLogger {
jmxCon1
=
null
;
mCon1
=
null
;
JMXServiceURL
url2
=
new
JMXServiceURL
(
"service:jmx:rmi://localhost:"
+
port2
+
"/jndi/rmi://localhost:"
+
port2
+
"/jmxrmi"
);
JMXServiceURL
url2
=
new
JMXServiceURL
(
"service:jmx:rmi://localhost:"
+
rep2
.
getPort
()
+
"/jndi/rmi://localhost:"
+
rep2
.
getPort
()
+
"/jmxrmi"
);
JMXConnector
jmxCon2
=
JMXConnectorFactory
.
connect
(
url2
);
MBeanServerConnection
mCon2
=
jmxCon2
.
getMBeanServerConnection
();
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录