This is an automated email from the ASF dual-hosted git repository.

amashenkov pushed a commit to branch ignite-19499
in repository https://gitbox.apache.org/repos/asf/ignite-3.git


The following commit(s) were added to refs/heads/ignite-19499 by this push:
     new c7d0c89dde wip.
c7d0c89dde is described below

commit c7d0c89dde4ef2cd658d000f90ae90201e4494af
Author: amashenkov <andrey.mashen...@gmail.com>
AuthorDate: Wed Aug 30 17:35:31 2023 +0300

    wip.
---
 .../internal/table/distributed/TableManager.java   | 43 +++++++++++++---------
 1 file changed, 25 insertions(+), 18 deletions(-)

diff --git 
a/modules/table/src/main/java/org/apache/ignite/internal/table/distributed/TableManager.java
 
b/modules/table/src/main/java/org/apache/ignite/internal/table/distributed/TableManager.java
index cb0797d361..5ff2062f40 100644
--- 
a/modules/table/src/main/java/org/apache/ignite/internal/table/distributed/TableManager.java
+++ 
b/modules/table/src/main/java/org/apache/ignite/internal/table/distributed/TableManager.java
@@ -1803,7 +1803,7 @@ public class TableManager extends Producer<TableEvent, 
TableEventParameters> imp
      * Return actual table id by given name or {@code null} if table doesn't 
exist.
      * TODO IGNITE-19499: Use id from Catalog here.
      *
-     * @param tableName Table name
+     * @param tableName Table name.
      * @return Table id or {@code null} if not found.
      */
     private @Nullable Integer resolveTableName(String tableName, 
HybridTimestamp timestamp) {
@@ -1877,6 +1877,7 @@ public class TableManager extends Producer<TableEvent, 
TableEventParameters> imp
     }
 
     /** {@inheritDoc} */
+    // TODO IGNITE-19499: This blocking method should be dropped or should 
return table instantly.
     @Override
     public TableImpl table(int id) throws NodeStoppingException {
         return join(tableAsync(id));
@@ -1932,23 +1933,7 @@ public class TableManager extends Producer<TableEvent, 
TableEventParameters> imp
             throw new IgniteException(new NodeStoppingException());
         }
         try {
-            HybridTimestamp now = clock.now();
-
-            return schemaSyncService.waitForMetadataCompleteness(now)
-                    .thenComposeAsync(ignore -> {
-                        // Here we are sure metadata is actual.
-                        // Thus, TableManager can return ready table instance 
or ensure no table exists.
-
-                        // TODO IGNITE-19499: Here, catalog descriptor 
existence is equal to table existence.
-                        //  let's try to avoid getting `tableReadyFuture`: 
e.g. do fast-return if TableImpl is available somehow,
-                        //  or uncomment the check to fail-fast.
-                        // if (catalogManager.table(id, now.longValue()) == 
null) {
-                        //    return completedFuture(null);
-                        // }
-
-                        // But we may need to wait for table initialization.
-                        return tableReadyFuture(id, true);
-                    }, ioExecutor);
+            return tableAsyncInternal(id);
         } finally {
             busyLock.leaveBusy();
         }
@@ -2014,6 +1999,28 @@ public class TableManager extends Producer<TableEvent, 
TableEventParameters> imp
         }
     }
 
+    /**
+     * Gets a table by id, if it was created before.
+     *
+     * @param tableId Table id.
+     * @return Future representing pending completion of the {@code 
TableManager#tableAsyncInternal} operation.
+     */
+    public CompletableFuture<TableImpl> tableAsyncInternal(int tableId) {
+        HybridTimestamp now = clock.now();
+
+        return schemaSyncService.waitForMetadataCompleteness(now)
+                .thenComposeAsync(ignore -> {
+                    // Here we are sure metadata is actual.
+                    if (catalogService.table(tableId, now.longValue()) == 
null) {
+                        return completedFuture(null);
+                    }
+
+                    // But we may need to wait for table initialization.
+                    return tableReadyFuture(tableId, true);
+                }, ioExecutor);
+    }
+
+
     /**
      * Internal method for getting table by id, without awaiting for actual 
metadata.
      *

Reply via email to