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%2Fraft%2FRaftActorLeadershipTransferCohort.java;h=c3d5af55cd401d2e66507d61983446a5e7e1b58b;hp=5b27d50130a980891dbbbc2f072d0705fa3b8c9b;hb=HEAD;hpb=de1ed2cb86a3c897d307a4b73a89384465c3ca6f diff --git a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/RaftActorLeadershipTransferCohort.java b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/RaftActorLeadershipTransferCohort.java index 5b27d50130..3aeaff6d89 100644 --- a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/RaftActorLeadershipTransferCohort.java +++ b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/RaftActorLeadershipTransferCohort.java @@ -11,12 +11,12 @@ import akka.actor.ActorRef; import akka.actor.ActorSelection; import akka.actor.Cancellable; import com.google.common.annotations.VisibleForTesting; -import com.google.common.base.Optional; import com.google.common.base.Stopwatch; import java.util.ArrayList; import java.util.List; +import java.util.Optional; import java.util.concurrent.TimeUnit; -import javax.annotation.Nullable; +import org.eclipse.jdt.annotation.Nullable; import org.opendaylight.controller.cluster.raft.base.messages.LeaderTransitioning; import org.opendaylight.controller.cluster.raft.behaviors.Leader; import org.opendaylight.controller.cluster.raft.behaviors.RaftActorBehavior; @@ -69,7 +69,7 @@ public class RaftActorLeadershipTransferCohort { this(raftActor, null); } - RaftActorLeadershipTransferCohort(final RaftActor raftActor, @Nullable final String requestedFollowerId) { + RaftActorLeadershipTransferCohort(final RaftActor raftActor, final @Nullable String requestedFollowerId) { this.raftActor = raftActor; this.requestedFollowerId = requestedFollowerId; @@ -89,7 +89,7 @@ public class RaftActorLeadershipTransferCohort { Optional roleChangeNotifier = raftActor.getRoleChangeNotifier(); if (roleChangeNotifier.isPresent()) { - roleChangeNotifier.get().tell(raftActor.newLeaderStateChanged(context.getId(), null, + roleChangeNotifier.orElseThrow().tell(raftActor.newLeaderStateChanged(context.getId(), null, currentBehavior.getLeaderPayloadVersion()), raftActor.self()); } @@ -122,9 +122,9 @@ public class RaftActorLeadershipTransferCohort { void doTransfer() { RaftActorBehavior behavior = raftActor.getCurrentBehavior(); // Sanity check... - if (behavior instanceof Leader) { + if (behavior instanceof Leader leader) { isTransferring = true; - ((Leader)behavior).transferLeadership(this); + leader.transferLeadership(this); } else { LOG.debug("{}: No longer the leader - skipping transfer", raftActor.persistenceId()); finish(true); @@ -206,7 +206,7 @@ public class RaftActorLeadershipTransferCohort { } public Optional getRequestedFollowerId() { - return Optional.fromNullable(requestedFollowerId); + return Optional.ofNullable(requestedFollowerId); } interface OnComplete {