Search in sources :

Example 21 with FragmentResponseMessage

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

the class TestMpTransactionState method createTestPlan.

// Currently emulates the code in ProcedureRunner.slowPath()
// So any change to how that stuff is built will need to
// be reflected here
MpTestPlan createTestPlan(int batchSize, boolean readOnly, boolean replicatedTable, boolean rollback, long[] remoteHSIds) throws IOException {
    boolean single_frag = readOnly && replicatedTable;
    MpTestPlan plan = new MpTestPlan();
    List<Integer> distributedOutputDepIds = new ArrayList<Integer>();
    List<Integer> depsToResumeList = new ArrayList<Integer>();
    List<Integer> depsForLocalTask = new ArrayList<Integer>();
    for (int i = 0; i < batchSize; i++) {
        // each SQL statement in the batch gets an output dep ID
        // which corresponds to a local fragment ID
        depsToResumeList.add(i);
        // the distributed output deps
        if (!single_frag) {
            // take the dep and add 1000
            depsForLocalTask.add(i + 1000);
            distributedOutputDepIds.add(i + 1000);
        } else {
            depsForLocalTask.add(-1);
        }
    }
    // store resume dependencies in the MpTestPlan for later.
    plan.depsToResume = depsToResumeList;
    // generate remote task with output IDs, fill in lists appropriately
    plan.remoteWork = new // try not to care?
    FragmentTaskMessage(// try not to care?
    Long.MIN_VALUE, // try not to care?
    Long.MIN_VALUE, // try not to care?
    Long.MIN_VALUE, // magic, change if it matters
    1234l, readOnly, false, // IV2 doesn't use final task (yet)
    false);
    for (int i = 0; i < distributedOutputDepIds.size(); i++) {
        plan.remoteWork.addFragment(VoltSystemProcedure.fragIdToHash(Long.MIN_VALUE), distributedOutputDepIds.get(i), createDummyParameterSet());
    }
    System.out.println("REMOTE TASK: " + plan.remoteWork.toString());
    if (!single_frag) {
        // generate a remote fragment response for each remote message
        for (int i = 0; i < remoteHSIds.length; i++) {
            FragmentResponseMessage resp = new FragmentResponseMessage(plan.remoteWork, remoteHSIds[i]);
            if (rollback && i == (remoteHSIds.length - 1)) {
                resp.setStatus(FragmentResponseMessage.UNEXPECTED_ERROR, new EEException(1234));
                resp.addDependency(new DependencyPair.TableDependencyPair(distributedOutputDepIds.get(0), new VoltTable(new ColumnInfo[] { new ColumnInfo("UNUSED", VoltType.INTEGER) }, 1)));
            } else {
                resp.setStatus(FragmentResponseMessage.SUCCESS, null);
                for (int j = 0; j < distributedOutputDepIds.size(); j++) {
                    resp.addDependency(new DependencyPair.TableDependencyPair(distributedOutputDepIds.get(j), new VoltTable(new VoltTable.ColumnInfo("BOGO", VoltType.BIGINT))));
                }
            }
            System.out.println("RESPONSE: " + resp);
            plan.generatedResponses.add(resp);
        }
    }
    // generate local task with new output IDs, use above outputs as inputs, if any
    plan.localWork = new // try not to care
    FragmentTaskMessage(// try not to care
    Long.MIN_VALUE, Long.MIN_VALUE, Long.MIN_VALUE, 1234l, readOnly, false, false);
    for (int i = 0; i < batchSize; i++) {
        plan.localWork.addFragment(VoltSystemProcedure.fragIdToHash(0L), depsToResumeList.get(i), createDummyParameterSet());
    }
    for (int i = 0; i < depsForLocalTask.size(); i++) {
        if (depsForLocalTask.get(i) < 0)
            continue;
        plan.localWork.addInputDepId(i, depsForLocalTask.get(i));
    }
    // create the FragmentResponse for the BorrowTask
    FragmentResponseMessage resp = new FragmentResponseMessage(plan.remoteWork, remoteHSIds[0]);
    resp.m_sourceHSId = buddyHSId;
    resp.setStatus(FragmentResponseMessage.SUCCESS, null);
    for (int j = 0; j < batchSize; j++) {
        resp.addDependency(new DependencyPair.TableDependencyPair(depsToResumeList.get(j), new VoltTable(new VoltTable.ColumnInfo("BOGO", VoltType.BIGINT))));
    }
    System.out.println("BORROW RESPONSE: " + resp);
    plan.generatedResponses.add(resp);
    System.out.println("LOCAL TASK: " + plan.localWork.toString());
    return plan;
}
Also used : ArrayList(java.util.ArrayList) ColumnInfo(org.voltdb.VoltTable.ColumnInfo) ColumnInfo(org.voltdb.VoltTable.ColumnInfo) VoltTable(org.voltdb.VoltTable) FragmentResponseMessage(org.voltdb.messaging.FragmentResponseMessage) EEException(org.voltdb.exceptions.EEException) DependencyPair(org.voltdb.DependencyPair)

Example 22 with FragmentResponseMessage

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

the class TestSpSchedulerDedupe method testPrimaryFragmentTaskResponseReplicas.

