tkalkirill commented on code in PR #2783:
URL: https://github.com/apache/ignite-3/pull/2783#discussion_r1381577541


##########
modules/index/src/main/java/org/apache/ignite/internal/index/IndexAvailabilityController.java:
##########
@@ -130,6 +150,31 @@ public void close() {
         busyLock.block();
     }
 
+    /**
+     * Recovers index availability on node recovery.
+     *
+     * @param recoveryRevision Metastore revision on recovery.
+     * @return Future of recovery execution.
+     */
+    public CompletableFuture<Void> recover(long recoveryRevision) {
+        return inBusyLockAsync(busyLock, () -> {
+            // It is expected that the method will only be called on recovery, 
when the deploy of metastore watches has not yet occurred.
+            int catalogVersion = catalogManager.latestCatalogVersion();
+
+            List<CompletableFuture<?>> futures = 
catalogManager.indexes(catalogVersion).stream()
+                    .map(indexDescriptor -> {
+                        if (indexDescriptor.available()) {
+                            return 
recoveryForAvailableIndexBusy(indexDescriptor, recoveryRevision);
+                        } else {
+                            return 
recoveryForRegisteredIndexBusy(indexDescriptor, recoveryRevision, 
catalogVersion);
+                        }
+                    })
+                    .collect(toList());
+
+            return allOf(futures.toArray(CompletableFuture[]::new));

Review Comment:
   I think it’s right to wait for the metastore update to complete, but not for 
the change to be applied, of course.



##########
modules/index/src/main/java/org/apache/ignite/internal/index/IndexAvailabilityController.java:
##########
@@ -130,6 +150,31 @@ public void close() {
         busyLock.block();
     }
 
+    /**
+     * Recovers index availability on node recovery.
+     *
+     * @param recoveryRevision Metastore revision on recovery.
+     * @return Future of recovery execution.
+     */
+    public CompletableFuture<Void> recover(long recoveryRevision) {
+        return inBusyLockAsync(busyLock, () -> {
+            // It is expected that the method will only be called on recovery, 
when the deploy of metastore watches has not yet occurred.
+            int catalogVersion = catalogManager.latestCatalogVersion();
+
+            List<CompletableFuture<?>> futures = 
catalogManager.indexes(catalogVersion).stream()
+                    .map(indexDescriptor -> {
+                        if (indexDescriptor.available()) {
+                            return 
recoveryForAvailableIndexBusy(indexDescriptor, recoveryRevision);
+                        } else {
+                            return 
recoveryForRegisteredIndexBusy(indexDescriptor, recoveryRevision, 
catalogVersion);
+                        }
+                    })
+                    .collect(toList());
+
+            return allOf(futures.toArray(CompletableFuture[]::new));

Review Comment:
   I think it’s right to wait for the metastore update to complete, but not for 
the change to be applied, of course.



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