2 * Copyright (c) 2015 Brocade Communications 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
8 package org.opendaylight.controller.cluster.raft.client.messages;
10 import java.util.Collections;
11 import java.util.List;
15 * The response to a GetOnDemandRaftState message,
17 * @author Thomas Pantelis
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 private String customRaftPolicyClassName;
38 private List<FollowerInfo> followerInfoList = Collections.emptyList();
39 private Map<String, String> peerAddresses = Collections.emptyMap();
41 private OnDemandRaftState() {
44 public static Builder builder() {
48 public long getLastLogIndex() {
52 public long getLastLogTerm() {
56 public long getCurrentTerm() {
60 public long getCommitIndex() {
64 public long getLastApplied() {
68 public long getLastIndex() {
72 public long getLastTerm() {
76 public long getSnapshotIndex() {
80 public long getSnapshotTerm() {
84 public long getReplicatedToAllIndex() {
85 return replicatedToAllIndex;
88 public long getInMemoryJournalDataSize() {
89 return inMemoryJournalDataSize;
92 public long getInMemoryJournalLogSize() {
93 return inMemoryJournalLogSize;
96 public String getLeader() {
100 public String getRaftState() {
104 public String getVotedFor() {
108 public boolean isSnapshotCaptureInitiated() {
109 return isSnapshotCaptureInitiated;
112 public List<FollowerInfo> getFollowerInfoList() {
113 return followerInfoList;
116 public Map<String, String> getPeerAddresses() {
117 return peerAddresses;
120 public String getCustomRaftPolicyClassName() {
121 return customRaftPolicyClassName;
124 public static class Builder {
125 private final OnDemandRaftState stats = new OnDemandRaftState();
127 public Builder lastLogIndex(long value) {
128 stats.lastLogIndex = value;
132 public Builder lastLogTerm(long value) {
133 stats.lastLogTerm = value;
137 public Builder currentTerm(long value) {
138 stats.currentTerm = value;
142 public Builder commitIndex(long value) {
143 stats.commitIndex = value;
147 public Builder lastApplied(long value) {
148 stats.lastApplied = value;
152 public Builder lastIndex(long value) {
153 stats.lastIndex = value;
157 public Builder lastTerm(long value) {
158 stats.lastTerm = value;
162 public Builder snapshotIndex(long value) {
163 stats.snapshotIndex = value;
167 public Builder snapshotTerm(long value) {
168 stats.snapshotTerm = value;
172 public Builder replicatedToAllIndex(long value) {
173 stats.replicatedToAllIndex = value;
177 public Builder inMemoryJournalDataSize(long value) {
178 stats.inMemoryJournalDataSize = value;
182 public Builder inMemoryJournalLogSize(long value) {
183 stats.inMemoryJournalLogSize = value;
187 public Builder leader(String value) {
188 stats.leader = value;
192 public Builder raftState(String value) {
193 stats.raftState = value;
197 public Builder votedFor(String value) {
198 stats.votedFor = value;
202 public Builder followerInfoList(List<FollowerInfo> followerInfoList) {
203 stats.followerInfoList = followerInfoList;
207 public Builder peerAddresses(Map<String, String> peerAddresses) {
208 stats.peerAddresses = peerAddresses;
212 public Builder isSnapshotCaptureInitiated(boolean value) {
213 stats.isSnapshotCaptureInitiated = value;
217 public Builder customRaftPolicyClassName(String className) {
218 stats.customRaftPolicyClassName = className;
222 public OnDemandRaftState build() {