Merge "Remove RaftReplicator and move hearbeat logic to the leader"
[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 import java.util.concurrent.atomic.AtomicLong;
17
18 /**
19  * The RaftActorContext contains that portion of the RaftActors state that
20  * needs to be shared with it's behaviors. A RaftActorContext should NEVER be
21  * used in any actor context outside the RaftActor that constructed it.
22  */
23 public interface RaftActorContext {
24     /**
25      * Create a new local actor
26       * @param props
27      * @return
28      */
29     ActorRef actorOf(Props props);
30
31     /**
32      * Create a actor selection
33      * @param path
34      * @return
35      */
36     ActorSelection actorSelection(String path);
37
38     /**
39      * Get the identifier for the RaftActor. This identifier represents the
40      * name of the actor whose common state is being shared. For example the
41      * id could be 'inventory'
42      * @return the identifier
43      */
44     String getId();
45
46     /**
47      * A reference to the RaftActor itself. This could be used to send messages
48      * to the RaftActor
49      * @return
50      */
51     ActorRef getActor();
52
53     /**
54      * Get the ElectionTerm information
55      * @return
56      */
57     ElectionTerm getTermInformation();
58
59     /**
60      * index of highest log entry known to be
61      * committed (initialized to 0, increases
62      *    monotonically)
63      * @return
64      */
65     AtomicLong getCommitIndex();
66
67     /**
68      * index of highest log entry applied to state
69      * machine (initialized to 0, increases
70      *    monotonically)
71      * @return
72      */
73     AtomicLong getLastApplied();
74
75     /**
76      * @return A representation of the log
77      */
78     ReplicatedLog getReplicatedLog();
79
80     /**
81      * @return The ActorSystem associated with this context
82      */
83     ActorSystem getActorSystem();
84 }