szetszwo commented on code in PR #658:
URL: https://github.com/apache/ratis/pull/658#discussion_r910204761


##########
ratis-common/src/main/java/org/apache/ratis/protocol/SetConfigurationRequest.java:
##########
@@ -17,39 +17,116 @@
  */
 package org.apache.ratis.protocol;
 
+import org.apache.ratis.proto.RaftProtos;
 import org.apache.ratis.util.Preconditions;
 
+import java.util.Arrays;
 import java.util.Collections;
 import java.util.List;
+import java.util.Optional;
 
 public class SetConfigurationRequest extends RaftClientRequest {
-  private final List<RaftPeer> peers;
-  private final List<RaftPeer> listeners;
 
-  public SetConfigurationRequest(ClientId clientId, RaftPeerId serverId,
-      RaftGroupId groupId, long callId, List<RaftPeer> peers) {
-    this(clientId, serverId, groupId, callId, peers, Collections.emptyList());
+  public enum Mode {
+    SET_UNCONDITIONALLY,
+    ADD
   }
 
-  public SetConfigurationRequest(ClientId clientId, RaftPeerId serverId,
-      RaftGroupId groupId, long callId, List<RaftPeer> peers, List<RaftPeer> 
listeners) {
-    super(clientId, serverId, groupId, callId, true, writeRequestType());
-    this.peers = peers != null? Collections.unmodifiableList(peers): 
Collections.emptyList();
-    this.listeners = listeners !=  null? 
Collections.unmodifiableList(listeners) : Collections.emptyList();
-    Preconditions.assertUnique(this.peers);
-    Preconditions.assertUnique(this.listeners);
+  public static final class Arguments {
+    private List<RaftPeer> serversInNewConf;
+    private List<RaftPeer> listenersInNewConf;
+    private Mode mode;

Review Comment:
   Add final so that the class becomes immutable.



##########
ratis-server/src/test/java/org/apache/ratis/server/impl/RaftReconfigurationBaseTest.java:
##########
@@ -23,6 +23,7 @@
 import org.apache.ratis.RaftTestUtil.SimpleMessage;
 import org.apache.ratis.client.RaftClient;
 import org.apache.ratis.client.RaftClientRpc;
+import org.apache.ratis.client.api.AdminApi;

Review Comment:
   This is unused.



##########
ratis-server/src/main/java/org/apache/ratis/server/impl/RaftConfigurationImpl.java:
##########
@@ -242,12 +242,22 @@ public String toString() {
     return logEntryIndex + ": " + conf + ", old=" + oldConf;
   }
 
-  boolean hasNoChange(Collection<RaftPeer> newMembers) {
-    if (!isStable() || conf.size() != newMembers.size()) {
+  boolean hasNoChange(Collection<RaftPeer> newMembers, Collection<RaftPeer> 
newListeners) {
+    if (!isStable() || conf.size() != newMembers.size()
+        || conf.getPeers(RaftPeerRole.LISTENER).size() != newListeners.size()) 
{
       return false;
     }
     for (RaftPeer peer : newMembers) {
       if (!conf.contains(peer.getId()) || 
conf.getPeer(peer.getId()).getPriority() != peer.getPriority()) {

Review Comment:
   This if-statement is no longer needed since the protos are compared below.



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