use of com.lmax.disruptor.dsl.stubs.DelayedEventHandler in project disruptor by LMAX-Exchange.
the class DisruptorTest method shouldThrowTimeoutExceptionIfShutdownDoesNotCompleteNormally.
@Test(expected = TimeoutException.class, timeout = 2000)
public void shouldThrowTimeoutExceptionIfShutdownDoesNotCompleteNormally() throws Exception {
//Given
final DelayedEventHandler delayedEventHandler = createDelayedEventHandler();
disruptor.handleEventsWith(delayedEventHandler);
publishEvent();
//When
disruptor.shutdown(1, SECONDS);
//Then
}
use of com.lmax.disruptor.dsl.stubs.DelayedEventHandler 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);
}
use of com.lmax.disruptor.dsl.stubs.DelayedEventHandler in project disruptor by LMAX-Exchange.
the class DisruptorTest method shouldSupportUsingWorkerPoolAsDependency.
@Test
public void shouldSupportUsingWorkerPoolAsDependency() throws Exception {
final TestWorkHandler workHandler1 = createTestWorkHandler();
final TestWorkHandler workHandler2 = createTestWorkHandler();
final DelayedEventHandler delayedEventHandler = createDelayedEventHandler();
disruptor.handleEventsWithWorkerPool(workHandler1, workHandler2).then(delayedEventHandler);
publishEvent();
publishEvent();
assertThat(disruptor.getBarrierFor(delayedEventHandler).getCursor(), equalTo(-1L));
workHandler2.processEvent();
workHandler1.processEvent();
delayedEventHandler.processEvent();
}
use of com.lmax.disruptor.dsl.stubs.DelayedEventHandler in project disruptor by LMAX-Exchange.
the class DisruptorTest method ensureTwoEventsProcessedAccordingToDependencies.
private void ensureTwoEventsProcessedAccordingToDependencies(final CountDownLatch countDownLatch, final DelayedEventHandler... dependencies) throws InterruptedException, BrokenBarrierException {
publishEvent();
publishEvent();
for (DelayedEventHandler dependency : dependencies) {
assertThatCountDownLatchEquals(countDownLatch, 2L);
dependency.processEvent();
dependency.processEvent();
}
assertThatCountDownLatchIsZero(countDownLatch);
}
use of com.lmax.disruptor.dsl.stubs.DelayedEventHandler 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();
}
Aggregations