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;
}
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));
}
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())));
}
}
}
Aggregations