You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ignite.apache.org by "tkalkirill (via GitHub)" <gi...@apache.org> on 2023/09/02 09:43:41 UTC
[GitHub] [ignite-3] tkalkirill opened a new pull request, #2538: IGNITE-20330 Create an abstraction for building indexes
tkalkirill opened a new pull request, #2538:
URL: https://github.com/apache/ignite-3/pull/2538
https://issues.apache.org/jira/browse/IGNITE-20330
Thank you for submitting the pull request.
To streamline the review process of the patch and ensure better code quality
we ask both an author and a reviewer to verify the following:
### The Review Checklist
- [ ] **Formal criteria:** TC status, codestyle, mandatory documentation. Also make sure to complete the following:
\- There is a single JIRA ticket related to the pull request.
\- The web-link to the pull request is attached to the JIRA ticket.
\- The JIRA ticket has the Patch Available state.
\- The description of the JIRA ticket explains WHAT was made, WHY and HOW.
\- The pull request title is treated as the final commit message. The following pattern must be used: IGNITE-XXXX Change summary where XXXX - number of JIRA issue.
- [ ] **Design:** new code conforms with the design principles of the components it is added to.
- [ ] **Patch quality:** patch cannot be split into smaller pieces, its size must be reasonable.
- [ ] **Code quality:** code is clean and readable, necessary developer documentation is added if needed.
- [ ] **Tests code quality:** test set covers positive/negative scenarios, happy/edge cases. Tests are effective in terms of execution time and resources.
### Notes
- [Apache Ignite Coding Guidelines](https://cwiki.apache.org/confluence/display/IGNITE/Java+Code+Style+Guide)
--
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: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [ignite-3] ibessonov commented on a diff in pull request #2538: IGNITE-20330 Create an abstraction for building indexes
Posted by "ibessonov (via GitHub)" <gi...@apache.org>.
ibessonov commented on code in PR #2538:
URL: https://github.com/apache/ignite-3/pull/2538#discussion_r1317120740
##########
modules/runner/src/main/java/org/apache/ignite/internal/app/IgniteImpl.java:
##########
@@ -840,17 +851,16 @@ private RuntimeException handleStartException(Throwable e) {
LOG.debug(errMsg, e);
- lifecycleManager.stopNode();
+ stop();
return new IgniteException(errMsg, e);
}
- /**
- * Stops ignite node.
- */
+ /** Stops ignite node. */
Review Comment:
Why do you re-format a good-looking comment? What's the purpose?
##########
modules/index/src/main/java/org/apache/ignite/internal/index/IndexManager.java:
##########
@@ -503,7 +510,8 @@ private CompletableFuture<?> createIndexLocally(
}
});
- return allOf(createIndexFuture, fireEventFuture);
+ return allOf(createIndexFuture, fireEventFuture)
+ .thenAccept(unused -> indexBuildController.onIndexCreate(tableDescriptor, indexDescriptor));
Review Comment:
This code upsets me deeply. I expected the inversion of dependencies, so that the code is not as tightly coupled. But instead we're making it even more coupled.
Considering that this is a refactoring PR, there's no reason to make the code worse. But maybe I'm too harsh. Please, let me explain my vision.
First of all, `indexBuildController` field should be removed. To my knowledge, it's a broken dependency.
Second, everything below `fireEvent(IndexEvent.CREATE...` should be executed in the listener of this very event. I see no reasons to put this code here. As a result, last statement in this method will be `return fireEventFuture;`, and we could even inline the variable, making code even simpler.
Third, the `indexBuildController.onIndexCreate...` should be inside of another `IndexEvent.CREATE` listener, that will be registered in `IndexBuildController`. Subscriptions should be local to components.
If that listener needs to wait something from other components, it should do it itself. Just like it's done here in this method right now - `schemaManager.schemaRegistry(causalityToken, tableId);`, for example.
Please tell me what you think about this proposition. I think it's better then what we have in the PR.
##########
modules/table/src/main/java/org/apache/ignite/internal/table/distributed/replicator/PartitionReplicaListener.java:
##########
@@ -2574,7 +2553,7 @@ public void onBecomePrimary(ClusterNode clusterNode) {
primary = true;
- startBuildIndexes();
+ indexBuildController.onBecomePrimary(replicationGroupId, mvTableStorage, raftClient);
Review Comment:
Ideally, this dependency should be inverted as well. We can discuss the subscription API with owners of the class and do it later.
##########
modules/index/src/main/java/org/apache/ignite/internal/index/IndexManager.java:
##########
@@ -503,7 +510,8 @@ private CompletableFuture<?> createIndexLocally(
}
});
- return allOf(createIndexFuture, fireEventFuture);
+ return allOf(createIndexFuture, fireEventFuture)
+ .thenAccept(unused -> indexBuildController.onIndexCreate(tableDescriptor, indexDescriptor));
Review Comment:
Do we have a drop index scenario here?
##########
modules/runner/src/main/java/org/apache/ignite/internal/app/IgniteImpl.java:
##########
@@ -840,17 +851,16 @@ private RuntimeException handleStartException(Throwable e) {
LOG.debug(errMsg, e);
- lifecycleManager.stopNode();
+ stop();
return new IgniteException(errMsg, e);
}
- /**
- * Stops ignite node.
- */
+ /** Stops ignite node. */
public void stop() {
lifecycleManager.stopNode();
restAddressReporter.removeReport();
+ indexBuilder.close();
Review Comment:
Please re-write this method using `closeAll`
##########
modules/table/src/test/java/org/apache/ignite/internal/table/distributed/index/IndexBuildControllerTest.java:
##########
@@ -0,0 +1,241 @@
+/*
+ * 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.table.distributed.index;
+
+import static org.apache.ignite.internal.schema.CatalogDescriptorUtils.toIndexDescriptor;
+import static org.apache.ignite.internal.schema.CatalogDescriptorUtils.toTableDescriptor;
+import static org.apache.ignite.internal.schema.configuration.SchemaConfigurationUtils.findIndexView;
+import static org.apache.ignite.internal.schema.configuration.SchemaConfigurationUtils.findTableView;
+import static org.apache.ignite.internal.testframework.matchers.CompletableFutureMatcher.willCompleteSuccessfully;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyInt;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.Mockito.clearInvocations;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.never;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import java.util.concurrent.CompletableFuture;
+import org.apache.ignite.internal.catalog.descriptors.CatalogIndexDescriptor;
+import org.apache.ignite.internal.catalog.descriptors.CatalogTableDescriptor;
+import org.apache.ignite.internal.configuration.testframework.ConfigurationExtension;
+import org.apache.ignite.internal.configuration.testframework.InjectConfiguration;
+import org.apache.ignite.internal.raft.service.RaftGroupService;
+import org.apache.ignite.internal.replicator.TablePartitionId;
+import org.apache.ignite.internal.schema.configuration.ExtendedTableChange;
+import org.apache.ignite.internal.schema.configuration.TableChange;
+import org.apache.ignite.internal.schema.configuration.TablesConfiguration;
+import org.apache.ignite.internal.schema.configuration.index.HashIndexChange;
+import org.apache.ignite.internal.schema.configuration.index.TableIndexChange;
+import org.apache.ignite.internal.storage.MvPartitionStorage;
+import org.apache.ignite.internal.storage.engine.MvTableStorage;
+import org.apache.ignite.internal.storage.index.IndexStorage;
+import org.apache.ignite.internal.testframework.BaseIgniteAbstractTest;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.mockito.Mock;
+import org.mockito.junit.jupiter.MockitoExtension;
+import org.mockito.junit.jupiter.MockitoSettings;
+import org.mockito.quality.Strictness;
+
+/** For {@link IndexBuildController} testing. */
+@ExtendWith(ConfigurationExtension.class)
+@ExtendWith(MockitoExtension.class)
+@MockitoSettings(strictness = Strictness.LENIENT)
+public class IndexBuildControllerTest extends BaseIgniteAbstractTest {
+ private static final String TABLE_NAME_0 = "test_table_0";
+
+ private static final String TABLE_NAME_1 = "test_table_1";
+
+ private static final String INDEX_NAME_0 = "test_index_table_0_index_0";
+
+ private static final String INDEX_NAME_1 = "test_index_table_1_index_0";
+
+ @InjectConfiguration
+ private TablesConfiguration tablesConfig;
+
+ @Mock
+ private IndexBuilder indexBuilder;
+
+ @Mock
+ private RaftGroupService raftClient;
+
+ private IndexBuildController controller;
+
+ @BeforeEach
+ void setUp() {
+ CompletableFuture<Void> changeConfigFuture = tablesConfig.change(tablesChange -> {
+ tablesChange.changeTables().create(TABLE_NAME_0, tableChange -> simpleTable(tableChange, 1));
+ tablesChange.changeTables().create(TABLE_NAME_1, tableChange -> simpleTable(tableChange, 2));
+
+ tablesChange.changeIndexes().create(INDEX_NAME_0, indexChange -> simpleIndex(indexChange, 1, 3));
+ tablesChange.changeIndexes().create(INDEX_NAME_1, indexChange -> simpleIndex(indexChange, 2, 5));
+ });
+
+ assertThat(changeConfigFuture, willCompleteSuccessfully());
+
+ controller = new IndexBuildController(indexBuilder, tablesConfig);
+ }
+
+ @Test
+ void testOnIndexCreate() {
Review Comment:
I feel like you check 4 scenarios at once. Can it be split into 4 independent tests then?
--
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: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [ignite-3] tkalkirill closed pull request #2538: IGNITE-20330 Create an abstraction for building indexes
Posted by "tkalkirill (via GitHub)" <gi...@apache.org>.
tkalkirill closed pull request #2538: IGNITE-20330 Create an abstraction for building indexes
URL: https://github.com/apache/ignite-3/pull/2538
--
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: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org