Search in sources :

Example 6 with TestWorkHandler

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

the class DisruptorTest method shouldProvideEventsMultipleWorkHandlers.

@Test
public void shouldProvideEventsMultipleWorkHandlers() throws Exception {
    final TestWorkHandler workHandler1 = createTestWorkHandler();
    final TestWorkHandler workHandler2 = createTestWorkHandler();
    final TestWorkHandler workHandler3 = createTestWorkHandler();
    final TestWorkHandler workHandler4 = createTestWorkHandler();
    final TestWorkHandler workHandler5 = createTestWorkHandler();
    final TestWorkHandler workHandler6 = createTestWorkHandler();
    final TestWorkHandler workHandler7 = createTestWorkHandler();
    final TestWorkHandler workHandler8 = createTestWorkHandler();
    disruptor.handleEventsWithWorkerPool(workHandler1, workHandler2).thenHandleEventsWithWorkerPool(workHandler3, workHandler4);
    disruptor.handleEventsWithWorkerPool(workHandler5, workHandler6).thenHandleEventsWithWorkerPool(workHandler7, workHandler8);
}
Also used : TestWorkHandler(com.lmax.disruptor.dsl.stubs.TestWorkHandler) Test(org.junit.Test)

Example 7 with TestWorkHandler

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

the class DisruptorTest method shouldSupportUsingWorkerPoolWithADependency.

@Test
public void shouldSupportUsingWorkerPoolWithADependency() throws Exception {
    final TestWorkHandler workHandler1 = createTestWorkHandler();
    final TestWorkHandler workHandler2 = createTestWorkHandler();
    final DelayedEventHandler delayedEventHandler = createDelayedEventHandler();
    disruptor.handleEventsWith(delayedEventHandler).thenHandleEventsWithWorkerPool(workHandler1, workHandler2);
    publishEvent();
    publishEvent();
    delayedEventHandler.processEvent();
    delayedEventHandler.processEvent();
    workHandler1.processEvent();
    workHandler2.processEvent();
}
Also used : TestWorkHandler(com.lmax.disruptor.dsl.stubs.TestWorkHandler) DelayedEventHandler(com.lmax.disruptor.dsl.stubs.DelayedEventHandler) Test(org.junit.Test)

Example 8 with TestWorkHandler

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

the class DisruptorTest method shouldSetSequenceForWorkProcessorIfAddedAfterPublish.

@Test
public void shouldSetSequenceForWorkProcessorIfAddedAfterPublish() throws Exception {
    RingBuffer<TestEvent> rb = disruptor.getRingBuffer();
    TestWorkHandler wh1 = createTestWorkHandler();
    TestWorkHandler wh2 = createTestWorkHandler();
    TestWorkHandler wh3 = createTestWorkHandler();
    rb.publish(rb.next());
    rb.publish(rb.next());
    rb.publish(rb.next());
    rb.publish(rb.next());
    rb.publish(rb.next());
    rb.publish(rb.next());
    disruptor.handleEventsWithWorkerPool(wh1, wh2, wh3);
    assertThat(disruptor.getRingBuffer().getMinimumGatingSequence(), is(5L));
}
Also used : TestWorkHandler(com.lmax.disruptor.dsl.stubs.TestWorkHandler) TestEvent(com.lmax.disruptor.support.TestEvent) Test(org.junit.Test)

Example 9 with TestWorkHandler

use of com.lmax.disruptor.dsl.stubs.TestWorkHandler 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();
}
Also used : TestWorkHandler(com.lmax.disruptor.dsl.stubs.TestWorkHandler) DelayedEventHandler(com.lmax.disruptor.dsl.stubs.DelayedEventHandler) Test(org.junit.Test)

Aggregations

TestWorkHandler (com.lmax.disruptor.dsl.stubs.TestWorkHandler)9 Test (org.junit.Test)7 DelayedEventHandler (com.lmax.disruptor.dsl.stubs.DelayedEventHandler)5 TestEvent (com.lmax.disruptor.support.TestEvent)1 After (org.junit.After)1