rkhachatryan commented on code in PR #19441: URL: https://github.com/apache/flink/pull/19441#discussion_r856152839
########## flink-dstl/flink-dstl-dfs/src/test/java/org/apache/flink/changelog/fs/ChangelogStorageMetricsTest.java: ########## @@ -295,6 +346,55 @@ public void close() { } } + private static class WaitingMaxAttemptUploader implements StateChangeUploader { + private final ConcurrentHashMap<UploadTask, CountDownLatch> remainingAttemptsPerTask; + private final int maxAttempts; + + public WaitingMaxAttemptUploader(int maxAttempts) { + if (maxAttempts < 1) { + throw new IllegalArgumentException("maxAttempts < 0"); + } + this.maxAttempts = maxAttempts; + this.remainingAttemptsPerTask = new ConcurrentHashMap<>(); + } + + @Override + public UploadTasksResult upload(Collection<UploadTask> tasks) throws IOException { + + for (UploadTask uploadTask : tasks) { + CountDownLatch remainingAttempts = remainingAttemptsPerTask.get(uploadTask); + if (remainingAttempts == null) { + remainingAttempts = new CountDownLatch(maxAttempts - 1); + remainingAttemptsPerTask.put(uploadTask, remainingAttempts); + } else { + remainingAttempts.countDown(); + } + } + for (UploadTask uploadTask : tasks) { + CountDownLatch remainingAttempts = remainingAttemptsPerTask.get(uploadTask); + try { + remainingAttempts.await(); Review Comment: You're right, completing first and last attempts sounds good. -- 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: issues-unsubscr...@flink.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org