Code Review
/
controller.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
review
|
tree
raw
|
inline
| side by side
Configuration Interface for Raft
[controller.git]
/
opendaylight
/
md-sal
/
sal-akka-raft
/
src
/
main
/
java
/
org
/
opendaylight
/
controller
/
cluster
/
example
/
ExampleActor.java
diff --git
a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/example/ExampleActor.java
b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/example/ExampleActor.java
index 8d4d5e48c81c6a91d2c089b0275f561575ee0baf..aa100df9d0517dfa014a78054e2319d8b1bd34fe 100644
(file)
--- a/
opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/example/ExampleActor.java
+++ b/
opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/example/ExampleActor.java
@@
-11,11
+11,14
@@
package org.opendaylight.controller.cluster.example;
import akka.actor.ActorRef;
import akka.actor.Props;
import akka.japi.Creator;
import akka.actor.ActorRef;
import akka.actor.Props;
import akka.japi.Creator;
+import com.google.common.base.Optional;
import org.opendaylight.controller.cluster.example.messages.KeyValue;
import org.opendaylight.controller.cluster.example.messages.KeyValueSaved;
import org.opendaylight.controller.cluster.example.messages.PrintRole;
import org.opendaylight.controller.cluster.example.messages.PrintState;
import org.opendaylight.controller.cluster.example.messages.KeyValue;
import org.opendaylight.controller.cluster.example.messages.KeyValueSaved;
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.RaftActor;
import org.opendaylight.controller.cluster.raft.RaftActor;
+import org.opendaylight.controller.cluster.raft.protobuff.client.messages.Payload;
import java.util.HashMap;
import java.util.Map;
import java.util.HashMap;
import java.util.Map;
@@
-30,25
+33,26
@@
public class ExampleActor extends RaftActor {
private long persistIdentifier = 1;
private long persistIdentifier = 1;
- public ExampleActor(String id, Map<String, String> peerAddresses) {
- super(id, peerAddresses);
+ public ExampleActor(String id, Map<String, String> peerAddresses,
+ Optional<ConfigParams> configParams) {
+ super(id, peerAddresses, configParams);
}
}
- public static Props props(final String id, final Map<String, String> peerAddresses){
+ public static Props props(final String id, final Map<String, String> peerAddresses,
+ final Optional<ConfigParams> configParams){
return Props.create(new Creator<ExampleActor>(){
@Override public ExampleActor create() throws Exception {
return Props.create(new Creator<ExampleActor>(){
@Override public ExampleActor create() throws Exception {
- return new ExampleActor(id, peerAddresses);
+ return new ExampleActor(id, peerAddresses
, configParams
);
}
});
}
@Override public void onReceiveCommand(Object message){
if(message instanceof KeyValue){
}
});
}
@Override public void onReceiveCommand(Object message){
if(message instanceof KeyValue){
-
if(isLeader()) {
String persistId = Long.toString(persistIdentifier++);
if(isLeader()) {
String persistId = Long.toString(persistIdentifier++);
- persistData(getSender(), persistId, message);
+ persistData(getSender(), persistId,
(Payload)
message);
} else {
if(getLeader() != null) {
getLeader().forward(message, getContext());
} else {
if(getLeader() != null) {
getLeader().forward(message, getContext());
@@
-56,12
+60,15
@@
public class ExampleActor extends RaftActor {
}
} else if (message instanceof PrintState) {
}
} else if (message instanceof PrintState) {
- LOG.debug("State of the node:"+getId() + " is="+state.size());
+ LOG.debug("State of the node:{} has entries={}, {}",
+ getId(), state.size(), getReplicatedLogState());
} else if (message instanceof PrintRole) {
} else if (message instanceof PrintRole) {
- LOG.debug(getId() + " = " + getRaftState());
+ LOG.debug("{} = {}, Peers={}", getId(), getRaftState(),getPeers());
+
+ } else {
+ super.onReceiveCommand(message);
}
}
- super.onReceiveCommand(message);
}
@Override protected void applyState(ActorRef clientActor, String identifier,
}
@Override protected void applyState(ActorRef clientActor, String identifier,
@@
-82,6
+89,7
@@
public class ExampleActor extends RaftActor {
@Override protected void applySnapshot(Object snapshot) {
state.clear();
state.putAll((HashMap) snapshot);
@Override protected void applySnapshot(Object snapshot) {
state.clear();
state.putAll((HashMap) snapshot);
+ LOG.debug("Snapshot applied to state :" + ((HashMap) snapshot).size());
}
@Override public void onReceiveRecover(Object message) {
}
@Override public void onReceiveRecover(Object message) {