Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
doujutun3207
flink
提交
5a545dbf
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,发现更多精彩内容 >>
提交
5a545dbf
编写于
12月 06, 2017
作者:
Z
zentol
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[hotfix][metrics] Refactor CheckpointStatsTrackerTest
上级
0bf0fdc2
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
27 addition
and
101 deletion
+27
-101
flink-runtime/src/test/java/org/apache/flink/runtime/checkpoint/CheckpointStatsTrackerTest.java
.../flink/runtime/checkpoint/CheckpointStatsTrackerTest.java
+27
-101
未找到文件。
flink-runtime/src/test/java/org/apache/flink/runtime/checkpoint/CheckpointStatsTrackerTest.java
浏览文件 @
5a545dbf
...
...
@@ -23,22 +23,17 @@ import static org.junit.Assert.assertFalse;
import
static
org
.
junit
.
Assert
.
assertNotEquals
;
import
static
org
.
junit
.
Assert
.
assertNotNull
;
import
static
org
.
junit
.
Assert
.
assertTrue
;
import
static
org
.
mockito
.
Matchers
.
any
;
import
static
org
.
mockito
.
Matchers
.
eq
;
import
static
org
.
mockito
.
Mockito
.
mock
;
import
static
org
.
mockito
.
Mockito
.
times
;
import
static
org
.
mockito
.
Mockito
.
verify
;
import
static
org
.
mockito
.
Mockito
.
when
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.Collection
;
import
java.util.Collections
;
import
java.util.HashMap
;
import
java.util.Iterator
;
import
java.util.Map
;
import
org.apache.flink.metrics.CharacterFilter
;
import
org.apache.flink.metrics.Counter
;
import
org.apache.flink.metrics.Gauge
;
import
org.apache.flink.metrics.Histogram
;
import
org.apache.flink.metrics.Meter
;
import
org.apache.flink.metrics.MetricGroup
;
import
org.apache.flink.metrics.groups.UnregisteredMetricsGroup
;
import
org.apache.flink.runtime.executiongraph.ExecutionJobVertex
;
...
...
@@ -287,7 +282,17 @@ public class CheckpointStatsTrackerTest {
*/
@Test
public
void
testMetricsRegistration
()
throws
Exception
{
MetricGroup
metricGroup
=
mock
(
MetricGroup
.
class
);
final
Collection
<
String
>
registeredGaugeNames
=
new
ArrayList
<>();
MetricGroup
metricGroup
=
new
UnregisteredMetricsGroup
()
{
@Override
public
<
T
,
G
extends
Gauge
<
T
>>
G
gauge
(
String
name
,
G
gauge
)
{
if
(
gauge
!=
null
)
{
registeredGaugeNames
.
add
(
name
);
}
return
gauge
;
}
};
ExecutionJobVertex
jobVertex
=
mock
(
ExecutionJobVertex
.
class
);
when
(
jobVertex
.
getJobVertexId
()).
thenReturn
(
new
JobVertexID
());
...
...
@@ -299,18 +304,19 @@ public class CheckpointStatsTrackerTest {
mock
(
CheckpointCoordinatorConfiguration
.
class
),
metricGroup
);
verify
(
metricGroup
,
times
(
1
)).
gauge
(
eq
(
CheckpointStatsTracker
.
NUMBER_OF_CHECKPOINTS_METRIC
),
any
(
Gauge
.
class
));
verify
(
metricGroup
,
times
(
1
)).
gauge
(
eq
(
CheckpointStatsTracker
.
NUMBER_OF_IN_PROGRESS_CHECKPOINTS_METRIC
),
any
(
Gauge
.
class
));
verify
(
metricGroup
,
times
(
1
)).
gauge
(
eq
(
CheckpointStatsTracker
.
NUMBER_OF_COMPLETED_CHECKPOINTS_METRIC
),
any
(
Gauge
.
class
));
verify
(
metricGroup
,
times
(
1
)).
gauge
(
eq
(
CheckpointStatsTracker
.
NUMBER_OF_FAILED_CHECKPOINTS_METRIC
),
any
(
Gauge
.
class
));
verify
(
metricGroup
,
times
(
1
)).
gauge
(
eq
(
CheckpointStatsTracker
.
LATEST_RESTORED_CHECKPOINT_TIMESTAMP_METRIC
),
any
(
Gauge
.
class
));
verify
(
metricGroup
,
times
(
1
)).
gauge
(
eq
(
CheckpointStatsTracker
.
LATEST_COMPLETED_CHECKPOINT_SIZE_METRIC
),
any
(
Gauge
.
class
));
verify
(
metricGroup
,
times
(
1
)).
gauge
(
eq
(
CheckpointStatsTracker
.
LATEST_COMPLETED_CHECKPOINT_DURATION_METRIC
),
any
(
Gauge
.
class
));
verify
(
metricGroup
,
times
(
1
)).
gauge
(
eq
(
CheckpointStatsTracker
.
LATEST_COMPLETED_CHECKPOINT_ALIGNMENT_BUFFERED_METRIC
),
any
(
Gauge
.
class
));
verify
(
metricGroup
,
times
(
1
)).
gauge
(
eq
(
CheckpointStatsTracker
.
LATEST_COMPLETED_CHECKPOINT_EXTERNAL_PATH_METRIC
),
any
(
Gauge
.
class
));
// Make sure this test is adjusted when further metrics are added
verify
(
metricGroup
,
times
(
9
)).
gauge
(
any
(
String
.
class
),
any
(
Gauge
.
class
));
assertTrue
(
registeredGaugeNames
.
containsAll
(
Arrays
.
asList
(
CheckpointStatsTracker
.
NUMBER_OF_CHECKPOINTS_METRIC
,
CheckpointStatsTracker
.
NUMBER_OF_IN_PROGRESS_CHECKPOINTS_METRIC
,
CheckpointStatsTracker
.
NUMBER_OF_COMPLETED_CHECKPOINTS_METRIC
,
CheckpointStatsTracker
.
NUMBER_OF_FAILED_CHECKPOINTS_METRIC
,
CheckpointStatsTracker
.
LATEST_RESTORED_CHECKPOINT_TIMESTAMP_METRIC
,
CheckpointStatsTracker
.
LATEST_COMPLETED_CHECKPOINT_SIZE_METRIC
,
CheckpointStatsTracker
.
LATEST_COMPLETED_CHECKPOINT_DURATION_METRIC
,
CheckpointStatsTracker
.
LATEST_COMPLETED_CHECKPOINT_ALIGNMENT_BUFFERED_METRIC
,
CheckpointStatsTracker
.
LATEST_COMPLETED_CHECKPOINT_EXTERNAL_PATH_METRIC
)));
assertEquals
(
9
,
registeredGaugeNames
.
size
());
}
/**
...
...
@@ -322,92 +328,12 @@ public class CheckpointStatsTrackerTest {
public
void
testMetricsAreUpdated
()
throws
Exception
{
final
Map
<
String
,
Gauge
<?>>
registeredGauges
=
new
HashMap
<>();
MetricGroup
metricGroup
=
new
MetricGroup
()
{
@Override
public
Counter
counter
(
int
name
)
{
throw
new
UnsupportedOperationException
(
"Not expected in this test"
);
}
@Override
public
Counter
counter
(
String
name
)
{
throw
new
UnsupportedOperationException
(
"Not expected in this test"
);
}
@Override
public
<
C
extends
Counter
>
C
counter
(
int
name
,
C
counter
)
{
throw
new
UnsupportedOperationException
(
"Not expected in this test"
);
}
@Override
public
<
C
extends
Counter
>
C
counter
(
String
name
,
C
counter
)
{
throw
new
UnsupportedOperationException
(
"Not expected in this test"
);
}
@Override
public
<
T
,
G
extends
Gauge
<
T
>>
G
gauge
(
int
name
,
G
gauge
)
{
throw
new
UnsupportedOperationException
(
"Not expected in this test"
);
}
MetricGroup
metricGroup
=
new
UnregisteredMetricsGroup
()
{
@Override
public
<
T
,
G
extends
Gauge
<
T
>>
G
gauge
(
String
name
,
G
gauge
)
{
registeredGauges
.
put
(
name
,
gauge
);
return
gauge
;
}
@Override
public
<
H
extends
Histogram
>
H
histogram
(
String
name
,
H
histogram
)
{
throw
new
UnsupportedOperationException
(
"Not expected in this test"
);
}
@Override
public
<
H
extends
Histogram
>
H
histogram
(
int
name
,
H
histogram
)
{
throw
new
UnsupportedOperationException
(
"Not expected in this test"
);
}
@Override
public
<
M
extends
Meter
>
M
meter
(
String
name
,
M
meter
)
{
throw
new
UnsupportedOperationException
(
"Not expected in this test"
);
}
@Override
public
<
M
extends
Meter
>
M
meter
(
int
name
,
M
meter
)
{
throw
new
UnsupportedOperationException
(
"Not expected in this test"
);
}
@Override
public
MetricGroup
addGroup
(
int
name
)
{
throw
new
UnsupportedOperationException
(
"Not expected in this test"
);
}
@Override
public
MetricGroup
addGroup
(
String
name
)
{
throw
new
UnsupportedOperationException
(
"Not expected in this test"
);
}
@Override
public
MetricGroup
addGroup
(
String
key
,
String
value
)
{
throw
new
UnsupportedOperationException
(
"Not expected in this test"
);
}
@Override
public
String
[]
getScopeComponents
()
{
throw
new
UnsupportedOperationException
(
"Not expected in this test"
);
}
@Override
public
Map
<
String
,
String
>
getAllVariables
()
{
throw
new
UnsupportedOperationException
(
"Not expected in this test"
);
}
@Override
public
String
getMetricIdentifier
(
String
metricName
)
{
throw
new
UnsupportedOperationException
(
"Not expected in this test"
);
}
@Override
public
String
getMetricIdentifier
(
String
metricName
,
CharacterFilter
filter
)
{
throw
new
UnsupportedOperationException
(
"Not expected in this test"
);
}
};
ExecutionJobVertex
jobVertex
=
mock
(
ExecutionJobVertex
.
class
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录