boolean isConfCommitted() { return getLog().getLastCommittedIndex() >= getRaftConf().getLogEntryIndex(); }
boolean isConfCommitted() { return getLog().getLastCommittedIndex() >= getRaftConf().getLogEntryIndex(); }
/** * check if the remote peer is not included in the current conf * and should shutdown. should shutdown if all the following stands: * 1. this is a leader * 2. current conf is stable and has been committed * 3. candidate id is not included in conf * 4. candidate's last entry's index < conf's index */ private boolean shouldSendShutdown(RaftPeerId candidateId, TermIndex candidateLastEntry) { return isLeader() && getRaftConf().isStable() && getState().isConfCommitted() && !getRaftConf().containsInConf(candidateId) && candidateLastEntry.getIndex() < getRaftConf().getLogEntryIndex() && role.getLeaderState().map(ls -> !ls.isBootStrappingPeer(candidateId)).orElse(false); }
private long initStatemachine(StateMachine sm, RaftProperties properties) throws IOException { sm.initialize(selfId, properties, storage); storage.setStateMachineStorage(sm.getStateMachineStorage()); SnapshotInfo snapshot = sm.getLatestSnapshot(); if (snapshot == null || snapshot.getTermIndex().getIndex() < 0) { return RaftServerConstants.INVALID_LOG_INDEX; } // get the raft configuration from the snapshot RaftConfiguration raftConf = sm.getRaftConfiguration(); if (raftConf != null) { configurationManager.addConfiguration(raftConf.getLogEntryIndex(), raftConf); } return snapshot.getIndex(); }
private long initStatemachine(StateMachine sm, RaftGroupId groupId) throws IOException { sm.initialize(server.getProxy(), groupId, storage); storage.setStateMachineStorage(sm.getStateMachineStorage()); SnapshotInfo snapshot = sm.getLatestSnapshot(); if (snapshot == null || snapshot.getTermIndex().getIndex() < 0) { return RaftServerConstants.INVALID_LOG_INDEX; } // get the raft configuration from raft metafile RaftConfiguration raftConf = storage.readRaftConfiguration(); if (raftConf != null) { setRaftConf(raftConf.getLogEntryIndex(), raftConf); } return snapshot.getIndex(); }
/** * check if the remote peer is not included in the current conf * and should shutdown. should shutdown if all the following stands: * 1. this is a leader * 2. current conf is stable and has been committed * 3. candidate id is not included in conf * 4. candidate's last entry's index < conf's index */ private boolean shouldSendShutdown(RaftPeerId candidateId, TermIndex candidateLastEntry) { return isLeader() && getRaftConf().isStable() && getState().isConfCommitted() && !getRaftConf().containsInConf(candidateId) && candidateLastEntry.getIndex() < getRaftConf().getLogEntryIndex() && !leaderState.isBootStrappingPeer(candidateId); }