Merge "Bug 2820 - LLDP TLV support and testing"
[controller.git] / opendaylight / md-sal / sal-akka-raft / src / main / java / org / opendaylight / controller / cluster / raft / client / messages / OnDemandRaftState.java
1 /*
2  * Copyright (c) 2015 Brocade Communications 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 package org.opendaylight.controller.cluster.raft.client.messages;
9
10 import java.util.Collections;
11 import java.util.List;
12 import java.util.Map;
13
14 /**
15  * The response to a GetOnDemandRaftState message,
16  *
17  * @author Thomas Pantelis
18  */
19 public class OnDemandRaftState {
20     private long lastLogIndex = -1L;
21     private long lastLogTerm = -1L;
22     private long currentTerm = -1L;
23     private long commitIndex = -1L;
24     private long lastApplied = -1L;
25     private long lastIndex = -1L;
26     private long lastTerm = -1L;
27     private long snapshotIndex = -1L;
28     private long snapshotTerm = -1L;
29     private long replicatedToAllIndex = -1L;
30     private long inMemoryJournalDataSize;
31     private long inMemoryJournalLogSize;
32     private String leader;
33     private String raftState;
34     private String votedFor;
35     private boolean isSnapshotCaptureInitiated;
36
37     private List<FollowerInfo> followerInfoList = Collections.emptyList();
38     private Map<String, String> peerAddresses = Collections.emptyMap();
39
40     private OnDemandRaftState() {
41     }
42
43     public static Builder builder() {
44         return new Builder();
45     }
46
47     public long getLastLogIndex() {
48         return lastLogIndex;
49     }
50
51     public long getLastLogTerm() {
52         return lastLogTerm;
53     }
54
55     public long getCurrentTerm() {
56         return currentTerm;
57     }
58
59     public long getCommitIndex() {
60         return commitIndex;
61     }
62
63     public long getLastApplied() {
64         return lastApplied;
65     }
66
67     public long getLastIndex() {
68         return lastIndex;
69     }
70
71     public long getLastTerm() {
72         return lastTerm;
73     }
74
75     public long getSnapshotIndex() {
76         return snapshotIndex;
77     }
78
79     public long getSnapshotTerm() {
80         return snapshotTerm;
81     }
82
83     public long getReplicatedToAllIndex() {
84         return replicatedToAllIndex;
85     }
86
87     public long getInMemoryJournalDataSize() {
88         return inMemoryJournalDataSize;
89     }
90
91     public long getInMemoryJournalLogSize() {
92         return inMemoryJournalLogSize;
93     }
94
95     public String getLeader() {
96         return leader;
97     }
98
99     public String getRaftState() {
100         return raftState;
101     }
102
103     public String getVotedFor() {
104         return votedFor;
105     }
106
107     public boolean isSnapshotCaptureInitiated() {
108         return isSnapshotCaptureInitiated;
109     }
110
111     public List<FollowerInfo> getFollowerInfoList() {
112         return followerInfoList;
113     }
114
115     public Map<String, String> getPeerAddresses() {
116         return peerAddresses;
117     }
118
119     public static class Builder {
120         private final OnDemandRaftState stats = new OnDemandRaftState();
121
122         public Builder lastLogIndex(long value) {
123             stats.lastLogIndex = value;
124             return this;
125         }
126
127         public Builder lastLogTerm(long value) {
128             stats.lastLogTerm = value;
129             return this;
130         }
131
132         public Builder currentTerm(long value) {
133             stats.currentTerm = value;
134             return this;
135         }
136
137         public Builder commitIndex(long value) {
138             stats.commitIndex = value;
139             return this;
140         }
141
142         public Builder lastApplied(long value) {
143             stats.lastApplied = value;
144             return this;
145         }
146
147         public Builder lastIndex(long value) {
148             stats.lastIndex = value;
149             return this;
150         }
151
152         public Builder lastTerm(long value) {
153             stats.lastTerm = value;
154             return this;
155         }
156
157         public Builder snapshotIndex(long value) {
158             stats.snapshotIndex = value;
159             return this;
160         }
161
162         public Builder snapshotTerm(long value) {
163             stats.snapshotTerm = value;
164             return this;
165         }
166
167         public Builder replicatedToAllIndex(long value) {
168             stats.replicatedToAllIndex = value;
169             return this;
170         }
171
172         public Builder inMemoryJournalDataSize(long value) {
173             stats.inMemoryJournalDataSize = value;
174             return this;
175         }
176
177         public Builder inMemoryJournalLogSize(long value) {
178             stats.inMemoryJournalLogSize = value;
179             return this;
180         }
181
182         public Builder leader(String value) {
183             stats.leader = value;
184             return this;
185         }
186
187         public Builder raftState(String value) {
188             stats.raftState = value;
189             return this;
190         }
191
192         public Builder votedFor(String value) {
193             stats.votedFor = value;
194             return this;
195         }
196
197         public Builder followerInfoList(List<FollowerInfo> followerInfoList) {
198             stats.followerInfoList = followerInfoList;
199             return this;
200         }
201
202         public Builder peerAddresses(Map<String, String> peerAddresses) {
203             stats.peerAddresses = peerAddresses;
204             return this;
205         }
206
207         public Builder isSnapshotCaptureInitiated(boolean value) {
208             stats.isSnapshotCaptureInitiated = value;
209             return this;
210         }
211
212         public OnDemandRaftState build() {
213             return stats;
214         }
215     }
216 }