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);
89 * @return A representation of the log
91 ReplicatedLog getReplicatedLog();
94 * @return The ActorSystem associated with this context
96 ActorSystem getActorSystem();
99 * Get the logger to be used for logging messages
103 LoggingAdapter getLogger();
106 * Get a mapping of peerId's to their addresses
111 Map<String, String> getPeerAddresses();
114 * Get the address of the peer as a String. This is the same format in
115 * which a consumer would provide the address
118 * @return The address of the peer or null if the address has not yet been
121 String getPeerAddress(String peerId);
128 void addToPeers(String name, String address);
134 public void removePeer(String name);
137 * Given a peerId return the corresponding actor
142 * @return The actorSelection corresponding to the peer or null if the
143 * address has not yet been resolved
145 ActorSelection getPeerActorSelection(String peerId);
148 * Set Peer Address can be called at a later time to change the address of
152 * Throws an IllegalStateException if the peer is unknown
157 void setPeerAddress(String peerId, String peerAddress);