Fix warnings and clean up javadocs in sal-akka-raft
[controller.git] / opendaylight / md-sal / sal-akka-raft / src / main / java / org / opendaylight / controller / cluster / raft / policy / RaftPolicy.java
1 /*
2  * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8
9 package org.opendaylight.controller.cluster.raft.policy;
10
11 /**
12  * The RaftPolicy is intended to change the default behavior of Raft. For example
13  * we may want to be able to determine which Raft replica should become the leader - with Raft elections are
14  * randomized so it is not possible to specify which replica should be the leader. The ability to specify
15  * the leader would be quite useful when testing a raft cluster.
16  * <p/>
17  * Similarly we may want to customize when exactly we apply a modification to the state - with Raft a modification
18  * is only applied to the state when the modification is replicated to a majority of the replicas. The ability to
19  * apply a modification to the state before consensus would be useful in scenarios where you have only 2 nodes
20  * in a Raft cluster and one of them is down but you still want the RaftActor to apply a modification to the state.
21  *
22  */
23 public interface RaftPolicy {
24     /**
25      * According to Raft a Follower which does not receive a heartbeat (aka AppendEntries) in a given period should
26      * become a Candidate and trigger an election.
27      *
28      * @return true to enable automatic Raft elections, false to disable them
29      */
30     boolean automaticElectionsEnabled();
31
32     /**
33      * According to Raft consensus on a Raft entry is achieved only after a Leader replicates a log entry to a
34      * majority of it's followers.
35      *
36      * @return true if modification should be applied before consensus, false to apply modification to state
37      *     as per Raft
38      */
39     boolean applyModificationToStateBeforeConsensus();
40 }