Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
doujutun3207
flink
提交
7ee719f7
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,发现更多精彩内容 >>
提交
7ee719f7
编写于
1月 18, 2016
作者:
S
Stephan Ewen
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[FLINK-3255] [streaming] Disable parallelism-dependent chaining optimization
This closes #1518
上级
4806158e
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
76 addition
and
32 deletion
+76
-32
flink-streaming-java/src/main/java/org/apache/flink/streaming/api/graph/StreamGraph.java
...ava/org/apache/flink/streaming/api/graph/StreamGraph.java
+4
-4
flink-streaming-java/src/main/java/org/apache/flink/streaming/api/graph/StreamingJobGraphGenerator.java
...flink/streaming/api/graph/StreamingJobGraphGenerator.java
+7
-8
flink-streaming-java/src/test/java/org/apache/flink/streaming/api/graph/StreamGraphGeneratorTest.java
...e/flink/streaming/api/graph/StreamGraphGeneratorTest.java
+3
-5
flink-streaming-java/src/test/java/org/apache/flink/streaming/api/graph/StreamingJobGraphGeneratorTest.java
...k/streaming/api/graph/StreamingJobGraphGeneratorTest.java
+62
-15
未找到文件。
flink-streaming-java/src/main/java/org/apache/flink/streaming/api/graph/StreamGraph.java
浏览文件 @
7ee719f7
...
...
@@ -465,7 +465,7 @@ public class StreamGraph extends StreamingPlan {
}
public
Set
<
Tuple2
<
Integer
,
StreamOperator
<?>>>
getOperators
()
{
Set
<
Tuple2
<
Integer
,
StreamOperator
<?>>>
operatorSet
=
new
HashSet
<
Tuple2
<
Integer
,
StreamOperator
<?>>
>();
Set
<
Tuple2
<
Integer
,
StreamOperator
<?>>>
operatorSet
=
new
HashSet
<>();
for
(
StreamNode
vertex
:
streamNodes
.
values
())
{
operatorSet
.
add
(
new
Tuple2
<
Integer
,
StreamOperator
<?>>(
vertex
.
getId
(),
vertex
.
getOperator
()));
...
...
@@ -496,7 +496,7 @@ public class StreamGraph extends StreamingPlan {
sinks
.
add
(
sink
.
getId
());
setParallelism
(
sink
.
getId
(),
parallelism
);
iterationSourceSinkPairs
.
add
(
new
Tuple2
<
StreamNode
,
StreamNode
>(
source
,
sink
));
iterationSourceSinkPairs
.
add
(
new
Tuple2
<>(
source
,
sink
));
source
.
setOperatorName
(
"IterationSource-"
+
loopId
);
sink
.
setOperatorName
(
"IterationSink-"
+
loopId
);
...
...
@@ -505,7 +505,7 @@ public class StreamGraph extends StreamingPlan {
this
.
vertexIDtoLoopTimeout
.
put
(
source
.
getId
(),
timeout
);
this
.
vertexIDtoLoopTimeout
.
put
(
sink
.
getId
(),
timeout
);
return
new
Tuple2
<
StreamNode
,
StreamNode
>(
source
,
sink
);
return
new
Tuple2
<>(
source
,
sink
);
}
public
Set
<
Tuple2
<
StreamNode
,
StreamNode
>>
getIterationSourceSinkPairs
()
{
...
...
@@ -518,7 +518,7 @@ public class StreamGraph extends StreamingPlan {
}
private
void
removeVertex
(
StreamNode
toRemove
)
{
Set
<
StreamEdge
>
edgesToRemove
=
new
HashSet
<
StreamEdge
>();
Set
<
StreamEdge
>
edgesToRemove
=
new
HashSet
<>();
edgesToRemove
.
addAll
(
toRemove
.
getInEdges
());
edgesToRemove
.
addAll
(
toRemove
.
getOutEdges
());
...
...
flink-streaming-java/src/main/java/org/apache/flink/streaming/api/graph/StreamingJobGraphGenerator.java
浏览文件 @
7ee719f7
...
...
@@ -229,14 +229,14 @@ public class StreamingJobGraphGenerator {
return
transitiveOutEdges
;
}
else
{
return
new
ArrayList
<
StreamEdge
>();
return
new
ArrayList
<>();
}
}
private
String
createChainedName
(
Integer
vertexID
,
List
<
StreamEdge
>
chainedOutputs
)
{
String
operatorName
=
streamGraph
.
getStreamNode
(
vertexID
).
getOperatorName
();
if
(
chainedOutputs
.
size
()
>
1
)
{
List
<
String
>
outputChainedNames
=
new
ArrayList
<
String
>();
List
<
String
>
outputChainedNames
=
new
ArrayList
<>();
for
(
StreamEdge
chainable
:
chainedOutputs
)
{
outputChainedNames
.
add
(
chainedNames
.
get
(
chainable
.
getTargetId
()));
}
...
...
@@ -395,8 +395,7 @@ public class StreamingJobGraphGenerator {
&&
(
headOperator
.
getChainingStrategy
()
==
ChainingStrategy
.
HEAD
||
headOperator
.
getChainingStrategy
()
==
ChainingStrategy
.
ALWAYS
||
headOperator
.
getChainingStrategy
()
==
ChainingStrategy
.
FORCE_ALWAYS
)
&&
(
edge
.
getPartitioner
()
instanceof
ForwardPartitioner
||
downStreamVertex
.
getParallelism
()
==
1
)
&&
(
edge
.
getPartitioner
()
instanceof
ForwardPartitioner
)
&&
upStreamVertex
.
getParallelism
()
==
downStreamVertex
.
getParallelism
()
&&
(
streamGraph
.
isChainingEnabled
()
||
outOperator
.
getChainingStrategy
()
==
ChainingStrategy
.
FORCE_ALWAYS
);
...
...
@@ -404,7 +403,7 @@ public class StreamingJobGraphGenerator {
private
void
setSlotSharing
()
{
Map
<
Integer
,
SlotSharingGroup
>
slotSharingGroups
=
new
HashMap
<
Integer
,
SlotSharingGroup
>();
Map
<
Integer
,
SlotSharingGroup
>
slotSharingGroups
=
new
HashMap
<>();
for
(
Entry
<
Integer
,
JobVertex
>
entry
:
jobVertices
.
entrySet
())
{
...
...
@@ -446,15 +445,15 @@ public class StreamingJobGraphGenerator {
// collect the vertices that receive "trigger checkpoint" messages.
// currently, these are all the sources
List
<
JobVertexID
>
triggerVertices
=
new
ArrayList
<
JobVertexID
>();
List
<
JobVertexID
>
triggerVertices
=
new
ArrayList
<>();
// collect the vertices that need to acknowledge the checkpoint
// currently, these are all vertices
List
<
JobVertexID
>
ackVertices
=
new
ArrayList
<
JobVertexID
>(
jobVertices
.
size
());
List
<
JobVertexID
>
ackVertices
=
new
ArrayList
<>(
jobVertices
.
size
());
// collect the vertices that receive "commit checkpoint" messages
// currently, these are all vertices
List
<
JobVertexID
>
commitVertices
=
new
ArrayList
<
JobVertexID
>();
List
<
JobVertexID
>
commitVertices
=
new
ArrayList
<>();
for
(
JobVertex
vertex
:
jobVertices
.
values
())
{
if
(
vertex
.
isInputVertex
())
{
...
...
flink-streaming-java/src/test/java/org/apache/flink/streaming/api/graph/StreamGraphGeneratorTest.java
浏览文件 @
7ee719f7
...
...
@@ -51,7 +51,7 @@ import static org.junit.Assert.assertTrue;
* specific tests, for example in {@link org.apache.flink.streaming.api.IterateTest} for
* iterations.
*/
public
class
StreamGraphGeneratorTest
extends
StreamingMultipleProgramsTestBase
{
public
class
StreamGraphGeneratorTest
{
/**
* This tests whether virtual Transformations behave correctly.
...
...
@@ -282,14 +282,12 @@ public class StreamGraphGeneratorTest extends StreamingMultipleProgramsTestBase
}
@Override
public
void
processElement
(
StreamRecord
<
Integer
>
element
)
throws
Exception
{
public
void
processElement
(
StreamRecord
<
Integer
>
element
)
{
output
.
collect
(
element
);
}
@Override
public
void
processWatermark
(
Watermark
mark
)
throws
Exception
{
}
public
void
processWatermark
(
Watermark
mark
)
{}
@Override
public
void
setOutputType
(
TypeInformation
<
Integer
>
outTypeInfo
,
ExecutionConfig
executionConfig
)
{
...
...
flink-streaming-java/src/test/java/org/apache/flink/streaming/api/graph/StreamingJobGraphGeneratorTest.java
浏览文件 @
7ee719f7
...
...
@@ -14,29 +14,30 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org.apache.flink.streaming.api.graph
;
import
java.io.IOException
;
import
java.util.Random
;
import
org.apache.flink.api.common.ExecutionConfig
;
import
org.apache.flink.api.common.functions.MapFunction
;
import
org.apache.flink.api.java.tuple.Tuple2
;
import
org.apache.flink.runtime.jobgraph.JobGraph
;
import
org.apache.flink.streaming.api.datastream.DataStream
;
import
org.apache.flink.streaming.api.environment.StreamExecutionEnvironment
;
import
org.apache.flink.streaming.util.StreamingMultipleProgramsTestBase
;
import
org.apache.flink.streaming.util.TestStreamEnvironment
;
import
org.apache.flink.streaming.api.functions.sink.SinkFunction
;
import
org.apache.flink.util.InstantiationUtil
;
import
org.junit.Assert
;
import
org.junit.Test
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
public
class
StreamingJobGraphGeneratorTest
extends
StreamingMultipleProgramsTestBase
{
private
static
final
Logger
LOG
=
LoggerFactory
.
getLogger
(
StreamingJobGraphGeneratorTest
.
class
);
import
static
org
.
junit
.
Assert
.*;
public
class
StreamingJobGraphGeneratorTest
{
@Test
public
void
testExecutionConfigSerialization
()
throws
IOException
,
ClassNotFoundException
{
final
long
seed
=
System
.
currentTimeMillis
();
LOG
.
info
(
"Test seed: {}"
,
new
Long
(
seed
));
final
Random
r
=
new
Random
(
seed
);
StreamExecutionEnvironment
env
=
StreamExecutionEnvironment
.
getExecutionEnvironment
();
...
...
@@ -76,16 +77,62 @@ public class StreamingJobGraphGeneratorTest extends StreamingMultipleProgramsTes
config
.
setParallelism
(
dop
);
JobGraph
jobGraph
=
compiler
.
createJobGraph
(
"test"
);
ExecutionConfig
executionConfig
=
(
ExecutionConfig
)
InstantiationUtil
.
readObjectFromConfig
(
ExecutionConfig
executionConfig
=
InstantiationUtil
.
readObjectFromConfig
(
jobGraph
.
getJobConfiguration
(),
ExecutionConfig
.
CONFIG_KEY
,
Thread
.
currentThread
().
getContextClassLoader
());
Assert
.
assertEquals
(
closureCleanerEnabled
,
executionConfig
.
isClosureCleanerEnabled
());
Assert
.
assertEquals
(
forceAvroEnabled
,
executionConfig
.
isForceAvroEnabled
());
Assert
.
assertEquals
(
forceKryoEnabled
,
executionConfig
.
isForceKryoEnabled
());
Assert
.
assertEquals
(
objectReuseEnabled
,
executionConfig
.
isObjectReuseEnabled
());
Assert
.
assertEquals
(
sysoutLoggingEnabled
,
executionConfig
.
isSysoutLoggingEnabled
());
Assert
.
assertEquals
(
dop
,
executionConfig
.
getParallelism
());
assertNotNull
(
executionConfig
);
assertEquals
(
closureCleanerEnabled
,
executionConfig
.
isClosureCleanerEnabled
());
assertEquals
(
forceAvroEnabled
,
executionConfig
.
isForceAvroEnabled
());
assertEquals
(
forceKryoEnabled
,
executionConfig
.
isForceKryoEnabled
());
assertEquals
(
objectReuseEnabled
,
executionConfig
.
isObjectReuseEnabled
());
assertEquals
(
sysoutLoggingEnabled
,
executionConfig
.
isSysoutLoggingEnabled
());
assertEquals
(
dop
,
executionConfig
.
getParallelism
());
}
@Test
public
void
testParallelismOneNotChained
()
{
// --------- the program ---------
final
StreamExecutionEnvironment
env
=
StreamExecutionEnvironment
.
getExecutionEnvironment
();
env
.
setParallelism
(
1
);
DataStream
<
Tuple2
<
String
,
String
>>
input
=
env
.
fromElements
(
"a"
,
"b"
,
"c"
,
"d"
,
"e"
,
"f"
)
.
map
(
new
MapFunction
<
String
,
Tuple2
<
String
,
String
>>()
{
@Override
public
Tuple2
<
String
,
String
>
map
(
String
value
)
{
return
new
Tuple2
<>(
value
,
value
);
}
});
DataStream
<
Tuple2
<
String
,
String
>>
result
=
input
.
keyBy
(
0
)
.
map
(
new
MapFunction
<
Tuple2
<
String
,
String
>,
Tuple2
<
String
,
String
>>()
{
@Override
public
Tuple2
<
String
,
String
>
map
(
Tuple2
<
String
,
String
>
value
)
{
return
value
;
}
});
result
.
addSink
(
new
SinkFunction
<
Tuple2
<
String
,
String
>>()
{
@Override
public
void
invoke
(
Tuple2
<
String
,
String
>
value
)
{}
});
// --------- the job graph ---------
StreamGraph
streamGraph
=
env
.
getStreamGraph
();
streamGraph
.
setJobName
(
"test job"
);
JobGraph
jobGraph
=
streamGraph
.
getJobGraph
();
assertEquals
(
2
,
jobGraph
.
getNumberOfVertices
());
assertEquals
(
1
,
jobGraph
.
getVerticesAsArray
()[
0
].
getParallelism
());
assertEquals
(
1
,
jobGraph
.
getVerticesAsArray
()[
1
].
getParallelism
());
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录