Search in sources :

Example 26 with Iv2InitiateTaskMessage

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

the class TestSpSchedulerDedupe method testReplicaInitiateTaskResponse.

@Test
public void testReplicaInitiateTaskResponse() throws Exception {
    long txnid = TxnEgo.makeZero(0).getTxnId();
    long primary_hsid = 1111l;
    createObjs();
    Iv2InitiateTaskMessage sptask = createMsg(txnid, false, true, primary_hsid);
    sptask.setSpHandle(txnid);
    dut.deliver(sptask);
    // verify no response sent yet
    verify(mbox, times(0)).send(anyLong(), (VoltMessage) anyObject());
    verify(mbox, times(0)).send(new long[] { anyLong() }, (VoltMessage) anyObject());
    InitiateResponseMessage resp = new InitiateResponseMessage(sptask);
    dut.deliver(resp);
    verify(mbox, times(1)).send(eq(primary_hsid), eq(resp));
}
Also used : Iv2InitiateTaskMessage(org.voltdb.messaging.Iv2InitiateTaskMessage) InitiateResponseMessage(org.voltdb.messaging.InitiateResponseMessage) Test(org.junit.Test)

Example 27 with Iv2InitiateTaskMessage

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

the class TestSpSchedulerDedupe method testPrimaryInitiateTaskResponseNoReplicas.

@Test
public void testPrimaryInitiateTaskResponseNoReplicas() throws Exception {
    long txnid = TxnEgo.makeZero(0).getTxnId();
    long primary_hsid = 1111l;
    createObjs();
    dut.setLeaderState(true);
    dut.updateReplicas(new ArrayList<Long>(), null);
    Iv2InitiateTaskMessage sptask = createMsg(txnid, true, true, primary_hsid);
    dut.deliver(sptask);
    // verify no response sent yet
    verify(mbox, times(0)).send(anyLong(), (VoltMessage) anyObject());
    verify(mbox, times(0)).send(new long[] { anyLong() }, (VoltMessage) anyObject());
    InitiateResponseMessage resp = new InitiateResponseMessage(sptask);
    dut.deliver(resp);
    verify(mbox, times(1)).send(eq(primary_hsid), eq(resp));
}
Also used : Iv2InitiateTaskMessage(org.voltdb.messaging.Iv2InitiateTaskMessage) Matchers.anyLong(org.mockito.Matchers.anyLong) InitiateResponseMessage(org.voltdb.messaging.InitiateResponseMessage) Test(org.junit.Test)

Example 28 with Iv2InitiateTaskMessage

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

the class TestMpTransactionState method testTruncationHandleForwarding.

@Test
public void testTruncationHandleForwarding() throws IOException {
    long truncPt = 100L;
    Iv2InitiateTaskMessage taskmsg = new Iv2InitiateTaskMessage(0, 0, truncPt, 101L, System.currentTimeMillis(), true, false, new StoredProcedureInvocation(), 0, 0, false);
    assertEquals(truncPt, taskmsg.getTruncationHandle());
    FragmentTaskMessage localFrag = mock(FragmentTaskMessage.class);
    FragmentTaskMessage remoteFrag = mock(FragmentTaskMessage.class);
    when(remoteFrag.getFragmentCount()).thenReturn(1);
    buddyHSId = 0;
    Mailbox mailbox = mock(Mailbox.class);
    MpTransactionState dut = new MpTransactionState(mailbox, taskmsg, allHsids, partMasters, buddyHSId, false);
    // create local work and verify the created localwork has the
    // expected truncation point.
    dut.createLocalFragmentWork(localFrag, false);
    verify(dut.m_localWork).setTruncationHandle(truncPt);
    // same with partcipating work.
    dut.createAllParticipatingFragmentWork(remoteFrag);
    verify(dut.m_remoteWork).setTruncationHandle(truncPt);
}
Also used : StoredProcedureInvocation(org.voltdb.StoredProcedureInvocation) FragmentTaskMessage(org.voltdb.messaging.FragmentTaskMessage) Mailbox(org.voltcore.messaging.Mailbox) Iv2InitiateTaskMessage(org.voltdb.messaging.Iv2InitiateTaskMessage) Test(org.junit.Test)

Example 29 with Iv2InitiateTaskMessage

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

the class TestMpTransactionState method testOneSitePartitionedReadWithRollback.

