use of org.neo4j.kernel.impl.transaction.log.TransactionCursor in project neo4j by neo4j.
the class ProduceNoopCommandsIT method listNoopCommands.
@AfterEach
void listNoopCommands() throws IOException {
LogicalTransactionStore txStore = ((GraphDatabaseAPI) db).getDependencyResolver().resolveDependency(LogicalTransactionStore.class);
try (TransactionCursor transactions = txStore.getTransactions(TransactionIdStore.BASE_TX_ID + 1)) {
while (transactions.next()) {
CommittedTransactionRepresentation tx = transactions.get();
TransactionRepresentation transactionRepresentation = tx.getTransactionRepresentation();
if (hasNoOpCommand(transactionRepresentation)) {
StringBuilder error = new StringBuilder("Tx contains no-op commands, " + tx.getStartEntry());
printNoOpCommands(transactionRepresentation, error);
error.append(format("%n%s", tx.getCommitEntry()));
fail(error.toString());
}
}
}
}
use of org.neo4j.kernel.impl.transaction.log.TransactionCursor in project neo4j by neo4j.
the class DatabaseUpgradeTransactionIT method assertUpgradeTransactionInOrder.
private void assertUpgradeTransactionInOrder(KernelVersion from, KernelVersion to, long fromTxId) throws Exception {
LogicalTransactionStore lts = db.getDependencyResolver().resolveDependency(LogicalTransactionStore.class);
ArrayList<KernelVersion> transactionVersions = new ArrayList<>();
ArrayList<CommittedTransactionRepresentation> transactions = new ArrayList<>();
try (TransactionCursor transactionCursor = lts.getTransactions(fromTxId + 1)) {
while (transactionCursor.next()) {
CommittedTransactionRepresentation representation = transactionCursor.get();
transactions.add(representation);
transactionVersions.add(representation.getStartEntry().getVersion());
}
}
// at least upgrade transaction and the triggering transaction
assertThat(transactionVersions).hasSizeGreaterThanOrEqualTo(2);
// Sorted means everything is in order
assertThat(transactionVersions).isSortedAccordingTo(Comparator.comparingInt(KernelVersion::version));
// First should be "from" version
assertThat(transactionVersions.get(0)).isEqualTo(from);
// And last the "to" version
assertThat(transactionVersions.get(transactionVersions.size() - 1)).isEqualTo(to);
CommittedTransactionRepresentation upgradeTransaction = transactions.get(transactionVersions.indexOf(to));
PhysicalTransactionRepresentation physicalRep = (PhysicalTransactionRepresentation) upgradeTransaction.getTransactionRepresentation();
physicalRep.accept(element -> {
assertThat(element).isInstanceOf(Command.MetaDataCommand.class);
return true;
});
}
use of org.neo4j.kernel.impl.transaction.log.TransactionCursor in project neo4j by neo4j.
the class ReversedMultiFileTransactionCursorTest method shouldReadSingleVersionReversed.
@Test
void shouldReadSingleVersionReversed() throws Exception {
// GIVEN
TransactionCursor cursor = new ReversedMultiFileTransactionCursor(logFile, log(5), 0, start());
// WHEN
CommittedTransactionRepresentation[] reversed = exhaust(cursor);
// THEN
assertTransactionRange(reversed, 5, 0);
}
use of org.neo4j.kernel.impl.transaction.log.TransactionCursor in project neo4j by neo4j.
the class ReversedMultiFileTransactionCursorTest method shouldHandleEmptySingleLogVersion.
@Test
void shouldHandleEmptySingleLogVersion() throws Exception {
// GIVEN
TransactionCursor cursor = new ReversedMultiFileTransactionCursor(logFile, log(0), 0, start());
// WHEN
CommittedTransactionRepresentation[] reversed = exhaust(cursor);
// THEN
assertTransactionRange(reversed, 0, 0);
}
use of org.neo4j.kernel.impl.transaction.log.TransactionCursor in project neo4j by neo4j.
the class ReversedMultiFileTransactionCursorTest method shouldRespectStartLogPosition.
@Test
void shouldRespectStartLogPosition() throws Exception {
// GIVEN
TransactionCursor cursor = new ReversedMultiFileTransactionCursor(logFile, log(5, 6, 8), 2, new LogPosition(1, CURRENT_FORMAT_LOG_HEADER_SIZE + 3));
// WHEN
CommittedTransactionRepresentation[] reversed = exhaust(cursor);
// THEN
assertTransactionRange(reversed, 5 + 6 + 8, 5 + 3);
}
Aggregations