use of org.neo4j.kernel.impl.transaction.log.TransactionIdStore in project neo4j by neo4j.
the class KernelTransactionsTest method newKernelTransactions.
private static KernelTransactions newKernelTransactions(Locks locks, StorageEngine storageEngine, TransactionCommitProcess commitProcess, boolean testKernelTransactions) throws Throwable {
LifeSupport life = new LifeSupport();
life.start();
TransactionIdStore transactionIdStore = mock(TransactionIdStore.class);
when(transactionIdStore.getLastCommittedTransaction()).thenReturn(new TransactionId(0, 0, 0));
Tracers tracers = new Tracers("null", NullLog.getInstance(), new Monitors(), mock(JobScheduler.class));
StatementLocksFactory statementLocksFactory = new SimpleStatementLocksFactory(locks);
StatementOperationContainer statementOperationsContianer = new StatementOperationContainer(null, null);
KernelTransactions transactions;
if (testKernelTransactions) {
transactions = createTestTransactions(storageEngine, commitProcess, transactionIdStore, tracers, statementLocksFactory, statementOperationsContianer, clock, availabilityGuard);
} else {
transactions = createTransactions(storageEngine, commitProcess, transactionIdStore, tracers, statementLocksFactory, statementOperationsContianer, clock, availabilityGuard);
}
transactions.start();
return transactions;
}
use of org.neo4j.kernel.impl.transaction.log.TransactionIdStore in project neo4j by neo4j.
the class TransactionRepresentationCommitProcessTest method shouldSuccessfullyCommitTransactionWithNoCommands.
@Test
public void shouldSuccessfullyCommitTransactionWithNoCommands() throws Exception {
// GIVEN
long txId = 11;
long commitTimestamp = System.currentTimeMillis();
TransactionIdStore transactionIdStore = mock(TransactionIdStore.class);
TransactionAppender appender = new TestableTransactionAppender(transactionIdStore);
when(transactionIdStore.nextCommittingTransactionId()).thenReturn(txId);
StorageEngine storageEngine = mock(StorageEngine.class);
TransactionCommitProcess commitProcess = new TransactionRepresentationCommitProcess(appender, storageEngine);
PhysicalTransactionRepresentation noCommandTx = new PhysicalTransactionRepresentation(Collections.emptyList());
noCommandTx.setHeader(new byte[0], -1, -1, -1, -1, -1, -1);
// WHEN
commitProcess.commit(new TransactionToApply(noCommandTx), commitEvent, INTERNAL);
verify(transactionIdStore).transactionCommitted(txId, FakeCommitment.CHECKSUM, FakeCommitment.TIMESTAMP);
}
use of org.neo4j.kernel.impl.transaction.log.TransactionIdStore in project neo4j by neo4j.
the class TransactionRepresentationCommitProcessTest method shouldCloseTransactionRegardlessOfWhetherOrNotItAppliedCorrectly.
@Test
public void shouldCloseTransactionRegardlessOfWhetherOrNotItAppliedCorrectly() throws Exception {
// GIVEN
TransactionIdStore transactionIdStore = mock(TransactionIdStore.class);
TransactionAppender appender = new TestableTransactionAppender(transactionIdStore);
long txId = 11;
when(transactionIdStore.nextCommittingTransactionId()).thenReturn(txId);
IOException rootCause = new IOException("Mock exception");
StorageEngine storageEngine = mock(StorageEngine.class);
doThrow(new IOException(rootCause)).when(storageEngine).apply(any(TransactionToApply.class), any(TransactionApplicationMode.class));
TransactionCommitProcess commitProcess = new TransactionRepresentationCommitProcess(appender, storageEngine);
TransactionToApply transaction = mockedTransaction();
// WHEN
try {
commitProcess.commit(transaction, commitEvent, INTERNAL);
} catch (TransactionFailureException e) {
assertThat(e.getMessage(), containsString("Could not apply the transaction to the store"));
assertTrue(contains(e, rootCause.getMessage(), rootCause.getClass()));
}
// THEN
// we can't verify transactionCommitted since that's part of the TransactionAppender, which we have mocked
verify(transactionIdStore, times(1)).transactionClosed(eq(txId), anyLong(), anyLong());
}
Aggregations