use of com.lmax.disruptor.dsl.stubs.DelayedEventHandler in project disruptor by LMAX-Exchange.
the class DisruptorTest method shouldSupportCustomProcessorsAndHandlersAsDependencies.
@Test
public void shouldSupportCustomProcessorsAndHandlersAsDependencies() throws Exception {
final DelayedEventHandler delayedEventHandler1 = createDelayedEventHandler();
final DelayedEventHandler delayedEventHandler2 = createDelayedEventHandler();
disruptor.handleEventsWith(delayedEventHandler1);
RingBuffer<TestEvent> ringBuffer = disruptor.getRingBuffer();
CountDownLatch countDownLatch = new CountDownLatch(2);
EventHandler<TestEvent> handlerWithBarrier = new EventHandlerStub<TestEvent>(countDownLatch);
final SequenceBarrier sequenceBarrier = disruptor.after(delayedEventHandler1).asSequenceBarrier();
final BatchEventProcessor<TestEvent> processor = new BatchEventProcessor<TestEvent>(ringBuffer, sequenceBarrier, delayedEventHandler2);
disruptor.after(delayedEventHandler1).and(processor).handleEventsWith(handlerWithBarrier);
ensureTwoEventsProcessedAccordingToDependencies(countDownLatch, delayedEventHandler1, delayedEventHandler2);
}
use of com.lmax.disruptor.dsl.stubs.DelayedEventHandler in project disruptor by LMAX-Exchange.
the class DisruptorTest method shouldSupportHandlersAsDependenciesToCustomProcessors.
@Test
public void shouldSupportHandlersAsDependenciesToCustomProcessors() throws Exception {
final DelayedEventHandler delayedEventHandler = createDelayedEventHandler();
disruptor.handleEventsWith(delayedEventHandler);
RingBuffer<TestEvent> ringBuffer = disruptor.getRingBuffer();
CountDownLatch countDownLatch = new CountDownLatch(2);
EventHandler<TestEvent> handlerWithBarrier = new EventHandlerStub<TestEvent>(countDownLatch);
final SequenceBarrier sequenceBarrier = disruptor.after(delayedEventHandler).asSequenceBarrier();
final BatchEventProcessor<TestEvent> processor = new BatchEventProcessor<TestEvent>(ringBuffer, sequenceBarrier, handlerWithBarrier);
disruptor.handleEventsWith(processor);
ensureTwoEventsProcessedAccordingToDependencies(countDownLatch, delayedEventHandler);
}
use of com.lmax.disruptor.dsl.stubs.DelayedEventHandler in project disruptor by LMAX-Exchange.
the class DisruptorTest method shouldSupportUsingWorkerPoolAsDependencyAndProcessFirstEventAsSoonAsItIsAvailable.
@Test
public void shouldSupportUsingWorkerPoolAsDependencyAndProcessFirstEventAsSoonAsItIsAvailable() throws Exception {
final TestWorkHandler workHandler1 = createTestWorkHandler();
final TestWorkHandler workHandler2 = createTestWorkHandler();
final DelayedEventHandler delayedEventHandler = createDelayedEventHandler();
disruptor.handleEventsWithWorkerPool(workHandler1, workHandler2).then(delayedEventHandler);
publishEvent();
publishEvent();
workHandler1.processEvent();
delayedEventHandler.processEvent();
workHandler2.processEvent();
delayedEventHandler.processEvent();
}
use of com.lmax.disruptor.dsl.stubs.DelayedEventHandler in project disruptor by LMAX-Exchange.
the class DisruptorTest method shouldAllowSpecifyingSpecificEventProcessorsToWaitFor.
@Test
public void shouldAllowSpecifyingSpecificEventProcessorsToWaitFor() throws Exception {
DelayedEventHandler handler1 = createDelayedEventHandler();
DelayedEventHandler handler2 = createDelayedEventHandler();
CountDownLatch countDownLatch = new CountDownLatch(2);
EventHandler<TestEvent> handlerWithBarrier = new EventHandlerStub<TestEvent>(countDownLatch);
disruptor.handleEventsWith(handler1, handler2);
disruptor.after(handler1, handler2).handleEventsWith(handlerWithBarrier);
ensureTwoEventsProcessedAccordingToDependencies(countDownLatch, handler1, handler2);
}
use of com.lmax.disruptor.dsl.stubs.DelayedEventHandler in project disruptor by LMAX-Exchange.
the class DisruptorTest method shouldWaitOnAllProducersJoinedByAnd.
@Test
public void shouldWaitOnAllProducersJoinedByAnd() throws Exception {
DelayedEventHandler handler1 = createDelayedEventHandler();
DelayedEventHandler handler2 = createDelayedEventHandler();
CountDownLatch countDownLatch = new CountDownLatch(2);
EventHandler<TestEvent> handlerWithBarrier = new EventHandlerStub<TestEvent>(countDownLatch);
disruptor.handleEventsWith(handler1);
final EventHandlerGroup<TestEvent> handler2Group = disruptor.handleEventsWith(handler2);
disruptor.after(handler1).and(handler2Group).handleEventsWith(handlerWithBarrier);
ensureTwoEventsProcessedAccordingToDependencies(countDownLatch, handler1, handler2);
}
Aggregations