Fix intermittent PreLeaderScenarioTest failure
[controller.git] / opendaylight / md-sal / sal-akka-raft / src / main / java / org / opendaylight / controller / cluster / raft / RaftActorContext.java
index 2896c44a2cef79ef12e002a5332b414e3368e4db..0fe6cf1e2fecbfd1529a85bc50a1d769fdcd6d9d 100644 (file)
@@ -16,10 +16,13 @@ import akka.cluster.Cluster;
 import com.google.common.annotations.VisibleForTesting;
 import java.util.Collection;
 import java.util.Optional;
+import java.util.function.Consumer;
 import java.util.function.LongSupplier;
 import javax.annotation.Nonnull;
 import javax.annotation.Nullable;
 import org.opendaylight.controller.cluster.DataPersistenceProvider;
+import org.opendaylight.controller.cluster.io.FileBackedOutputStream;
+import org.opendaylight.controller.cluster.raft.base.messages.ApplyState;
 import org.opendaylight.controller.cluster.raft.behaviors.RaftActorBehavior;
 import org.opendaylight.controller.cluster.raft.persisted.ServerConfigurationPayload;
 import org.opendaylight.controller.cluster.raft.policy.RaftPolicy;
@@ -316,4 +319,35 @@ public interface RaftActorContext {
      * @return current behavior.
      */
     RaftActorBehavior getCurrentBehavior();
+
+    /**
+     * Returns the consumer of ApplyState operations. This is invoked by a behavior when a log entry needs to be
+     * applied to the state.
+     *
+     * @return the Consumer
+     */
+    Consumer<ApplyState> getApplyStateConsumer();
+
+    /**
+     * Creates a FileBackedOutputStream with a common configuration.
+     *
+     * @return a FileBackedOutputStream instance
+     */
+    @Nonnull
+    FileBackedOutputStream newFileBackedOutputStream();
+
+    /**
+     * Returns the RaftActorLeadershipTransferCohort if leadership transfer is in progress.
+     *
+     * @return the RaftActorLeadershipTransferCohort if leadership transfer is in progress, null otherwise
+     */
+    @Nullable
+    RaftActorLeadershipTransferCohort getRaftActorLeadershipTransferCohort();
+
+    /**
+     * Sets the RaftActorLeadershipTransferCohort for transferring leadership.
+     *
+     * @param leadershipTransferCohort the RaftActorLeadershipTransferCohort or null to clear the existing one
+     */
+    void setRaftActorLeadershipTransferCohort(@Nullable RaftActorLeadershipTransferCohort leadershipTransferCohort);
 }