use of org.neo4j.kernel.impl.api.TransactionToApply in project neo4j by neo4j.
the class ApplyRecoveredTransactionsTest method applyExternalTransaction.
private void applyExternalTransaction(long transactionId, Command... commands) throws Exception {
LockService lockService = mock(LockService.class);
when(lockService.acquireNodeLock(anyLong(), any(LockService.LockType.class))).thenReturn(LockService.NO_LOCK);
when(lockService.acquireRelationshipLock(anyLong(), any(LockService.LockType.class))).thenReturn(LockService.NO_LOCK);
NeoStoreBatchTransactionApplier applier = new NeoStoreBatchTransactionApplier(neoStores, mock(CacheAccessBackDoor.class), lockService);
TransactionRepresentation tx = new PhysicalTransactionRepresentation(Arrays.asList(commands));
CommandHandlerContract.apply(applier, txApplier -> {
tx.accept(txApplier);
return false;
}, new TransactionToApply(tx, transactionId));
}
use of org.neo4j.kernel.impl.api.TransactionToApply in project neo4j by neo4j.
the class BatchingTxApplierTest method assertTransactionsCommitted.
private void assertTransactionsCommitted(long startTxId, long expectedCount) throws TransactionFailureException {
ArgumentCaptor<TransactionToApply> batchCaptor = ArgumentCaptor.forClass(TransactionToApply.class);
verify(commitProcess).commit(batchCaptor.capture(), eq(NULL), eq(EXTERNAL));
TransactionToApply batch = Iterables.single(batchCaptor.getAllValues());
long expectedTxId = startTxId;
long count = 0;
while (batch != null) {
assertEquals(expectedTxId, batch.transactionId());
expectedTxId++;
batch = batch.next();
count++;
}
assertEquals(expectedCount, count);
}
use of org.neo4j.kernel.impl.api.TransactionToApply in project neo4j by neo4j.
the class TransactionBatchCommitterTest method tx.
private TransactionToApply tx(long id, long commitTimestamp) {
PhysicalTransactionRepresentation representation = new PhysicalTransactionRepresentation(emptyList());
representation.setHeader(new byte[0], 0, 0, commitTimestamp - 10, id - 1, commitTimestamp, 0);
return new TransactionToApply(representation, id);
}
use of org.neo4j.kernel.impl.api.TransactionToApply in project neo4j by neo4j.
the class TransactionBatchCommitterTest method createTxChain.
private TransactionChain createTxChain(int txCount, long firstCommitTimestamp, long commitTimestampInterval) {
TransactionToApply first = null;
TransactionToApply last = null;
long commitTimestamp = firstCommitTimestamp;
for (long i = BASE_TX_ID; i < BASE_TX_ID + txCount; i++) {
TransactionToApply tx = tx(i, commitTimestamp);
if (first == null) {
first = tx;
last = tx;
} else {
last.next(tx);
last = tx;
}
commitTimestamp += commitTimestampInterval;
}
return new TransactionChain(first, last);
}
use of org.neo4j.kernel.impl.api.TransactionToApply in project neo4j by neo4j.
the class BatchingTransactionAppenderTest method shouldKernelPanicIfTransactionIdsMismatch.
@Test
void shouldKernelPanicIfTransactionIdsMismatch() {
// Given
BatchingTransactionAppender appender = life.add(createTransactionAppender());
when(transactionIdStore.nextCommittingTransactionId()).thenReturn(42L);
TransactionToApply batch = new TransactionToApply(mock(TransactionRepresentation.class), 43L, NULL);
// When
var e = assertThrows(IllegalStateException.class, () -> appender.append(batch, LogAppendEvent.NULL));
// Then
verify(databaseHealth).panic(e);
}
Aggregations