Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
doujutun3207
flink
提交
fc149066
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,发现更多精彩内容 >>
提交
fc149066
编写于
7月 14, 2014
作者:
G
gyfora
提交者:
Stephan Ewen
8月 18, 2014
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[streaming] performance util refactor
上级
a2caec7e
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
125 addition
and
95 deletion
+125
-95
flink-addons/flink-streaming/src/main/java/eu/stratosphere/streaming/examples/wordcount/WordCountRemote.java
...osphere/streaming/examples/wordcount/WordCountRemote.java
+6
-6
flink-addons/flink-streaming/src/main/java/eu/stratosphere/streaming/util/PerformanceCounter.java
...va/eu/stratosphere/streaming/util/PerformanceCounter.java
+35
-0
flink-addons/flink-streaming/src/main/java/eu/stratosphere/streaming/util/PerformanceTimer.java
...java/eu/stratosphere/streaming/util/PerformanceTimer.java
+43
-0
flink-addons/flink-streaming/src/main/java/eu/stratosphere/streaming/util/PerformanceTracker.java
...va/eu/stratosphere/streaming/util/PerformanceTracker.java
+17
-70
flink-addons/flink-streaming/src/test/java/eu/stratosphere/streaming/util/PerformanceTrackerTest.java
...u/stratosphere/streaming/util/PerformanceTrackerTest.java
+24
-19
未找到文件。
flink-addons/flink-streaming/src/main/java/eu/stratosphere/streaming/examples/wordcount/WordCountRemote.java
浏览文件 @
fc149066
...
...
@@ -35,14 +35,14 @@ import eu.stratosphere.streaming.api.invokable.UserSourceInvokable;
import
eu.stratosphere.streaming.api.invokable.UserTaskInvokable
;
import
eu.stratosphere.streaming.api.streamrecord.StreamRecord
;
import
eu.stratosphere.streaming.util.LogUtils
;
import
eu.stratosphere.streaming.util.Performance
Track
er
;
import
eu.stratosphere.streaming.util.Performance
Count
er
;
public
class
WordCountRemote
{
private
final
static
int
recordsEmitted
=
100000
;
public
static
class
WordCountDebugSource
extends
UserSourceInvokable
{
private
Performance
Tracker
perf
=
new
PerformanceTracker
(
"SourceEmitCounter"
,
1000
,
10000
);
private
Performance
Counter
perf
=
new
PerformanceCounter
(
"SourceEmitCounter"
,
1000
,
10000
);
StreamRecord
record
=
new
StreamRecord
(
new
Tuple1
<
String
>());
...
...
@@ -70,7 +70,7 @@ public class WordCountRemote {
public
static
class
WordCountDebugSplitter
extends
UserTaskInvokable
{
private
Performance
Tracker
perf
=
new
PerformanceTracker
(
"SplitterEmitCounter"
,
1000
,
10000
);
private
Performance
Counter
perf
=
new
PerformanceCounter
(
"SplitterEmitCounter"
,
1000
,
10000
);
private
String
[]
words
=
new
String
[]
{};
private
StreamRecord
outputRecord
=
new
StreamRecord
(
new
Tuple1
<
String
>());
...
...
@@ -93,7 +93,7 @@ public class WordCountRemote {
}
public
static
class
WordCountDebugCounter
extends
UserTaskInvokable
{
private
Performance
Tracker
perf
=
new
PerformanceTracker
(
"CounterEmitCounter"
,
1000
,
10000
);
private
Performance
Counter
perf
=
new
PerformanceCounter
(
"CounterEmitCounter"
,
1000
,
10000
);
private
Map
<
String
,
Integer
>
wordCounts
=
new
HashMap
<
String
,
Integer
>();
private
String
word
=
""
;
...
...
@@ -127,7 +127,7 @@ public class WordCountRemote {
}
public
static
class
WordCountDebugSink
extends
UserSinkInvokable
{
private
Performance
Tracker
perf
=
new
PerformanceTracker
(
"SinkEmitCounter"
,
1000
,
10000
);
private
Performance
Counter
perf
=
new
PerformanceCounter
(
"SinkEmitCounter"
,
1000
,
10000
);
@Override
public
void
invoke
(
StreamRecord
record
)
throws
Exception
{
...
...
@@ -145,7 +145,7 @@ public class WordCountRemote {
graphBuilder
.
setSource
(
"WordCountSource"
,
WordCountDebugSource
.
class
,
2
,
1
);
graphBuilder
.
setTask
(
"WordCountSplitter"
,
WordCountDebugSplitter
.
class
,
2
,
1
);
graphBuilder
.
setTask
(
"WordCountCounter"
,
WordCountDebugCounter
.
class
,
2
,
1
);
graphBuilder
.
setSink
(
"WordCountSink"
,
WordCountDebugSink
.
class
,
2
,
1
);
graphBuilder
.
setSink
(
"WordCountSink"
,
WordCountDebugSink
.
class
,
2
,
1
);
graphBuilder
.
shuffleConnect
(
"WordCountSource"
,
"WordCountSplitter"
);
graphBuilder
.
fieldsConnect
(
"WordCountSplitter"
,
"WordCountCounter"
,
0
);
...
...
flink-addons/flink-streaming/src/main/java/eu/stratosphere/streaming/util/PerformanceCounter.java
0 → 100755
浏览文件 @
fc149066
package
eu.stratosphere.streaming.util
;
public
class
PerformanceCounter
extends
PerformanceTracker
{
public
PerformanceCounter
(
String
name
,
int
counterLength
,
int
countInterval
)
{
super
(
name
,
counterLength
,
countInterval
);
}
public
PerformanceCounter
(
String
name
)
{
super
(
name
);
}
public
void
count
(
long
i
,
String
label
)
{
buffer
=
buffer
+
i
;
intervalCounter
++;
if
(
intervalCounter
%
interval
==
0
)
{
intervalCounter
=
0
;
timeStamps
.
add
(
System
.
currentTimeMillis
());
values
.
add
(
buffer
);
labels
.
add
(
label
);
}
}
public
void
count
(
long
i
)
{
count
(
i
,
"counter"
);
}
public
void
count
(
String
label
)
{
count
(
1
,
label
);
}
public
void
count
()
{
count
(
1
,
"counter"
);
}
}
flink-addons/flink-streaming/src/main/java/eu/stratosphere/streaming/util/PerformanceTimer.java
0 → 100755
浏览文件 @
fc149066
package
eu.stratosphere.streaming.util
;
public
class
PerformanceTimer
extends
PerformanceTracker
{
long
timer
;
boolean
millis
;
public
PerformanceTimer
(
String
name
,
int
counterLength
,
int
countInterval
)
{
super
(
name
,
counterLength
,
countInterval
);
}
public
PerformanceTimer
(
String
name
)
{
super
(
name
);
}
public
void
startTimer
(
boolean
millis
)
{
this
.
millis
=
millis
;
if
(
millis
)
{
timer
=
System
.
currentTimeMillis
();
}
else
{
timer
=
System
.
nanoTime
();
}
}
public
void
startTimer
()
{
startTimer
(
true
);
}
public
void
stopTimer
(
String
label
)
{
if
(
millis
)
{
track
(
System
.
currentTimeMillis
()
-
timer
,
label
);
}
else
{
track
(
System
.
nanoTime
()
-
timer
,
label
);
}
}
public
void
stopTimer
()
{
stopTimer
(
"timer"
);
}
}
flink-addons/flink-streaming/src/main/java/eu/stratosphere/streaming/util/PerformanceTracker.java
浏览文件 @
fc149066
...
...
@@ -7,42 +7,39 @@ import java.util.List;
public
class
PerformanceTracker
{
List
<
Long
>
timeStamps
;
List
<
Long
>
values
;
List
<
String
>
labels
;
long
counter
;
long
countInterval
;
long
intervalCounter
;
long
buffer
;
long
timer
;
boolean
millis
;
String
name
;
protected
List
<
Long
>
timeStamps
;
protected
List
<
Long
>
values
;
protected
List
<
String
>
labels
;
public
PerformanceTracker
(
String
name
)
{
protected
int
interval
;
protected
int
intervalCounter
;
protected
String
name
;
protected
long
buffer
;
public
PerformanceTracker
(
String
name
)
{
timeStamps
=
new
ArrayList
<
Long
>();
values
=
new
ArrayList
<
Long
>();
labels
=
new
ArrayList
<
String
>();
this
.
countInterval
=
1
;
counter
=
0
;
this
.
interval
=
1
;
this
.
name
=
name
;
buffer
=
0
;
}
public
PerformanceTracker
(
String
name
,
int
counterLength
,
int
countInterval
)
{
timeStamps
=
new
ArrayList
<
Long
>(
counterLength
);
values
=
new
ArrayList
<
Long
>(
counterLength
);
labels
=
new
ArrayList
<
String
>(
counterLength
);
this
.
countInterval
=
countInterval
;
counter
=
0
;
public
PerformanceTracker
(
String
name
,
int
capacity
,
int
interval
)
{
timeStamps
=
new
ArrayList
<
Long
>(
capacity
);
values
=
new
ArrayList
<
Long
>(
capacity
);
labels
=
new
ArrayList
<
String
>(
capacity
);
this
.
interval
=
interval
;
this
.
name
=
name
;
buffer
=
0
;
}
public
void
track
(
Long
value
,
String
label
)
{
buffer
=
buffer
+
value
;
intervalCounter
++;
if
(
intervalCounter
%
countI
nterval
==
0
)
{
if
(
intervalCounter
%
i
nterval
==
0
)
{
timeStamps
.
add
(
System
.
currentTimeMillis
());
values
.
add
(
buffer
);
...
...
@@ -68,56 +65,6 @@ public class PerformanceTracker {
track
(
1
);
}
public
void
startTimer
(
boolean
millis
)
{
this
.
millis
=
millis
;
if
(
millis
)
{
timer
=
System
.
currentTimeMillis
();
}
else
{
timer
=
System
.
nanoTime
();
}
}
public
void
startTimer
()
{
startTimer
(
true
);
}
public
void
stopTimer
(
String
label
)
{
if
(
millis
)
{
track
(
System
.
currentTimeMillis
()
-
timer
,
label
);
}
else
{
track
(
System
.
nanoTime
()
-
timer
,
label
);
}
}
public
void
stopTimer
()
{
stopTimer
(
"timer"
);
}
public
void
count
(
long
i
,
String
label
)
{
counter
=
counter
+
i
;
intervalCounter
++;
if
(
intervalCounter
%
countInterval
==
0
)
{
intervalCounter
=
0
;
timeStamps
.
add
(
System
.
currentTimeMillis
());
values
.
add
(
counter
);
labels
.
add
(
label
);
}
}
public
void
count
(
long
i
)
{
count
(
i
,
"counter"
);
}
public
void
count
(
String
label
)
{
count
(
1
,
label
);
}
public
void
count
()
{
count
(
1
,
"counter"
);
}
@Override
public
String
toString
()
{
StringBuilder
csv
=
new
StringBuilder
();
...
...
flink-addons/flink-streaming/src/test/java/eu/stratosphere/streaming/util/PerformanceTrackerTest.java
浏览文件 @
fc149066
...
...
@@ -19,48 +19,53 @@ public class PerformanceTrackerTest {
@Test
public
void
testTrack
()
{
PerformanceTracker
pT
=
new
PerformanceTracker
(
"t
estcount
er"
);
PerformanceTracker
pT
=
new
PerformanceTracker
(
"t
rack
er"
);
pT
.
track
();
pT
.
track
(
3
);
pT
.
track
(
1
);
assertEquals
(
2
,
pT
.
timeStamps
.
size
());
assertEquals
(
2
,
pT
.
values
.
size
());
assertEquals
(
3
,
pT
.
timeStamps
.
size
());
assertEquals
(
3
,
pT
.
values
.
size
());
assertEquals
(
Long
.
valueOf
(
1
),
pT
.
values
.
get
(
0
));
assertEquals
(
Long
.
valueOf
(
3
),
pT
.
values
.
get
(
1
));
assertEquals
(
Long
.
valueOf
(
1
),
pT
.
values
.
get
(
2
));
PerformanceTracker
pT2
=
new
PerformanceTracker
(
"testcounter"
,
10
,
2
);
PerformanceTracker
pT2
=
new
PerformanceTracker
(
"tracker"
,
10
,
2
);
pT2
.
track
(
1
);
pT2
.
track
(
3
);
pT2
.
track
(
1
);
pT2
.
track
(
3
);
assertEquals
(
1
,
pT2
.
timeStamps
.
size
());
assertEquals
(
1
,
pT2
.
values
.
size
());
assertEquals
(
2
,
pT2
.
timeStamps
.
size
());
assertEquals
(
2
,
pT2
.
values
.
size
());
assertEquals
(
Long
.
valueOf
(
4
),
pT2
.
values
.
get
(
0
));
assertEquals
(
Long
.
valueOf
(
4
),
pT2
.
values
.
get
(
1
));
System
.
out
.
println
(
pT
);
System
.
out
.
println
(
pT
2
);
System
.
out
.
println
(
"--------------"
);
}
@Test
public
void
testCount
()
{
Performance
Tracker
pT
=
new
PerformanceTracker
(
"test
counter"
);
p
T
.
count
();
p
T
.
count
(
10
);
p
T
.
count
();
Performance
Counter
pC
=
new
PerformanceCounter
(
"
counter"
);
p
C
.
count
();
p
C
.
count
(
10
);
p
C
.
count
();
assertEquals
(
3
,
p
T
.
timeStamps
.
size
());
assertEquals
(
3
,
p
T
.
values
.
size
());
assertEquals
(
3
,
p
C
.
timeStamps
.
size
());
assertEquals
(
3
,
p
C
.
values
.
size
());
assertEquals
(
Long
.
valueOf
(
1
),
p
T
.
values
.
get
(
0
));
assertEquals
(
Long
.
valueOf
(
11
),
p
T
.
values
.
get
(
1
));
assertEquals
(
Long
.
valueOf
(
12
),
p
T
.
values
.
get
(
2
));
assertEquals
(
Long
.
valueOf
(
1
),
p
C
.
values
.
get
(
0
));
assertEquals
(
Long
.
valueOf
(
11
),
p
C
.
values
.
get
(
1
));
assertEquals
(
Long
.
valueOf
(
12
),
p
C
.
values
.
get
(
2
));
System
.
out
.
println
(
p
T
);
System
.
out
.
println
(
p
C
);
System
.
out
.
println
(
"--------------"
);
Performance
Tracker
pT2
=
new
PerformanceTracker
(
"test
counter"
,
1000
,
10000
);
Performance
Counter
pT2
=
new
PerformanceCounter
(
"
counter"
,
1000
,
10000
);
for
(
int
i
=
0
;
i
<
10000000
;
i
++)
{
pT2
.
count
(
"test"
);
...
...
@@ -74,7 +79,7 @@ public class PerformanceTrackerTest {
@Test
public
void
testTimer
()
throws
InterruptedException
{
PerformanceT
racker
pT
=
new
PerformanceTracker
(
"testcount
er"
);
PerformanceT
imer
pT
=
new
PerformanceTimer
(
"tim
er"
);
pT
.
startTimer
(
true
);
Thread
.
sleep
(
100
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录