Properly handle RequestVote in all states
[controller.git] / opendaylight / md-sal / sal-akka-raft / src / main / java / org / opendaylight / controller / cluster / raft / RaftActorContext.java
1 /*
2  * Copyright (c) 2014 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;
10
11 import akka.actor.ActorRef;
12 import akka.actor.ActorSelection;
13 import akka.actor.ActorSystem;
14 import akka.actor.Props;
15
16 /**
17  * The RaftActorContext contains that portion of the RaftActors state that
18  * needs to be shared with it's behaviors. A RaftActorContext should NEVER be
19  * used in any actor context outside the RaftActor that constructed it.
20  */
21 public interface RaftActorContext {
22     /**
23      * Create a new local actor
24       * @param props
25      * @return
26      */
27     ActorRef actorOf(Props props);
28
29     /**
30      * Create a actor selection
31      * @param path
32      * @return
33      */
34     ActorSelection actorSelection(String path);
35
36     /**
37      * Get the identifier for the RaftActor. This identifier represents the
38      * name of the actor whose common state is being shared. For example the
39      * id could be 'inventory'
40      * @return the identifier
41      */
42     String getId();
43
44     /**
45      * A reference to the RaftActor itself. This could be used to send messages
46      * to the RaftActor
47      * @return
48      */
49     ActorRef getActor();
50
51     /**
52      * Get the ElectionTerm information
53      * @return
54      */
55     ElectionTerm getTermInformation();
56
57     /**
58      * index of highest log entry known to be
59      * committed (initialized to 0, increases
60      *    monotonically)
61      * @return
62      */
63     long getCommitIndex();
64
65
66     /**
67      *
68      */
69     void setCommitIndex(long commitIndex);
70
71     /**
72      * index of highest log entry applied to state
73      * machine (initialized to 0, increases
74      *    monotonically)
75      * @return
76      */
77     long getLastApplied();
78
79
80     /**
81      *
82      */
83     void setLastApplied(long lastApplied);
84
85     /**
86      * @return A representation of the log
87      */
88     ReplicatedLog getReplicatedLog();
89
90     /**
91      * @return The ActorSystem associated with this context
92      */
93     ActorSystem getActorSystem();
94 }