sashapolo commented on code in PR #3340:
URL: https://github.com/apache/ignite-3/pull/3340#discussion_r1510897644
##########
modules/table/src/main/java/org/apache/ignite/internal/table/distributed/LowWatermark.java:
##########
@@ -131,17 +140,15 @@ public void start() {
LOG.info(
"Low watermark has been successfully retrieved from the
vault and is scheduled to be updated: {}",
Review Comment:
This logging message is not 100% correct anymore, we should probably
rephrase it
##########
modules/runner/src/main/java/org/apache/ignite/internal/app/IgniteImpl.java:
##########
@@ -1035,6 +1042,9 @@ public CompletableFuture<Ignite> start(Path configPath) {
.thenComposeAsync(ignored ->
awaitSelfInLocalLogicalTopology(), startupExecutor)
.thenRunAsync(() -> {
try {
+ // Enable watermark events.
+ lifecycleManager.startComponent(lowWatermark);
Review Comment:
I would suggest to rework this component's API a little bit, current
approach is confusing to me.
1. Make `LowWatermark#start` method perform the recovery instead of
`recoverFromVault`.
2. Add a `LowWatermark#scheduleUpdates` to enable the LW updates.
##########
modules/table/src/main/java/org/apache/ignite/internal/table/distributed/LowWatermarkChangedListener.java:
##########
@@ -0,0 +1,37 @@
+/*
+ * 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.ignite.internal.table.distributed;
+
+import java.util.concurrent.CompletableFuture;
+import org.apache.ignite.internal.hlc.HybridTimestamp;
+
+/**
+ * LWM event listener interface.
+ *
+ * @see LowWatermark
+ */
+@FunctionalInterface
+public interface LowWatermarkChangedListener {
+ /**
+ * Low watermark changed callback.
+ *
+ * @param ts New low watermark.
+ * @return A future, which completes when event sill be processed.
Review Comment:
```suggestion
* @return A future, which completes after the event has been processed.
```
##########
modules/table/src/main/java/org/apache/ignite/internal/table/distributed/LowWatermark.java:
##########
@@ -68,15 +72,15 @@ public class LowWatermark implements ManuallyCloseable {
private final VaultManager vaultManager;
- private final MvGc mvGc;
+ private final List<LowWatermarkChangedListener> updateListeners = new
CopyOnWriteArrayList<>();
Review Comment:
We already have the `EventProducer` mechansim, can we reuse it here?
##########
modules/table/src/main/java/org/apache/ignite/internal/table/distributed/LowWatermark.java:
##########
@@ -131,17 +140,15 @@ public void start() {
LOG.info(
"Low watermark has been successfully retrieved from the
vault and is scheduled to be updated: {}",
- lowWatermark
+ lowWatermarkCandidate
);
- txManager.updateLowWatermark(lowWatermark)
- .thenRun(() -> inBusyLock(busyLock, () -> {
- this.lowWatermark = lowWatermark;
-
- runGcAndScheduleUpdateLowWatermarkBusy(lowWatermark);
- }))
+ txManager.updateLowWatermark(lowWatermarkCandidate)
+ .thenCompose(unused -> inBusyLock(busyLock, () ->
notifyListeners(lowWatermarkCandidate)))
Review Comment:
`thenComposeAsync`?
--
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]