Package com.bytedesk.core.uid.buffer
Class BufferPaddingExecutor
java.lang.Object
com.bytedesk.core.uid.buffer.BufferPaddingExecutor
Represents an executor for padding
RingBuffer<br>
There are two kinds of executors: one for scheduled padding, the other for padding immediately.- Author:
- yutianbao
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final ExecutorServicePadding immediately by the thread poolprivate final ScheduledExecutorServicePadding schedule threadprivate static final long5 minutesprivate final PaddedAtomicLongWe can borrow UIDs from the future, here store the last second we have consumedprivate static final org.slf4j.Loggerprivate final RingBufferRingBuffer and BufferUidProviderprivate final AtomicBooleanWhether buffer padding is runningprivate static final Stringprivate longSchedule interval Unit as secondsprivate final BufferedUidProviderprivate static final StringConstants -
Constructor Summary
ConstructorsConstructorDescriptionBufferPaddingExecutor(RingBuffer ringBuffer, BufferedUidProvider uidProvider) Constructor withRingBufferandBufferedUidProvider, default use scheduleBufferPaddingExecutor(RingBuffer ringBuffer, BufferedUidProvider uidProvider, boolean usingSchedule) Constructor withRingBuffer,BufferedUidProvider, and whether use schedule padding -
Method Summary
Modifier and TypeMethodDescriptionvoidPadding buffer in the thread poolWhether is paddingvoidPadding buffer fill the slots until to catch the cursorvoidsetScheduleInterval(long scheduleInterval) Settersvoidshutdown()Shutdown executorsvoidstart()Start executors such as schedule
-
Field Details
-
LOGGER
private static final org.slf4j.Logger LOGGER -
WORKER_NAME
Constants- See Also:
-
SCHEDULE_NAME
- See Also:
-
DEFAULT_SCHEDULE_INTERVAL
private static final long DEFAULT_SCHEDULE_INTERVAL5 minutes- See Also:
-
running
Whether buffer padding is running -
lastSecond
We can borrow UIDs from the future, here store the last second we have consumed -
ringBuffer
RingBuffer and BufferUidProvider -
uidProvider
-
bufferPadExecutors
Padding immediately by the thread pool -
bufferPadSchedule
Padding schedule thread -
scheduleInterval
private long scheduleIntervalSchedule interval Unit as seconds
-
-
Constructor Details
-
BufferPaddingExecutor
Constructor withRingBufferandBufferedUidProvider, default use schedule- Parameters:
ringBuffer-RingBufferuidProvider-BufferedUidProvider
-
BufferPaddingExecutor
public BufferPaddingExecutor(RingBuffer ringBuffer, BufferedUidProvider uidProvider, boolean usingSchedule) Constructor withRingBuffer,BufferedUidProvider, and whether use schedule padding- Parameters:
ringBuffer-RingBufferuidProvider-BufferedUidProviderusingSchedule-
-
-
Method Details
-
start
public void start()Start executors such as schedule -
shutdown
public void shutdown()Shutdown executors -
isRunning
Whether is padding- Returns:
-
asyncPadding
public void asyncPadding()Padding buffer in the thread pool -
paddingBuffer
public void paddingBuffer()Padding buffer fill the slots until to catch the cursor -
setScheduleInterval
public void setScheduleInterval(long scheduleInterval) Setters
-