use of com.lmax.disruptor.FatalExceptionHandler in project disruptor by LMAX-Exchange.
the class DisruptorTest method shouldOnlyApplyExceptionsHandlersSpecifiedViaHandleExceptionsWithOnNewEventProcessors.
@Test
public void shouldOnlyApplyExceptionsHandlersSpecifiedViaHandleExceptionsWithOnNewEventProcessors() throws Exception {
AtomicReference<Throwable> eventHandled = new AtomicReference<Throwable>();
ExceptionHandler exceptionHandler = new StubExceptionHandler(eventHandled);
RuntimeException testException = new RuntimeException();
ExceptionThrowingEventHandler handler = new ExceptionThrowingEventHandler(testException);
disruptor.handleExceptionsWith(exceptionHandler);
disruptor.handleEventsWith(handler);
disruptor.handleExceptionsWith(new FatalExceptionHandler());
publishEvent();
final Throwable actualException = waitFor(eventHandled);
assertSame(testException, actualException);
}
use of com.lmax.disruptor.FatalExceptionHandler in project opennms by OpenNMS.
the class NewtsWriter method setUpWorkerPool.
private void setUpWorkerPool() {
// Executor that will be used to construct new threads for consumers
final ThreadFactory namedThreadFactory = new ThreadFactoryBuilder().setNameFormat("NewtsWriter-Consumer-%d").build();
final Executor executor = Executors.newCachedThreadPool(namedThreadFactory);
@SuppressWarnings("unchecked") final WorkHandler<SampleBatchEvent>[] handlers = new WorkHandler[m_numWriterThreads];
for (int i = 0; i < m_numWriterThreads; i++) {
handlers[i] = this;
}
m_ringBuffer = RingBuffer.createMultiProducer(SampleBatchEvent::new, m_ringBufferSize);
m_workerPool = new WorkerPool<SampleBatchEvent>(m_ringBuffer, m_ringBuffer.newBarrier(), new FatalExceptionHandler(), handlers);
m_ringBuffer.addGatingSequences(m_workerPool.getWorkerSequences());
m_workerPool.start(executor);
}
Aggregations