xtern commented on code in PR #4042:
URL: https://github.com/apache/ignite-3/pull/4042#discussion_r1665583411


##########
modules/catalog/src/integrationTest/java/org/apache/ignite/internal/catalog/ItCatalogCompactionCoordinatorChoosingTest.java:
##########
@@ -0,0 +1,118 @@
+/*
+ * 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.catalog;
+
+import static 
org.apache.ignite.internal.testframework.IgniteTestUtils.waitForCondition;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import java.util.stream.Collectors;
+import java.util.stream.IntStream;
+import org.apache.ignite.internal.ClusterPerClassIntegrationTest;
+import org.apache.ignite.internal.app.IgniteImpl;
+import org.hamcrest.CustomMatcher;
+import org.hamcrest.Matcher;
+import org.junit.jupiter.api.Test;
+
+/**
+ * Tests to verify choosing of coordinator for catalog compaction.
+ */
+class ItCatalogCompactionCoordinatorChoosingTest extends 
ClusterPerClassIntegrationTest {
+    private static final int CLUSTER_SIZE = 5;
+    private static final int MINORITY_SIZE = (CLUSTER_SIZE - 1) / 2;
+
+    // test is sensible to count of nodes in custer
+    @Override
+    protected int initialNodes() {
+        return CLUSTER_SIZE;
+    }
+
+    @Override
+    protected int[] cmgMetastoreNodes() {
+        return IntStream.range(0, CLUSTER_SIZE).toArray();
+    }
+
+    @Test
+    void coordinatorIsChosenAfterStartAndReelectedAfterNodeCrash() throws 
Exception {
+        Set<String> coordinators = new HashSet<>();
+
+        int coordinatorHasNotBeanUpdatedCount = 0;
+        for (IgniteImpl node : runningNodes()) {
+            String coordinatorNodeId = ((CatalogManagerImpl) 
node.catalogManager()).compactionCoordinator();
+
+            if (coordinatorNodeId == null) {
+                coordinatorHasNotBeanUpdatedCount++;
+            } else {
+                coordinators.add(coordinatorNodeId);
+            }
+        }
+
+        assertThat(coordinatorHasNotBeanUpdatedCount, 
lessOrEqualTo(MINORITY_SIZE));

Review Comment:
   does it mean "not metastorage" nodes? (just to clarify)



##########
modules/catalog/src/integrationTest/java/org/apache/ignite/internal/catalog/ItCatalogCompactionCoordinatorChoosingTest.java:
##########
@@ -0,0 +1,118 @@
+/*
+ * 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.catalog;
+
+import static 
org.apache.ignite.internal.testframework.IgniteTestUtils.waitForCondition;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import java.util.stream.Collectors;
+import java.util.stream.IntStream;
+import org.apache.ignite.internal.ClusterPerClassIntegrationTest;
+import org.apache.ignite.internal.app.IgniteImpl;
+import org.hamcrest.CustomMatcher;
+import org.hamcrest.Matcher;
+import org.junit.jupiter.api.Test;
+
+/**
+ * Tests to verify choosing of coordinator for catalog compaction.
+ */
+class ItCatalogCompactionCoordinatorChoosingTest extends 
ClusterPerClassIntegrationTest {
+    private static final int CLUSTER_SIZE = 5;
+    private static final int MINORITY_SIZE = (CLUSTER_SIZE - 1) / 2;
+
+    // test is sensible to count of nodes in custer

Review Comment:
   ```suggestion
       // test is sensible to count of nodes in cluster
   ```



##########
modules/metastorage/src/main/java/org/apache/ignite/internal/metastorage/impl/MetaStorageLeaderElectionListener.java:
##########
@@ -91,18 +93,22 @@ public class MetaStorageLeaderElectionListener implements 
LeaderElectionListener
             LogicalTopologyService logicalTopologyService,
             CompletableFuture<MetaStorageServiceImpl> metaStorageSvcFut,
             ClusterTimeImpl clusterTime,
-            CompletableFuture<MetaStorageConfiguration> 
metaStorageConfigurationFuture
+            CompletableFuture<MetaStorageConfiguration> 
metaStorageConfigurationFuture,
+            List<ElectionListener> electionListeners
     ) {
         this.busyLock = busyLock;
         this.nodeName = clusterService.nodeName();
         this.logicalTopologyService = logicalTopologyService;
         this.metaStorageSvcFut = metaStorageSvcFut;
         this.clusterTime = clusterTime;
         this.metaStorageConfigurationFuture = metaStorageConfigurationFuture;
+        this.electionListeners = electionListeners;
     }
 
     @Override
     public void onLeaderElected(ClusterNode node, long term) {
+        electionListeners.forEach(listener -> listener.onLeaderElected(node));

Review Comment:
   It looks like the javadoc should note that the listener is called on the 
same thread as the metastorage election listener, and therefore shouldn't 
contain slow computations? 



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