Search in sources :

Example 16 with StoredProcedureInvocation

use of org.voltdb.StoredProcedureInvocation in project voltdb by VoltDB.

the class TestVoltMessageSerialization method testFragmentTaskWithInitiateTask.

public void testFragmentTaskWithInitiateTask() throws IOException {
    // The fragment task.
    FragmentTaskMessage ft = new FragmentTaskMessage(9, 70654312, -75, 99, true, true, false);
    ft.addFragment(new byte[20], 12, ByteBuffer.allocate(0));
    ft.setFragmentTaskType(FragmentTaskMessage.SYS_PROC_PER_PARTITION);
    // The initiate task.
    StoredProcedureInvocation spi = new StoredProcedureInvocation();
    spi.setClientHandle(25);
    spi.setProcName("johnisgreat");
    spi.setParams(57, "gooniestoo", "dudemandude");
    Iv2InitiateTaskMessage itask = new Iv2InitiateTaskMessage(23, 8, 10L, 100045, 99, true, false, spi, 2101, 3101, true);
    itask.setSpHandle(31337);
    // this is the important part.
    ft.setStateForDurability(itask, Sets.newHashSet(0, 1, 2));
    assertTrue(ft.getInitiateTask() != null);
    assertTrue(ft.m_initiateTaskBuffer != null);
    assertTrue(ft.m_initiateTaskBuffer.remaining() > 0);
    FragmentTaskMessage ft2 = (FragmentTaskMessage) checkVoltMessage(ft);
    assertTrue(ft2.getInitiateTask() != null);
    assertEquals(ft.getInitiatorHSId(), ft2.getInitiatorHSId());
    assertEquals(ft.getCoordinatorHSId(), ft2.getCoordinatorHSId());
    assertEquals(ft.getTxnId(), ft2.getTxnId());
    assertEquals(ft.getUniqueId(), ft2.getUniqueId());
    assertEquals(ft.isReadOnly(), ft2.isReadOnly());
    assertEquals(ft.isForReplay(), ft2.isForReplay());
    assertEquals(ft.getFragmentCount(), ft2.getFragmentCount());
    assertEquals(ft.isFinalTask(), ft2.isFinalTask());
    assertEquals(ft.isSysProcTask(), ft2.isSysProcTask());
    Iv2InitiateTaskMessage itask2 = ft2.getInitiateTask();
    assertEquals(10L, itask.getTruncationHandle());
    assertEquals(itask.getInitiatorHSId(), itask2.getInitiatorHSId());
    assertEquals(itask.getTruncationHandle(), itask2.getTruncationHandle());
    assertEquals(itask.getTxnId(), itask2.getTxnId());
    assertEquals(itask.getUniqueId(), itask2.getUniqueId());
    assertEquals(itask.isReadOnly(), itask2.isReadOnly());
    assertEquals(itask.isSinglePartition(), itask2.isSinglePartition());
    assertEquals(itask.getStoredProcedureName(), itask2.getStoredProcedureName());
    assertEquals(itask.getParameterCount(), itask2.getParameterCount());
    assertEquals(itask.getClientInterfaceHandle(), itask2.getClientInterfaceHandle());
    assertEquals(itask.getClientInterfaceHandle(), 2101);
    assertEquals(itask.getConnectionId(), 3101);
    assertEquals(itask.getSpHandle(), itask2.getSpHandle());
    assertEquals(31337, itask.getSpHandle());
    assertTrue(itask.isForReplay());
}
Also used : StoredProcedureInvocation(org.voltdb.StoredProcedureInvocation)

Example 17 with StoredProcedureInvocation

use of org.voltdb.StoredProcedureInvocation in project voltdb by VoltDB.

the class TestVoltMessageSerialization method testInitiateResponseForIv2.

public void testInitiateResponseForIv2() throws IOException {
    StoredProcedureInvocation spi = new StoredProcedureInvocation();
    spi.setClientHandle(25);
    spi.setProcName("elmerfudd");
    spi.setParams(57, "wrascallywabbit");
    Iv2InitiateTaskMessage itask = new Iv2InitiateTaskMessage(23, 8, 10L, 100045, 99, true, false, spi, 2101, 3101, true);
    VoltTable table = new VoltTable(new VoltTable.ColumnInfo("foobar", VoltType.STRING));
    table.addRow("howmanylicksdoesittaketogettothecenterofatootsiepop");
    InitiateResponseMessage iresponse = new InitiateResponseMessage(itask);
    iresponse.setResults(new ClientResponseImpl(ClientResponse.GRACEFUL_FAILURE, new VoltTable[] { table, table }, "knockknockbananna"));
    iresponse.setClientHandle(99);
    InitiateResponseMessage iresponse2 = (InitiateResponseMessage) checkVoltMessage(iresponse);
    assertEquals(iresponse.getTxnId(), iresponse2.getTxnId());
    assertTrue(iresponse2.isReadOnly());
}
Also used : StoredProcedureInvocation(org.voltdb.StoredProcedureInvocation) ClientResponseImpl(org.voltdb.ClientResponseImpl) VoltTable(org.voltdb.VoltTable)

Example 18 with StoredProcedureInvocation

use of org.voltdb.StoredProcedureInvocation 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 19 with StoredProcedureInvocation

use of org.voltdb.StoredProcedureInvocation 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 20 with StoredProcedureInvocation

use of org.voltdb.StoredProcedureInvocation 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

StoredProcedureInvocation (org.voltdb.StoredProcedureInvocation)28 Iv2InitiateTaskMessage (org.voltdb.messaging.Iv2InitiateTaskMessage)13 Test (org.junit.Test)8 Mailbox (org.voltcore.messaging.Mailbox)7 SiteProcedureConnection (org.voltdb.SiteProcedureConnection)6 FragmentResponseMessage (org.voltdb.messaging.FragmentResponseMessage)6 ArrayList (java.util.ArrayList)4 List (java.util.List)4 ClientResponseImpl (org.voltdb.ClientResponseImpl)4 VoltTable (org.voltdb.VoltTable)4 ByteBuffer (java.nio.ByteBuffer)3 IOException (java.io.IOException)2 ParameterSet (org.voltdb.ParameterSet)2 EEException (org.voltdb.exceptions.EEException)2 FragmentTaskMessage (org.voltdb.messaging.FragmentTaskMessage)2 BorrowTaskMessage (org.voltdb.messaging.BorrowTaskMessage)1 InitiateResponseMessage (org.voltdb.messaging.InitiateResponseMessage)1