public SegmentedRaftLog(RaftPeerId selfId, RaftServerImpl server, RaftStorage storage, long lastIndexInSnapshot, RaftProperties properties) throws IOException { super(selfId, RaftServerConfigKeys.Log.Appender.bufferCapacity(properties) .getSizeInt()); this.server = server; this.storage = storage; segmentMaxSize = RaftServerConfigKeys.Log.segmentSizeMax(properties).getSize(); cache = new RaftLogCache(selfId, storage, properties); fileLogWorker = new RaftLogWorker(selfId, server, storage, properties); lastCommitted.set(lastIndexInSnapshot); }
/** * note we do not apply log entries to the state machine here since we do not * know whether they have been committed. */ private RaftLog initLog(RaftPeerId id, RaftProperties prop, long lastIndexInSnapshot, Consumer<LogEntryProto> logConsumer) throws IOException { final RaftLog log; if (RaftServerConfigKeys.Log.useMemory(prop)) { final int maxBufferSize = RaftServerConfigKeys.Log.Appender.bufferCapacity(prop).getSizeInt(); log = new MemoryRaftLog(id, maxBufferSize); } else { log = new SegmentedRaftLog(id, server, this.storage, lastIndexInSnapshot, prop); } log.open(lastIndexInSnapshot, logConsumer); return log; }
public LogAppender(RaftServerImpl server, LeaderState leaderState, FollowerInfo f) { this.follower = f; this.server = server; this.leaderState = leaderState; this.raftLog = server.getState().getLog(); final RaftProperties properties = server.getProxy().getProperties(); this.maxBufferSize = RaftServerConfigKeys.Log.Appender.bufferCapacity(properties).getSizeInt(); this.batchSending = RaftServerConfigKeys.Log.Appender.batchEnabled(properties); this.snapshotChunkMaxSize = RaftServerConfigKeys.Log.Appender.snapshotChunkSizeMax(properties).getSizeInt(); this.halfMinTimeoutMs = server.getMinTimeoutMs() / 2; this.buffer = new LogEntryBuffer(); this.lifeCycle = new LifeCycle(this); }