Search in sources :

Example 31 with Iv2InitiateTaskMessage

use of org.voltdb.messaging.Iv2InitiateTaskMessage in project voltdb by VoltDB.

the class TestRepairLog method testTrackBinaryLogUniqueId.

@Test
public void testTrackBinaryLogUniqueId() {
    // The end unique id for an @ApplyBinaryLogSP invocation is recorded
    // as its fifth parameter. Create a realistic invocation, deliver it
    // to the repair log, and see what we get
    final long endSpUniqueId = 42;
    final long endMpUniqueId = 25;
    StoredProcedureInvocation spi = new StoredProcedureInvocation();
    spi.setProcName("@ApplyBinaryLogSP");
    spi.setParams(0, endSpUniqueId - 10, endSpUniqueId, endSpUniqueId, endMpUniqueId, new byte[] { 0 });
    Iv2InitiateTaskMessage msg = new Iv2InitiateTaskMessage(0l, 0l, 0l, Long.MIN_VALUE, 0l, false, true, spi, 0l, 0l, false);
    msg.setSpHandle(900l);
    RepairLog log = new RepairLog();
    log.deliver(msg);
    validateRepairLog(log.contents(1l, false), endSpUniqueId, endMpUniqueId);
}
Also used : StoredProcedureInvocation(org.voltdb.StoredProcedureInvocation) Iv2InitiateTaskMessage(org.voltdb.messaging.Iv2InitiateTaskMessage) Test(org.junit.Test)

Example 32 with Iv2InitiateTaskMessage

use of org.voltdb.messaging.Iv2InitiateTaskMessage in project voltdb by VoltDB.

the class TestRepairLog method testFuzz.

@Test
public void testFuzz() {
    TxnEgo sphandle = TxnEgo.makeZero(0);
    UniqueIdGenerator spbuig = new UniqueIdGenerator(0, 0);
    UniqueIdGenerator mpbuig = new UniqueIdGenerator(0, 0);
    sphandle = sphandle.makeNext();
    RandomMsgGenerator msgGen = new RandomMsgGenerator();
    RepairLog dut = new RepairLog();
    long spBinaryLogSpUniqueId = Long.MIN_VALUE;
    long spBinaryLogMpUniqueId = Long.MIN_VALUE;
    long mpBinaryLogMpUniqueId = Long.MIN_VALUE;
    for (int i = 0; i < 4000; i++) {
        // get next message, update the sphandle according to SpScheduler rules,
        // but only submit messages that would have been forwarded by the master
        // to the repair log.
        TransactionInfoBaseMessage msg = msgGen.generateRandomMessageInStream();
        msg.setSpHandle(sphandle.getTxnId());
        if (msg instanceof Iv2InitiateTaskMessage) {
            Pair<Long, Long> uids = setBinaryLogUniqueId(msg, spbuig, mpbuig);
            spBinaryLogSpUniqueId = Math.max(spBinaryLogSpUniqueId, uids.getFirst());
            spBinaryLogMpUniqueId = Math.max(spBinaryLogMpUniqueId, uids.getSecond());
        } else if (msg instanceof FragmentTaskMessage) {
            mpBinaryLogMpUniqueId = Math.max(mpBinaryLogMpUniqueId, setBinaryLogUniqueId(msg, null, mpbuig).getSecond());
        }
        sphandle = sphandle.makeNext();
        if (!msg.isReadOnly() || msg instanceof CompleteTransactionMessage) {
            dut.deliver(msg);
        }
    }
    List<Iv2RepairLogResponseMessage> stuff = dut.contents(1l, false);
    validateRepairLog(stuff, spBinaryLogSpUniqueId, spBinaryLogMpUniqueId);
    // Also check the MP version
    stuff = dut.contents(1l, true);
    validateRepairLog(stuff, Long.MIN_VALUE, mpBinaryLogMpUniqueId);
}
Also used : Iv2RepairLogResponseMessage(org.voltdb.messaging.Iv2RepairLogResponseMessage) FragmentTaskMessage(org.voltdb.messaging.FragmentTaskMessage) Iv2InitiateTaskMessage(org.voltdb.messaging.Iv2InitiateTaskMessage) AtomicLong(java.util.concurrent.atomic.AtomicLong) CompleteTransactionMessage(org.voltdb.messaging.CompleteTransactionMessage) TransactionInfoBaseMessage(org.voltcore.messaging.TransactionInfoBaseMessage) Test(org.junit.Test)

