- protected RaftActorBehavior switchBehavior(RaftActorBehavior behavior) {
- LOG.info("{} :- Switching from behavior {} to {}", logName(), this.state(), behavior.state());
+ @Override
+ public RaftActorBehavior switchBehavior(RaftActorBehavior behavior) {
+ return internalSwitchBehavior(behavior);
+ }
+
+ protected RaftActorBehavior internalSwitchBehavior(RaftState newState) {
+ if(context.getRaftPolicy().automaticElectionsEnabled()){
+ return internalSwitchBehavior(newState.createBehavior(context));
+ }
+ return this;
+ }
+
+ private RaftActorBehavior internalSwitchBehavior(RaftActorBehavior newBehavior) {
+ LOG.info("{} :- Switching from behavior {} to {}", logName(), this.state(), newBehavior.state());