vldpyatkov commented on a change in pull request #399:
URL: https://github.com/apache/ignite-3/pull/399#discussion_r733174713
##########
File path: modules/raft/src/main/java/org/apache/ignite/internal/raft/Loza.java
##########
@@ -154,73 +163,38 @@ public Loza(ClusterService clusterNetSvc, Path dataPath) {
}
/**
- * Creates a raft group service providing operations on a raft group.
- * If {@code nodes} contains the current node, then raft group starts on
the current node.
- *
- * @param groupId Raft group id.
- * @param nodes Raft group nodes.
- * @param lsnrSupplier Raft group listener supplier.
- * @return Future representing pending completion of the operation.
- */
- public CompletableFuture<RaftGroupService> prepareRaftGroup(
- String groupId,
- List<ClusterNode> nodes,
- Supplier<RaftGroupListener> lsnrSupplier) {
-
- return prepareRaftGroup(groupId, nodes, lsnrSupplier, TIMEOUT,
NETWORK_TIMEOUT);
- }
-
- /**
- * Stops a raft group on the current node if {@code nodes} contains the
current node.
+ * Changes peers for a group.
*
* @param groupId Raft group id.
- * @param nodes Raft group nodes.
- */
- public void stopRaftGroup(String groupId, List<ClusterNode> nodes) {
- assert !nodes.isEmpty();
-
- String locNodeName =
clusterNetSvc.topologyService().localMember().name();
-
- if (nodes.stream().anyMatch(n -> locNodeName.equals(n.name())))
- raftServer.stopRaftGroup(groupId);
- }
-
- /**
- * Creates a raft group service providing operations on a raft group.
- * If {@code deltaNodes} contains the current node, then raft group starts
on the current node.
- * @param groupId Raft group id.
- * @param nodes Full set of raft group nodes.
- * @param deltaNodes New raft group nodes.
- * @param lsnrSupplier Raft group listener supplier.
- * @return Future representing pending completion of the operation.
- * @return
+ * @param expectedNodes Nodes before.
+ * @param changedNodes Nodes to change.
+ * @return Future which will complete when peers change.
*/
- public CompletableFuture<RaftGroupService> updateRaftGroup(
- String groupId,
- Collection<ClusterNode> nodes,
- Collection<ClusterNode> deltaNodes,
- Supplier<RaftGroupListener> lsnrSupplier
- ) {
- assert !nodes.isEmpty();
-
- List<Peer> peers = nodes.stream().map(n -> new
Peer(n.address())).collect(Collectors.toList());
-
- String locNodeName =
clusterNetSvc.topologyService().localMember().name();
-
- if (deltaNodes.stream().anyMatch(n -> locNodeName.equals(n.name()))) {
- if (!raftServer.startRaftGroup(groupId, lsnrSupplier.get(), peers))
- LOG.error("Failed to start raft group on node " + locNodeName);
- }
+ public CompletableFuture<Void> chagePeers(String groupId,
List<ClusterNode> expectedNodes, List<ClusterNode> changedNodes) {
+ List<Peer> expectedPeers = expectedNodes.stream().map(n -> new
Peer(n.address())).collect(Collectors.toList());
+ List<Peer> changedPeers = changedNodes.stream().map(n -> new
Peer(n.address())).collect(Collectors.toList());
return RaftGroupServiceImpl.start(
groupId,
clusterNetSvc,
FACTORY,
- TIMEOUT,
- peers,
+ 10 * TIMEOUT,
+ 10 * NETWORK_TIMEOUT,
+ expectedPeers,
true,
DELAY,
executor
- );
+ ).thenCompose(srvc -> srvc.changePeers(changedPeers)
+ .thenRun(() -> srvc.shutdown()));
+ }
+
+ /**
+ * Stops a raft group on the current node.
+ *
+ * @param groupId Raft group id.
+ */
+ public void stopRaftGroup(String groupId) {
Review comment:
Done.
--
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]