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 import java.util.concurrent.atomic.AtomicLong;
19 public class RaftActorContextImpl implements RaftActorContext{
21 private final ActorRef actor;
23 private final UntypedActorContext context;
25 private final String id;
27 private final ElectionTerm termInformation;
29 private final AtomicLong commitIndex;
31 private final AtomicLong lastApplied;
33 private final ReplicatedLog replicatedLog;
35 public RaftActorContextImpl(ActorRef actor, UntypedActorContext context,
37 ElectionTerm termInformation, AtomicLong commitIndex,
38 AtomicLong lastApplied, ReplicatedLog replicatedLog) {
40 this.context = context;
42 this.termInformation = termInformation;
43 this.commitIndex = commitIndex;
44 this.lastApplied = lastApplied;
45 this.replicatedLog = replicatedLog;
48 public ActorRef actorOf(Props props){
49 return context.actorOf(props);
52 public ActorSelection actorSelection(String path){
53 return context.actorSelection(path);
56 public String getId() {
60 public ActorRef getActor() {
64 public ElectionTerm getTermInformation() {
65 return termInformation;
68 public AtomicLong getCommitIndex() {
72 public AtomicLong getLastApplied() {
76 @Override public ReplicatedLog getReplicatedLog() {
80 @Override public ActorSystem getActorSystem() {
81 return context.system();