Search in sources :

Example 1 with DummySequenceBarrier

use of com.lmax.disruptor.support.DummySequenceBarrier in project disruptor by LMAX-Exchange.

the class TimeoutBlockingWaitStrategyTest method shouldTimeoutWaitFor.

@Test
public void shouldTimeoutWaitFor() throws Exception {
    final SequenceBarrier sequenceBarrier = new DummySequenceBarrier();
    long theTimeout = 500;
    TimeoutBlockingWaitStrategy waitStrategy = new TimeoutBlockingWaitStrategy(theTimeout, TimeUnit.MILLISECONDS);
    Sequence cursor = new Sequence(5);
    Sequence dependent = cursor;
    long t0 = System.currentTimeMillis();
    try {
        waitStrategy.waitFor(6, cursor, dependent, sequenceBarrier);
        fail("TimeoutException should have been thrown");
    } catch (TimeoutException e) {
    }
    long t1 = System.currentTimeMillis();
    long timeWaiting = t1 - t0;
    assertTrue(timeWaiting >= theTimeout);
}
Also used : DummySequenceBarrier(com.lmax.disruptor.support.DummySequenceBarrier) DummySequenceBarrier(com.lmax.disruptor.support.DummySequenceBarrier) Test(org.junit.Test)

Example 2 with DummySequenceBarrier

use of com.lmax.disruptor.support.DummySequenceBarrier 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();
}
Also used : SleepingEventHandler(com.lmax.disruptor.dsl.stubs.SleepingEventHandler) DummyEventProcessor(com.lmax.disruptor.support.DummyEventProcessor) DummySequenceBarrier(com.lmax.disruptor.support.DummySequenceBarrier) TestEvent(com.lmax.disruptor.support.TestEvent) Sequence(com.lmax.disruptor.Sequence) Before(org.junit.Before)

Example 3 with DummySequenceBarrier

use of com.lmax.disruptor.support.DummySequenceBarrier in project disruptor by LMAX-Exchange.

the class LiteTimeoutBlockingWaitStrategyTest method shouldTimeoutWaitFor.

@Test
public void shouldTimeoutWaitFor() throws Exception {
    final SequenceBarrier sequenceBarrier = new DummySequenceBarrier();
    long theTimeout = 500;
    LiteTimeoutBlockingWaitStrategy waitStrategy = new LiteTimeoutBlockingWaitStrategy(theTimeout, TimeUnit.MILLISECONDS);
    Sequence cursor = new Sequence(5);
    Sequence dependent = cursor;
    long t0 = System.currentTimeMillis();
    try {
        waitStrategy.waitFor(6, cursor, dependent, sequenceBarrier);
        fail("TimeoutException should have been thrown");
    } catch (TimeoutException e) {
    }
    long t1 = System.currentTimeMillis();
    long timeWaiting = t1 - t0;
    assertTrue(timeWaiting >= theTimeout);
}
Also used : DummySequenceBarrier(com.lmax.disruptor.support.DummySequenceBarrier) DummySequenceBarrier(com.lmax.disruptor.support.DummySequenceBarrier) Test(org.junit.Test)

Aggregations

DummySequenceBarrier (com.lmax.disruptor.support.DummySequenceBarrier)3 Test (org.junit.Test)2 Sequence (com.lmax.disruptor.Sequence)1 SleepingEventHandler (com.lmax.disruptor.dsl.stubs.SleepingEventHandler)1 DummyEventProcessor (com.lmax.disruptor.support.DummyEventProcessor)1 TestEvent (com.lmax.disruptor.support.TestEvent)1 Before (org.junit.Before)1