Fix warnings and javadocs in sal-akka-raft
[controller.git] / opendaylight / md-sal / sal-akka-raft / src / main / java / org / opendaylight / controller / cluster / raft / RaftActorLeadershipTransferCohort.java
index b83bfd370948dc18a3826633568e2a78eeb650ac..7efc7586d8c196ea9750afde1169729125c0e5f4 100644 (file)
@@ -52,16 +52,14 @@ public class RaftActorLeadershipTransferCohort {
     private static final Logger LOG = LoggerFactory.getLogger(RaftActorLeadershipTransferCohort.class);
 
     private final RaftActor raftActor;
-    private final ActorRef replyTo;
     private Cancellable newLeaderTimer;
     private final List<OnComplete> onCompleteCallbacks = new ArrayList<>();
     private long newLeaderTimeoutInMillis = 2000;
     private final Stopwatch transferTimer = Stopwatch.createUnstarted();
     private boolean isTransferring;
 
-    RaftActorLeadershipTransferCohort(RaftActor raftActor, ActorRef replyTo) {
+    RaftActorLeadershipTransferCohort(RaftActor raftActor) {
         this.raftActor = raftActor;
-        this.replyTo = replyTo;
     }
 
     void init() {
@@ -76,11 +74,10 @@ public class RaftActorLeadershipTransferCohort {
                     currentBehavior.getLeaderPayloadVersion()), raftActor.self());
         }
 
-        LeaderTransitioning leaderTransitioning = new LeaderTransitioning();
         for(String peerId: context.getPeerIds()) {
             ActorSelection followerActor = context.getPeerActorSelection(peerId);
             if(followerActor != null) {
-                followerActor.tell(leaderTransitioning, context.getActor());
+                followerActor.tell(LeaderTransitioning.INSTANCE, context.getActor());
             }
         }
 
@@ -139,12 +136,9 @@ public class RaftActorLeadershipTransferCohort {
         // safely run on the actor's thread dispatcher.
         FiniteDuration timeout = FiniteDuration.create(newLeaderTimeoutInMillis, TimeUnit.MILLISECONDS);
         newLeaderTimer = raftActor.getContext().system().scheduler().scheduleOnce(timeout, raftActor.self(),
-                new Runnable() {
-                    @Override
-                    public void run() {
-                        LOG.debug("{}: leader not elected in time", raftActor.persistenceId());
-                        finish(true);
-                    }
+                (Runnable) () -> {
+                    LOG.debug("{}: leader not elected in time", raftActor.persistenceId());
+                    finish(true);
                 }, raftActor.getContext().system().dispatcher(), raftActor.self());
     }
 
@@ -162,18 +156,17 @@ public class RaftActorLeadershipTransferCohort {
             transferTimer.stop();
             if(success) {
                 LOG.info("{}: Successfully transferred leadership to {} in {}", raftActor.persistenceId(),
-                        raftActor.getLeaderId(), transferTimer.toString());
+                        raftActor.getLeaderId(), transferTimer);
             } else {
-                LOG.warn("{}: Failed to transfer leadership in {}", raftActor.persistenceId(),
-                        transferTimer.toString());
+                LOG.warn("{}: Failed to transfer leadership in {}", raftActor.persistenceId(), transferTimer);
             }
         }
 
         for(OnComplete onComplete: onCompleteCallbacks) {
             if(success) {
-                onComplete.onSuccess(raftActor.self(), replyTo);
+                onComplete.onSuccess(raftActor.self());
             } else {
-                onComplete.onFailure(raftActor.self(), replyTo);
+                onComplete.onFailure(raftActor.self());
             }
         }
     }
@@ -192,7 +185,7 @@ public class RaftActorLeadershipTransferCohort {
     }
 
     interface OnComplete {
-        void onSuccess(ActorRef raftActorRef, ActorRef replyTo);
-        void onFailure(ActorRef raftActorRef, ActorRef replyTo);
+        void onSuccess(ActorRef raftActorRef);
+        void onFailure(ActorRef raftActorRef);
     }
 }