Example 33 with Iv2InitiateTaskMessage

use of org.voltdb.messaging.Iv2InitiateTaskMessage in project voltdb by VoltDB.

the class TestRepairLog method truncInitMsg.

VoltMessage truncInitMsg(long truncPt, long handle) {
    Iv2InitiateTaskMessage msg = mock(Iv2InitiateTaskMessage.class);
    when(msg.getTruncationHandle()).thenReturn(truncPt);
    when(msg.getSpHandle()).thenReturn(handle);
    return msg;
}
Also used : Iv2InitiateTaskMessage(org.voltdb.messaging.Iv2InitiateTaskMessage)

Example 34 with Iv2InitiateTaskMessage

use of org.voltdb.messaging.Iv2InitiateTaskMessage in project voltdb by VoltDB.

the class TestSite method makeInit.

private static Iv2InitiateTaskMessage makeInit(String procName) {
    Iv2InitiateTaskMessage msg = mock(Iv2InitiateTaskMessage.class);
    doReturn(procName).when(msg).getStoredProcedureName();
    return msg;
}
Also used : Iv2InitiateTaskMessage(org.voltdb.messaging.Iv2InitiateTaskMessage)

Example 35 with Iv2InitiateTaskMessage

use of org.voltdb.messaging.Iv2InitiateTaskMessage in project voltdb by VoltDB.

the class TestSpPromoteAlgo method makeResponse.

Iv2RepairLogResponseMessage makeResponse(long spHandle) {
    Iv2RepairLogResponseMessage m = mock(Iv2RepairLogResponseMessage.class);
    when(m.getHandle()).thenReturn(spHandle);
    Iv2InitiateTaskMessage im = mock(Iv2InitiateTaskMessage.class);
    when(m.getPayload()).thenReturn(im);
    return m;
}
Also used : Iv2RepairLogResponseMessage(org.voltdb.messaging.Iv2RepairLogResponseMessage) Iv2InitiateTaskMessage(org.voltdb.messaging.Iv2InitiateTaskMessage)

Aggregations

Iv2InitiateTaskMessage (org.voltdb.messaging.Iv2InitiateTaskMessage)40 Test (org.junit.Test)14 StoredProcedureInvocation (org.voltdb.StoredProcedureInvocation)13 Mailbox (org.voltcore.messaging.Mailbox)8 FragmentTaskMessage (org.voltdb.messaging.FragmentTaskMessage)8 InitiateResponseMessage (org.voltdb.messaging.InitiateResponseMessage)8 ArrayList (java.util.ArrayList)7 CompleteTransactionMessage (org.voltdb.messaging.CompleteTransactionMessage)7 SiteProcedureConnection (org.voltdb.SiteProcedureConnection)6 FragmentResponseMessage (org.voltdb.messaging.FragmentResponseMessage)6 List (java.util.List)5 Iv2RepairLogResponseMessage (org.voltdb.messaging.Iv2RepairLogResponseMessage)5 Matchers.anyLong (org.mockito.Matchers.anyLong)4 ExecutionException (java.util.concurrent.ExecutionException)3 TransactionInfoBaseMessage (org.voltcore.messaging.TransactionInfoBaseMessage)3 ClientResponseImpl (org.voltdb.ClientResponseImpl)3 ParameterSet (org.voltdb.ParameterSet)3 VoltTable (org.voltdb.VoltTable)3 VoltTrace (org.voltdb.utils.VoltTrace)3 HashMap (java.util.HashMap)2