Search in sources :

Example 11 with InitiateResponseMessage

use of org.voltdb.messaging.InitiateResponseMessage 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 12 with InitiateResponseMessage

use of org.voltdb.messaging.InitiateResponseMessage 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 13 with InitiateResponseMessage

use of org.voltdb.messaging.InitiateResponseMessage 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 14 with InitiateResponseMessage

use of org.voltdb.messaging.InitiateResponseMessage 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 15 with InitiateResponseMessage

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

the class ProcedureRunnerNT method call.

/**
     * Synchronous call to NT procedure run(..) method.
     *
     * Wraps coreCall with statistics.
     *
     * @return True if done and null if there is an
     * async task still running.
     */
protected boolean call(Object... paramListIn) {
    m_perCallStats = m_statsCollector.beginProcedure();
    // if we're keeping track, calculate parameter size
    if (m_perCallStats.samplingProcedure()) {
        ParameterSet params = ParameterSet.fromArrayNoCopy(paramListIn);
        m_perCallStats.setParameterSize(params.getSerializedSize());
    }
    ClientResponseImpl response = coreCall(paramListIn);
    // null response means this procedure isn't over and has some async component
    if (response == null) {
        return false;
    }
    // if we're keeping track, calculate result size
    if (m_perCallStats.samplingProcedure()) {
        m_perCallStats.setResultSize(response.getResults());
    }
    m_statsCollector.endProcedure(response.getStatus() == ClientResponse.USER_ABORT, (response.getStatus() != ClientResponse.USER_ABORT) && (response.getStatus() != ClientResponse.SUCCESS), m_perCallStats);
    // send the response to caller
    // must be done as IRM to CI mailbox for backpressure accounting
    response.setClientHandle(m_clientHandle);
    InitiateResponseMessage irm = InitiateResponseMessage.messageForNTProcResponse(m_ciHandle, m_ccxn.connectionId(), response);
    m_mailbox.deliver(irm);
    // remove record of this procedure in NTPS
    // only done if procedure is really done
    m_ntProcService.handleNTProcEnd(this);
    return true;
}
Also used : InitiateResponseMessage(org.voltdb.messaging.InitiateResponseMessage)

Aggregations

InitiateResponseMessage (org.voltdb.messaging.InitiateResponseMessage)17 ClientResponseImpl (org.voltdb.ClientResponseImpl)7 Iv2InitiateTaskMessage (org.voltdb.messaging.Iv2InitiateTaskMessage)7 VoltTable (org.voltdb.VoltTable)5 Test (org.junit.Test)4 Matchers.anyLong (org.mockito.Matchers.anyLong)3 VoltMessage (org.voltcore.messaging.VoltMessage)3 VoltTrace (org.voltdb.utils.VoltTrace)2 PrintWriter (java.io.PrintWriter)1 StringWriter (java.io.StringWriter)1 Writer (java.io.Writer)1 ByteBuffer (java.nio.ByteBuffer)1 ArrayList (java.util.ArrayList)1 LinkedList (java.util.LinkedList)1 TransactionInfoBaseMessage (org.voltcore.messaging.TransactionInfoBaseMessage)1 DeferredSerialization (org.voltcore.utils.DeferredSerialization)1 ExpectedProcedureException (org.voltdb.ExpectedProcedureException)1 ProcedureRunner (org.voltdb.ProcedureRunner)1 StoredProcedureInvocation (org.voltdb.StoredProcedureInvocation)1 CompleteTransactionMessage (org.voltdb.messaging.CompleteTransactionMessage)1