use of com.lmax.disruptor.dsl.stubs.DelayedEventHandler in project disruptor by LMAX-Exchange.
the class DisruptorTest method createDelayedEventHandler.
private DelayedEventHandler createDelayedEventHandler() {
final DelayedEventHandler delayedEventHandler = new DelayedEventHandler();
delayedEventHandlers.add(delayedEventHandler);
return delayedEventHandler;
}
use of com.lmax.disruptor.dsl.stubs.DelayedEventHandler in project disruptor by LMAX-Exchange.
the class DisruptorTest method shouldWaitUntilAllFirstEventProcessorsProcessEventBeforeMakingItAvailableToDependentEventProcessors.
@Test
public void shouldWaitUntilAllFirstEventProcessorsProcessEventBeforeMakingItAvailableToDependentEventProcessors() throws Exception {
DelayedEventHandler eventHandler1 = createDelayedEventHandler();
CountDownLatch countDownLatch = new CountDownLatch(2);
EventHandler<TestEvent> eventHandler2 = new EventHandlerStub<TestEvent>(countDownLatch);
disruptor.handleEventsWith(eventHandler1).then(eventHandler2);
ensureTwoEventsProcessedAccordingToDependencies(countDownLatch, eventHandler1);
}
use of com.lmax.disruptor.dsl.stubs.DelayedEventHandler in project disruptor by LMAX-Exchange.
the class DisruptorTest method shouldSupportCombiningWorkerPoolWithEventHandlerAsDependencyWhenNotPreviouslyRegistered.
@Test
public void shouldSupportCombiningWorkerPoolWithEventHandlerAsDependencyWhenNotPreviouslyRegistered() throws Exception {
final TestWorkHandler workHandler1 = createTestWorkHandler();
final DelayedEventHandler delayedEventHandler1 = createDelayedEventHandler();
final DelayedEventHandler delayedEventHandler2 = createDelayedEventHandler();
disruptor.handleEventsWith(delayedEventHandler1).and(disruptor.handleEventsWithWorkerPool(workHandler1)).then(delayedEventHandler2);
publishEvent();
publishEvent();
delayedEventHandler1.processEvent();
delayedEventHandler1.processEvent();
workHandler1.processEvent();
delayedEventHandler2.processEvent();
workHandler1.processEvent();
delayedEventHandler2.processEvent();
}
use of com.lmax.disruptor.dsl.stubs.DelayedEventHandler in project disruptor by LMAX-Exchange.
the class DisruptorTest method shouldSupportCustomProcessorsAsDependencies.
@Test
public void shouldSupportCustomProcessorsAsDependencies() throws Exception {
RingBuffer<TestEvent> ringBuffer = disruptor.getRingBuffer();
final DelayedEventHandler delayedEventHandler = createDelayedEventHandler();
CountDownLatch countDownLatch = new CountDownLatch(2);
EventHandler<TestEvent> handlerWithBarrier = new EventHandlerStub<TestEvent>(countDownLatch);
final BatchEventProcessor<TestEvent> processor = new BatchEventProcessor<TestEvent>(ringBuffer, ringBuffer.newBarrier(), delayedEventHandler);
disruptor.handleEventsWith(processor).then(handlerWithBarrier);
ensureTwoEventsProcessedAccordingToDependencies(countDownLatch, delayedEventHandler);
}
use of com.lmax.disruptor.dsl.stubs.DelayedEventHandler in project disruptor by LMAX-Exchange.
the class DisruptorTest method tearDown.
@After
public void tearDown() throws Exception {
for (DelayedEventHandler delayedEventHandler : delayedEventHandlers) {
delayedEventHandler.stopWaiting();
}
for (TestWorkHandler testWorkHandler : testWorkHandlers) {
testWorkHandler.stopWaiting();
}
disruptor.halt();
executor.joinAllThreads();
}
Aggregations