9ec8dddf6a11773cb07f1206350cd9175e6c8b9d
[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.Props;
14 import akka.actor.UntypedActorContext;
15
16 import java.util.concurrent.atomic.AtomicLong;
17
18 public class RaftActorContextImpl implements RaftActorContext{
19
20     private final ActorRef actor;
21
22     private final UntypedActorContext context;
23
24     private final String id;
25
26     private final ElectionTerm termInformation;
27
28     private final AtomicLong commitIndex;
29
30     private final AtomicLong lastApplied;
31
32     private final ReplicatedLog replicatedLog;
33
34     public RaftActorContextImpl(ActorRef actor, UntypedActorContext context,
35         String id,
36         ElectionTerm termInformation, AtomicLong commitIndex,
37         AtomicLong lastApplied, ReplicatedLog replicatedLog) {
38         this.actor = actor;
39         this.context = context;
40         this.id = id;
41         this.termInformation = termInformation;
42         this.commitIndex = commitIndex;
43         this.lastApplied = lastApplied;
44         this.replicatedLog = replicatedLog;
45     }
46
47     public ActorRef actorOf(Props props){
48         return context.actorOf(props);
49     }
50
51     public ActorSelection actorSelection(String path){
52         return context.actorSelection(path);
53     }
54
55     public String getId() {
56         return id;
57     }
58
59     public ActorRef getActor() {
60         return actor;
61     }
62
63     public ElectionTerm getTermInformation() {
64         return termInformation;
65     }
66
67     public AtomicLong getCommitIndex() {
68         return commitIndex;
69     }
70
71     public AtomicLong getLastApplied() {
72         return lastApplied;
73     }
74
75     @Override public ReplicatedLog getReplicatedLog() {
76         return replicatedLog;
77     }
78 }