Merge "Startup archetype: remove 'Impl' from config subsystem Module name."
[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 import java.util.Map;
16 import org.slf4j.Logger;
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     long getCommitIndex();
66
67
68     /**
69      *
70      */
71     void setCommitIndex(long commitIndex);
72
73     /**
74      * index of highest log entry applied to state
75      * machine (initialized to 0, increases
76      *    monotonically)
77      * @return
78      */
79     long getLastApplied();
80
81
82     /**
83      *
84      */
85     void setLastApplied(long lastApplied);
86
87     /**
88      *
89      * @param replicatedLog
90      */
91     void setReplicatedLog(ReplicatedLog replicatedLog);
92
93     /**
94      * @return A representation of the log
95      */
96     ReplicatedLog getReplicatedLog();
97
98     /**
99      * @return The ActorSystem associated with this context
100      */
101     ActorSystem getActorSystem();
102
103     /**
104      * Get the logger to be used for logging messages
105      *
106      * @return
107      */
108     Logger getLogger();
109
110     /**
111      * Get a mapping of peerId's to their addresses
112      *
113      * @return
114      *
115      */
116     Map<String, String> getPeerAddresses();
117
118     /**
119      * Get the address of the peer as a String. This is the same format in
120      * which a consumer would provide the address
121      *
122      * @param peerId
123      * @return The address of the peer or null if the address has not yet been
124      *         resolved
125      */
126     String getPeerAddress(String peerId);
127
128     /**
129      * Add to actor peers
130      * @param name
131      * @param address
132      */
133     void addToPeers(String name, String address);
134
135     /**
136      *
137      * @param name
138      */
139     void removePeer(String name);
140
141     /**
142      * Given a peerId return the corresponding actor
143      * <p>
144      *
145      *
146      * @param peerId
147      * @return The actorSelection corresponding to the peer or null if the
148      *         address has not yet been resolved
149      */
150     ActorSelection getPeerActorSelection(String peerId);
151
152     /**
153      * Set Peer Address can be called at a later time to change the address of
154      * a known peer.
155      *
156      * <p>
157      * Throws an IllegalStateException if the peer is unknown
158      *
159      * @param peerId
160      * @param peerAddress
161      */
162     void setPeerAddress(String peerId, String peerAddress);
163
164     /**
165      * @return ConfigParams
166      */
167     ConfigParams getConfigParams();
168
169     void setSnapshotCaptureInitiated(boolean snapshotCaptureInitiated);
170
171     boolean isSnapshotCaptureInitiated();
172
173 }