@Test
public void testOneSitePartitionedReadWithRollback() throws IOException {
    long txnId = 1234l;
    int batch_size = 3;
    Iv2InitiateTaskMessage taskmsg = new Iv2InitiateTaskMessage(0, 0, (txnId - 1), txnId, System.currentTimeMillis(), true, false, new StoredProcedureInvocation(), 0, 0, false);
    int hsids = 1;
    buddyHSId = 0;
    long[] non_local = configureHSIds(hsids);
    MpTestPlan plan = createTestPlan(batch_size, true, false, true, non_local);
    Mailbox mailbox = mock(Mailbox.class);
    SiteProcedureConnection siteConnection = mock(SiteProcedureConnection.class);
    MpTransactionState dut = new MpTransactionState(mailbox, taskmsg, allHsids, partMasters, buddyHSId, false);
    // emulate ProcedureRunner's use for a single local fragment
    dut.setupProcedureResume(true, plan.depsToResume);
    dut.createLocalFragmentWork(plan.localWork, false);
    // This will be passed a FragmentTaskMessage with no deps
    dut.createAllParticipatingFragmentWork(plan.remoteWork);
    // we should send one message
    verify(mailbox).send(eq(new long[] { 0 }), (VoltMessage) any());
    // offer all the necessary fragment responses to satisfy deps
    for (FragmentResponseMessage msg : plan.generatedResponses) {
        System.out.println("Offering response: " + msg);
        dut.offerReceivedFragmentResponse(msg);
    }
    // We're getting an error, so this should throw something
    boolean threw = false;
    try {
        dut.recursableRun(siteConnection);
        fail();
    } catch (EEException eee) {
        if (eee.getErrorCode() == 1234) {
            threw = true;
        }
    }
    assertTrue(threw);
}
Also used : StoredProcedureInvocation(org.voltdb.StoredProcedureInvocation) Mailbox(org.voltcore.messaging.Mailbox) SiteProcedureConnection(org.voltdb.SiteProcedureConnection) Iv2InitiateTaskMessage(org.voltdb.messaging.Iv2InitiateTaskMessage) FragmentResponseMessage(org.voltdb.messaging.FragmentResponseMessage) EEException(org.voltdb.exceptions.EEException) Test(org.junit.Test)

Example 30 with Iv2InitiateTaskMessage

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

the class TestMpTransactionState method testMultiSitePartitionedRead.

@Test
public void testMultiSitePartitionedRead() throws IOException {
    long txnId = 1234l;
    int batch_size = 3;
    Iv2InitiateTaskMessage taskmsg = new Iv2InitiateTaskMessage(0, -1, (txnId - 1), txnId, System.currentTimeMillis(), true, false, new StoredProcedureInvocation(), 0, 0, false);
    int hsids = 6;
    buddyHSId = 0;
    long[] non_local = configureHSIds(hsids);
    MpTestPlan plan = createTestPlan(batch_size, true, false, false, non_local);
    Mailbox mailbox = mock(Mailbox.class);
    SiteProcedureConnection siteConnection = mock(SiteProcedureConnection.class);
    MpTransactionState dut = new MpTransactionState(mailbox, taskmsg, allHsids, partMasters, buddyHSId, false);
    // emulate ProcedureRunner's use for a single local fragment
    dut.setupProcedureResume(true, plan.depsToResume);
    dut.createLocalFragmentWork(plan.localWork, false);
    // This will be passed a FragmentTaskMessage with no deps
    dut.createAllParticipatingFragmentWork(plan.remoteWork);
    // we should send 6 messages
    verify(mailbox).send(eq(non_local), (VoltMessage) any());
    // offer all the necessary fragment responses to satisfy deps
    for (FragmentResponseMessage msg : plan.generatedResponses) {
        dut.offerReceivedFragmentResponse(msg);
    }
    // if we've satisfied everything, this should run to completion
    Map<Integer, List<VoltTable>> results = dut.recursableRun(siteConnection);
    verify(mailbox).send(eq(buddyHSId), (BorrowTaskMessage) any());
    // verify returned deps/tables
    assertEquals(batch_size, results.size());
    System.out.println(results);
}
Also used : StoredProcedureInvocation(org.voltdb.StoredProcedureInvocation) Iv2InitiateTaskMessage(org.voltdb.messaging.Iv2InitiateTaskMessage) Mailbox(org.voltcore.messaging.Mailbox) SiteProcedureConnection(org.voltdb.SiteProcedureConnection) FragmentResponseMessage(org.voltdb.messaging.FragmentResponseMessage) ArrayList(java.util.ArrayList) List(java.util.List) Test(org.junit.Test)

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