Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IGNITE-22218 Remove TableRaftService in favor of using RaftGroupService from Replica instances #3973

Open
wants to merge 76 commits into
base: main
Choose a base branch
from

Conversation

JAkutenshi
Copy link
Contributor

@JAkutenshi JAkutenshi commented Jun 24, 2024

JIRA Ticket: IGNITE-22218 | Remove TableRaftService in favor of using RaftGroupService from Replica instances

The goal

The goal of the PR is to remove TableRaftService and it's usages.

The reason

TableRaftService is a leakage of RAFT-specific code onto other layers that should be prohibited.

The solution

All occurrences should be replaced with:

replicaManager
    .replica(...)
    .thenCompose(replica -> {
             TableRaftService raftClient = replica.raftClient();
             // do that there should be checked or done like `.updateConfiguration()`
        }

Class TableRaftService should be removed completely.


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

# Conflicts:
#	modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/ItIgniteInMemoryNodeRestartTest.java
#	modules/table/src/main/java/org/apache/ignite/internal/table/distributed/TableManager.java
# Conflicts:
#	modules/index/src/integrationTest/java/org/apache/ignite/internal/index/ItBuildIndexTest.java
#	modules/replicator/src/main/java/org/apache/ignite/internal/replicator/ReplicaManager.java
#	modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/ItIgniteInMemoryNodeRestartTest.java
#	modules/table/src/integrationTest/java/org/apache/ignite/internal/rebalance/ItRebalanceDistributedTest.java
#	modules/table/src/main/java/org/apache/ignite/internal/table/distributed/TableManager.java
…Started` calls and `replica(...)` calls are asynchronous now.
…re events (eg inhibitors are enabled) => no primary => return false
…DestroyPartitionAndUpdateClients` with chaining of peer set update future and stop&destroy partition future instead of allOf.
# Conflicts:
#	modules/client/src/test/java/org/apache/ignite/client/fakes/FakeInternalTable.java
#	modules/table/src/integrationTest/java/org/apache/ignite/internal/rebalance/ItRebalanceDistributedTest.java
#	modules/table/src/test/java/org/apache/ignite/internal/table/distributed/TableManagerRecoveryTest.java
# Conflicts:
#	modules/index/src/integrationTest/java/org/apache/ignite/internal/index/ItBuildIndexTest.java
@@ -81,6 +81,7 @@ dependencies {
integrationTestImplementation testFixtures(project(':ignite-table'))
integrationTestImplementation testFixtures(project(':ignite-storage-api'))
integrationTestImplementation testFixtures(project(':ignite-catalog'))
integrationTestImplementation testFixtures(project(':ignite-replicator'))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need this dependency?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new ReplicaTestUtils is placed there

ScheduledExecutorService rebalanceScheduler
) {
ScheduledExecutorService rebalanceScheduler,
ClockService clockService, PlacementDriver placementDriver) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One at a row, please. Please also move ) { to a separate row.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@@ -190,6 +205,9 @@ public PartitionReplicaLifecycleManager(
this.lowWatermark = lowWatermark;
this.ioExecutor = ioExecutor;
this.rebalanceScheduler = rebalanceScheduler;
this.clockService = clockService;
// should it be ExecutorInclinedPlacementDriver as in TableManager?
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes it should. And don't forget to remove the comment.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couldn't pass ExecutorInclinedPlacementDriver there because it came from :ignite-table, but there a circular dependency arises:

:ignite-partition-replicator:compileJava
\--- :ignite-table:compileJava
     \--- :ignite-partition-replicator:compileJava (*)

Is it crucial?

return assignments.stream().anyMatch(isLocalNodeAssignment);
}

private CompletableFuture<Boolean> isLocalNodeLeaseholder(ReplicationGroupId replicationGroupId) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd rather use isLocalNodeIsPrimary instead of "...Leaseholder".

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Renamed

return assignments.stream().anyMatch(isLocalNodeAssignment);
}

private CompletableFuture<Boolean> isLocalNodeLeaseholder(ReplicationGroupId replicationGroupId) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please add javadoc explaning contract of the method. Especially it's important to clarify how do we evaluate base timestamp for leaseholder detection.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Java doc is added, the method is fixed due to the lifecycle manager's version some how became is out of date a little.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants