pnowojski commented on a change in pull request #14839: URL: https://github.com/apache/flink/pull/14839#discussion_r587582166
########## File path: flink-dstl/flink-dstl-dfs/src/main/java/org/apache/flink/changelog/fs/BatchingStateChangeStore.java ########## @@ -0,0 +1,153 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.flink.changelog.fs; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.Collection; +import java.util.concurrent.ArrayBlockingQueue; +import java.util.concurrent.BlockingQueue; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.atomic.AtomicBoolean; + +import static java.util.concurrent.TimeUnit.MILLISECONDS; +import static java.util.concurrent.TimeUnit.SECONDS; +import static org.apache.flink.util.ExceptionUtils.findThrowable; +import static org.apache.flink.util.ExceptionUtils.rethrow; + +/** + * A {@link StateChangeStore} that waits for some configured amount of time before passing the + * accumulated state changes to the actual store. + */ +class BatchingStateChangeStore implements StateChangeStore { + private static final Logger LOG = LoggerFactory.getLogger(BatchingStateChangeStore.class); + + private final ScheduledExecutorService scheduler; + private final long scheduleDelayMs; + private final BlockingQueue<StateChangeSet> scheduled; + private final AtomicBoolean drainScheduled; + private final RetryPolicy retryPolicy; + private volatile Throwable error; Review comment: (`ArrayBlockingQueue` hides one lock. `AtomicBoolean` and `volatile Throwable` were two other volatiles complicating reasoning) ---------------------------------------------------------------- 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. For queries about this service, please contact Infrastructure at: [email protected]
