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);
this.logFlushTimer = JavaUtils.memoize(() -> RatisMetricsRegistry.getRegistry()
.timer(MetricRegistry.name(RaftLogWorker.class, selfId.toString(), "flush-time")));
}