Class DisruptorDispatcher<T extends DispatcherContainer<T>>
java.lang.Object
com.sportradar.livedata.sdk.dispatch.DisruptorDispatcher<T>
- Type Parameters:
- T- Specifies the type used by disruptor to store unprocessed messages.
- Direct Known Subclasses:
- LiveScoutDisruptorDispatcher
A base class for dispatcher classes which internally uses a disruptor pattern for dispatching.
- 
Field SummaryFields
- 
Constructor SummaryConstructorsModifierConstructorDescriptionprotectedDisruptorDispatcher(ExecutorService executor, int dispatcherCount, int dispatcherQueueSize) Initializes a new instance of theDisruptorDispatcherclass.
- 
Method SummaryModifier and TypeMethodDescriptionprotected abstract com.lmax.disruptor.EventHandler[]protected voidPublishes the passedcontainerto the ring buffer.protected voidstartDisruptor(com.lmax.disruptor.EventFactory<T> containerFactory) Constructs and starts the disruptor and associated elementsprotected voidstopDisruptor(long timeout, TimeUnit timeUnit) Gracefully stops the disruptor in given interval and disposes resources associated with the currentDisruptorDispatcherinstance.
- 
Field Details- 
sdkLoggerTheSdkLoggerinstance used for structured logging.
- 
dispatcherCountprotected final int dispatcherCountThe number of the dispatchers
- 
dispatcherQueueSizeprotected final int dispatcherQueueSizeThe size of the disruptor
- 
halfDispatcherQueueSizeprotected final long halfDispatcherQueueSizeThe half size of the disruptor
 
- 
- 
Constructor Details- 
DisruptorDispatcherprotected DisruptorDispatcher(ExecutorService executor, int dispatcherCount, int dispatcherQueueSize) Initializes a new instance of theDisruptorDispatcherclass.- Parameters:
- executor- The- ExecutorServiceused to spawn background threads
- dispatcherCount- The number of the dispatchers.
- dispatcherQueueSize- The size of the disruptor.
 
 
- 
- 
Method Details- 
publishPublishes the passedcontainerto the ring buffer.- Parameters:
- container- The container to be published
- Throws:
- IllegalStateException- The dispatcher is stopped.
- IllegalArgumentException- The- containeris a null reference.
- com.lmax.disruptor.InsufficientCapacityException- Ring buffer is full.
 
- 
startDisruptorConstructs and starts the disruptor and associated elements Notice that method is not thread safe and should only be called within critical region. - Parameters:
- containerFactory- A- EventFactoryimplementation used to construct containers
- Throws:
- IllegalStateException- the- DisruptorDispatcheris already started.
 
- 
buildConsumersprotected abstract com.lmax.disruptor.EventHandler[] buildConsumers()
- 
stopDisruptorGracefully stops the disruptor in given interval and disposes resources associated with the currentDisruptorDispatcherinstance.- Parameters:
- timeout- timeout
- timeUnit- timeUnit
 
 
-