BUG 2303 : Remove the implementation of AddRaftPeer/RemoveRaftPeer 07/12607/2
authorMoiz Raja <moraja@cisco.com>
Tue, 4 Nov 2014 01:10:59 +0000 (17:10 -0800)
committerMoiz Raja <moraja@cisco.com>
Fri, 7 Nov 2014 17:03:56 +0000 (17:03 +0000)
It is both unused and incorrect

Change-Id: Ie0a9844ccf4de7dae68586954031599b55646c47
Signed-off-by: Moiz Raja <moraja@cisco.com>
opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/example/TestDriver.java
opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/RaftActor.java
opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/client/messages/AddRaftPeer.java [deleted file]
opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/client/messages/RemoveRaftPeer.java [deleted file]

index cb51a89..f202a8b 100644 (file)
@@ -6,7 +6,6 @@ import com.google.common.base.Optional;
 import org.opendaylight.controller.cluster.example.messages.PrintRole;
 import org.opendaylight.controller.cluster.example.messages.PrintState;
 import org.opendaylight.controller.cluster.raft.ConfigParams;
-import org.opendaylight.controller.cluster.raft.client.messages.AddRaftPeer;
 
 import java.io.BufferedReader;
 import java.io.InputStreamReader;
@@ -35,7 +34,6 @@ public class TestDriver {
      * Commands
      *  bye
      *  createNodes:{num}
-     *  addNodes:{num}
      *  stopNode:{nodeName}
      *  reinstateNode:{nodeName}
      *  addClients:{num}
@@ -66,11 +64,6 @@ public class TestDriver {
                 int n = Integer.parseInt(arr[1]);
                 td.createNodes(n);
 
-            } else if (command.startsWith("addNodes")) {
-                String[] arr = command.split(":");
-                int n = Integer.parseInt(arr[1]);
-                td.addNodes(n);
-
             } else if (command.startsWith("addClients")) {
                 String[] arr = command.split(":");
                 int n = Integer.parseInt(arr[1]);
@@ -134,32 +127,6 @@ public class TestDriver {
         }
     }
 
-    // add new nodes , pass in the count
-    public void addNodes(int num) {
-        Map<String, String> newPeers = new HashMap<>();
-        for (int i=0; i < num; i++)  {
-            nameCounter = nameCounter + 1;
-            newPeers.put("example-"+nameCounter, "akka://default/user/example-"+nameCounter);
-            allPeers.put("example-"+nameCounter, "akka://default/user/example-"+nameCounter);
-
-        }
-        Map<String, ActorRef> newActorRefs = new HashMap<String, ActorRef>(num);
-        for (Map.Entry<String, String> entry : newPeers.entrySet())  {
-            ActorRef exampleActor = createExampleActor(entry.getKey());
-            newActorRefs.put(entry.getKey(), exampleActor);
-
-            //now also add these new nodes as peers from the previous nodes
-            for (ActorRef actor : actorRefs.values()) {
-                actor.tell(new AddRaftPeer(entry.getKey(), entry.getValue()), null);
-            }
-
-            System.out.println("Added node:" + entry);
-        }
-
-        actorRefs.putAll(newActorRefs);
-    }
-
-
     // add num clients to all nodes in the system
     public void addClients(int num) {
         for(Map.Entry<String,ActorRef> actorRefEntry : actorRefs.entrySet()) {
index f02b52b..617bb7e 100644 (file)
@@ -35,10 +35,8 @@ import org.opendaylight.controller.cluster.raft.base.messages.SendInstallSnapsho
 import org.opendaylight.controller.cluster.raft.behaviors.AbstractRaftActorBehavior;
 import org.opendaylight.controller.cluster.raft.behaviors.Follower;
 import org.opendaylight.controller.cluster.raft.behaviors.RaftActorBehavior;
-import org.opendaylight.controller.cluster.raft.client.messages.AddRaftPeer;
 import org.opendaylight.controller.cluster.raft.client.messages.FindLeader;
 import org.opendaylight.controller.cluster.raft.client.messages.FindLeaderReply;
-import org.opendaylight.controller.cluster.raft.client.messages.RemoveRaftPeer;
 import org.opendaylight.controller.cluster.raft.messages.AppendEntriesReply;
 import org.opendaylight.controller.cluster.raft.protobuff.client.messages.Payload;
 import org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages;
@@ -343,20 +341,6 @@ public abstract class RaftActor extends AbstractUntypedPersistentActor {
                 context.getReplicatedLog().getSnapshotTerm(),
                 context.getReplicatedLog().size());
 
-        } else if (message instanceof AddRaftPeer){
-
-            // FIXME : Do not add raft peers like this.
-            // When adding a new Peer we have to ensure that the a majority of
-            // the peers know about the new Peer. Doing it this way may cause
-            // a situation where multiple Leaders may emerge
-            AddRaftPeer arp = (AddRaftPeer)message;
-           context.addToPeers(arp.getName(), arp.getAddress());
-
-        } else if (message instanceof RemoveRaftPeer){
-
-            RemoveRaftPeer rrp = (RemoveRaftPeer)message;
-            context.removePeer(rrp.getName());
-
         } else if (message instanceof CaptureSnapshot) {
             LOG.info("CaptureSnapshot received by actor");
             CaptureSnapshot cs = (CaptureSnapshot)message;
diff --git a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/client/messages/AddRaftPeer.java b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/client/messages/AddRaftPeer.java
deleted file mode 100644 (file)
index d1f4c43..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-package org.opendaylight.controller.cluster.raft.client.messages;
-
-/**
- * Created by kramesha on 7/17/14.
- */
-public class AddRaftPeer {
-
-    private String name;
-    private String address;
-
-    public AddRaftPeer(String name, String address) {
-        this.name = name;
-        this.address = address;
-    }
-
-    public String getName() {
-        return name;
-    }
-
-    public String getAddress() {
-        return address;
-    }
-}
diff --git a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/client/messages/RemoveRaftPeer.java b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/client/messages/RemoveRaftPeer.java
deleted file mode 100644 (file)
index 4b766e0..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-package org.opendaylight.controller.cluster.raft.client.messages;
-
-/**
- * Created by kramesha on 7/17/14.
- */
-public class RemoveRaftPeer {
-    private String name;
-
-    public RemoveRaftPeer(String name) {
-        this.name = name;
-    }
-
-    public String getName() {
-        return name;
-    }
-}