X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-akka-raft%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fcluster%2Fexample%2FExampleActor.java;h=9aff86ba2b09572a44200ac2095331d03c687a66;hb=cfc94248aa44307e7dc9aaefcb6748c478f93138;hp=684c3ac30ecb5cbcb441f90bf430e63e0b5267a7;hpb=71c540b3572415aef56acd4a31b503f24e9da437;p=controller.git 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 684c3ac30e..9aff86ba2b 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 @@ -41,7 +41,7 @@ public class ExampleActor extends RaftActor { private final DataPersistenceProvider dataPersistenceProvider; private long persistIdentifier = 1; - private Optional roleChangeNotifier; + private final Optional roleChangeNotifier; public ExampleActor(String id, Map peerAddresses, @@ -75,9 +75,8 @@ public class ExampleActor extends RaftActor { } else if (message instanceof PrintRole) { if(LOG.isDebugEnabled()) { - String followers = ""; if (getRaftState() == RaftState.Leader || getRaftState() == RaftState.IsolatedLeader) { - followers = ((Leader)this.getCurrentBehavior()).printFollowerStates(); + final String followers = ((Leader)this.getCurrentBehavior()).printFollowerStates(); LOG.debug("{} = {}, Peers={}, followers={}", getId(), getRaftState(), getRaftActorContext().getPeerAddresses().keySet(), followers); } else { @@ -128,10 +127,10 @@ public class ExampleActor extends RaftActor { } catch (Exception e) { LOG.error(e, "Exception in creating snapshot"); } - getSelf().tell(new CaptureSnapshotReply(bs), null); + getSelf().tell(new CaptureSnapshotReply(bs.toByteArray()), null); } - @Override protected void applySnapshot(ByteString snapshot) { + @Override protected void applySnapshot(byte [] snapshot) { state.clear(); try { state.putAll((HashMap) toObject(snapshot)); @@ -163,12 +162,12 @@ public class ExampleActor extends RaftActor { } } - private Object toObject(ByteString bs) throws ClassNotFoundException, IOException { + private Object toObject(byte [] bs) throws ClassNotFoundException, IOException { Object obj = null; ByteArrayInputStream bis = null; ObjectInputStream ois = null; try { - bis = new ByteArrayInputStream(bs.toByteArray()); + bis = new ByteArrayInputStream(bs); ois = new ObjectInputStream(bis); obj = ois.readObject(); } finally { @@ -216,6 +215,6 @@ public class ExampleActor extends RaftActor { } @Override - protected void applyRecoverySnapshot(ByteString snapshot) { + protected void applyRecoverySnapshot(byte[] snapshot) { } }