rkhachatryan commented on code in PR #22864:
URL: https://github.com/apache/flink/pull/22864#discussion_r1242125390
##########
flink-streaming-java/src/test/java/org/apache/flink/streaming/api/graph/StreamingJobGraphGeneratorTest.java:
##########
@@ -304,6 +304,35 @@ void testTransformationSetMaxParallelism() {
.isEqualTo(20);
}
+ /**
+ * Tests that the maxParallelism for an operator chain is correctly
determined as the minimal
+ * maxParallelism of all operators in the chain.
+ */
+ @Test
+ void testTransformationSetMinimalMaxParallelismForChain() {
+ StreamExecutionEnvironment env =
StreamExecutionEnvironment.getExecutionEnvironment();
+ env.setMaxParallelism(16);
+
+ DataStreamSource<Long> source = env.fromSequence(1L, 3L);
+ source.setParallelism(1)
+ .setMaxParallelism(128)
+ .map(i -> i)
+ .setParallelism(1)
+ .setMaxParallelism(1)
+ .print()
+ .setParallelism(1);
Review Comment:
Would it also make sense to test the reverse order:
source.maxParallelism(1)
sink.maxParallelism(128)
?
##########
flink-streaming-java/src/main/java/org/apache/flink/streaming/api/graph/StreamingJobGraphGenerator.java:
##########
@@ -1008,6 +1008,23 @@ private StreamConfig createJobVertex(Integer
streamNodeId, OperatorChainInfo cha
jobVertex.setInvokableClass(streamNode.getJobVertexClass());
+ // Find the minimal max parallelism in the chain for operators that
have a configured max
+ // parallelism (>0). If no operator has max parallelism configured,
returns the default -1.
+ int chainMinimalMaxParallelism =
+ chainInfo.getAllChainedNodes().stream()
+ .mapToInt(StreamNode::getMaxParallelism)
+ .filter(maxParallelism -> maxParallelism > 0)
+ .min()
+ .orElse(-1);
+
+ jobVertex.setMaxParallelism(chainMinimalMaxParallelism);
+
+ boolean anyParallelismInChainConfigured =
+ chainInfo.getAllChainedNodes().stream()
+ .anyMatch(StreamNode::isParallelismConfigured);
+
+ jobVertex.setParallelismConfigured(anyParallelismInChainConfigured);
Review Comment:
This is called in `createJobVertex` which is called from `createChain`,
which is recursive.
Because `createChain` is recursive, I'm wondering whether `chainInfo` (and
its nodes) is "complete" at this point; or there might be more vertices added
with `maxParallelism` less then the current?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]