RaftLogWorker(RaftPeerId selfId, RaftServerImpl raftServer, RaftStorage storage, RaftProperties properties) { this.name = selfId + "-" + getClass().getSimpleName(); LOG.info("new {} for {}", name, storage); this.raftServer = raftServer; this.stateMachine = raftServer != null? raftServer.getStateMachine(): null; this.storage = storage; this.segmentMaxSize = RaftServerConfigKeys.Log.segmentSizeMax(properties).getSize(); this.preallocatedSize = RaftServerConfigKeys.Log.preallocatedSize(properties).getSize(); this.bufferSize = RaftServerConfigKeys.Log.writeBufferSize(properties).getSizeInt(); this.forceSyncNum = RaftServerConfigKeys.Log.forceSyncNum(properties); this.workerThread = new Thread(this, name); // Server Id can be null in unit tests Supplier<String> serverId = () -> raftServer == null || raftServer.getId() == null ? "null" : raftServer.getId().toString(); this.logFlushTimer = JavaUtils.memoize(() -> RatisMetricsRegistry.getRegistry() .timer(MetricRegistry.name(RaftLogWorker.class, serverId.get(), "flush-time"))); }
RaftLogWorker(RaftPeerId selfId, StateMachine stateMachine, Runnable submitUpdateCommitEvent, RaftStorage storage, RaftProperties properties) { this.name = selfId + "-" + getClass().getSimpleName(); LOG.info("new {} for {}", name, storage); this.submitUpdateCommitEvent = submitUpdateCommitEvent; this.stateMachine = stateMachine; this.storage = storage; final SizeInBytes queueByteLimit = RaftServerConfigKeys.Log.queueByteLimit(properties); final int queueElementLimit = RaftServerConfigKeys.Log.queueElementLimit(properties); this.queue = new DataBlockingQueue<>(name, queueByteLimit, queueElementLimit, Task::getSerializedSize); this.segmentMaxSize = RaftServerConfigKeys.Log.segmentSizeMax(properties).getSize(); this.preallocatedSize = RaftServerConfigKeys.Log.preallocatedSize(properties).getSize(); this.bufferSize = RaftServerConfigKeys.Log.writeBufferSize(properties).getSizeInt(); this.forceSyncNum = RaftServerConfigKeys.Log.forceSyncNum(properties); this.stateMachineDataPolicy = new StateMachineDataPolicy(properties); this.workerThread = new Thread(this, name); // Server Id can be null in unit tests this.logFlushTimer = JavaUtils.memoize(() -> RatisMetricsRegistry.getRegistry() .timer(MetricRegistry.name(RaftLogWorker.class, selfId.toString(), "flush-time"))); }
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); }
@Before public void setup() throws Exception { storageDir = getTestDir(); properties = new RaftProperties(); RaftServerConfigKeys.setStorageDir(properties, storageDir); storage = new RaftStorage(storageDir, RaftServerConstants.StartupOption.REGULAR); this.segmentMaxSize = RaftServerConfigKeys.Log.segmentSizeMax(properties).getSize(); this.preallocatedSize = RaftServerConfigKeys.Log.preallocatedSize(properties).getSize(); this.bufferSize = RaftServerConfigKeys.Log.writeBufferSize(properties).getSizeInt(); }
@Before public void setup() throws Exception { storageDir = getTestDir(); properties = new RaftProperties(); RaftServerConfigKeys.setStorageDirs(properties, Collections.singletonList(storageDir)); storage = new RaftStorage(storageDir, RaftServerConstants.StartupOption.REGULAR); this.segmentMaxSize = RaftServerConfigKeys.Log.segmentSizeMax(properties).getSize(); this.preallocatedSize = RaftServerConfigKeys.Log.preallocatedSize(properties).getSize(); this.bufferSize = RaftServerConfigKeys.Log.writeBufferSize(properties).getSizeInt(); }
@Before public void setup() throws Exception { RaftProperties properties = new RaftProperties(); storageDir = getTestDir(); RaftServerConfigKeys.setStorageDirs(properties, Collections.singletonList(storageDir)); this.segmentMaxSize = RaftServerConfigKeys.Log.segmentSizeMax(properties).getSize(); this.preallocatedSize = RaftServerConfigKeys.Log.preallocatedSize(properties).getSize(); this.bufferSize = RaftServerConfigKeys.Log.writeBufferSize(properties).getSizeInt(); }
@Before public void setup() throws Exception { storageDir = getTestDir(); RaftProperties properties = new RaftProperties(); RaftServerConfigKeys.setStorageDirs(properties, Collections.singletonList(storageDir)); this.segmentMaxSize = RaftServerConfigKeys.Log.segmentSizeMax(properties).getSize(); this.preallocatedSize = RaftServerConfigKeys.Log.preallocatedSize(properties).getSize(); this.bufferSize = RaftServerConfigKeys.Log.writeBufferSize(properties).getSizeInt(); }
@Before public void setup() throws Exception { storageDir = getTestDir(); RaftProperties properties = new RaftProperties(); RaftServerConfigKeys.setStorageDir(properties, storageDir); this.segmentMaxSize = RaftServerConfigKeys.Log.segmentSizeMax(properties).getSize(); this.preallocatedSize = RaftServerConfigKeys.Log.preallocatedSize(properties).getSize(); this.bufferSize = RaftServerConfigKeys.Log.writeBufferSize(properties).getSizeInt(); }
SegmentedRaftLog(RaftPeerId selfId, RaftServerImpl server, StateMachine stateMachine, Runnable submitUpdateCommitEvent, RaftStorage storage, long lastIndexInSnapshot, RaftProperties properties) { super(selfId, lastIndexInSnapshot, RaftServerConfigKeys.Log.Appender.bufferByteLimit(properties).getSizeInt()); this.server = Optional.ofNullable(server); this.storage = storage; segmentMaxSize = RaftServerConfigKeys.Log.segmentSizeMax(properties).getSize(); cache = new RaftLogCache(selfId, storage, properties); this.fileLogWorker = new RaftLogWorker(selfId, stateMachine, submitUpdateCommitEvent, storage, properties); stateMachineCachingEnabled = RaftServerConfigKeys.Log.StateMachineData.cachingEnabled(properties); }
@Before public void setup() throws Exception { RaftProperties properties = new RaftProperties(); storageDir = getTestDir(); RaftServerConfigKeys.setStorageDir(properties, storageDir); this.segmentMaxSize = RaftServerConfigKeys.Log.segmentSizeMax(properties).getSize(); this.preallocatedSize = RaftServerConfigKeys.Log.preallocatedSize(properties).getSize(); this.bufferSize = RaftServerConfigKeys.Log.writeBufferSize(properties).getSizeInt(); }