use of org.voltdb.SiteProcedureConnection 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.SiteProcedureConnection 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);
}
use of org.voltdb.SiteProcedureConnection in project voltdb by VoltDB.
the class TestMpTransactionState method testOneSitePartitionedRead.
@Test
public void testOneSitePartitionedRead() 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 = 1;
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 one message
verify(mailbox).send(eq(new long[] { buddyHSId }), (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);
}
// if we've satisfied everything, this should run to completion
Map<Integer, List<VoltTable>> results = dut.recursableRun(siteConnection);
// Verify we send a BorrowTask
verify(mailbox).send(eq(buddyHSId), (BorrowTaskMessage) any());
// verify returned deps/tables
assertEquals(batch_size, results.size());
System.out.println(results);
}
use of org.voltdb.SiteProcedureConnection in project voltdb by VoltDB.
the class TestMpTransactionState method testSingleReplicatedReadFragment.
@Test
public void testSingleReplicatedReadFragment() throws IOException {
long txnId = 1234l;
int batch_size = 3;
Iv2InitiateTaskMessage taskmsg = new Iv2InitiateTaskMessage(3, 4, (txnId - 1), txnId, System.currentTimeMillis(), true, false, new StoredProcedureInvocation(), 0, 0, false);
int hsids = 6;
buddyHSId = 3;
long[] non_local = configureHSIds(hsids);
MpTestPlan plan = createTestPlan(batch_size, true, true, 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);
// verify no messages sent to non-3 HSIDs for read-only
verify(mailbox, never()).send(anyLong(), (VoltMessage) any());
verify(mailbox, never()).send(new long[] { anyLong() }, (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);
}
use of org.voltdb.SiteProcedureConnection in project voltdb by VoltDB.
the class TestMpTransactionState method testMPReadWithDummyResponse.
@Test
public void testMPReadWithDummyResponse() 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);
// replace the last remote fragment response with a dummy
for (FragmentResponseMessage dummy : plan.generatedResponses) {
if (dummy.getExecutorSiteId() == non_local[non_local.length - 1]) {
dummy.setRecovering(true);
for (int i = 0; i < dummy.getTableCount(); i++) {
VoltTable depTable = dummy.getTableAtIndex(i);
depTable.setStatusCode(VoltTableUtil.NULL_DEPENDENCY_STATUS);
depTable.clearRowData();
}
}
}
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);
ArgumentCaptor<BorrowTaskMessage> borrowCaptor = ArgumentCaptor.forClass(BorrowTaskMessage.class);
verify(mailbox).send(eq(buddyHSId), borrowCaptor.capture());
// make sure that the borrow task message doesn't have any dummy dependency tables as input
BorrowTaskMessage borrowMsg = borrowCaptor.getValue();
Map<Integer, List<VoltTable>> inputDepMap = borrowMsg.getInputDepMap();
for (List<VoltTable> tables : inputDepMap.values()) {
for (VoltTable table : tables) {
assertNotSame(VoltTableUtil.NULL_DEPENDENCY_STATUS, table.getStatusCode());
}
}
// verify returned deps/tables
assertEquals(batch_size, results.size());
System.out.println(results);
}
Aggregations