summary |
shortlog |
log |
commit | commitdiff |
review |
tree
raw |
patch |
inline | side by side (from parent 1:
872a40f)
Modified it to continue with leadership transfer if pauseLeader times out
instead of aborting. The shard may have a lot of transactions queued up
which it can't finish in time but there may still be a follower that is
caught up (ie whose matchIndex equals the leader's lastIndex) or would be
caught up if leadership transfer continued. Worst case is no follower is
available and the "catch up" phase of leadership transfer also times out
which would lengthen shut down time but that should be fine.
Change-Id: I1ec1ef43bb556e50416bb7239ce3c267265db9b3
Signed-off-by: Tom Pantelis <tompantelis@gmail.com>
(cherry picked from commit
dac16f0d464eff3325b3800a803e81b303964e4b)
raftActor.pauseLeader(new TimedRunnable(context.getConfigParams().getElectionTimeOutInterval(), raftActor) {
@Override
protected void doRun() {
raftActor.pauseLeader(new TimedRunnable(context.getConfigParams().getElectionTimeOutInterval(), raftActor) {
@Override
protected void doRun() {
+ LOG.debug("{}: pauseLeader successfully completed - doing transfer", raftActor.persistenceId());
doTransfer();
}
@Override
protected void doCancel() {
doTransfer();
}
@Override
protected void doCancel() {
- LOG.debug("{}: pauseLeader timed out - aborting transfer", raftActor.persistenceId());
- abortTransfer();
+ LOG.debug("{}: pauseLeader timed out - continuing with transfer", raftActor.persistenceId());
+ doTransfer();
import org.junit.After;
import org.junit.Test;
import org.opendaylight.controller.cluster.raft.RaftActorLeadershipTransferCohort.OnComplete;
import org.junit.After;
import org.junit.Test;
import org.opendaylight.controller.cluster.raft.RaftActorLeadershipTransferCohort.OnComplete;
+import org.opendaylight.controller.cluster.raft.behaviors.Leader;
import org.opendaylight.controller.cluster.raft.policy.DisableElectionsRaftPolicy;
/**
import org.opendaylight.controller.cluster.raft.policy.DisableElectionsRaftPolicy;
/**
private void setup(String testName) {
String persistenceId = factory.generateActorId(testName + "-leader-");
private void setup(String testName) {
String persistenceId = factory.generateActorId(testName + "-leader-");
+ config.setCustomRaftPolicyImplementationClass(DisableElectionsRaftPolicy.class.getName());
mockRaftActor = factory.<MockRaftActor>createTestActor(MockRaftActor.builder().id(persistenceId).config(config)
.pauseLeaderFunction(pauseLeaderFunction).props().withDispatcher(Dispatchers.DefaultDispatcherId()),
persistenceId).underlyingActor();
mockRaftActor = factory.<MockRaftActor>createTestActor(MockRaftActor.builder().id(persistenceId).config(config)
.pauseLeaderFunction(pauseLeaderFunction).props().withDispatcher(Dispatchers.DefaultDispatcherId()),
persistenceId).underlyingActor();
@Test
public void testNotLeaderOnDoTransfer() {
@Test
public void testNotLeaderOnDoTransfer() {
- config.setCustomRaftPolicyImplementationClass(DisableElectionsRaftPolicy.class.getName());
setup("testNotLeaderOnDoTransfer");
cohort.doTransfer();
verify(onComplete).onSuccess(mockRaftActor.self());
setup("testNotLeaderOnDoTransfer");
cohort.doTransfer();
verify(onComplete).onSuccess(mockRaftActor.self());
@Test
public void testPauseLeaderTimeout() {
pauseLeaderFunction = input -> null;
@Test
public void testPauseLeaderTimeout() {
pauseLeaderFunction = input -> null;
setup("testPauseLeaderTimeout");
setup("testPauseLeaderTimeout");
+
+ Leader leader = new Leader(mockRaftActor.getRaftActorContext()) {
+ @Override
+ public void transferLeadership(RaftActorLeadershipTransferCohort leadershipTransferCohort) {
+ leadershipTransferCohort.transferComplete();
+ }
+ };
+ mockRaftActor.setCurrentBehavior(leader);
+
- verify(onComplete, timeout(2000)).onFailure(mockRaftActor.self());
+ verify(onComplete, timeout(2000)).onSuccess(mockRaftActor.self());