Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
doujutun3207
flink
提交
687ff805
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,发现更多精彩内容 >>
提交
687ff805
编写于
7月 14, 2014
作者:
G
gyfora
提交者:
Stephan Ewen
8月 18, 2014
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[streaming] ack and fail event updated + WordCountRemote modified for debugging
上级
84e67e7c
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
130 addition
and
7 deletion
+130
-7
flink-addons/flink-streaming/src/main/java/eu/stratosphere/streaming/api/streamcomponent/StreamInvokableComponent.java
...reaming/api/streamcomponent/StreamInvokableComponent.java
+2
-2
flink-addons/flink-streaming/src/main/java/eu/stratosphere/streaming/examples/wordcount/WordCountRemote.java
...osphere/streaming/examples/wordcount/WordCountRemote.java
+120
-5
flink-addons/flink-streaming/src/main/java/eu/stratosphere/streaming/faulttolerance/AckEvent.java
...va/eu/stratosphere/streaming/faulttolerance/AckEvent.java
+4
-0
flink-addons/flink-streaming/src/main/java/eu/stratosphere/streaming/faulttolerance/FailEvent.java
...a/eu/stratosphere/streaming/faulttolerance/FailEvent.java
+4
-0
未找到文件。
flink-addons/flink-streaming/src/main/java/eu/stratosphere/streaming/api/streamcomponent/StreamInvokableComponent.java
浏览文件 @
687ff805
...
...
@@ -46,14 +46,14 @@ public abstract class StreamInvokableComponent {
public
final
void
emit
(
StreamRecord
record
)
{
record
.
setId
(
channelID
);
emittedRecords
.
addRecord
(
record
);
//
emittedRecords.addRecord(record);
try
{
for
(
RecordWriter
<
StreamRecord
>
output
:
outputs
)
{
output
.
emit
(
record
);
log
.
info
(
"EMITTED: "
+
record
.
getId
()
+
" -- "
+
name
);
}
}
catch
(
Exception
e
)
{
emittedRecords
.
failRecord
(
record
.
getId
());
//
emittedRecords.failRecord(record.getId());
log
.
warn
(
"FAILED: "
+
record
.
getId
()
+
" -- "
+
name
+
" -- due to "
+
e
.
getClass
().
getSimpleName
());
}
...
...
flink-addons/flink-streaming/src/main/java/eu/stratosphere/streaming/examples/wordcount/WordCountRemote.java
浏览文件 @
687ff805
...
...
@@ -17,25 +17,140 @@ package eu.stratosphere.streaming.examples.wordcount;
import
java.io.File
;
import
java.net.InetSocketAddress
;
import
java.util.HashMap
;
import
java.util.Map
;
import
org.apache.log4j.Level
;
import
eu.stratosphere.api.java.tuple.Tuple1
;
import
eu.stratosphere.api.java.tuple.Tuple2
;
import
eu.stratosphere.client.program.Client
;
import
eu.stratosphere.client.program.JobWithJars
;
import
eu.stratosphere.configuration.Configuration
;
import
eu.stratosphere.core.fs.Path
;
import
eu.stratosphere.nephele.jobgraph.JobGraph
;
import
eu.stratosphere.streaming.api.JobGraphBuilder
;
import
eu.stratosphere.streaming.api.invokable.UserSinkInvokable
;
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
;
public
class
WordCountRemote
{
public
static
class
WordCountDebugSource
extends
UserSourceInvokable
{
StreamRecord
record
=
new
StreamRecord
(
new
Tuple1
<
String
>());
@Override
public
void
invoke
()
throws
Exception
{
long
time
=
System
.
currentTimeMillis
();
for
(
int
i
=
1
;
i
<=
100000
;
i
++)
{
if
(
i
%
10000
==
0
)
{
System
.
out
.
println
(
"Source: "
+
i
+
"\t time: "
+
(
System
.
currentTimeMillis
()
-
time
)
+
" ms"
);
time
=
System
.
currentTimeMillis
();
}
if
(
i
%
2
==
0
)
{
record
.
setString
(
0
,
"Gyula Marci switched"
);
}
else
{
record
.
setString
(
0
,
"Gabor Frank to FINISHED"
);
}
emit
(
record
);
}
}
}
public
static
class
WordCountDebugSplitter
extends
UserTaskInvokable
{
private
String
[]
words
=
new
String
[]
{};
private
int
i
=
0
;
private
StreamRecord
outputRecord
=
new
StreamRecord
(
new
Tuple1
<
String
>());
long
time
=
System
.
currentTimeMillis
();
@Override
public
void
invoke
(
StreamRecord
record
)
throws
Exception
{
i
++;
if
(
i
%
10000
==
0
)
{
System
.
out
.
println
(
"Splitter: "
+
i
+
"\t time: "
+
(
System
.
currentTimeMillis
()
-
time
)
+
" ms"
);
time
=
System
.
currentTimeMillis
();
}
words
=
record
.
getString
(
0
).
split
(
" "
);
for
(
String
word
:
words
)
{
outputRecord
.
setString
(
0
,
word
);
emit
(
outputRecord
);
}
}
}
public
static
class
WordCountDebugCounter
extends
UserTaskInvokable
{
private
Map
<
String
,
Integer
>
wordCounts
=
new
HashMap
<
String
,
Integer
>();
private
String
word
=
""
;
private
Integer
count
=
0
;
private
int
i
=
0
;
private
long
time
=
System
.
currentTimeMillis
();
private
StreamRecord
outRecord
=
new
StreamRecord
(
new
Tuple2
<
String
,
Integer
>());
@Override
public
void
invoke
(
StreamRecord
record
)
throws
Exception
{
word
=
record
.
getString
(
0
);
i
++;
if
(
i
%
30000
==
0
)
{
System
.
out
.
println
(
"Counter: "
+
i
+
"\t time: "
+
(
System
.
currentTimeMillis
()
-
time
)
+
" ms"
);
time
=
System
.
currentTimeMillis
();
}
if
(
wordCounts
.
containsKey
(
word
))
{
count
=
wordCounts
.
get
(
word
)
+
1
;
wordCounts
.
put
(
word
,
count
);
}
else
{
count
=
1
;
wordCounts
.
put
(
word
,
1
);
}
outRecord
.
setString
(
0
,
word
);
outRecord
.
setInteger
(
1
,
count
);
emit
(
outRecord
);
}
}
public
static
class
WordCountDebugSink
extends
UserSinkInvokable
{
int
nrOfRecords
=
0
;
private
long
time
=
System
.
currentTimeMillis
();
@Override
public
void
invoke
(
StreamRecord
record
)
throws
Exception
{
nrOfRecords
++;
if
(
nrOfRecords
%
30000
==
0
)
{
System
.
out
.
println
(
"Sink: "
+
nrOfRecords
+
"\t time: "
+
(
System
.
currentTimeMillis
()
-
time
)
+
" ms"
);
time
=
System
.
currentTimeMillis
();
}
}
@Override
public
String
getResult
()
{
return
String
.
valueOf
(
nrOfRecords
);
}
}
private
static
JobGraph
getJobGraph
()
throws
Exception
{
JobGraphBuilder
graphBuilder
=
new
JobGraphBuilder
(
"testGraph"
);
graphBuilder
.
setSource
(
"WordCountSource"
,
WordCountD
ummySource2
.
class
);
graphBuilder
.
setTask
(
"WordCountSplitter"
,
WordCount
Splitter
.
class
,
2
,
2
);
graphBuilder
.
setTask
(
"WordCountCounter"
,
WordCountCounter
.
class
,
2
,
1
);
graphBuilder
.
setSink
(
"WordCountSink"
,
WordCountSink
.
class
);
graphBuilder
.
setSource
(
"WordCountSource"
,
WordCountD
ebugSource
.
class
,
2
,
1
);
graphBuilder
.
setTask
(
"WordCountSplitter"
,
WordCount
DebugSplitter
.
class
,
2
,
1
);
graphBuilder
.
setTask
(
"WordCountCounter"
,
WordCount
Debug
Counter
.
class
,
2
,
1
);
graphBuilder
.
setSink
(
"WordCountSink"
,
WordCount
Debug
Sink
.
class
);
graphBuilder
.
shuffleConnect
(
"WordCountSource"
,
"WordCountSplitter"
);
graphBuilder
.
fieldsConnect
(
"WordCountSplitter"
,
"WordCountCounter"
,
0
);
...
...
@@ -45,7 +160,7 @@ public class WordCountRemote {
}
public
static
void
main
(
String
[]
args
)
{
LogUtils
.
initializeDefaultConsoleLogger
(
Level
.
ERROR
,
Level
.
INFO
);
LogUtils
.
initializeDefaultConsoleLogger
(
Level
.
DEBUG
,
Level
.
INFO
);
try
{
File
file
=
new
File
(
"target/stratosphere-streaming-0.5-SNAPSHOT.jar"
);
...
...
flink-addons/flink-streaming/src/main/java/eu/stratosphere/streaming/faulttolerance/AckEvent.java
浏览文件 @
687ff805
...
...
@@ -40,6 +40,10 @@ public class AckEvent extends AbstractTaskEvent {
setRecordId
(
recordId
);
}
public
AckEvent
()
{
this
.
recordId
=
""
;
}
@Override
public
void
write
(
DataOutput
out
)
throws
IOException
{
StringValue
recordIdValue
=
new
StringValue
(
recordId
);
...
...
flink-addons/flink-streaming/src/main/java/eu/stratosphere/streaming/faulttolerance/FailEvent.java
浏览文件 @
687ff805
...
...
@@ -41,6 +41,10 @@ public class FailEvent extends AbstractTaskEvent {
setRecordId
(
recordId
);
}
public
FailEvent
()
{
this
.
recordId
=
""
;
}
@Override
public
void
write
(
DataOutput
out
)
throws
IOException
{
StringValue
recordIdValue
=
new
StringValue
(
recordId
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录