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 com.google.common.annotations.VisibleForTesting;
16 import com.google.common.base.Supplier;
18 import org.opendaylight.controller.cluster.DataPersistenceProvider;
19 import org.slf4j.Logger;
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.
26 public interface RaftActorContext {
28 * Create a new local actor
32 ActorRef actorOf(Props props);
35 * Create a actor selection
39 ActorSelection actorSelection(String path);
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 * @return the identifier
50 * A reference to the RaftActor itself. This could be used to send messages
57 * Get the ElectionTerm information
60 ElectionTerm getTermInformation();
63 * index of highest log entry known to be
64 * committed (initialized to 0, increases
68 long getCommitIndex();
74 void setCommitIndex(long commitIndex);
77 * index of highest log entry applied to state
78 * machine (initialized to 0, increases
82 long getLastApplied();
88 void setLastApplied(long lastApplied);
92 * @param replicatedLog
94 void setReplicatedLog(ReplicatedLog replicatedLog);
97 * @return A representation of the log
99 ReplicatedLog getReplicatedLog();
102 * @return The ActorSystem associated with this context
104 ActorSystem getActorSystem();
107 * Get the logger to be used for logging messages
114 * Get a mapping of peerId's to their addresses
119 Map<String, String> getPeerAddresses();
122 * Get the address of the peer as a String. This is the same format in
123 * which a consumer would provide the address
126 * @return The address of the peer or null if the address has not yet been
129 String getPeerAddress(String peerId);
136 void addToPeers(String name, String address);
142 void removePeer(String name);
145 * Given a peerId return the corresponding actor
150 * @return The actorSelection corresponding to the peer or null if the
151 * address has not yet been resolved
153 ActorSelection getPeerActorSelection(String peerId);
156 * Set Peer Address can be called at a later time to change the address of
160 * Throws an IllegalStateException if the peer is unknown
165 void setPeerAddress(String peerId, String peerAddress);
168 * @return ConfigParams
170 ConfigParams getConfigParams();
172 SnapshotManager getSnapshotManager();
174 DataPersistenceProvider getPersistenceProvider();
176 boolean hasFollowers();
178 long getTotalMemory();
181 void setTotalMemoryRetriever(Supplier<Long> retriever);