ferenc-csaky commented on code in PR #28926:
URL: https://github.com/apache/flink/pull/28926#discussion_r3802945357
##########
flink-runtime/src/test/java/org/apache/flink/runtime/io/network/partition/hybrid/tiered/file/ProducerMergedPartitionFileIndexTest.java:
##########
@@ -68,6 +75,59 @@ void testAddBufferAndGetRegion() {
assertThat(numExpectedRegions).isEqualTo(numGetRegions);
}
+ @Test
+ @Timeout(60)
+ void testConcurrentPartitionFileIndexes() throws Exception {
+ ProducerMergedPartitionFileIndex firstIndex = createIndex(".index-1");
+ ProducerMergedPartitionFileIndex secondIndex = createIndex(".index-2");
+ ExecutorService executor = Executors.newFixedThreadPool(2);
+ final int numIterations = 10_000;
+
+ try {
+ Future<Void> firstTask =
+ executor.submit(() -> repeatedlySpillAndRead(firstIndex,
numIterations));
+ Future<Void> secondTask =
+ executor.submit(() -> repeatedlySpillAndRead(secondIndex,
numIterations));
+
+ firstTask.get();
+ secondTask.get();
+ } finally {
+ ExecutorUtils.gracefulShutdown(10_000L, TimeUnit.MILLISECONDS,
executor);
+ firstIndex.release();
+ secondIndex.release();
+ }
+ }
+
+ private ProducerMergedPartitionFileIndex createIndex(String fileName) {
+ return new ProducerMergedPartitionFileIndex(
+ 1, indexFilePath.resolveSibling(fileName), 256, 1);
+ }
+
+ private static Void repeatedlySpillAndRead(
+ ProducerMergedPartitionFileIndex index, int numIterations) {
+ for (int iteration = 0; iteration < numIterations; iteration++) {
+ int bufferIndex = iteration % 2 * 2;
+ index.addBuffers(
+ Collections.singletonList(
Review Comment:
nit: List.of
--
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]