Merge "Fixed for bug : 1171 - issue while creating subnet"
[controller.git] / opendaylight / md-sal / sal-akka-raft / src / main / java / org / opendaylight / controller / cluster / raft / FollowerLogInformationImpl.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 java.util.concurrent.atomic.AtomicLong;
12
13 public class FollowerLogInformationImpl implements FollowerLogInformation{
14
15     private final String id;
16
17     private final AtomicLong nextIndex;
18
19     private final AtomicLong matchIndex;
20
21     public FollowerLogInformationImpl(String id, AtomicLong nextIndex,
22         AtomicLong matchIndex) {
23         this.id = id;
24         this.nextIndex = nextIndex;
25         this.matchIndex = matchIndex;
26     }
27
28     public long incrNextIndex(){
29         return nextIndex.incrementAndGet();
30     }
31
32     @Override public long decrNextIndex() {
33         return nextIndex.decrementAndGet();
34     }
35
36     @Override public void setNextIndex(long nextIndex) {
37         this.nextIndex.set(nextIndex);
38     }
39
40     public long incrMatchIndex(){
41         return matchIndex.incrementAndGet();
42     }
43
44     @Override public void setMatchIndex(long matchIndex) {
45         this.matchIndex.set(matchIndex);
46     }
47
48     public String getId() {
49         return id;
50     }
51
52     public AtomicLong getNextIndex() {
53         return nextIndex;
54     }
55
56     public AtomicLong getMatchIndex() {
57         return matchIndex;
58     }
59
60 }