Package com.bytedesk.core.uid.buffer
Class BufferPaddingExecutor
java.lang.Object
com.bytedesk.core.uid.buffer.BufferPaddingExecutor
Represents an executor for padding
There are two kinds of executors: one for scheduled padding, the other for padding immediately.
RingBuffer
There are two kinds of executors: one for scheduled padding, the other for padding immediately.
- Author:
- yutianbao
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final ExecutorService
Padding immediately by the thread poolprivate final ScheduledExecutorService
Padding schedule threadprivate static final long
5 minutesprivate final PaddedAtomicLong
We can borrow UIDs from the future, here store the last second we have consumedprivate static final org.slf4j.Logger
private final RingBuffer
RingBuffer and BufferUidProviderprivate final AtomicBoolean
Whether buffer padding is runningprivate static final String
private long
Schedule interval Unit as secondsprivate final BufferedUidProvider
private static final String
Constants -
Constructor Summary
ConstructorsConstructorDescriptionBufferPaddingExecutor
(RingBuffer ringBuffer, BufferedUidProvider uidProvider) Constructor withRingBuffer
andBufferedUidProvider
, default use scheduleBufferPaddingExecutor
(RingBuffer ringBuffer, BufferedUidProvider uidProvider, boolean usingSchedule) Constructor withRingBuffer
,BufferedUidProvider
, and whether use schedule padding -
Method Summary
Modifier and TypeMethodDescriptionvoid
Padding buffer in the thread poolboolean
Whether is paddingvoid
Padding buffer fill the slots until to catch the cursorvoid
setScheduleInterval
(long scheduleInterval) Settersvoid
shutdown()
Shutdown executorsvoid
start()
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 withRingBuffer
andBufferedUidProvider
, default use schedule- Parameters:
ringBuffer
-RingBuffer
uidProvider
-BufferedUidProvider
-
BufferPaddingExecutor
public BufferPaddingExecutor(RingBuffer ringBuffer, BufferedUidProvider uidProvider, boolean usingSchedule) Constructor withRingBuffer
,BufferedUidProvider
, and whether use schedule padding- Parameters:
ringBuffer
-RingBuffer
uidProvider
-BufferedUidProvider
usingSchedule
-
-
-
Method Details
-
start
public void start()Start executors such as schedule -
shutdown
public void shutdown()Shutdown executors -
isRunning
public boolean 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
-