Merge "Fixed unneeded wrapping of guava for karaf"
[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      * @return A representation of the log
90      */
91     ReplicatedLog getReplicatedLog();
92
93     /**
94      * @return The ActorSystem associated with this context
95      */
96     ActorSystem getActorSystem();
97
98     /**
99      *
100      * @return
101      */
102     LoggingAdapter getLogger();
103
104     /**
105      * Get a mapping of peer id's their addresses
106      * @return
107      */
108     Map<String, String> getPeerAddresses();
109
110     /**
111      *
112      * @param peerId
113      * @return
114      */
115     String getPeerAddress(String peerId);
116
117     /**
118      * Add to actor peers
119      * @param name
120      * @param address
121      */
122     void addToPeers(String name, String address);
123
124     /**
125      *
126      * @param name
127      */
128     public void removePeer(String name);
129 }