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;
37 private List<FollowerInfo> followerInfoList = Collections.emptyList();
38 private Map<String, String> peerAddresses = Collections.emptyMap();
40 private OnDemandRaftState() {
43 public static Builder builder() {
47 public long getLastLogIndex() {
51 public long getLastLogTerm() {
55 public long getCurrentTerm() {
59 public long getCommitIndex() {
63 public long getLastApplied() {
67 public long getLastIndex() {
71 public long getLastTerm() {
75 public long getSnapshotIndex() {
79 public long getSnapshotTerm() {
83 public long getReplicatedToAllIndex() {
84 return replicatedToAllIndex;
87 public long getInMemoryJournalDataSize() {
88 return inMemoryJournalDataSize;
91 public long getInMemoryJournalLogSize() {
92 return inMemoryJournalLogSize;
95 public String getLeader() {
99 public String getRaftState() {
103 public String getVotedFor() {
107 public boolean isSnapshotCaptureInitiated() {
108 return isSnapshotCaptureInitiated;
111 public List<FollowerInfo> getFollowerInfoList() {
112 return followerInfoList;
115 public Map<String, String> getPeerAddresses() {
116 return peerAddresses;
119 public static class Builder {
120 private final OnDemandRaftState stats = new OnDemandRaftState();
122 public Builder lastLogIndex(long value) {
123 stats.lastLogIndex = value;
127 public Builder lastLogTerm(long value) {
128 stats.lastLogTerm = value;
132 public Builder currentTerm(long value) {
133 stats.currentTerm = value;
137 public Builder commitIndex(long value) {
138 stats.commitIndex = value;
142 public Builder lastApplied(long value) {
143 stats.lastApplied = value;
147 public Builder lastIndex(long value) {
148 stats.lastIndex = value;
152 public Builder lastTerm(long value) {
153 stats.lastTerm = value;
157 public Builder snapshotIndex(long value) {
158 stats.snapshotIndex = value;
162 public Builder snapshotTerm(long value) {
163 stats.snapshotTerm = value;
167 public Builder replicatedToAllIndex(long value) {
168 stats.replicatedToAllIndex = value;
172 public Builder inMemoryJournalDataSize(long value) {
173 stats.inMemoryJournalDataSize = value;
177 public Builder inMemoryJournalLogSize(long value) {
178 stats.inMemoryJournalLogSize = value;
182 public Builder leader(String value) {
183 stats.leader = value;
187 public Builder raftState(String value) {
188 stats.raftState = value;
192 public Builder votedFor(String value) {
193 stats.votedFor = value;
197 public Builder followerInfoList(List<FollowerInfo> followerInfoList) {
198 stats.followerInfoList = followerInfoList;
202 public Builder peerAddresses(Map<String, String> peerAddresses) {
203 stats.peerAddresses = peerAddresses;
207 public Builder isSnapshotCaptureInitiated(boolean value) {
208 stats.isSnapshotCaptureInitiated = value;
212 public OnDemandRaftState build() {