CLEANUP : Fix javadoc warnings in sal-akka-raft code
[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 com.google.common.annotations.VisibleForTesting;
16 import com.google.common.base.Supplier;
17 import java.util.Map;
18 import org.opendaylight.controller.cluster.DataPersistenceProvider;
19 import org.slf4j.Logger;
20
21 /**
22  * The RaftActorContext contains that portion of the RaftActors state that
23  * needs to be shared with it's behaviors. A RaftActorContext should NEVER be
24  * used in any actor context outside the RaftActor that constructed it.
25  */
26 public interface RaftActorContext {
27     /**
28      * Create a new local actor
29      * @param props
30      * @return a reference to the newly created actor
31      */
32     ActorRef actorOf(Props props);
33
34     /**
35      * Create a actor selection
36      * @param path
37      * @return an actor selection for the given actor path
38      */
39     ActorSelection actorSelection(String path);
40
41     /**
42      * Get the identifier for the RaftActor. This identifier represents the
43      * name of the actor whose common state is being shared. For example the
44      * id could be 'inventory'
45      *
46      * @return the identifier
47      */
48     String getId();
49
50     /**
51      * @return A reference to the RaftActor itself. This could be used to send messages
52      * to the RaftActor
53      */
54     ActorRef getActor();
55
56     /**
57      * @return the ElectionTerm information
58      */
59     ElectionTerm getTermInformation();
60
61     /**
62      * @return index of highest log entry known to be committed (initialized to 0, increases monotonically)
63      */
64     long getCommitIndex();
65
66
67     /**
68      * @param commitIndex new commit index
69      */
70     void setCommitIndex(long commitIndex);
71
72     /**
73      * @return index of highest log entry applied to state machine (initialized to 0, increases monotonically)
74      */
75     long getLastApplied();
76
77
78     /**
79      * @param lastApplied the index of the last log entry that was applied to the state
80      */
81     void setLastApplied(long lastApplied);
82
83     /**
84      *
85      * @param replicatedLog the replicated log of the current RaftActor
86      */
87     void setReplicatedLog(ReplicatedLog replicatedLog);
88
89     /**
90      * @return A representation of the log
91      */
92     ReplicatedLog getReplicatedLog();
93
94     /**
95      * @return The ActorSystem associated with this context
96      */
97     ActorSystem getActorSystem();
98
99     /**
100      * @return the logger to be used for logging messages to a log file
101      */
102     Logger getLogger();
103
104     /**
105      * @return a mapping of peerId's to their addresses
106      *
107      */
108     Map<String, String> getPeerAddresses();
109
110     /**
111      * Get the address of the peer as a String. This is the same format in
112      * which a consumer would provide the address
113      *
114      * @param peerId
115      * @return The address of the peer or null if the address has not yet been
116      *         resolved
117      */
118     String getPeerAddress(String peerId);
119
120     /**
121      * Add to actor peers
122      *
123      * @param name
124      * @param address
125      */
126     void addToPeers(String name, String address);
127
128     /**
129      *
130      * @param name
131      */
132     void removePeer(String name);
133
134     /**
135      * Given a peerId return the corresponding actor
136      * <p>
137      *
138      *
139      * @param peerId
140      * @return The actorSelection corresponding to the peer or null if the
141      *         address has not yet been resolved
142      */
143     ActorSelection getPeerActorSelection(String peerId);
144
145     /**
146      * Set Peer Address can be called at a later time to change the address of
147      * a known peer.
148      *
149      * <p>
150      * Throws an IllegalStateException if the peer is unknown
151      *
152      * @param peerId
153      * @param peerAddress
154      */
155     void setPeerAddress(String peerId, String peerAddress);
156
157     /**
158      * @return ConfigParams
159      */
160     ConfigParams getConfigParams();
161
162     /**
163      *
164      * @return the SnapshotManager for this RaftActor
165      */
166     SnapshotManager getSnapshotManager();
167
168     /**
169      *
170      * @return the DataPersistenceProvider for this RaftActor
171      */
172     DataPersistenceProvider getPersistenceProvider();
173
174     /**
175      *
176      * @return true if the RaftActor has followers else false
177      */
178     boolean hasFollowers();
179
180     /**
181      *
182      * @return the total memory used by the ReplicatedLog
183      */
184     long getTotalMemory();
185
186     /**
187      *
188      * @param retriever a supplier of the total memory metric
189      */
190     @VisibleForTesting
191     void setTotalMemoryRetriever(Supplier<Long> retriever);
192
193     /**
194      *
195      * @return the payload version to be used when replicating data
196      */
197     short getPayloadVersion();
198 }