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