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();
102 LoggingAdapter getLogger();
105 * Get a mapping of peer id's their addresses
108 Map<String, String> getPeerAddresses();
115 String getPeerAddress(String peerId);
122 void addToPeers(String name, String address);
128 public void removePeer(String name);