Merge "BUG-2679 Workaround for wrong nagasena encode/decode with reused transmogrifier"
[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 akka.event.LoggingAdapter;
16
17 import java.util.Map;
18
19 /**
20  * The RaftActorContext contains that portion of the RaftActors state that
21  * needs to be shared with it's behaviors. A RaftActorContext should NEVER be
22  * used in any actor context outside the RaftActor that constructed it.
23  */
24 public interface RaftActorContext {
25     /**
26      * Create a new local actor
27       * @param props
28      * @return
29      */
30     ActorRef actorOf(Props props);
31
32     /**
33      * Create a actor selection
34      * @param path
35      * @return
36      */
37     ActorSelection actorSelection(String path);
38
39     /**
40      * Get the identifier for the RaftActor. This identifier represents the
41      * name of the actor whose common state is being shared. For example the
42      * id could be 'inventory'
43      * @return the identifier
44      */
45     String getId();
46
47     /**
48      * A reference to the RaftActor itself. This could be used to send messages
49      * to the RaftActor
50      * @return
51      */
52     ActorRef getActor();
53
54     /**
55      * Get the ElectionTerm information
56      * @return
57      */
58     ElectionTerm getTermInformation();
59
60     /**
61      * index of highest log entry known to be
62      * committed (initialized to 0, increases
63      *    monotonically)
64      * @return
65      */
66     long getCommitIndex();
67
68
69     /**
70      *
71      */
72     void setCommitIndex(long commitIndex);
73
74     /**
75      * index of highest log entry applied to state
76      * machine (initialized to 0, increases
77      *    monotonically)
78      * @return
79      */
80     long getLastApplied();
81
82
83     /**
84      *
85      */
86     void setLastApplied(long lastApplied);
87
88     /**
89      *
90      * @param replicatedLog
91      */
92     void setReplicatedLog(ReplicatedLog replicatedLog);
93
94     /**
95      * @return A representation of the log
96      */
97     ReplicatedLog getReplicatedLog();
98
99     /**
100      * @return The ActorSystem associated with this context
101      */
102     ActorSystem getActorSystem();
103
104     /**
105      * Get the logger to be used for logging messages
106      *
107      * @return
108      */
109     LoggingAdapter getLogger();
110
111     /**
112      * Get a mapping of peerId's to their addresses
113      *
114      * @return
115      *
116      */
117     Map<String, String> getPeerAddresses();
118
119     /**
120      * Get the address of the peer as a String. This is the same format in
121      * which a consumer would provide the address
122      *
123      * @param peerId
124      * @return The address of the peer or null if the address has not yet been
125      *         resolved
126      */
127     String getPeerAddress(String peerId);
128
129     /**
130      * Add to actor peers
131      * @param name
132      * @param address
133      */
134     void addToPeers(String name, String address);
135
136     /**
137      *
138      * @param name
139      */
140     void removePeer(String name);
141
142     /**
143      * Given a peerId return the corresponding actor
144      * <p>
145      *
146      *
147      * @param peerId
148      * @return The actorSelection corresponding to the peer or null if the
149      *         address has not yet been resolved
150      */
151     ActorSelection getPeerActorSelection(String peerId);
152
153     /**
154      * Set Peer Address can be called at a later time to change the address of
155      * a known peer.
156      *
157      * <p>
158      * Throws an IllegalStateException if the peer is unknown
159      *
160      * @param peerId
161      * @param peerAddress
162      */
163     void setPeerAddress(String peerId, String peerAddress);
164
165     /**
166      * @return ConfigParams
167      */
168     ConfigParams getConfigParams();
169
170     void setSnapshotCaptureInitiated(boolean snapshotCaptureInitiated);
171
172     boolean isSnapshotCaptureInitiated();
173
174 }