Search in sources :

Example 1 with EventHandlerStub

use of com.lmax.disruptor.dsl.stubs.EventHandlerStub 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);
}
Also used : EventHandlerStub(com.lmax.disruptor.dsl.stubs.EventHandlerStub) TestEvent(com.lmax.disruptor.support.TestEvent) CountDownLatch(java.util.concurrent.CountDownLatch) DelayedEventHandler(com.lmax.disruptor.dsl.stubs.DelayedEventHandler) Test(org.junit.Test)

Example 2 with EventHandlerStub

use of com.lmax.disruptor.dsl.stubs.EventHandlerStub 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);
}
Also used : TestEvent(com.lmax.disruptor.support.TestEvent) EventHandlerStub(com.lmax.disruptor.dsl.stubs.EventHandlerStub) BatchEventProcessor(com.lmax.disruptor.BatchEventProcessor) CountDownLatch(java.util.concurrent.CountDownLatch) DelayedEventHandler(com.lmax.disruptor.dsl.stubs.DelayedEventHandler) Test(org.junit.Test)

Example 3 with EventHandlerStub

use of com.lmax.disruptor.dsl.stubs.EventHandlerStub in project disruptor by LMAX-Exchange.

the class DisruptorTest method shouldAllowEventHandlerWithSuperType.

@Test
public void shouldAllowEventHandlerWithSuperType() throws Exception {
    final CountDownLatch latch = new CountDownLatch(2);
    final EventHandler<Object> objectHandler = new EventHandlerStub<Object>(latch);
    disruptor.handleEventsWith(objectHandler);
    ensureTwoEventsProcessedAccordingToDependencies(latch);
}
Also used : EventHandlerStub(com.lmax.disruptor.dsl.stubs.EventHandlerStub) CountDownLatch(java.util.concurrent.CountDownLatch) Test(org.junit.Test)

Example 4 with EventHandlerStub

use of com.lmax.disruptor.dsl.stubs.EventHandlerStub in project disruptor by LMAX-Exchange.

the class DisruptorTest method shouldMakeEntriesAvailableToFirstHandlersImmediately.

@Test
public void shouldMakeEntriesAvailableToFirstHandlersImmediately() throws Exception {
    CountDownLatch countDownLatch = new CountDownLatch(2);
    EventHandler<TestEvent> eventHandler = new EventHandlerStub<TestEvent>(countDownLatch);
    disruptor.handleEventsWith(createDelayedEventHandler(), eventHandler);
    ensureTwoEventsProcessedAccordingToDependencies(countDownLatch);
}
Also used : EventHandlerStub(com.lmax.disruptor.dsl.stubs.EventHandlerStub) TestEvent(com.lmax.disruptor.support.TestEvent) CountDownLatch(java.util.concurrent.CountDownLatch) Test(org.junit.Test)

Example 5 with EventHandlerStub

use of com.lmax.disruptor.dsl.stubs.EventHandlerStub in project disruptor by LMAX-Exchange.

the class DisruptorTest method shouldAllowChainingEventHandlersWithSuperType.

@Test
public void shouldAllowChainingEventHandlersWithSuperType() throws Exception {
    final CountDownLatch latch = new CountDownLatch(2);
    final DelayedEventHandler delayedEventHandler = createDelayedEventHandler();
    final EventHandler<Object> objectHandler = new EventHandlerStub<Object>(latch);
    disruptor.handleEventsWith(delayedEventHandler).then(objectHandler);
    ensureTwoEventsProcessedAccordingToDependencies(latch, delayedEventHandler);
}
Also used : EventHandlerStub(com.lmax.disruptor.dsl.stubs.EventHandlerStub) CountDownLatch(java.util.concurrent.CountDownLatch) DelayedEventHandler(com.lmax.disruptor.dsl.stubs.DelayedEventHandler) Test(org.junit.Test)

Aggregations

EventHandlerStub (com.lmax.disruptor.dsl.stubs.EventHandlerStub)11 CountDownLatch (java.util.concurrent.CountDownLatch)11 Test (org.junit.Test)11 TestEvent (com.lmax.disruptor.support.TestEvent)9 DelayedEventHandler (com.lmax.disruptor.dsl.stubs.DelayedEventHandler)8 BatchEventProcessor (com.lmax.disruptor.BatchEventProcessor)5 EventProcessor (com.lmax.disruptor.EventProcessor)2 Sequence (com.lmax.disruptor.Sequence)2 SequenceBarrier (com.lmax.disruptor.SequenceBarrier)2