27
27
import org .apache .flink .configuration .Configuration ;
28
28
import org .apache .flink .configuration .ExternalizedCheckpointRetention ;
29
29
import org .apache .flink .configuration .MemorySize ;
30
+ import org .apache .flink .configuration .RestartStrategyOptions ;
30
31
import org .apache .flink .configuration .StateRecoveryOptions ;
31
32
import org .apache .flink .configuration .TaskManagerOptions ;
32
33
import org .apache .flink .connector .datagen .source .DataGeneratorSource ;
57
58
import java .util .List ;
58
59
import java .util .Random ;
59
60
61
+ import static org .apache .flink .configuration .RestartStrategyOptions .RestartStrategyType .NO_RESTART_STRATEGY ;
62
+
60
63
/**
61
64
* Integration test for rescaling jobs with mixed (UC-supported and UC-unsupported) exchanges from
62
65
* an unaligned checkpoint.
@@ -80,7 +83,8 @@ public static Collection<ExecuteJobViaEnv> parameter() {
80
83
UnalignedCheckpointRescaleWithMixedExchangesITCase ::createMultiOutputDAG ,
81
84
UnalignedCheckpointRescaleWithMixedExchangesITCase ::createMultiInputDAG ,
82
85
UnalignedCheckpointRescaleWithMixedExchangesITCase ::createRescalePartitionerDAG ,
83
- UnalignedCheckpointRescaleWithMixedExchangesITCase ::createMixedComplexityDAG );
86
+ UnalignedCheckpointRescaleWithMixedExchangesITCase ::createMixedComplexityDAG ,
87
+ UnalignedCheckpointRescaleWithMixedExchangesITCase ::createPartEmptyHashExchangeDAG );
84
88
}
85
89
86
90
@ Before
@@ -137,6 +141,7 @@ private StreamExecutionEnvironment getUnalignedCheckpointEnv(@Nullable String re
137
141
conf .set (CheckpointingOptions .CHECKPOINTING_INTERVAL , Duration .ofSeconds (1 ));
138
142
// Disable aligned timeout to ensure it works with unaligned checkpoint directly
139
143
conf .set (CheckpointingOptions .ALIGNED_CHECKPOINT_TIMEOUT , Duration .ofSeconds (0 ));
144
+ conf .set (RestartStrategyOptions .RESTART_STRATEGY , NO_RESTART_STRATEGY .getMainValue ());
140
145
conf .set (
141
146
CheckpointingOptions .EXTERNALIZED_CHECKPOINT_RETENTION ,
142
147
ExternalizedCheckpointRetention .RETAIN_ON_CANCELLATION );
@@ -336,6 +341,53 @@ private static JobClient createMixedComplexityDAG(StreamExecutionEnvironment env
336
341
return env .executeAsync ();
337
342
}
338
343
344
+ /**
345
+ * Creates a DAG where the downstream MapAfterKeyBy task receives input from two hash exchanges:
346
+ * one with actual data and one that is empty due to filtering. This tests unaligned checkpoint
347
+ * rescaling with mixed empty and non-empty hash partitions.
348
+ */
349
+ private static JobClient createPartEmptyHashExchangeDAG (StreamExecutionEnvironment env )
350
+ throws Exception {
351
+ int source1Parallelism = getRandomParallelism ();
352
+ DataGeneratorSource <Long > source1 =
353
+ new DataGeneratorSource <>(
354
+ index -> index ,
355
+ Long .MAX_VALUE ,
356
+ RateLimiterStrategy .perSecond (5000 ),
357
+ Types .LONG );
358
+ DataStream <Long > sourceStream1 =
359
+ env .fromSource (source1 , WatermarkStrategy .noWatermarks (), "Source 1" )
360
+ .setParallelism (source1Parallelism );
361
+
362
+ int source2Parallelism = getRandomParallelism ();
363
+ DataGeneratorSource <Long > source2 =
364
+ new DataGeneratorSource <>(
365
+ index -> index ,
366
+ Long .MAX_VALUE ,
367
+ RateLimiterStrategy .perSecond (5000 ),
368
+ Types .LONG );
369
+
370
+ // Filter all records to simulate empty state exchange
371
+ DataStream <Long > sourceStream2 =
372
+ env .fromSource (source2 , WatermarkStrategy .noWatermarks (), "Source 2" )
373
+ .setParallelism (source2Parallelism )
374
+ .filter (value -> false )
375
+ .setParallelism (source2Parallelism );
376
+
377
+ sourceStream1
378
+ .union (sourceStream2 )
379
+ .keyBy ((KeySelector <Long , Long >) value -> value )
380
+ .map (
381
+ x -> {
382
+ Thread .sleep (5 );
383
+ return x ;
384
+ })
385
+ .name ("MapAfterKeyBy" )
386
+ .setParallelism (getRandomParallelism ());
387
+
388
+ return env .executeAsync ();
389
+ }
390
+
339
391
private static int getRandomParallelism () {
340
392
return RANDOM .nextInt (MAX_SLOTS ) + 1 ;
341
393
}
0 commit comments