use of com.lmax.disruptor.dsl.stubs.SleepingEventHandler in project disruptor by LMAX-Exchange.
the class ConsumerRepositoryTest method setUp.
@Before
public void setUp() throws Exception {
consumerRepository = new ConsumerRepository<TestEvent>();
eventProcessor1 = new DummyEventProcessor(new Sequence());
eventProcessor2 = new DummyEventProcessor(new Sequence());
eventProcessor1.run();
eventProcessor2.run();
handler1 = new SleepingEventHandler();
handler2 = new SleepingEventHandler();
barrier1 = new DummySequenceBarrier();
barrier2 = new DummySequenceBarrier();
}
use of com.lmax.disruptor.dsl.stubs.SleepingEventHandler in project disruptor by LMAX-Exchange.
the class DisruptorTest method shouldThrowExceptionWhenAddingEventProcessorsAfterTheProducerBarrierHasBeenCreated.
@Test(expected = IllegalStateException.class)
public void shouldThrowExceptionWhenAddingEventProcessorsAfterTheProducerBarrierHasBeenCreated() throws Exception {
executor.ignoreExecutions();
disruptor.handleEventsWith(new SleepingEventHandler());
disruptor.start();
disruptor.handleEventsWith(new SleepingEventHandler());
}
use of com.lmax.disruptor.dsl.stubs.SleepingEventHandler in project disruptor by LMAX-Exchange.
the class DisruptorTest method shouldAddEventProcessorsAfterPublishing.
@Test
public void shouldAddEventProcessorsAfterPublishing() throws Exception {
RingBuffer<TestEvent> rb = disruptor.getRingBuffer();
BatchEventProcessor<TestEvent> b1 = new BatchEventProcessor<TestEvent>(rb, rb.newBarrier(), new SleepingEventHandler());
BatchEventProcessor<TestEvent> b2 = new BatchEventProcessor<TestEvent>(rb, rb.newBarrier(b1.getSequence()), new SleepingEventHandler());
BatchEventProcessor<TestEvent> b3 = new BatchEventProcessor<TestEvent>(rb, rb.newBarrier(b2.getSequence()), new SleepingEventHandler());
assertThat(b1.getSequence().get(), is(-1L));
assertThat(b2.getSequence().get(), is(-1L));
assertThat(b3.getSequence().get(), is(-1L));
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.handleEventsWith(b1, b2, b3);
assertThat(b1.getSequence().get(), is(5L));
assertThat(b2.getSequence().get(), is(5L));
assertThat(b3.getSequence().get(), is(5L));
}
use of com.lmax.disruptor.dsl.stubs.SleepingEventHandler in project disruptor by LMAX-Exchange.
the class DisruptorTest method should.
@Test
public void should() throws Exception {
RingBuffer<TestEvent> rb = disruptor.getRingBuffer();
BatchEventProcessor<TestEvent> b1 = new BatchEventProcessor<TestEvent>(rb, rb.newBarrier(), new SleepingEventHandler());
EventProcessorFactory<TestEvent> b2 = new EventProcessorFactory<TestEvent>() {
@Override
public EventProcessor createEventProcessor(RingBuffer<TestEvent> ringBuffer, Sequence[] barrierSequences) {
return new BatchEventProcessor<TestEvent>(ringBuffer, ringBuffer.newBarrier(barrierSequences), new SleepingEventHandler());
}
};
disruptor.handleEventsWith(b1).then(b2);
disruptor.start();
}
use of com.lmax.disruptor.dsl.stubs.SleepingEventHandler in project disruptor by LMAX-Exchange.
the class DisruptorTest method shouldThrowExceptionIfStartIsCalledTwice.
@Test(expected = IllegalStateException.class)
public void shouldThrowExceptionIfStartIsCalledTwice() throws Exception {
executor.ignoreExecutions();
disruptor.handleEventsWith(new SleepingEventHandler());
disruptor.start();
disruptor.start();
}
Aggregations