845011a7e372548999c9b643d26630528543e473
[controller.git] / opendaylight / md-sal / sal-akka-raft / src / main / java / org / opendaylight / controller / cluster / raft / RaftActorContextImpl.java
1 /*
2  * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
3  *
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
7  */
8
9 package org.opendaylight.controller.cluster.raft;
10
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;
16
17 public class RaftActorContextImpl implements RaftActorContext{
18
19     private final ActorRef actor;
20
21     private final UntypedActorContext context;
22
23     private final String id;
24
25     private final ElectionTerm termInformation;
26
27     private long commitIndex;
28
29     private long lastApplied;
30
31     private final ReplicatedLog replicatedLog;
32
33     public RaftActorContextImpl(ActorRef actor, UntypedActorContext context,
34         String id,
35         ElectionTerm termInformation, long commitIndex,
36         long lastApplied, ReplicatedLog replicatedLog) {
37         this.actor = actor;
38         this.context = context;
39         this.id = id;
40         this.termInformation = termInformation;
41         this.commitIndex = commitIndex;
42         this.lastApplied = lastApplied;
43         this.replicatedLog = replicatedLog;
44     }
45
46     public ActorRef actorOf(Props props){
47         return context.actorOf(props);
48     }
49
50     public ActorSelection actorSelection(String path){
51         return context.actorSelection(path);
52     }
53
54     public String getId() {
55         return id;
56     }
57
58     public ActorRef getActor() {
59         return actor;
60     }
61
62     public ElectionTerm getTermInformation() {
63         return termInformation;
64     }
65
66     public long getCommitIndex() {
67         return commitIndex;
68     }
69
70     @Override public void setCommitIndex(long commitIndex) {
71         this.commitIndex = commitIndex;
72     }
73
74     public long getLastApplied() {
75         return lastApplied;
76     }
77
78     @Override public void setLastApplied(long lastApplied) {
79         this.lastApplied = lastApplied;
80     }
81
82     @Override public ReplicatedLog getReplicatedLog() {
83         return replicatedLog;
84     }
85
86     @Override public ActorSystem getActorSystem() {
87         return context.system();
88     }
89 }