X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-akka-raft%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fcluster%2Fexample%2FExampleActor.java;h=6dfa4afd6b6951a351790d0fb87679b40d19dc90;hp=81b4670b71cb0eb728bed02d9c1da48163fc9b1f;hb=443d331f01bcc9e3aa8442f60b84211b2f175967;hpb=ad587084842de7086a54e57a3152bf3232a30702 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 81b4670b71..6dfa4afd6b 100644 --- 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 @@ -27,7 +27,9 @@ 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.RaftState; import org.opendaylight.controller.cluster.raft.base.messages.CaptureSnapshotReply; +import org.opendaylight.controller.cluster.raft.behaviors.Leader; import org.opendaylight.controller.cluster.raft.protobuff.client.messages.Payload; /** @@ -50,6 +52,7 @@ public class ExampleActor extends RaftActor { public static Props props(final String id, final Map peerAddresses, final Optional configParams){ return Props.create(new Creator(){ + private static final long serialVersionUID = 1L; @Override public ExampleActor create() throws Exception { return new ExampleActor(id, peerAddresses, configParams); @@ -76,7 +79,15 @@ public class ExampleActor extends RaftActor { } else if (message instanceof PrintRole) { if(LOG.isDebugEnabled()) { - LOG.debug("{} = {}, Peers={}", getId(), getRaftState(), getPeers()); + String followers = ""; + if (getRaftState() == RaftState.Leader || getRaftState() == RaftState.IsolatedLeader) { + followers = ((Leader)this.getCurrentBehavior()).printFollowerStates(); + LOG.debug("{} = {}, Peers={}, followers={}", getId(), getRaftState(), getPeers(), followers); + } else { + LOG.debug("{} = {}, Peers={}", getId(), getRaftState(), getPeers()); + } + + } } else { @@ -108,12 +119,12 @@ public class ExampleActor extends RaftActor { @Override protected void applySnapshot(final ByteString snapshot) { state.clear(); try { - state.putAll((HashMap) toObject(snapshot)); + state.putAll((Map) toObject(snapshot)); } catch (Exception e) { LOG.error(e, "Exception in applying snapshot"); } if(LOG.isDebugEnabled()) { - LOG.debug("Snapshot applied to state : {}", ((HashMap) state).size()); + LOG.debug("Snapshot applied to state : {}", ((Map) state).size()); } }