Search in sources :

Example 21 with TransactionInfoBaseMessage

use of org.voltcore.messaging.TransactionInfoBaseMessage in project voltdb by VoltDB.

the class TestReplaySequencer method testSentinelsAndFragsWithSameTxnId.

/**
     * This tests multiple @LoadMultipartitionTable transactions with the same
     * txnId as DR does.
     */
@Test
public void testSentinelsAndFragsWithSameTxnId() {
    ReplaySequencer dut = new ReplaySequencer();
    TransactionInfoBaseMessage sntl = makeSentinel(1L);
    TransactionInfoBaseMessage frag = makeFragment(1L);
    TransactionInfoBaseMessage frag2 = makeFragment(1L);
    Assert.assertTrue(dut.offer(1L, sntl));
    Assert.assertTrue(dut.offer(1L, frag));
    Assert.assertEquals(frag, dut.poll());
    Assert.assertEquals(null, dut.poll());
    Assert.assertNull(dut.drain());
    // subsequent fragments won't block the queue.
    Assert.assertFalse(dut.offer(1L, frag2));
    Assert.assertEquals(null, dut.poll());
    Assert.assertNull(dut.drain());
    // Dupe sentinels and fragments
    Assert.assertTrue(dut.offer(1L, sntl));
    Assert.assertFalse(dut.offer(1L, frag));
    Assert.assertFalse(dut.offer(1L, frag2));
    Assert.assertEquals(null, dut.poll());
    Assert.assertNull(dut.drain());
}
Also used : TransactionInfoBaseMessage(org.voltcore.messaging.TransactionInfoBaseMessage) Test(org.junit.Test)

Example 22 with TransactionInfoBaseMessage

use of org.voltcore.messaging.TransactionInfoBaseMessage in project voltdb by VoltDB.

the class TestReplaySequencer method testOfferSentinelThenFragments.

@Test
public void testOfferSentinelThenFragments() {
    boolean result;
    ReplaySequencer dut = new ReplaySequencer();
    TransactionInfoBaseMessage sntl = makeSentinel(1L);
    TransactionInfoBaseMessage frag = makeFragment(1L);
    TransactionInfoBaseMessage frag2 = makeFragment(1L);
    result = dut.offer(1L, sntl);
    // toString should not throw
    try {
        dut.dump(1);
    } catch (Exception e) {
        fail(e.getMessage());
    }
    result = dut.offer(1L, frag);
    Assert.assertEquals(true, result);
    Assert.assertEquals(frag, dut.poll());
    Assert.assertEquals(null, dut.poll());
    // subsequent fragments won't block the queue.
    result = dut.offer(1L, frag2);
    Assert.assertEquals(false, result);
    Assert.assertEquals(null, dut.poll());
    Assert.assertNull(dut.drain());
}
Also used : TransactionInfoBaseMessage(org.voltcore.messaging.TransactionInfoBaseMessage) Test(org.junit.Test)

Example 23 with TransactionInfoBaseMessage

use of org.voltcore.messaging.TransactionInfoBaseMessage in project voltdb by VoltDB.

the class TestReplaySequencer method testCompleteWithoutFirstFrag.

@Test
public void testCompleteWithoutFirstFrag() {
    ReplaySequencer dut = new ReplaySequencer();
    TransactionInfoBaseMessage sntl = makeSentinel(1L);
    TransactionInfoBaseMessage frag = makeFragment(1L);
    TransactionInfoBaseMessage cmpl = makeCompleteTxn(1L);
    Assert.assertTrue(dut.offer(1L, sntl));
    // a restart complete arrives before the first fragment
    Assert.assertFalse(dut.offer(1L, cmpl));
    Assert.assertTrue(dut.offer(1L, frag));
    // CompleteTxn will not be queued, it always forwards to scheduler directly.
    Assert.assertFalse(dut.offer(1L, cmpl));
    Assert.assertEquals(frag, dut.poll());
    Assert.assertNull(dut.poll());
}
Also used : TransactionInfoBaseMessage(org.voltcore.messaging.TransactionInfoBaseMessage) Test(org.junit.Test)

Example 24 with TransactionInfoBaseMessage

use of org.voltcore.messaging.TransactionInfoBaseMessage in project voltdb by VoltDB.

the class TestReplaySequencer method testEarlyMPIEOL.

@Test
public void testEarlyMPIEOL() {
    ReplaySequencer dut = new ReplaySequencer();
    // need
    // Fragment 1
    // Fragment 2
    // MPI EOL
    // Sentinel 1
    // Sentinel 2
    TransactionInfoBaseMessage frag1 = makeFragment(1L);
    TransactionInfoBaseMessage sentinel1 = makeSentinel(1L);
    TransactionInfoBaseMessage complete1 = makeCompleteTxn(1L);
    TransactionInfoBaseMessage frag2 = makeFragment(2L);
    TransactionInfoBaseMessage sentinel2 = makeSentinel(2L);
    TransactionInfoBaseMessage complete2 = makeCompleteTxn(2L);
    Assert.assertTrue(dut.offer(1L, frag1));
    Assert.assertFalse(dut.offer(1L, complete1));
    Assert.assertTrue(dut.offer(2L, frag2));
    Assert.assertFalse(dut.offer(2L, complete2));
    // We get a really early MPI EOL before we have any of our partition's sentinels
    Assert.assertTrue(dut.offer(0L, makeMPIEOL()));
    Assert.assertTrue(dut.offer(1L, sentinel1));
    Assert.assertEquals(frag1, dut.poll());
    Assert.assertTrue(dut.offer(2L, sentinel2));
    Assert.assertEquals(frag2, dut.poll());
    Assert.assertNull(dut.poll());
    Assert.assertNull(dut.drain());
}
Also used : TransactionInfoBaseMessage(org.voltcore.messaging.TransactionInfoBaseMessage) Test(org.junit.Test)

Example 25 with TransactionInfoBaseMessage

use of org.voltcore.messaging.TransactionInfoBaseMessage in project voltdb by VoltDB.

the class TestReplaySequencer method testOfferSentinelThenFragment.

@Test
public void testOfferSentinelThenFragment() {
    boolean result;
    ReplaySequencer dut = new ReplaySequencer();
    TransactionInfoBaseMessage sntl = makeSentinel(1L);
    TransactionInfoBaseMessage frag = makeFragment(1L);
    result = dut.offer(1L, sntl);
    Assert.assertEquals(true, result);
    Assert.assertEquals(null, dut.poll());
    result = dut.offer(1L, frag);
    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)

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