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%2Fraft%2Fbehaviors%2FIsolatedLeader.java;h=9ba39c2fcc456bf5b9a2ad528d411ef99e81abd6;hb=bfe4439155b27fbf9ae300252420c8a81fcbdb80;hp=a623660dfd4b97d6b868a9aa8751d9cb645c1ab0;hpb=f7f6b1742311d27967f1740795a25772da74f2c8;p=controller.git diff --git a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/behaviors/IsolatedLeader.java b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/behaviors/IsolatedLeader.java index a623660dfd..9ba39c2fcc 100644 --- a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/behaviors/IsolatedLeader.java +++ b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/behaviors/IsolatedLeader.java @@ -8,26 +8,33 @@ package org.opendaylight.controller.cluster.raft.behaviors; import akka.actor.ActorRef; +import javax.annotation.Nullable; import org.opendaylight.controller.cluster.raft.RaftActorContext; import org.opendaylight.controller.cluster.raft.RaftState; import org.opendaylight.controller.cluster.raft.messages.AppendEntriesReply; /** * Leader which is termed as isolated. - *

+ * + *

* If the reply from the majority of the followers is not received then the leader changes its behavior * to IsolatedLeader. An isolated leader may have followers and they would continue to receive replicated messages. - *

+ * + *

* A schedule is run, at an interval of (10 * Heartbeat-time-interval), in the Leader * to check if its isolated or not. - *

+ * + *

* In the Isolated Leader , on every AppendEntriesReply, we aggressively check if the leader is isolated. * If no, then the state is switched back to Leader. - * */ public class IsolatedLeader extends AbstractLeader { + IsolatedLeader(RaftActorContext context, @Nullable AbstractLeader initializeFromLeader) { + super(context, RaftState.IsolatedLeader, initializeFromLeader); + } + public IsolatedLeader(RaftActorContext context) { - super(context, RaftState.IsolatedLeader); + this(context, null); } // we received an Append Entries reply, we should switch the Behavior to Leader @@ -39,8 +46,8 @@ public class IsolatedLeader extends AbstractLeader { // it can happen that this isolated leader interacts with a new leader in the cluster and // changes its state to Follower, hence we only need to switch to Leader if the state is still Isolated if (ret.state() == RaftState.IsolatedLeader && !isLeaderIsolated()) { - LOG.info("IsolatedLeader {} switching from IsolatedLeader to Leader", leaderId); - return internalSwitchBehavior(RaftState.Leader); + log.info("IsolatedLeader {} switching from IsolatedLeader to Leader", getLeaderId()); + return internalSwitchBehavior(new Leader(context, this)); } return ret; }