You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by am...@apache.org on 2024/02/02 19:37:33 UTC

(ignite-3) branch ignite-20680-conflicts created (now c17e273fac)

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

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


      at c17e273fac Fix test after merge with main

This branch includes the following new commits:

     new c17e273fac Fix test after merge with main

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



(ignite-3) 01/01: Fix test after merge with main

Posted by am...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit c17e273fac906bcfdedec5d99e1423025c8a5fc9
Author: amashenkov <an...@gmail.com>
AuthorDate: Fri Feb 2 22:37:19 2024 +0300

    Fix test after merge with main
---
 .../ignite/internal/index/ItIndexManagerTest.java  |  4 +-
 .../apache/ignite/internal/index/IndexManager.java | 36 ++++++---------
 .../ignite/internal/index/IndexManagerTest.java    | 54 ++++++++++++++++------
 3 files changed, 54 insertions(+), 40 deletions(-)

diff --git a/modules/index/src/integrationTest/java/org/apache/ignite/internal/index/ItIndexManagerTest.java b/modules/index/src/integrationTest/java/org/apache/ignite/internal/index/ItIndexManagerTest.java
index 5339808b74..07512e3a2f 100644
--- a/modules/index/src/integrationTest/java/org/apache/ignite/internal/index/ItIndexManagerTest.java
+++ b/modules/index/src/integrationTest/java/org/apache/ignite/internal/index/ItIndexManagerTest.java
@@ -113,8 +113,8 @@ public class ItIndexManagerTest extends ClusterPerClassIntegrationTest {
     }
 
     private static List<Integer> collectIndexIdsFromCatalogForRecovery(IgniteImpl ignite, TableImpl table) {
-        return collectIndexesForRecovery(ignite.catalogManager()).entrySet().stream()
-                .filter(e -> e.getKey().id() == table.tableId())
+        return collectIndexesForRecovery(ignite.catalogManager()).int2ObjectEntrySet().stream()
+                .filter(e -> e.getIntKey() == table.tableId())
                 .flatMap(e -> e.getValue().stream())
                 .map(CatalogObjectDescriptor::id)
                 .sorted()
diff --git a/modules/index/src/main/java/org/apache/ignite/internal/index/IndexManager.java b/modules/index/src/main/java/org/apache/ignite/internal/index/IndexManager.java
index 0fc33db90c..b4afc8e50b 100644
--- a/modules/index/src/main/java/org/apache/ignite/internal/index/IndexManager.java
+++ b/modules/index/src/main/java/org/apache/ignite/internal/index/IndexManager.java
@@ -23,20 +23,18 @@ import static java.util.concurrent.CompletableFuture.failedFuture;
 import static java.util.stream.Collectors.toMap;
 import static org.apache.ignite.internal.catalog.events.CatalogEvent.INDEX_CREATE;
 import static org.apache.ignite.internal.catalog.events.CatalogEvent.INDEX_REMOVED;
-import static org.apache.ignite.internal.catalog.events.CatalogEvent.INDEX_STOPPING;
-import static org.apache.ignite.internal.util.CompletableFutures.falseCompletedFuture;
 import static org.apache.ignite.internal.util.CompletableFutures.nullCompletedFuture;
 import static org.apache.ignite.internal.util.IgniteUtils.inBusyLock;
 import static org.apache.ignite.internal.util.IgniteUtils.inBusyLockAsync;
 
 import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
+import it.unimi.dsi.fastutil.ints.Int2ObjectMap.Entry;
 import it.unimi.dsi.fastutil.ints.Int2ObjectMaps;
 import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.List;
 import java.util.Map;
-import java.util.Map.Entry;
 import java.util.concurrent.CompletableFuture;
 import java.util.concurrent.atomic.AtomicBoolean;
 import java.util.function.BiFunction;
@@ -44,6 +42,7 @@ import java.util.function.Consumer;
 import java.util.function.Function;
 import java.util.function.LongFunction;
 import org.apache.ignite.internal.catalog.CatalogManager;
+import org.apache.ignite.internal.catalog.CatalogManagerImpl;
 import org.apache.ignite.internal.catalog.CatalogService;
 import org.apache.ignite.internal.catalog.commands.RemoveIndexCommand;
 import org.apache.ignite.internal.catalog.descriptors.CatalogIndexDescriptor;
@@ -52,7 +51,6 @@ import org.apache.ignite.internal.catalog.descriptors.CatalogTableDescriptor;
 import org.apache.ignite.internal.catalog.events.CatalogEvent;
 import org.apache.ignite.internal.catalog.events.CreateIndexEventParameters;
 import org.apache.ignite.internal.catalog.events.RemoveIndexEventParameters;
-import org.apache.ignite.internal.catalog.events.StoppingIndexEventParameters;
 import org.apache.ignite.internal.causality.IncrementalVersionedValue;
 import org.apache.ignite.internal.logger.IgniteLogger;
 import org.apache.ignite.internal.logger.Loggers;
@@ -76,6 +74,7 @@ import org.apache.ignite.internal.storage.index.StorageSortedIndexDescriptor;
 import org.apache.ignite.internal.table.TableViewInternal;
 import org.apache.ignite.internal.table.distributed.PartitionSet;
 import org.apache.ignite.internal.table.distributed.TableManager;
+import org.apache.ignite.internal.util.CollectionUtils;
 import org.apache.ignite.internal.util.IgniteSpinBusyLock;
 
 /**
@@ -148,17 +147,6 @@ public class IndexManager implements IgniteComponent {
             return onIndexCreate((CreateIndexEventParameters) parameters);
         });
 
-        // TODO: IGNITE-21117 - remove this.
-        catalogManager.listen(INDEX_STOPPING, (parameters, exception) -> {
-            if (exception != null) {
-                return failedFuture(exception);
-            }
-
-            removeIndex(((StoppingIndexEventParameters) parameters).indexId());
-
-            return falseCompletedFuture();
-        });
-
         catalogManager.listen(INDEX_REMOVED, (parameters, exception) -> {
             if (exception != null) {
                 return failedFuture(exception);
@@ -358,15 +346,17 @@ public class IndexManager implements IgniteComponent {
 
         List<CompletableFuture<?>> startIndexFutures = new ArrayList<>();
 
-        Map<CatalogTableDescriptor, Collection<CatalogIndexDescriptor>> indexesForRecovery = collectIndexesForRecovery(catalogManager);
-        for (Entry<CatalogTableDescriptor, Collection<CatalogIndexDescriptor>> e : indexesForRecovery.entrySet()) {
-            CatalogTableDescriptor table = e.getKey();
+        int catalogVersion = catalogManager.latestCatalogVersion();
+
+        Int2ObjectMap<Collection<CatalogIndexDescriptor>> indexesForRecovery = collectIndexesForRecovery(catalogManager);
+        for (Int2ObjectMap.Entry<Collection<CatalogIndexDescriptor>> e : indexesForRecovery.int2ObjectEntrySet()) {
+            CatalogTableDescriptor table = catalogManager.table(e.getIntKey(), catalogVersion);
 
             for (CatalogIndexDescriptor index : e.getValue()) {
                 // TODO: IGNITE-21117 - remove this.
                 if (index.status() == CatalogIndexStatus.STOPPING
-                        && catalogManager.index(index.id(), catalogManager.latestCatalogVersion()) != null) {
-                    startIndexFutures.add(removeIndex(index.id()));
+                        && catalogManager.index(index.id(), catalogVersion) != null) {
+                    // startIndexFutures.add(removeIndex(index.id()));
                 }
 
                 startIndexFutures.add(startIndexAsync(table, index, causalityToken));
@@ -500,7 +490,7 @@ public class IndexManager implements IgniteComponent {
      *
      * @param catalogService Catalog service.
      */
-    static Map<CatalogTableDescriptor, Collection<CatalogIndexDescriptor>> collectIndexesForRecovery(CatalogService catalogService) {
+    static Int2ObjectMap<Collection<CatalogIndexDescriptor>> collectIndexesForRecovery(CatalogService catalogService) {
         int earliestCatalogVersion = catalogService.earliestCatalogVersion();
         int latestCatalogVersion = catalogService.latestCatalogVersion();
 
@@ -522,8 +512,8 @@ public class IndexManager implements IgniteComponent {
 
         return indexesByTableId.int2ObjectEntrySet()
                 .stream()
-                .collect(toMap(
-                        entry -> catalogService.table(entry.getIntKey(), latestCatalogVersion),
+                .collect(CollectionUtils.toIntMapCollector(
+                        Entry::getIntKey,
                         entry -> entry.getValue().values()
                 ));
     }
diff --git a/modules/index/src/test/java/org/apache/ignite/internal/index/IndexManagerTest.java b/modules/index/src/test/java/org/apache/ignite/internal/index/IndexManagerTest.java
index 435f5ca7cf..4a319b88c8 100644
--- a/modules/index/src/test/java/org/apache/ignite/internal/index/IndexManagerTest.java
+++ b/modules/index/src/test/java/org/apache/ignite/internal/index/IndexManagerTest.java
@@ -60,6 +60,7 @@ import static org.mockito.Mockito.times;
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
 
+import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
 import java.nio.file.Path;
 import java.util.ArrayList;
 import java.util.Collection;
@@ -212,12 +213,35 @@ public class IndexManagerTest extends BaseIgniteAbstractTest {
     }
 
     @Test
-    void testDontUnregisterIndexOnCatalogEventIndexDrop() {
+    void testUnregisterNonReadyIndexOnCatalogEventIndexDrop() {
         createIndex(TABLE_NAME, INDEX_NAME);
         dropIndex(INDEX_NAME);
 
         TableViewInternal tableViewInternal = tableViewInternalByTableId.get(tableId());
 
+        verify(tableViewInternal).unregisterIndex(anyInt());
+    }
+
+    @Test
+    void testUnregisterBuildingIndexOnCatalogEventIndexDrop() {
+        createIndex(TABLE_NAME, INDEX_NAME);
+        startBuildingIndex(INDEX_NAME);
+        dropIndex(INDEX_NAME);
+
+        TableViewInternal tableViewInternal = tableViewInternalByTableId.get(tableId());
+
+        verify(tableViewInternal).unregisterIndex(anyInt());
+    }
+
+    @Test
+    void testDontUnregisterAvailableIndexOnCatalogEventIndexDrop() {
+        createIndex(TABLE_NAME, INDEX_NAME);
+        startBuildingIndex(INDEX_NAME);
+        makeIndexAvailable(INDEX_NAME);
+        dropIndex(INDEX_NAME);
+
+        TableViewInternal tableViewInternal = tableViewInternalByTableId.get(tableId());
+
         verify(tableViewInternal, never()).unregisterIndex(anyInt());
     }
 
@@ -252,18 +276,18 @@ public class IndexManagerTest extends BaseIgniteAbstractTest {
     void testCollectIndexesForRecoveryForCreatedTables() {
         createTable(OTHER_TABLE_NAME);
 
-        Map<CatalogTableDescriptor, Collection<CatalogIndexDescriptor>> collectedIndexes = collectIndexesForRecovery();
+        Int2ObjectMap<Collection<CatalogIndexDescriptor>> collectedIndexes = collectIndexesForRecovery();
 
         int latestCatalogVersion = catalogManager.latestCatalogVersion();
 
         CatalogTableDescriptor table = table(latestCatalogVersion, TABLE_NAME);
         CatalogTableDescriptor otherTable = table(latestCatalogVersion, OTHER_TABLE_NAME);
 
-        assertThat(collectedIndexes, hasKey(table));
-        assertThat(collectedIndexes, hasKey(otherTable));
+        assertThat(collectedIndexes, hasKey(table.id()));
+        assertThat(collectedIndexes, hasKey(otherTable.id()));
 
-        assertThat(collectedIndexes.get(table), hasItems(index(latestCatalogVersion, PK_INDEX_NAME)));
-        assertThat(collectedIndexes.get(otherTable), hasItems(index(latestCatalogVersion, PK_INDEX_NAME_OTHER_TABLE)));
+        assertThat(collectedIndexes.get(table.id()), hasItems(index(latestCatalogVersion, PK_INDEX_NAME)));
+        assertThat(collectedIndexes.get(otherTable.id()), hasItems(index(latestCatalogVersion, PK_INDEX_NAME_OTHER_TABLE)));
     }
 
     @Test
@@ -298,18 +322,18 @@ public class IndexManagerTest extends BaseIgniteAbstractTest {
         List<CatalogIndexDescriptor> droppedIndexes = dropIndexes(indexName1, indexName2);
         List<CatalogIndexDescriptor> droppedIndexesOtherTable = dropIndexes(indexNameOtherTable0, indexNameOtherTable1);
 
-        Map<CatalogTableDescriptor, Collection<CatalogIndexDescriptor>> collectedIndexes = collectIndexesForRecovery();
+        Int2ObjectMap<Collection<CatalogIndexDescriptor>> collectedIndexes = collectIndexesForRecovery();
 
         int latestCatalogVersion = catalogManager.latestCatalogVersion();
 
         CatalogTableDescriptor table = table(latestCatalogVersion, TABLE_NAME);
         CatalogTableDescriptor otherTable = table(latestCatalogVersion, OTHER_TABLE_NAME);
 
-        assertThat(collectedIndexes, hasKey(table));
-        assertThat(collectedIndexes, hasKey(otherTable));
+        assertThat(collectedIndexes, hasKey(table.id()));
+        assertThat(collectedIndexes, hasKey(otherTable.id()));
 
         assertThat(
-                collectedIndexes.get(table),
+                collectedIndexes.get(table.id()),
                 hasItems(
                         index(latestCatalogVersion, PK_INDEX_NAME),
                         index(latestCatalogVersion, indexName0),
@@ -321,7 +345,7 @@ public class IndexManagerTest extends BaseIgniteAbstractTest {
         );
 
         assertThat(
-                collectedIndexes.get(otherTable),
+                collectedIndexes.get(otherTable.id()),
                 hasItems(
                         index(latestCatalogVersion, PK_INDEX_NAME_OTHER_TABLE),
                         index(latestCatalogVersion, indexNameOtherTable2),
@@ -338,12 +362,12 @@ public class IndexManagerTest extends BaseIgniteAbstractTest {
         createTable(OTHER_TABLE_NAME);
         dropTable(OTHER_TABLE_NAME);
 
-        Map<CatalogTableDescriptor, Collection<CatalogIndexDescriptor>> collectedIndexes = collectIndexesForRecovery();
+        Int2ObjectMap<Collection<CatalogIndexDescriptor>> collectedIndexes = collectIndexesForRecovery();
 
         CatalogTableDescriptor table = table(catalogManager.latestCatalogVersion(), TABLE_NAME);
 
         assertThat(collectedIndexes, aMapWithSize(1));
-        assertThat(collectedIndexes, hasKey(table));
+        assertThat(collectedIndexes, hasKey(table.id()));
     }
 
     @Test
@@ -378,7 +402,7 @@ public class IndexManagerTest extends BaseIgniteAbstractTest {
 
         assertThat(
                 captor.getAllValues().stream().map(StorageHashIndexDescriptor::id).sorted().collect(toList()),
-                equalTo(collectIndexesForRecovery().get(table).stream().map(CatalogObjectDescriptor::id).sorted().collect(toList()))
+                equalTo(collectIndexesForRecovery().get(table.id()).stream().map(CatalogObjectDescriptor::id).sorted().collect(toList()))
         );
     }
 
@@ -514,7 +538,7 @@ public class IndexManagerTest extends BaseIgniteAbstractTest {
         return res;
     }
 
-    private Map<CatalogTableDescriptor, Collection<CatalogIndexDescriptor>> collectIndexesForRecovery() {
+    private Int2ObjectMap<Collection<CatalogIndexDescriptor>> collectIndexesForRecovery() {
         return IndexManager.collectIndexesForRecovery(catalogManager);
     }
 }