use of org.voltcore.messaging.TransactionInfoBaseMessage in project voltdb by VoltDB.
the class TestReplaySequencer method testSentinelThenFragment.
@Test
public void testSentinelThenFragment() {
boolean result;
ReplaySequencer dut = new ReplaySequencer();
TransactionInfoBaseMessage sntl = makeSentinel(1L);
TransactionInfoBaseMessage frag = makeFragment(1L);
TransactionInfoBaseMessage frag2 = makeFragment(1L);
TransactionInfoBaseMessage complete = makeCompleteTxn(1L);
dut.offer(1L, sntl);
result = dut.offer(1L, frag);
Assert.assertTrue(result);
Assert.assertEquals(frag, dut.poll());
Assert.assertNull(dut.poll());
Assert.assertNull(dut.drain());
result = dut.offer(1L, frag2);
Assert.assertFalse(result);
Assert.assertNull(dut.poll());
Assert.assertNull(dut.drain());
result = dut.offer(1L, complete);
Assert.assertFalse(result);
Assert.assertNull(dut.poll());
Assert.assertNull(dut.drain());
}
use of org.voltcore.messaging.TransactionInfoBaseMessage in project voltdb by VoltDB.
the class TestReplaySequencer method testPollsInOrder2.
@Test
public void testPollsInOrder2() {
TransactionInfoBaseMessage sntl1 = makeSentinel(1L);
TransactionInfoBaseMessage frag1 = makeFragment(1L);
TransactionInfoBaseMessage cmpl1 = makeCompleteTxn(1L);
TransactionInfoBaseMessage sntl2 = makeSentinel(2L);
TransactionInfoBaseMessage frag2 = makeFragment(2L);
TransactionInfoBaseMessage cmpl2 = makeCompleteTxn(2L);
TransactionInfoBaseMessage sp2a = makeIv2InitTask(104L);
TransactionInfoBaseMessage sp2b = makeIv2InitTask(105L);
ReplaySequencer dut = new ReplaySequencer();
dut.offer(1L, sntl1);
dut.offer(2L, sntl2);
dut.offer(104L, sp2a);
dut.offer(105L, sp2b);
// Nothing satisified.
Assert.assertEquals(null, dut.poll());
Assert.assertNull(dut.drain());
// Offer the first fragment to free up the first half.
dut.offer(1L, frag1);
dut.offer(1L, cmpl1);
Assert.assertEquals(frag1, dut.poll());
// CompleteTxn will not be queued, it always forwards to scheduler directly.
Assert.assertEquals(null, dut.poll());
Assert.assertNull(dut.drain());
// Offer the second fragment to free up the second half and SPs being queued
dut.offer(2L, frag2);
Assert.assertEquals(frag2, dut.poll());
Assert.assertEquals(sp2a, dut.poll());
Assert.assertEquals(sp2b, dut.poll());
Assert.assertEquals(null, dut.poll());
// Completed the second mp
dut.offer(2L, cmpl2);
Assert.assertNull(dut.drain());
}
use of org.voltcore.messaging.TransactionInfoBaseMessage in project voltdb by VoltDB.
the class TestReplaySequencer method testOfferFragmentThenSentinel.
@Test
public void testOfferFragmentThenSentinel() {
boolean result;
ReplaySequencer dut = new ReplaySequencer();
TransactionInfoBaseMessage sntl = makeSentinel(1L);
TransactionInfoBaseMessage frag = makeFragment(1L);
result = dut.offer(1L, frag);
Assert.assertEquals(true, result);
Assert.assertEquals(null, dut.poll());
// toString should not throw
try {
dut.dump(1);
} catch (Exception e) {
fail(e.getMessage());
}
result = dut.offer(1L, sntl);
Assert.assertEquals(true, result);
Assert.assertEquals(frag, dut.poll());
Assert.assertEquals(null, dut.poll());
Assert.assertNull(dut.drain());
}
use of org.voltcore.messaging.TransactionInfoBaseMessage in project voltdb by VoltDB.
the class TestReplaySequencer method testDupSentinels.
/**
* No harm in sending duplicate sentinels
*/
@Test
public void testDupSentinels() {
ReplaySequencer dut = new ReplaySequencer();
TransactionInfoBaseMessage sntl1 = makeSentinel(1L);
TransactionInfoBaseMessage frag1 = makeFragment(1L);
TransactionInfoBaseMessage cmpl1 = makeCompleteTxn(1L);
TransactionInfoBaseMessage init1 = makeIv2InitTask(2L);
TransactionInfoBaseMessage init2 = makeIv2InitTask(3L);
Assert.assertTrue(dut.offer(1L, sntl1));
Assert.assertTrue(dut.offer(1L, frag1));
Assert.assertTrue(dut.offer(2L, init1));
Assert.assertEquals(frag1, dut.poll());
Assert.assertFalse(dut.offer(1L, cmpl1));
Assert.assertEquals(init1, dut.poll());
Assert.assertNull(dut.poll());
// don't care about sentinels
Assert.assertNull(dut.dedupe(1L, sntl1));
Assert.assertTrue(dut.offer(1L, sntl1));
Assert.assertFalse(dut.offer(3L, init2));
Assert.assertNull(dut.poll());
}
use of org.voltcore.messaging.TransactionInfoBaseMessage in project voltdb by VoltDB.
the class TestReplaySequencer method testRejectedSP.
@Test
public void testRejectedSP() {
boolean result;
ReplaySequencer dut = new ReplaySequencer();
TransactionInfoBaseMessage m = makeIv2InitTask(2L);
result = dut.offer(2L, m);
Assert.assertEquals(false, result);
}
Aggregations