use of org.voltdb.messaging.Iv2InitiateTaskMessage 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.Iv2InitiateTaskMessage 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.Iv2InitiateTaskMessage in project voltdb by VoltDB.
the class TestMpTransactionState method testTruncationHandleForwarding.
@Test
public void testTruncationHandleForwarding() throws IOException {
long truncPt = 100L;
Iv2InitiateTaskMessage taskmsg = new Iv2InitiateTaskMessage(0, 0, truncPt, 101L, System.currentTimeMillis(), true, false, new StoredProcedureInvocation(), 0, 0, false);
assertEquals(truncPt, taskmsg.getTruncationHandle());
FragmentTaskMessage localFrag = mock(FragmentTaskMessage.class);
FragmentTaskMessage remoteFrag = mock(FragmentTaskMessage.class);
when(remoteFrag.getFragmentCount()).thenReturn(1);
buddyHSId = 0;
Mailbox mailbox = mock(Mailbox.class);
MpTransactionState dut = new MpTransactionState(mailbox, taskmsg, allHsids, partMasters, buddyHSId, false);
// create local work and verify the created localwork has the
// expected truncation point.
dut.createLocalFragmentWork(localFrag, false);
verify(dut.m_localWork).setTruncationHandle(truncPt);
// same with partcipating work.
dut.createAllParticipatingFragmentWork(remoteFrag);
verify(dut.m_remoteWork).setTruncationHandle(truncPt);
}
use of org.voltdb.messaging.Iv2InitiateTaskMessage in project voltdb by VoltDB.
the class TestMpTransactionState method testOneSitePartitionedReadWithRollback.
@Test
public void testOneSitePartitionedReadWithRollback() throws IOException {
long txnId = 1234l;
int batch_size = 3;
Iv2InitiateTaskMessage taskmsg = new Iv2InitiateTaskMessage(0, 0, (txnId - 1), txnId, System.currentTimeMillis(), true, false, new StoredProcedureInvocation(), 0, 0, false);
int hsids = 1;
buddyHSId = 0;
long[] non_local = configureHSIds(hsids);
MpTestPlan plan = createTestPlan(batch_size, true, false, true, non_local);
Mailbox mailbox = mock(Mailbox.class);
SiteProcedureConnection siteConnection = mock(SiteProcedureConnection.class);
MpTransactionState dut = new MpTransactionState(mailbox, taskmsg, allHsids, partMasters, buddyHSId, false);
// emulate ProcedureRunner's use for a single local fragment
dut.setupProcedureResume(true, plan.depsToResume);
dut.createLocalFragmentWork(plan.localWork, false);
// This will be passed a FragmentTaskMessage with no deps
dut.createAllParticipatingFragmentWork(plan.remoteWork);
// we should send one message
verify(mailbox).send(eq(new long[] { 0 }), (VoltMessage) any());
// offer all the necessary fragment responses to satisfy deps
for (FragmentResponseMessage msg : plan.generatedResponses) {
System.out.println("Offering response: " + msg);
dut.offerReceivedFragmentResponse(msg);
}
// We're getting an error, so this should throw something
boolean threw = false;
try {
dut.recursableRun(siteConnection);
fail();
} catch (EEException eee) {
if (eee.getErrorCode() == 1234) {
threw = true;
}
}
assertTrue(threw);
}
use of org.voltdb.messaging.Iv2InitiateTaskMessage in project voltdb by VoltDB.
the class TestMpTransactionState method testMultiSitePartitionedRead.
@Test
public void testMultiSitePartitionedRead() throws IOException {
long txnId = 1234l;
int batch_size = 3;
Iv2InitiateTaskMessage taskmsg = new Iv2InitiateTaskMessage(0, -1, (txnId - 1), txnId, System.currentTimeMillis(), true, false, new StoredProcedureInvocation(), 0, 0, false);
int hsids = 6;
buddyHSId = 0;
long[] non_local = configureHSIds(hsids);
MpTestPlan plan = createTestPlan(batch_size, true, false, false, non_local);
Mailbox mailbox = mock(Mailbox.class);
SiteProcedureConnection siteConnection = mock(SiteProcedureConnection.class);
MpTransactionState dut = new MpTransactionState(mailbox, taskmsg, allHsids, partMasters, buddyHSId, false);
// emulate ProcedureRunner's use for a single local fragment
dut.setupProcedureResume(true, plan.depsToResume);
dut.createLocalFragmentWork(plan.localWork, false);
// This will be passed a FragmentTaskMessage with no deps
dut.createAllParticipatingFragmentWork(plan.remoteWork);
// we should send 6 messages
verify(mailbox).send(eq(non_local), (VoltMessage) any());
// offer all the necessary fragment responses to satisfy deps
for (FragmentResponseMessage msg : plan.generatedResponses) {
dut.offerReceivedFragmentResponse(msg);
}
// if we've satisfied everything, this should run to completion
Map<Integer, List<VoltTable>> results = dut.recursableRun(siteConnection);
verify(mailbox).send(eq(buddyHSId), (BorrowTaskMessage) any());
// verify returned deps/tables
assertEquals(batch_size, results.size());
System.out.println(results);
}
Aggregations