Code Review
/
controller.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
review
|
tree
raw
|
inline
| side by side
Merge "Bug#1854 - Exit command in console causing OOM."
[controller.git]
/
opendaylight
/
md-sal
/
sal-akka-raft
/
src
/
main
/
java
/
org
/
opendaylight
/
controller
/
cluster
/
example
/
TestDriver.java
diff --git
a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/example/TestDriver.java
b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/example/TestDriver.java
index 18c14e71241c10f803b22990234548d60f60eea4..978ea91089dbcb1a530c9d66f6878ffa06579e2d 100644
(file)
--- a/
opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/example/TestDriver.java
+++ b/
opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/example/TestDriver.java
@@
-2,8
+2,10
@@
package org.opendaylight.controller.cluster.example;
import akka.actor.ActorRef;
import akka.actor.ActorSystem;
import akka.actor.ActorRef;
import akka.actor.ActorSystem;
+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.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 org.opendaylight.controller.cluster.raft.client.messages.RemoveRaftPeer;
import org.opendaylight.controller.cluster.raft.client.messages.AddRaftPeer;
import org.opendaylight.controller.cluster.raft.client.messages.RemoveRaftPeer;
@@
-27,6
+29,7
@@
public class TestDriver {
private static Map<String, ActorRef> actorRefs = new HashMap<String, ActorRef>();
private static LogGenerator logGenerator = new LogGenerator();
private int nameCounter = 0;
private static Map<String, ActorRef> actorRefs = new HashMap<String, ActorRef>();
private static LogGenerator logGenerator = new LogGenerator();
private int nameCounter = 0;
+ private static ConfigParams configParams = new ExampleConfigParamsImpl();
/**
* Create nodes, add clients and start logging.
/**
* Create nodes, add clients and start logging.
@@
-106,11
+109,18
@@
public class TestDriver {
td.printState();
} else if (command.startsWith("printNodes")) {
td.printNodes();
td.printState();
} else if (command.startsWith("printNodes")) {
td.printNodes();
+ } else {
+ System.out.println("Invalid command:" + command);
}
}
}
}
}
}
+ public static ActorRef createExampleActor(String name) {
+ return actorSystem.actorOf(ExampleActor.props(name, withoutPeer(name),
+ Optional.of(configParams)), name);
+ }
+
public void createNodes(int num) {
for (int i=0; i < num; i++) {
nameCounter = nameCounter + 1;
public void createNodes(int num) {
for (int i=0; i < num; i++) {
nameCounter = nameCounter + 1;
@@
-118,8
+128,7
@@
public class TestDriver {
}
for (String s : allPeers.keySet()) {
}
for (String s : allPeers.keySet()) {
- ActorRef exampleActor = actorSystem.actorOf(
- ExampleActor.props(s, withoutPeer(s)), s);
+ ActorRef exampleActor = createExampleActor(s);
actorRefs.put(s, exampleActor);
System.out.println("Created node:"+s);
actorRefs.put(s, exampleActor);
System.out.println("Created node:"+s);
@@
-137,8
+146,7
@@
public class TestDriver {
}
Map<String, ActorRef> newActorRefs = new HashMap<String, ActorRef>(num);
for (Map.Entry<String, String> entry : newPeers.entrySet()) {
}
Map<String, ActorRef> newActorRefs = new HashMap<String, ActorRef>(num);
for (Map.Entry<String, String> entry : newPeers.entrySet()) {
- ActorRef exampleActor = actorSystem.actorOf(
- ExampleActor.props(entry.getKey(), withoutPeer(entry.getKey())), entry.getKey());
+ ActorRef exampleActor = createExampleActor(entry.getKey());
newActorRefs.put(entry.getKey(), exampleActor);
//now also add these new nodes as peers from the previous nodes
newActorRefs.put(entry.getKey(), exampleActor);
//now also add these new nodes as peers from the previous nodes
@@
-200,7
+208,7
@@
public class TestDriver {
String address = "akka://default/user/"+actorName;
allPeers.put(actorName, address);
String address = "akka://default/user/"+actorName;
allPeers.put(actorName, address);
- ActorRef exampleActor =
actorSystem.actorOf(ExampleActor.props(actorName, withoutPeer(actorName)),
actorName);
+ ActorRef exampleActor =
createExampleActor(
actorName);
for (ActorRef actor : actorRefs.values()) {
actor.tell(new AddRaftPeer(actorName, address), null);
for (ActorRef actor : actorRefs.values()) {
actor.tell(new AddRaftPeer(actorName, address), null);