MCPcopy Create free account
hub / github.com/e2wugui/zeze / Raft

Method Raft

ZezeJava/ZezeJavaTest/src/SimpleRaft/Raft.java:195–208  ·  view source on GitHub ↗
(final @NotNull Env env, final int raftCount, final int selfId, final long curTime)

Source from the content-addressed store, hash-verified

193 private final HashMap<Long, Long> appendingLogMap = new HashMap<>(); // <index, serial>
194
195 public Raft(final @NotNull Env env, final int raftCount, final int selfId, final long curTime) {
196 if (raftCount < 2 || raftCount > 127)
197 throw new IllegalArgumentException("raftCount=" + raftCount + " is not in [2,127]");
198 if (selfId < 0 || selfId >= raftCount)
199 throw new IllegalArgumentException("selfId=" + selfId + " is not in [0," + raftCount + ')');
200 this.env = env;
201 this.raftCount = (byte)raftCount;
202 this.selfId = (byte)selfId;
203 timeout = curTime + env.random(RANDOM_TIMEOUT_MAX);
204 nextIndexes = new long[raftCount];
205 appendingTimeouts = new long[raftCount];
206 if (ENABLE_TRACE)
207 env.traceInfo("started: timeout=" + timeout);
208 }
209
210 public int getLeaderId() {
211 return leaderId;

Callers

nothing calls this directly

Calls 2

randomMethod · 0.65
traceInfoMethod · 0.65

Tested by

no test coverage detected