ibessonov commented on code in PR #1011:
URL: https://github.com/apache/ignite-3/pull/1011#discussion_r946669048


##########
modules/storage-rocksdb/src/main/java/org/apache/ignite/internal/storage/rocksdb/RocksDbTableStorage.java:
##########
@@ -223,10 +232,63 @@ public void start() throws StorageException {
         }
     }
 
+    /**
+     * Returns a future to wait next flush operation from the current point in 
time. Uses {@link RocksDB#getLatestSequenceNumber()} to
+     * achieve this.
+     *
+     * @param schedule {@code true} if {@link RocksDB#flush(FlushOptions)} 
should be explicitly triggerred in the near future.
+     *
+     * @see #scheduleFlush()
+     */
+    public CompletableFuture<Void> awaitFlush(boolean schedule) {
+        CompletableFuture<Void> future;
+
+        long dbSequenceNumber = db.getLatestSequenceNumber();
+
+        synchronized (this) {

Review Comment:
   Laziness



##########
modules/storage-rocksdb/src/main/java/org/apache/ignite/internal/storage/rocksdb/RocksDbTableStorage.java:
##########
@@ -223,10 +232,63 @@ public void start() throws StorageException {
         }
     }
 
+    /**
+     * Returns a future to wait next flush operation from the current point in 
time. Uses {@link RocksDB#getLatestSequenceNumber()} to
+     * achieve this.
+     *
+     * @param schedule {@code true} if {@link RocksDB#flush(FlushOptions)} 
should be explicitly triggerred in the near future.
+     *
+     * @see #scheduleFlush()
+     */
+    public CompletableFuture<Void> awaitFlush(boolean schedule) {
+        CompletableFuture<Void> future;
+
+        long dbSequenceNumber = db.getLatestSequenceNumber();
+
+        synchronized (this) {
+            if (dbSequenceNumber <= latestPersistedSequenceNumber) {
+                return CompletableFuture.completedFuture(null);
+            }
+
+            future = 
flushFuturesBySequenceNumber.computeIfAbsent(dbSequenceNumber, l -> new 
CompletableFuture<>());
+        }
+
+        if (schedule) {
+            scheduleFlush();
+        }
+
+        return future;
+    }
+
+    /**
+     * Completes all futures in {@link #flushFuturesBySequenceNumber} up to a 
given sequence number.
+     */
+    void completeFutures(long sequenceNumber) {
+        synchronized (this) {

Review Comment:
   Same reason



-- 
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]

Reply via email to