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.actor.UntypedActorContext;
17 public class RaftActorContextImpl implements RaftActorContext{
19 private final ActorRef actor;
21 private final UntypedActorContext context;
23 private final String id;
25 private final ElectionTerm termInformation;
27 private long commitIndex;
29 private long lastApplied;
31 private final ReplicatedLog replicatedLog;
33 public RaftActorContextImpl(ActorRef actor, UntypedActorContext context,
35 ElectionTerm termInformation, long commitIndex,
36 long lastApplied, ReplicatedLog replicatedLog) {
38 this.context = context;
40 this.termInformation = termInformation;
41 this.commitIndex = commitIndex;
42 this.lastApplied = lastApplied;
43 this.replicatedLog = replicatedLog;
46 public ActorRef actorOf(Props props){
47 return context.actorOf(props);
50 public ActorSelection actorSelection(String path){
51 return context.actorSelection(path);
54 public String getId() {
58 public ActorRef getActor() {
62 public ElectionTerm getTermInformation() {
63 return termInformation;
66 public long getCommitIndex() {
70 @Override public void setCommitIndex(long commitIndex) {
71 this.commitIndex = commitIndex;
74 public long getLastApplied() {
78 @Override public void setLastApplied(long lastApplied) {
79 this.lastApplied = lastApplied;
82 @Override public ReplicatedLog getReplicatedLog() {
86 @Override public ActorSystem getActorSystem() {
87 return context.system();