use of org.voltdb.messaging.Iv2InitiateTaskMessage in project voltdb by VoltDB.
the class TestTransactionTaskQueue method createSpProc.
// Cases to test:
// several single part txns
private SpProcedureTask createSpProc(long localTxnId, TransactionTaskQueue queue) {
// Mock an initiate message; override its txnid to return
// the default SP value (usually set by ClientInterface).
Iv2InitiateTaskMessage init = mock(Iv2InitiateTaskMessage.class);
when(init.getTxnId()).thenReturn(Iv2InitiateTaskMessage.UNUSED_MP_TXNID);
when(init.getSpHandle()).thenReturn(localTxnId);
InitiatorMailbox mbox = mock(InitiatorMailbox.class);
when(mbox.getHSId()).thenReturn(1337l);
SpProcedureTask task = new SpProcedureTask(mbox, "TestProc", queue, init);
return task;
}
use of org.voltdb.messaging.Iv2InitiateTaskMessage in project voltdb by VoltDB.
the class TestSpSchedulerDedupe method createMsg.
private Iv2InitiateTaskMessage createMsg(long txnId, boolean readOnly, boolean singlePart, long destHSId) {
// Mock an invocation for MockSPName.
StoredProcedureInvocation spi = mock(StoredProcedureInvocation.class);
when(spi.getProcName()).thenReturn(MockSPName);
ParameterSet bleh = mock(ParameterSet.class);
when(spi.getParams()).thenReturn(bleh);
Iv2InitiateTaskMessage task = new // initHSID
Iv2InitiateTaskMessage(// initHSID
destHSId, // coordHSID
Long.MIN_VALUE, // truncationHandle
txnId - 1, // txnId
txnId, // uniqueID
UniqueIdGenerator.makeIdFromComponents(System.currentTimeMillis(), 0, 0), // readonly
readOnly, // single-part
singlePart, // invocation
spi, // client interface handle
Long.MAX_VALUE, // connectionId
Long.MAX_VALUE, // isForReplay
false);
// sp: sphandle == txnid
task.setTxnId(txnId);
task.setSpHandle(txnId);
return task;
}
use of org.voltdb.messaging.Iv2InitiateTaskMessage in project voltdb by VoltDB.
the class TestSpSchedulerDedupe method testReplicaInitiateTaskResponseShortCircuitRead.
@Test
public void testReplicaInitiateTaskResponseShortCircuitRead() throws Exception {
// replica does not receive reads on SAFE mode, except for FAST mode
m_readLevel = Consistency.ReadLevel.FAST;
long txnid = TxnEgo.makeZero(0).getTxnId();
createObjs();
Iv2InitiateTaskMessage sptask = createMsg(txnid, true, true, dut_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(dut_hsid), eq(resp));
m_readLevel = Consistency.ReadLevel.SAFE;
}
use of org.voltdb.messaging.Iv2InitiateTaskMessage in project voltdb by VoltDB.
the class TestReplaySequencer method makeIv2InitTask.
TransactionInfoBaseMessage makeIv2InitTask(long unused, String procName) {
Iv2InitiateTaskMessage m = mock(Iv2InitiateTaskMessage.class);
StoredProcedureInvocation invocation = mock(StoredProcedureInvocation.class);
when(invocation.getProcName()).thenReturn(procName);
when(m.getStoredProcedureInvocation()).thenReturn(invocation);
when(m.isForReplay()).thenReturn(true);
return m;
}
use of org.voltdb.messaging.Iv2InitiateTaskMessage in project voltdb by VoltDB.
the class ProcedureRunnerNT method callAllNodeNTProcedure.
/**
* Send an invocation directly to each host's CI mailbox.
* This ONLY works for NT procedures.
* Track responses and complete the returned future when they're all accounted for.
*/
protected CompletableFuture<Map<Integer, ClientResponse>> callAllNodeNTProcedure(String procName, Object... params) {
// only one of these at a time
if (m_outstandingAllHostProc.get()) {
throw new VoltAbortException(new IllegalStateException("Only one AllNodeNTProcedure operation can be running at a time."));
}
m_outstandingAllHostProc.set(true);
StoredProcedureInvocation invocation = new StoredProcedureInvocation();
invocation.setProcName(procName);
invocation.setParams(params);
invocation.setClientHandle(m_id);
final Iv2InitiateTaskMessage workRequest = new Iv2InitiateTaskMessage(m_mailbox.getHSId(), m_mailbox.getHSId(), Iv2InitiateTaskMessage.UNUSED_TRUNC_HANDLE, m_id, m_id, true, false, invocation, m_id, ClientInterface.NT_REMOTE_PROC_CID, false);
m_allHostFut = new CompletableFuture<>();
m_allHostResponses = new HashMap<>();
Set<Integer> liveHostIds = null;
// also held when
synchronized (m_allHostCallbackLock) {
// collect the set of live client interface mailbox ids
liveHostIds = VoltDB.instance().getHostMessenger().getLiveHostIds();
m_outstandingAllHostProcedureHostIds = liveHostIds;
}
// convert host ids to hsids
long[] hsids = liveHostIds.stream().map(hostId -> CoreUtils.getHSIdFromHostAndSite(hostId, HostMessenger.CLIENT_INTERFACE_SITE_ID)).mapToLong(x -> x).toArray();
// you get a concurrent modification exception
for (long hsid : hsids) {
m_mailbox.send(hsid, workRequest);
}
return m_allHostFut;
}
Aggregations