SzyWilliam commented on code in PR #987:
URL: https://github.com/apache/ratis/pull/987#discussion_r1431290828


##########
ratis-docs/src/site/markdown/membership-change.md:
##########
@@ -0,0 +1,104 @@
+<!---
+  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.
+-->
+
+# Ratis Membership Change
+
+## Overview
+
+Adjusting the configuration, such as replacing failed servers or changing 
replication levels, 
+is sometimes necessary in practice. 
+Ratis facilitates these functionalities through joint consensus, 
+allowing for simultaneous addition or replacement of multiple servers in a 
cluster.
+
+> For details on how joint consensus algorithm works, please refer to section 
4.3 in 
+[Raft Paper](https://web.stanford.edu/~ouster/cgi-bin/papers/OngaroPhD.pdf)
+
+During membership changes, the availability guarantee of Raft is more 
vulnerable than usual.
+Agreement (for elections and entry commitment) requires separate majorities 
from both the
+old and new configurations.
+For example, when changing from a cluster of 3 servers to a different cluster 
of 9 servers, 
+agreement requires both 2 of the 3 servers in the old configuration 
+and 5 of the 9 servers in the new configuration.
+Be carefully to keep both separate majorities online! 
+
+## Adding a new server
+
+To add a new node (e.g., N3) to an existing group (e.g., N0, N1, N2), follow 
these steps:
+
+1. Start the new peer N3 with **EMPTY** group. 
+
+```java
+this.serverN3 = RaftServer.newBuilder()
+    .setGroup(RaftGroup.emptygroup())
+    .setProperties(properties)
+    .setServerId(N3)
+    .setStateMachine(userStateMachine)
+    .build();
+this.serverN3.start()
+```
+
+2. Issue a `setConfiguration` request to any member of the existing group. 
+This command waits for the new peer to catch up before returning.
+```java
+RaftClientReply reply = client.admin()
+    .setConfiguration(List.of(N0, N1, N2, N3))
+```
+
+
+> Avoid starting N3 with the group (N0, N1, N2, N3) as it may lead to shutdown 
scenarios, 
+> particularly if N3 initiates a leader election before being recognized by 
original peers.
+
+
+## Removing an existing peer
+To remove an existing node (e.g., N3) from a group (e.g., N0, N1, N2, N3), 
follow these steps:
+
+1. Issue a `setConfiguration` request to the existing group to inform about 
the configuration change.
+```java
+RaftClientReply reply = client.admin()
+    .setConfiguration(List.of(N0, N1, N2))
+```
+
+2. After successful completion of Step 1, stop N3 and clean up its data.

Review Comment:
   You are right! We just need to remove the data through `groupManagement`.



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