Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
doujutun3207
flink
提交
edb79b0a
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,发现更多精彩内容 >>
提交
edb79b0a
编写于
6月 12, 2017
作者:
Z
zentol
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[FLINK-6898] [metrics] Limit size of operator component in metric name
This closes #4109.
上级
08580765
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
26 addition
and
1 deletion
+26
-1
flink-runtime/src/main/java/org/apache/flink/runtime/metrics/groups/AbstractMetricGroup.java
...che/flink/runtime/metrics/groups/AbstractMetricGroup.java
+1
-1
flink-runtime/src/main/java/org/apache/flink/runtime/metrics/groups/TaskMetricGroup.java
.../apache/flink/runtime/metrics/groups/TaskMetricGroup.java
+6
-0
flink-runtime/src/test/java/org/apache/flink/runtime/metrics/groups/TaskMetricGroupTest.java
...che/flink/runtime/metrics/groups/TaskMetricGroupTest.java
+19
-0
未找到文件。
flink-runtime/src/main/java/org/apache/flink/runtime/metrics/groups/AbstractMetricGroup.java
浏览文件 @
edb79b0a
...
@@ -63,7 +63,7 @@ import static org.apache.flink.util.Preconditions.checkNotNull;
...
@@ -63,7 +63,7 @@ import static org.apache.flink.util.Preconditions.checkNotNull;
@Internal
@Internal
public
abstract
class
AbstractMetricGroup
<
A
extends
AbstractMetricGroup
<?>>
implements
MetricGroup
{
public
abstract
class
AbstractMetricGroup
<
A
extends
AbstractMetricGroup
<?>>
implements
MetricGroup
{
pr
ivate
static
final
Logger
LOG
=
LoggerFactory
.
getLogger
(
MetricGroup
.
class
);
pr
otected
static
final
Logger
LOG
=
LoggerFactory
.
getLogger
(
MetricGroup
.
class
);
// ------------------------------------------------------------------------
// ------------------------------------------------------------------------
...
...
flink-runtime/src/main/java/org/apache/flink/runtime/metrics/groups/TaskMetricGroup.java
浏览文件 @
edb79b0a
...
@@ -42,6 +42,8 @@ public class TaskMetricGroup extends ComponentMetricGroup<TaskManagerJobMetricGr
...
@@ -42,6 +42,8 @@ public class TaskMetricGroup extends ComponentMetricGroup<TaskManagerJobMetricGr
private
final
Map
<
String
,
OperatorMetricGroup
>
operators
=
new
HashMap
<>();
private
final
Map
<
String
,
OperatorMetricGroup
>
operators
=
new
HashMap
<>();
static
final
int
METRICS_OPERATOR_NAME_MAX_LENGTH
=
80
;
private
final
TaskIOMetricGroup
ioMetrics
;
private
final
TaskIOMetricGroup
ioMetrics
;
/** The execution Id uniquely identifying the executed task represented by this metrics group. */
/** The execution Id uniquely identifying the executed task represented by this metrics group. */
...
@@ -131,6 +133,10 @@ public class TaskMetricGroup extends ComponentMetricGroup<TaskManagerJobMetricGr
...
@@ -131,6 +133,10 @@ public class TaskMetricGroup extends ComponentMetricGroup<TaskManagerJobMetricGr
// ------------------------------------------------------------------------
// ------------------------------------------------------------------------
public
OperatorMetricGroup
addOperator
(
String
name
)
{
public
OperatorMetricGroup
addOperator
(
String
name
)
{
if
(
name
!=
null
&&
name
.
length
()
>
METRICS_OPERATOR_NAME_MAX_LENGTH
)
{
LOG
.
warn
(
"The operator name {} exceeded the {} characters length limit and was truncated."
,
name
,
METRICS_OPERATOR_NAME_MAX_LENGTH
);
name
=
name
.
substring
(
0
,
METRICS_OPERATOR_NAME_MAX_LENGTH
);
}
OperatorMetricGroup
operator
=
new
OperatorMetricGroup
(
this
.
registry
,
this
,
name
);
OperatorMetricGroup
operator
=
new
OperatorMetricGroup
(
this
.
registry
,
this
,
name
);
synchronized
(
this
)
{
synchronized
(
this
)
{
...
...
flink-runtime/src/test/java/org/apache/flink/runtime/metrics/groups/TaskMetricGroupTest.java
浏览文件 @
edb79b0a
...
@@ -25,10 +25,12 @@ import org.apache.flink.metrics.Metric;
...
@@ -25,10 +25,12 @@ import org.apache.flink.metrics.Metric;
import
org.apache.flink.runtime.metrics.MetricRegistry
;
import
org.apache.flink.runtime.metrics.MetricRegistry
;
import
org.apache.flink.runtime.metrics.MetricRegistryConfiguration
;
import
org.apache.flink.runtime.metrics.MetricRegistryConfiguration
;
import
org.apache.flink.runtime.metrics.dump.QueryScopeInfo
;
import
org.apache.flink.runtime.metrics.dump.QueryScopeInfo
;
import
org.apache.flink.runtime.metrics.scope.ScopeFormat
;
import
org.apache.flink.runtime.metrics.util.DummyCharacterFilter
;
import
org.apache.flink.runtime.metrics.util.DummyCharacterFilter
;
import
org.apache.flink.util.AbstractID
;
import
org.apache.flink.util.AbstractID
;
import
org.apache.flink.util.TestLogger
;
import
org.apache.flink.util.TestLogger
;
import
org.junit.Assert
;
import
org.junit.Test
;
import
org.junit.Test
;
import
static
org
.
junit
.
Assert
.
assertArrayEquals
;
import
static
org
.
junit
.
Assert
.
assertArrayEquals
;
...
@@ -150,6 +152,23 @@ public class TaskMetricGroupTest extends TestLogger {
...
@@ -150,6 +152,23 @@ public class TaskMetricGroupTest extends TestLogger {
registry
.
shutdown
();
registry
.
shutdown
();
}
}
@Test
public
void
testOperatorNameTruncation
()
{
Configuration
cfg
=
new
Configuration
();
cfg
.
setString
(
MetricOptions
.
SCOPE_NAMING_OPERATOR
,
ScopeFormat
.
SCOPE_OPERATOR_NAME
);
MetricRegistry
registry
=
new
MetricRegistry
(
MetricRegistryConfiguration
.
fromConfiguration
(
cfg
));
TaskManagerMetricGroup
tm
=
new
TaskManagerMetricGroup
(
registry
,
"host"
,
"id"
);
TaskManagerJobMetricGroup
job
=
new
TaskManagerJobMetricGroup
(
registry
,
tm
,
new
JobID
(),
"jobname"
);
TaskMetricGroup
taskMetricGroup
=
new
TaskMetricGroup
(
registry
,
job
,
new
AbstractID
(),
new
AbstractID
(),
"task"
,
0
,
0
);
String
originalName
=
new
String
(
new
char
[
100
]).
replace
(
"\0"
,
"-"
);
OperatorMetricGroup
operatorMetricGroup
=
taskMetricGroup
.
addOperator
(
originalName
);
String
storedName
=
operatorMetricGroup
.
getScopeComponents
()[
0
];
Assert
.
assertEquals
(
TaskMetricGroup
.
METRICS_OPERATOR_NAME_MAX_LENGTH
,
storedName
.
length
());
Assert
.
assertEquals
(
originalName
.
substring
(
0
,
TaskMetricGroup
.
METRICS_OPERATOR_NAME_MAX_LENGTH
),
storedName
);
}
private
static
class
CountingMetricRegistry
extends
MetricRegistry
{
private
static
class
CountingMetricRegistry
extends
MetricRegistry
{
private
int
counter
=
0
;
private
int
counter
=
0
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录