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