use of org.opendaylight.controller.cluster.raft.messages.RequestLeadership in project controller by opendaylight.
the class LeadershipTransferIntegrationTest method sendFollower2RequestLeadershipTransferToLeader.
private void sendFollower2RequestLeadershipTransferToLeader() {
testLog.info("sendFollower2RequestLeadershipTransferToLeader starting");
leaderActor.tell(new RequestLeadership(follower2Id, requestLeadershipResultCollectorActor), ActorRef.noSender());
testLog.info("sendFollower2RequestLeadershipTransferToLeader ending");
}
use of org.opendaylight.controller.cluster.raft.messages.RequestLeadership in project controller by opendaylight.
the class Shard method onMakeLeaderLocal.
private void onMakeLeaderLocal() {
LOG.debug("{}: onMakeLeaderLocal received", persistenceId());
if (isLeader()) {
getSender().tell(new Status.Success(null), getSelf());
return;
}
final ActorSelection leader = getLeader();
if (leader == null) {
// Leader is not present. The cluster is most likely trying to
// elect a leader and we should let that run its normal course
// TODO we can wait for the election to complete and retry the
// request. We can also let the caller retry by sending a flag
// in the response indicating the request is "reTryable".
getSender().tell(new Failure(new LeadershipTransferFailedException("We cannot initiate leadership transfer to local node. " + "Currently there is no leader for " + persistenceId())), getSelf());
return;
}
leader.tell(new RequestLeadership(getId(), getSender()), getSelf());
}
use of org.opendaylight.controller.cluster.raft.messages.RequestLeadership in project controller by opendaylight.
the class RaftActor method handleCommand.
/**
* Handles a message.
*
* @deprecated This method is not final for testing purposes. DO NOT OVERRIDE IT, override
* {@link #handleNonRaftCommand(Object)} instead.
*/
@Deprecated
@Override
protected // FIXME: make this method final once our unit tests do not need to override it
void handleCommand(final Object message) {
if (serverConfigurationSupport.handleMessage(message, getSender())) {
return;
}
if (snapshotSupport.handleSnapshotMessage(message, getSender())) {
return;
}
if (message instanceof ApplyState) {
ApplyState applyState = (ApplyState) message;
if (!hasFollowers()) {
// for single node, the capture should happen after the apply state
// as we delete messages from the persistent journal which have made it to the snapshot
// capturing the snapshot before applying makes the persistent journal and snapshot out of sync
// and recovery shows data missing
context.getReplicatedLog().captureSnapshotIfReady(applyState.getReplicatedLogEntry());
context.getSnapshotManager().trimLog(context.getLastApplied());
}
possiblyHandleBehaviorMessage(message);
} else if (message instanceof ApplyJournalEntries) {
ApplyJournalEntries applyEntries = (ApplyJournalEntries) message;
LOG.debug("{}: Persisting ApplyJournalEntries with index={}", persistenceId(), applyEntries.getToIndex());
persistence().persistAsync(applyEntries, NoopProcedure.instance());
} else if (message instanceof FindLeader) {
getSender().tell(new FindLeaderReply(getLeaderAddress()), getSelf());
} else if (message instanceof GetOnDemandRaftState) {
onGetOnDemandRaftStats();
} else if (message instanceof InitiateCaptureSnapshot) {
captureSnapshot();
} else if (message instanceof SwitchBehavior) {
switchBehavior((SwitchBehavior) message);
} else if (message instanceof LeaderTransitioning) {
onLeaderTransitioning((LeaderTransitioning) message);
} else if (message instanceof Shutdown) {
onShutDown();
} else if (message instanceof Runnable) {
((Runnable) message).run();
} else if (message instanceof NoopPayload) {
persistData(null, null, (NoopPayload) message, false);
} else if (message instanceof RequestLeadership) {
onRequestLeadership((RequestLeadership) message);
} else if (!possiblyHandleBehaviorMessage(message)) {
handleNonRaftCommand(message);
}
}
Aggregations