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(); }