Search in sources :

Example 1 with SequenceNumberRange

use of org.apache.flink.runtime.state.changelog.SequenceNumberRange in project flink by apache.

the class FsStateChangelogWriter method persistInternal.

private CompletableFuture<ChangelogStateHandleStreamImpl> persistInternal(SequenceNumber from) throws IOException {
    synchronized (lock) {
        ensureCanPersist(from);
        rollover();
        Map<SequenceNumber, StateChangeSet> toUpload = drainTailMap(notUploaded, from);
        NavigableMap<SequenceNumber, UploadResult> readyToReturn = uploaded.tailMap(from, true);
        LOG.debug("collected readyToReturn: {}, toUpload: {}", readyToReturn, toUpload);
        SequenceNumberRange range = SequenceNumberRange.generic(from, activeSequenceNumber);
        if (range.size() == readyToReturn.size()) {
            checkState(toUpload.isEmpty());
            return completedFuture(buildHandle(keyGroupRange, readyToReturn, 0L));
        } else {
            CompletableFuture<ChangelogStateHandleStreamImpl> future = new CompletableFuture<>();
            uploadCompletionListeners.add(new UploadCompletionListener(keyGroupRange, range, readyToReturn, future));
            if (!toUpload.isEmpty()) {
                uploader.upload(new UploadTask(toUpload.values(), this::handleUploadSuccess, this::handleUploadFailure));
            }
            return future;
        }
    }
}
Also used : ChangelogStateHandleStreamImpl(org.apache.flink.runtime.state.changelog.ChangelogStateHandleStreamImpl) CompletableFuture(java.util.concurrent.CompletableFuture) UploadTask(org.apache.flink.changelog.fs.StateChangeUploader.UploadTask) SequenceNumberRange(org.apache.flink.runtime.state.changelog.SequenceNumberRange) SequenceNumber(org.apache.flink.runtime.state.changelog.SequenceNumber)

Aggregations

CompletableFuture (java.util.concurrent.CompletableFuture)1 UploadTask (org.apache.flink.changelog.fs.StateChangeUploader.UploadTask)1 ChangelogStateHandleStreamImpl (org.apache.flink.runtime.state.changelog.ChangelogStateHandleStreamImpl)1 SequenceNumber (org.apache.flink.runtime.state.changelog.SequenceNumber)1 SequenceNumberRange (org.apache.flink.runtime.state.changelog.SequenceNumberRange)1