import org.opendaylight.controller.cluster.example.messages.PrintRole;
import org.opendaylight.controller.cluster.example.messages.PrintState;
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;
@Override public void onReceiveCommand(Object message){
if(message instanceof KeyValue){
-
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 (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) {
- 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 applySnapshot(Object snapshot) {
state.clear();
state.putAll((HashMap) snapshot);
+ LOG.debug("Snapshot applied to state :" + ((HashMap) snapshot).size());
}
@Override public void onReceiveRecover(Object message) {