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.slf4j.Logger;
21 * The RaftActorContext contains that portion of the RaftActors state that
22 * needs to be shared with it's behaviors. A RaftActorContext should NEVER be
23 * used in any actor context outside the RaftActor that constructed it.
25 public interface RaftActorContext {
27 * Create a new local actor
31 ActorRef actorOf(Props props);
34 * Create a actor selection
38 ActorSelection actorSelection(String path);
41 * Get the identifier for the RaftActor. This identifier represents the
42 * name of the actor whose common state is being shared. For example the
43 * id could be 'inventory'
44 * @return the identifier
49 * A reference to the RaftActor itself. This could be used to send messages
56 * Get the ElectionTerm information
59 ElectionTerm getTermInformation();
62 * index of highest log entry known to be
63 * committed (initialized to 0, increases
67 long getCommitIndex();
73 void setCommitIndex(long commitIndex);
76 * index of highest log entry applied to state
77 * machine (initialized to 0, increases
81 long getLastApplied();
87 void setLastApplied(long lastApplied);
91 * @param replicatedLog
93 void setReplicatedLog(ReplicatedLog replicatedLog);
96 * @return A representation of the log
98 ReplicatedLog getReplicatedLog();
101 * @return The ActorSystem associated with this context
103 ActorSystem getActorSystem();
106 * Get the logger to be used for logging messages
113 * Get a mapping of peerId's to their addresses
118 Map<String, String> getPeerAddresses();
121 * Get the address of the peer as a String. This is the same format in
122 * which a consumer would provide the address
125 * @return The address of the peer or null if the address has not yet been
128 String getPeerAddress(String peerId);
135 void addToPeers(String name, String address);
141 void removePeer(String name);
144 * Given a peerId return the corresponding actor
149 * @return The actorSelection corresponding to the peer or null if the
150 * address has not yet been resolved
152 ActorSelection getPeerActorSelection(String peerId);
155 * Set Peer Address can be called at a later time to change the address of
159 * Throws an IllegalStateException if the peer is unknown
164 void setPeerAddress(String peerId, String peerAddress);
167 * @return ConfigParams
169 ConfigParams getConfigParams();
171 SnapshotManager getSnapshotManager();
173 boolean hasFollowers();
175 long getTotalMemory();
178 void setTotalMemoryRetriever(Supplier<Long> retriever);