You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ignite.apache.org by "AMashenkov (via GitHub)" <gi...@apache.org> on 2024/03/01 17:51:23 UTC

[PR] Make LWM top level component [ignite-3]

AMashenkov opened a new pull request, #3340:
URL: https://github.com/apache/ignite-3/pull/3340

   https://issues.apache.org/jira/browse/IGNITE-21658
   Minor LowWatermark refactoring.
   
   
   Thank you for submitting the pull request.
   
   To streamline the review process of the patch and ensure better code quality
   we ask both an author and a reviewer to verify the following:
   
   ### The Review Checklist
   - [ ] **Formal criteria:** TC status, codestyle, mandatory documentation. Also make sure to complete the following:  
   \- There is a single JIRA ticket related to the pull request.  
   \- The web-link to the pull request is attached to the JIRA ticket.  
   \- The JIRA ticket has the Patch Available state.  
   \- The description of the JIRA ticket explains WHAT was made, WHY and HOW.  
   \- The pull request title is treated as the final commit message. The following pattern must be used: IGNITE-XXXX Change summary where XXXX - number of JIRA issue.
   - [ ] **Design:** new code conforms with the design principles of the components it is added to.
   - [ ] **Patch quality:** patch cannot be split into smaller pieces, its size must be reasonable.
   - [ ] **Code quality:** code is clean and readable, necessary developer documentation is added if needed.
   - [ ] **Tests code quality:** test set covers positive/negative scenarios, happy/edge cases. Tests are effective in terms of execution time and resources.
   
   ### Notes
   - [Apache Ignite Coding Guidelines](https://cwiki.apache.org/confluence/display/IGNITE/Java+Code+Style+Guide)


-- 
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: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] IGNITE-21658 Make LowWatermark a top level component [ignite-3]

Posted by "sashapolo (via GitHub)" <gi...@apache.org>.
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: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] IGNITE-21658 Make LowWatermark a top level component [ignite-3]

Posted by "AMashenkov (via GitHub)" <gi...@apache.org>.
AMashenkov commented on code in PR #3340:
URL: https://github.com/apache/ignite-3/pull/3340#discussion_r1510942518


##########
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:
   LowWatermark produces a single event type, while EventProducer supports multiple types.
   EventProducer requires creating a enum for Event type, an Event class for event objects, which provides a factory method for EventParameters. All this stuff is required just for passing a HybridTimestamp.
   I think DRY principle is overkill here?
   



-- 
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: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] IGNITE-21658 Make LowWatermark a top level component [ignite-3]

Posted by "AMashenkov (via GitHub)" <gi...@apache.org>.
AMashenkov commented on code in PR #3340:
URL: https://github.com/apache/ignite-3/pull/3340#discussion_r1510971144


##########
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:
   Fixed.



-- 
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: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] IGNITE-21658 Make LowWatermark a top level component [ignite-3]

Posted by "AMashenkov (via GitHub)" <gi...@apache.org>.
AMashenkov merged PR #3340:
URL: https://github.com/apache/ignite-3/pull/3340


-- 
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: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] IGNITE-21658 Make LowWatermark a top level component [ignite-3]

Posted by "sashapolo (via GitHub)" <gi...@apache.org>.
sashapolo commented on code in PR #3340:
URL: https://github.com/apache/ignite-3/pull/3340#discussion_r1511002950


##########
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:
   Makes sense



-- 
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: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org