Search in sources :

Example 16 with TransactionInfoBaseMessage

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());
}
Also used : TransactionInfoBaseMessage(org.voltcore.messaging.TransactionInfoBaseMessage) Test(org.junit.Test)

Example 17 with TransactionInfoBaseMessage

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());
}
Also used : TransactionInfoBaseMessage(org.voltcore.messaging.TransactionInfoBaseMessage) Test(org.junit.Test)

Example 18 with TransactionInfoBaseMessage

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());
}
Also used : TransactionInfoBaseMessage(org.voltcore.messaging.TransactionInfoBaseMessage) Test(org.junit.Test)

Example 19 with TransactionInfoBaseMessage

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());
}
Also used : TransactionInfoBaseMessage(org.voltcore.messaging.TransactionInfoBaseMessage) Test(org.junit.Test)

Example 20 with TransactionInfoBaseMessage

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);
}
Also used : TransactionInfoBaseMessage(org.voltcore.messaging.TransactionInfoBaseMessage) Test(org.junit.Test)

Aggregations

TransactionInfoBaseMessage (org.voltcore.messaging.TransactionInfoBaseMessage)27 Test (org.junit.Test)24 CompleteTransactionMessage (org.voltdb.messaging.CompleteTransactionMessage)4 ArrayList (java.util.ArrayList)3 FragmentTaskMessage (org.voltdb.messaging.FragmentTaskMessage)3 Iv2InitiateTaskMessage (org.voltdb.messaging.Iv2InitiateTaskMessage)3 Iv2RepairLogResponseMessage (org.voltdb.messaging.Iv2RepairLogResponseMessage)3 HashMap (java.util.HashMap)2 Random (java.util.Random)2 RepairResult (org.voltdb.iv2.RepairAlgo.RepairResult)2 IOException (java.io.IOException)1 ByteBuffer (java.nio.ByteBuffer)1 List (java.util.List)1 Map (java.util.Map)1 AtomicLong (java.util.concurrent.atomic.AtomicLong)1 Request (org.apache.zookeeper_voltpatches.server.Request)1 JSONObject (org.json_voltpatches.JSONObject)1 Matchers.anyLong (org.mockito.Matchers.anyLong)1 AgreementTaskMessage (org.voltcore.messaging.AgreementTaskMessage)1 BinaryPayloadMessage (org.voltcore.messaging.BinaryPayloadMessage)1