AMashenkov commented on code in PR #2254:
URL: https://github.com/apache/ignite-3/pull/2254#discussion_r1261208386


##########
modules/index/src/main/java/org/apache/ignite/internal/index/IndexManager.java:
##########
@@ -108,226 +111,164 @@ public class IndexManager extends Producer<IndexEvent, 
IndexEventParameters> imp
      * @param tablesCfg Tables and indexes configuration.
      * @param schemaManager Schema manager.
      * @param tableManager Table manager.
+     * @param catalogManager Catalog manager.
      */
     public IndexManager(
             TablesConfiguration tablesCfg,
             SchemaManager schemaManager,
-            TableManager tableManager
+            TableManager tableManager,
+            CatalogManager catalogManager
     ) {
         this.tablesCfg = Objects.requireNonNull(tablesCfg, "tablesCfg");
         this.schemaManager = Objects.requireNonNull(schemaManager, 
"schemaManager");
         this.tableManager = tableManager;
+        this.catalogManager = catalogManager;
     }
 
-    /** {@inheritDoc} */
     @Override
     public void start() {
-        LOG.debug("Index manager is about to start");
+        if (LOG.isDebugEnabled()) {
+            LOG.debug("Index manager is about to start");
+        }
 
-        tablesCfg.indexes().listenElements(new ConfigurationListener());
+        catalogManager.listen(INDEX_CREATE, (parameters, exception) -> {
+            assert exception == null;
 
-        tableManager.listen(TableEvent.CREATE, (param, ex) -> {
-            if (ex != null) {
-                return completedFuture(false);
-            }
+            return onIndexCreate((CreateIndexEventParameters) parameters);
+        });
 
-            // We can't return this future as the listener's result, because a 
deadlock can happen in the configuration component:
-            // this listener is called inside a configuration notification 
thread and all notifications are required to finish before
-            // new configuration modifications can occur (i.e. we are creating 
an index below). Therefore we create the index fully
-            // asynchronously and rely on the underlying components to handle 
PK index synchronisation.
-            tableManager.tableAsync(param.causalityToken(), param.tableId())
-                    .thenCompose(table -> {
-                        String[] pkColumns = 
Arrays.stream(table.schemaView().schema().keyColumns().columns())
-                                .map(Column::name)
-                                .toArray(String[]::new);
-
-                        String pkName = table.name() + "_PK";
-
-                        return createIndexAsync("PUBLIC", pkName, 
table.name(), false,
-                                change -> 
change.changeUniq(true).convert(HashIndexChange.class)
-                                        .changeColumnNames(pkColumns)
-                        );
-                    })
-                    .whenComplete((v, e) -> {
-                        if (e != null) {
-                            LOG.error("Error when creating index: " + e);
-                        }
-                    });
+        catalogManager.listen(INDEX_DROP, (parameters, exception) -> {
+            assert exception == null;
 
-            return completedFuture(false);
+            return onIndexDrop((DropIndexEventParameters) parameters);
         });
 
-        LOG.info("Index manager started");
+        if (LOG.isInfoEnabled()) {
+            LOG.info("Index manager started");
+        }

Review Comment:
   Log level is checked in the call in depth.



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