JAkutenshi commented on code in PR #3633: URL: https://github.com/apache/ignite-3/pull/3633#discussion_r1619378264
########## modules/replicator/src/main/java/org/apache/ignite/internal/replicator/ReplicaManager.java: ########## @@ -466,75 +490,167 @@ private void stopLeaseProlongation(ReplicationGroupId groupId, @Nullable String }); } + private CompletableFuture<Boolean> startReplicaInternal( + MetaStorageManager metaStorageMgr, + RaftGroupListener raftGroupListener, + MvTableStorage mvTableStorage, + SnapshotStorageFactory snapshotStorageFactory, + Consumer<RaftGroupService> updateTableRaftService, + Function<RaftGroupService, ReplicaListener> createListener, + int zoneId, + PendingComparableValuesTracker<Long, Void> storageIndexTracker, + TablePartitionId replicaGrpId, + PeersAndLearners newConfiguration + ) throws NodeStoppingException { + RaftNodeId raftNodeId = new RaftNodeId(replicaGrpId, new Peer(localNodeConsistentId)); + + RaftGroupOptions groupOptions = groupOptionsForPartition( + mvTableStorage, + snapshotStorageFactory); + + RaftGroupEventsListener raftGroupEventsListener = createRaftGroupEventsListener(metaStorageMgr, zoneId, + replicaGrpId); + + // TODO: use RaftManager interface, see https://issues.apache.org/jira/browse/IGNITE-18273 + CompletableFuture<TopologyAwareRaftGroupService> newRaftClientFut = ((Loza) raftManager).startRaftGroupNode( + raftNodeId, + newConfiguration, + raftGroupListener, + raftGroupEventsListener, + groupOptions, + raftGroupServiceFactory + ); + + return startReplica( + replicaGrpId, + newConfiguration, + updateTableRaftService, + createListener, storageIndexTracker, + newRaftClientFut); + + } + /** - * Starts a replica. If a replica with the same partition id already exists, the method throws an exception. + * Creates and starts a new replica. * + * @param metaStorageMgr Metastore manager. + * @param raftGroupListener Raft group listener for raft group starting. + * @param mvTableStorage Multi-version table storage. + * @param snapshotStorageFactory Snapshot storage factory for raft group option's parameterization. + * @param updateTableRaftService Temporal consumer while TableRaftService wouldn't be removed in + * TODO: https://issues.apache.org/jira/browse/IGNITE-22218. + * @param createListener Due to creation of ReplicaListener in TableManager, the function returns desired listener by created + * raft-client inside {@link #startReplica} method. + * @param zoneId Distribution zone ID. * @param replicaGrpId Replication group id. - * @param listener Replica listener. - * @param raftClient Topology aware Raft client. * @param storageIndexTracker Storage index tracker. - * @throws NodeStoppingException If node is stopping. - * @throws ReplicaIsAlreadyStartedException Is thrown when a replica with the same replication group id has already been - * started. + * @param newConfiguration A configuration for new raft group. + * @return Future that promises ready new replica when done. */ - public CompletableFuture<Replica> startReplica( - ReplicationGroupId replicaGrpId, - ReplicaListener listener, - TopologyAwareRaftGroupService raftClient, - PendingComparableValuesTracker<Long, Void> storageIndexTracker + public CompletableFuture<Boolean> startReplica( + MetaStorageManager metaStorageMgr, + RaftGroupListener raftGroupListener, + MvTableStorage mvTableStorage, + SnapshotStorageFactory snapshotStorageFactory, + Consumer<RaftGroupService> updateTableRaftService, + Function<RaftGroupService, ReplicaListener> createListener, + int zoneId, + PendingComparableValuesTracker<Long, Void> storageIndexTracker, + TablePartitionId replicaGrpId, + PeersAndLearners newConfiguration ) throws NodeStoppingException { if (!busyLock.enterBusy()) { throw new NodeStoppingException(); } try { - return startReplicaInternal(replicaGrpId, listener, raftClient, storageIndexTracker); + return startReplicaInternal( + metaStorageMgr, + raftGroupListener, + mvTableStorage, + snapshotStorageFactory, + updateTableRaftService, + createListener, + zoneId, + storageIndexTracker, + replicaGrpId, + newConfiguration); } finally { busyLock.leaveBusy(); } } /** - * Internal method for starting a replica. + * Starts a raft-client and pass it to a replica creation if the replica should be started too. If a replica with the same partition id + * already exists, the method throws an exception. * * @param replicaGrpId Replication group id. Review Comment: Added missed params javadoc and added todos with https://issues.apache.org/jira/browse/IGNITE-22373 and https://issues.apache.org/jira/browse/IGNITE-22218 -- 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-unsubscr...@ignite.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org