<NME> ConfigurationUtils.java
<BEF> package com.github.wenweihu86.raft.util;

import com.github.wenweihu86.raft.proto.Raft;

import java.util.List;

/**
 */
public class ConfigurationUtils {

    // configuration不会太大，所以这里直接遍历了
    public static boolean containsServer(RaftProto.Configuration configuration, int serverId) {
        for (RaftProto.Server server : configuration.getServersList()) {
            if (server.getServerId() == serverId) {
                return true;
            }
        }
        return false;
    }

    public static RaftProto.Configuration removeServers(
            Raft.Configuration configuration, List<Raft.Server> servers) {
        Raft.Configuration.Builder confBuilder = Raft.Configuration.newBuilder();
        for (Raft.Server server : configuration.getServersList()) {
            boolean isExist = false;
            for (Raft.Server server1 : servers) {
                if (server.getServerId() == server1.getServerId()) {
                    isExist = true;
                    break;
                }
            }
            if (!isExist) {
                confBuilder.addServers(server);
            }
        }
        return confBuilder.build();
    }

    public static RaftProto.Server getServer(RaftProto.Configuration configuration, int serverId) {
        for (RaftProto.Server server : configuration.getServersList()) {
            if (server.getServerId() == serverId) {
                return server;
            }
        }
        return null;
    }

}

<MSG> update remove configuration

<DFF> @@ -2,6 +2,7 @@ package com.github.wenweihu86.raft.util;
 
 import com.github.wenweihu86.raft.proto.Raft;
 
+import java.util.ArrayList;
 import java.util.List;
 
 /**
@@ -22,14 +23,14 @@ public class ConfigurationUtils {
             Raft.Configuration configuration, List<Raft.Server> servers) {
         Raft.Configuration.Builder confBuilder = Raft.Configuration.newBuilder();
         for (Raft.Server server : configuration.getServersList()) {
-            boolean isExist = false;
+            boolean toBeRemoved = false;
             for (Raft.Server server1 : servers) {
                 if (server.getServerId() == server1.getServerId()) {
-                    isExist = true;
+                    toBeRemoved = true;
                     break;
                 }
             }
-            if (!isExist) {
+            if (!toBeRemoved) {
                 confBuilder.addServers(server);
             }
         }

update remove configuration