2 * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
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
9 package org.opendaylight.controller.cluster.raft;
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;
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.
24 public interface RaftActorContext {
26 * Create a new local actor
30 ActorRef actorOf(Props props);
33 * Create a actor selection
37 ActorSelection actorSelection(String path);
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
48 * A reference to the RaftActor itself. This could be used to send messages
55 * Get the ElectionTerm information
58 ElectionTerm getTermInformation();
61 * index of highest log entry known to be
62 * committed (initialized to 0, increases
66 long getCommitIndex();
72 void setCommitIndex(long commitIndex);
75 * index of highest log entry applied to state
76 * machine (initialized to 0, increases
80 long getLastApplied();
86 void setLastApplied(long lastApplied);
90 * @param replicatedLog
92 public void setReplicatedLog(ReplicatedLog replicatedLog);
95 * @return A representation of the log
97 ReplicatedLog getReplicatedLog();
100 * @return The ActorSystem associated with this context
102 ActorSystem getActorSystem();
105 * Get the logger to be used for logging messages
109 LoggingAdapter getLogger();
112 * Get a mapping of peerId's to their addresses
117 Map<String, String> getPeerAddresses();
120 * Get the address of the peer as a String. This is the same format in
121 * which a consumer would provide the address
124 * @return The address of the peer or null if the address has not yet been
127 String getPeerAddress(String peerId);
134 void addToPeers(String name, String address);
140 public void removePeer(String name);
143 * Given a peerId return the corresponding actor
148 * @return The actorSelection corresponding to the peer or null if the
149 * address has not yet been resolved
151 ActorSelection getPeerActorSelection(String peerId);
154 * Set Peer Address can be called at a later time to change the address of
158 * Throws an IllegalStateException if the peer is unknown
163 void setPeerAddress(String peerId, String peerAddress);
166 * @return ConfigParams
168 public ConfigParams getConfigParams();