Search in sources :

Example 36 with Iv2InitiateTaskMessage

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

the class TestSpSchedulerDedupe method testPrimaryInitiateTaskResponseReplicas.

@Test
public void testPrimaryInitiateTaskResponseReplicas() throws Exception {
    long txnid = TxnEgo.makeZero(0).getTxnId();
    long primary_hsid = 1111l;
    createObjs();
    dut.setLeaderState(true);
    List<Long> replicas = new ArrayList<Long>();
    replicas.add(2l);
    dut.updateReplicas(replicas, null);
    Iv2InitiateTaskMessage sptask = createMsg(txnid, false, true, primary_hsid);
    dut.deliver(sptask);
    verify(mbox, times(0)).send(anyLong(), (VoltMessage) anyObject());
    // Capture the InitiateTaskMessage that gets sent to the replica so we can test it,
    // use it for response construction, etc.
    ArgumentCaptor<Iv2InitiateTaskMessage> replmsg = ArgumentCaptor.forClass(Iv2InitiateTaskMessage.class);
    verify(mbox, times(1)).send(eq(new long[] { 2 }), replmsg.capture());
    assertEquals(dut_hsid, replmsg.getValue().getInitiatorHSId());
    InitiateResponseMessage resp = new InitiateResponseMessage(sptask);
    ClientResponseImpl cr = mock(ClientResponseImpl.class);
    resp.setResults(cr);
    InitiateResponseMessage replresp = new InitiateResponseMessage(replmsg.getValue());
    replresp.setResults(cr);
    dut.deliver(resp);
    dut.deliver(replresp);
    verify(mbox, times(1)).send(eq(primary_hsid), eq(resp));
}
Also used : Iv2InitiateTaskMessage(org.voltdb.messaging.Iv2InitiateTaskMessage) ArrayList(java.util.ArrayList) Matchers.anyLong(org.mockito.Matchers.anyLong) InitiateResponseMessage(org.voltdb.messaging.InitiateResponseMessage) ClientResponseImpl(org.voltdb.ClientResponseImpl) Test(org.junit.Test)

Example 37 with Iv2InitiateTaskMessage

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

the class ReplaySequencer method dedupe.

/**
     * Dedupe initiate task messages. Check if the initiate task message is seen before.
     *
     * @param inUniqueId The uniqueId of the message
     * @param in The initiate task message
     * @return A client response to return if it's a duplicate, otherwise null.
     */
public InitiateResponseMessage dedupe(long inUniqueId, TransactionInfoBaseMessage in) {
    if (in instanceof Iv2InitiateTaskMessage) {
        final Iv2InitiateTaskMessage init = (Iv2InitiateTaskMessage) in;
        final StoredProcedureInvocation invocation = init.getStoredProcedureInvocation();
        final String procName = invocation.getProcName();
        /*
             * Ning - @LoadSinglepartTable and @LoadMultipartTable always have the same txnId
             * which is the txnId of the snapshot.
             */
        if (!(procName.equalsIgnoreCase("@LoadSinglepartitionTable") || procName.equalsIgnoreCase("@LoadMultipartitionTable")) && inUniqueId <= m_lastSeenUniqueId) {
            // already sequenced
            final InitiateResponseMessage resp = new InitiateResponseMessage(init);
            resp.setResults(new ClientResponseImpl(ClientResponseImpl.UNEXPECTED_FAILURE, new VoltTable[0], ClientResponseImpl.IGNORED_TRANSACTION));
            return resp;
        }
    }
    return null;
}
Also used : StoredProcedureInvocation(org.voltdb.StoredProcedureInvocation) Iv2InitiateTaskMessage(org.voltdb.messaging.Iv2InitiateTaskMessage) InitiateResponseMessage(org.voltdb.messaging.InitiateResponseMessage) ClientResponseImpl(org.voltdb.ClientResponseImpl) VoltTable(org.voltdb.VoltTable)

Example 38 with Iv2InitiateTaskMessage

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

the class RandomMsgGenerator method generateRandomMessageInStream.

