Casting to Follower is not needed, as we can access the leader ID from
the RaftActorBehavior interface.
Change-Id: Id1b0e20571eb12b14791e7e42abe846ebe3a6b9f
Signed-off-by: Robert Varga <rovarga@cisco.com>
// but transfer the previous leaderId so it doesn't immediately try to schedule an election. This
// avoids potential disruption. Otherwise, switch to Follower normally.
RaftActorBehavior behavior = getCurrentBehavior();
// but transfer the previous leaderId so it doesn't immediately try to schedule an election. This
// avoids potential disruption. Otherwise, switch to Follower normally.
RaftActorBehavior behavior = getCurrentBehavior();
- if(behavior instanceof Follower) {
- String previousLeaderId = ((Follower)behavior).getLeaderId();
+ if (behavior != null && behavior.state() == RaftState.Follower) {
+ String previousLeaderId = behavior.getLeaderId();
short previousLeaderPayloadVersion = behavior.getLeaderPayloadVersion();
LOG.debug("{}: Re-initializing to Follower with previous leaderId {}", persistenceId(), previousLeaderId);
short previousLeaderPayloadVersion = behavior.getLeaderPayloadVersion();
LOG.debug("{}: Re-initializing to Follower with previous leaderId {}", persistenceId(), previousLeaderId);
- @Override public String getLeaderId() {
+ @Override
+ public String getLeaderId() {