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;
16 import org.slf4j.Logger;
19 * The RaftActorContext contains that portion of the RaftActors state that
20 * needs to be shared with it's behaviors. A RaftActorContext should NEVER be
21 * used in any actor context outside the RaftActor that constructed it.
23 public interface RaftActorContext {
25 * Create a new local actor
29 ActorRef actorOf(Props props);
32 * Create a actor selection
36 ActorSelection actorSelection(String path);
39 * Get the identifier for the RaftActor. This identifier represents the
40 * name of the actor whose common state is being shared. For example the
41 * id could be 'inventory'
42 * @return the identifier
47 * A reference to the RaftActor itself. This could be used to send messages
54 * Get the ElectionTerm information
57 ElectionTerm getTermInformation();
60 * index of highest log entry known to be
61 * committed (initialized to 0, increases
65 long getCommitIndex();
71 void setCommitIndex(long commitIndex);
74 * index of highest log entry applied to state
75 * machine (initialized to 0, increases
79 long getLastApplied();
85 void setLastApplied(long lastApplied);
89 * @param replicatedLog
91 void setReplicatedLog(ReplicatedLog replicatedLog);
94 * @return A representation of the log
96 ReplicatedLog getReplicatedLog();
99 * @return The ActorSystem associated with this context
101 ActorSystem getActorSystem();
104 * Get the logger to be used for logging messages
111 * Get a mapping of peerId's to their addresses
116 Map<String, String> getPeerAddresses();
119 * Get the address of the peer as a String. This is the same format in
120 * which a consumer would provide the address
123 * @return The address of the peer or null if the address has not yet been
126 String getPeerAddress(String peerId);
133 void addToPeers(String name, String address);
139 void removePeer(String name);
142 * Given a peerId return the corresponding actor
147 * @return The actorSelection corresponding to the peer or null if the
148 * address has not yet been resolved
150 ActorSelection getPeerActorSelection(String peerId);
153 * Set Peer Address can be called at a later time to change the address of
157 * Throws an IllegalStateException if the peer is unknown
162 void setPeerAddress(String peerId, String peerAddress);
165 * @return ConfigParams
167 ConfigParams getConfigParams();
169 void setSnapshotCaptureInitiated(boolean snapshotCaptureInitiated);
171 boolean isSnapshotCaptureInitiated();