@Test
public void testPrimaryFragmentTaskResponseReplicas() 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);
    FragmentTaskMessage sptask = createFrag(txnid, false, primary_hsid);
    dut.deliver(sptask);
    // verify no response sent yet
    verify(mbox, times(0)).send(anyLong(), (VoltMessage) anyObject());
    ArgumentCaptor<FragmentTaskMessage> replmsg = ArgumentCaptor.forClass(FragmentTaskMessage.class);
    verify(mbox, times(1)).send(eq(new long[] { 2 }), replmsg.capture());
    assertEquals(dut_hsid, replmsg.getValue().getCoordinatorHSId());
    FragmentResponseMessage resp = new FragmentResponseMessage(sptask, 0l);
    dut.deliver(resp);
    FragmentResponseMessage replresp = new FragmentResponseMessage(replmsg.getValue(), 0l);
    dut.deliver(replresp);
    verify(mbox, times(1)).send(eq(primary_hsid), eq(resp));
}
Also used : FragmentTaskMessage(org.voltdb.messaging.FragmentTaskMessage) ArrayList(java.util.ArrayList) Matchers.anyLong(org.mockito.Matchers.anyLong) FragmentResponseMessage(org.voltdb.messaging.FragmentResponseMessage) Test(org.junit.Test)

Example 23 with FragmentResponseMessage

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

the class Iv2Trace method logInitiatorRxMsg.

public static void logInitiatorRxMsg(VoltMessage msg, long localHSId) {
    if (IV2_TRACE_ENABLED) {
        if (msg instanceof InitiateResponseMessage) {
            InitiateResponseMessage iresp = (InitiateResponseMessage) msg;
            String logmsg = "rxInitRsp %s from %s ciHandle %s txnId %s spHandle %s status %s";
            iv2log.trace(String.format(logmsg, CoreUtils.hsIdToString(localHSId), CoreUtils.hsIdToString(iresp.m_sourceHSId), ClientInterfaceHandleManager.handleToString(iresp.getClientInterfaceHandle()), txnIdToString(iresp.getTxnId()), txnIdToString(iresp.getSpHandle()), respStatusToString(iresp.getClientResponseData().getStatus())));
        } else if (msg instanceof FragmentResponseMessage) {
            FragmentResponseMessage fresp = (FragmentResponseMessage) msg;
            String logmsg = "rxFragRsp %s from %s txnId %s spHandle %s status %s";
            iv2log.trace(String.format(logmsg, CoreUtils.hsIdToString(localHSId), CoreUtils.hsIdToString(fresp.m_sourceHSId), txnIdToString(fresp.getTxnId()), txnIdToString(fresp.getSpHandle()), fragStatusToString(fresp.getStatusCode())));
        } else if (msg instanceof CompleteTransactionResponseMessage) {
            CompleteTransactionResponseMessage cresp = (CompleteTransactionResponseMessage) msg;
            String logmsg = "rxCompRsp %s from %s txnId %s spHandle %s SPI %s restart %s recovering %s";
            iv2log.trace(String.format(logmsg, CoreUtils.hsIdToString(localHSId), CoreUtils.hsIdToString(cresp.m_sourceHSId), txnIdToString(cresp.getTxnId()), txnIdToString(cresp.getSpHandle()), txnIdToString(cresp.getSPIHSId()), cresp.isRestart(), cresp.isRecovering()));
        } else if (msg instanceof DummyTransactionResponseMessage) {
            DummyTransactionResponseMessage dresp = (DummyTransactionResponseMessage) msg;
            String logmsg = "rxDummyRsp %s from %s to %s for txnId %s";
            iv2log.trace(String.format(logmsg, CoreUtils.hsIdToString(localHSId), CoreUtils.hsIdToString(dresp.m_sourceHSId), txnIdToString(dresp.getSPIHSId()), txnIdToString(dresp.getTxnId())));
        }
    }
}
Also used : CompleteTransactionResponseMessage(org.voltdb.messaging.CompleteTransactionResponseMessage) DummyTransactionResponseMessage(org.voltdb.messaging.DummyTransactionResponseMessage) InitiateResponseMessage(org.voltdb.messaging.InitiateResponseMessage) FragmentResponseMessage(org.voltdb.messaging.FragmentResponseMessage)

Aggregations

FragmentResponseMessage (org.voltdb.messaging.FragmentResponseMessage)23 ArrayList (java.util.ArrayList)9 Test (org.junit.Test)9 List (java.util.List)6 Mailbox (org.voltcore.messaging.Mailbox)6 DependencyPair (org.voltdb.DependencyPair)6 SiteProcedureConnection (org.voltdb.SiteProcedureConnection)6 StoredProcedureInvocation (org.voltdb.StoredProcedureInvocation)6 Iv2InitiateTaskMessage (org.voltdb.messaging.Iv2InitiateTaskMessage)6 VoltTable (org.voltdb.VoltTable)5 EEException (org.voltdb.exceptions.EEException)5 FragmentTaskMessage (org.voltdb.messaging.FragmentTaskMessage)5 VoltTrace (org.voltdb.utils.VoltTrace)4 Matchers.anyLong (org.mockito.Matchers.anyLong)2 ParameterSet (org.voltdb.ParameterSet)2 TransactionState (org.voltdb.dtxn.TransactionState)2 SQLException (org.voltdb.exceptions.SQLException)2 SerializableException (org.voltdb.exceptions.SerializableException)2 TransactionRestartException (org.voltdb.exceptions.TransactionRestartException)2 BorrowTaskMessage (org.voltdb.messaging.BorrowTaskMessage)2