public TransactionInfoBaseMessage generateRandomMessageInStream() {
    if (m_rand.nextDouble() > MPCHANCE) {
        double type = m_rand.nextDouble();
        boolean readOnly = (type < READCHANCE);
        boolean binaryLog = (!readOnly && type < BINARYLOGCHANCE);
        Iv2InitiateTaskMessage msg = makeIv2InitiateTaskMsg(readOnly, binaryLog, false);
        return msg;
    } else if (!m_mpInProgress) {
        double type = m_rand.nextDouble();
        m_currentMpReadOnly = (type < READCHANCE);
        boolean binaryLog = (!m_currentMpReadOnly && type < BINARYLOGCHANCE);
        FragmentTaskMessage msg = makeFragmentTaskMsg(m_currentMpReadOnly, false);
        msg.setStateForDurability(makeIv2InitiateTaskMsg(false, binaryLog, true), Sets.newHashSet(0, 1, 2));
        m_mpInProgress = true;
        return msg;
    } else if (m_rand.nextDouble() > MPDONECHANCE) {
        // generate another MP fragment
        FragmentTaskMessage msg = makeFragmentTaskMsg(m_currentMpReadOnly, false);
        return msg;
    } else {
        // generate MP complete
        // fake restarts
        boolean restart = (!m_currentMpReadOnly && m_rand.nextDouble() < MPRESTARTCHANCE);
        CompleteTransactionMessage msg = makeCompleteTxnMsg(m_currentMpReadOnly, restart, restart);
        if (!restart) {
            m_mpInProgress = false;
            m_mpiTxnEgo = m_mpiTxnEgo.makeNext();
        }
        return msg;
    }
}
Also used : FragmentTaskMessage(org.voltdb.messaging.FragmentTaskMessage) Iv2InitiateTaskMessage(org.voltdb.messaging.Iv2InitiateTaskMessage) CompleteTransactionMessage(org.voltdb.messaging.CompleteTransactionMessage)

Example 39 with Iv2InitiateTaskMessage

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

the class RandomMsgGenerator method makeIv2InitiateTaskMsg.

private Iv2InitiateTaskMessage makeIv2InitiateTaskMsg(boolean readOnly, boolean binaryLog, boolean isMp) {
    StoredProcedureInvocation spi = mock(StoredProcedureInvocation.class);
    ParameterSet ps = mock(ParameterSet.class);
    when(spi.getParams()).thenReturn(ps);
    if (binaryLog) {
        when(ps.toArray()).thenReturn(new Object[] { null, 0l, 0l, Long.MIN_VALUE, Long.MIN_VALUE, null });
        if (!isMp) {
            when(spi.getProcName()).thenReturn("@ApplyBinaryLogSP");
        } else {
            when(spi.getProcName()).thenReturn("@ApplyBinaryLogMP");
        }
    } else {
        when(ps.toArray()).thenReturn(new Object[] { null, 0l, 0l, Long.MIN_VALUE, null });
        when(spi.getProcName()).thenReturn("dummy");
    }
    Iv2InitiateTaskMessage msg = new Iv2InitiateTaskMessage(0l, 0l, 0l, Long.MIN_VALUE, 0l, readOnly, !isMp, spi, 0l, 0l, false);
    return msg;
}
Also used : ParameterSet(org.voltdb.ParameterSet) StoredProcedureInvocation(org.voltdb.StoredProcedureInvocation) Iv2InitiateTaskMessage(org.voltdb.messaging.Iv2InitiateTaskMessage)

Example 40 with Iv2InitiateTaskMessage

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

the class MpInitiatorMailbox method repairReplicasWithInternal.

private void repairReplicasWithInternal(List<Long> needsRepair, VoltMessage repairWork) {
    assert (lockingVows());
    if (repairWork instanceof Iv2InitiateTaskMessage) {
        Iv2InitiateTaskMessage m = (Iv2InitiateTaskMessage) repairWork;
        Iv2InitiateTaskMessage work = new Iv2InitiateTaskMessage(m.getInitiatorHSId(), getHSId(), m);
        m_scheduler.updateLastSeenUniqueIds(work);
        m_scheduler.handleMessageRepair(needsRepair, work);
    } else if (repairWork instanceof CompleteTransactionMessage) {
        send(com.google_voltpatches.common.primitives.Longs.toArray(needsRepair), repairWork);
    } else {
        throw new RuntimeException("During MPI repair: Invalid repair message type: " + repairWork);
    }
}
Also used : Iv2InitiateTaskMessage(org.voltdb.messaging.Iv2InitiateTaskMessage) CompleteTransactionMessage(org.voltdb.messaging.CompleteTransactionMessage)

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