Class BufferPaddingExecutor

java.lang.Object
com.bytedesk.core.uid.buffer.BufferPaddingExecutor

public class BufferPaddingExecutor extends Object
Represents an executor for padding RingBuffer
There are two kinds of executors: one for scheduled padding, the other for padding immediately.
Author:
yutianbao
  • Field Details

    • LOGGER

      private static final org.slf4j.Logger LOGGER
    • WORKER_NAME

      private static final String WORKER_NAME
      Constants
      See Also:
    • SCHEDULE_NAME

      private static final String SCHEDULE_NAME
      See Also:
    • DEFAULT_SCHEDULE_INTERVAL

      private static final long DEFAULT_SCHEDULE_INTERVAL
      5 minutes
      See Also:
    • running

      private final AtomicBoolean running
      Whether buffer padding is running
    • lastSecond

      private final PaddedAtomicLong lastSecond
      We can borrow UIDs from the future, here store the last second we have consumed
    • ringBuffer

      private final RingBuffer ringBuffer
      RingBuffer and BufferUidProvider
    • uidProvider

      private final BufferedUidProvider uidProvider
    • bufferPadExecutors

      private final ExecutorService bufferPadExecutors
      Padding immediately by the thread pool
    • bufferPadSchedule

      private final ScheduledExecutorService bufferPadSchedule
      Padding schedule thread
    • scheduleInterval

      private long scheduleInterval
      Schedule interval Unit as seconds
  • Constructor Details

  • 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