From e0b857e08121d18c1d2d9d0e8cf240ea51f2520f Mon Sep 17 00:00:00 2001 From: Mattias Persson Date: Mon, 12 Sep 2016 16:05:53 +0200 Subject: [PATCH] Further simplifications of recovery code and some comment typos fixed --- .../log/LogicalTransactionStore.java | 4 ++-- .../log/PhysicalLogicalTransactionStore.java | 2 +- .../log/PhysicalTransactionCursor.java | 7 +------ ...TransactionLogAppendAndRotateStressIT.java | 20 +++++++++---------- 4 files changed, 13 insertions(+), 20 deletions(-) diff --git a/community/kernel/src/main/java/org/neo4j/kernel/impl/transaction/log/LogicalTransactionStore.java b/community/kernel/src/main/java/org/neo4j/kernel/impl/transaction/log/LogicalTransactionStore.java index 01007bb807dea..282bcecd78a7f 100644 --- a/community/kernel/src/main/java/org/neo4j/kernel/impl/transaction/log/LogicalTransactionStore.java +++ b/community/kernel/src/main/java/org/neo4j/kernel/impl/transaction/log/LogicalTransactionStore.java @@ -49,12 +49,12 @@ TransactionCursor getTransactions( long transactionIdToStartFrom ) /** * Acquires a {@link TransactionCursor cursor} which will provide {@link CommittedTransactionRepresentation} * instances for committed transactions, starting from the specified {@link LogPosition}. - * This is useful for placing a cursor at a position refered to by a {@link CheckPoint}. + * This is useful for placing a cursor at a position referred to by a {@link CheckPoint}. * Transactions will be returned from the cursor in transaction-id-sequential order. * * @param position {@link LogPosition} of the first transaction that the cursor will return. * @return an {@link TransactionCursor} capable of returning {@link CommittedTransactionRepresentation} instances - * for committed transactions, starting from the specified {@code transactionIdToStartFrom}. + * for committed transactions, starting from the specified {@code position}. * @throws NoSuchTransactionException if the requested transaction hasn't been committed, * or if the transaction has been committed, but information about it is no longer available for some reason. * @throws IOException if there was an I/O related error looking for the start transaction. diff --git a/community/kernel/src/main/java/org/neo4j/kernel/impl/transaction/log/PhysicalLogicalTransactionStore.java b/community/kernel/src/main/java/org/neo4j/kernel/impl/transaction/log/PhysicalLogicalTransactionStore.java index 3c2065b76a3f8..ce813cbaaefc4 100644 --- a/community/kernel/src/main/java/org/neo4j/kernel/impl/transaction/log/PhysicalLogicalTransactionStore.java +++ b/community/kernel/src/main/java/org/neo4j/kernel/impl/transaction/log/PhysicalLogicalTransactionStore.java @@ -52,7 +52,7 @@ public PhysicalLogicalTransactionStore( LogFile logFile, TransactionMetadataCach } @Override - public TransactionCursor getTransactions( LogPosition position ) throws NoSuchTransactionException, IOException + public TransactionCursor getTransactions( LogPosition position ) throws IOException { return new PhysicalTransactionCursor<>( logFile.getReader( position ), new VersionAwareLogEntryReader<>() ); } diff --git a/community/kernel/src/main/java/org/neo4j/kernel/impl/transaction/log/PhysicalTransactionCursor.java b/community/kernel/src/main/java/org/neo4j/kernel/impl/transaction/log/PhysicalTransactionCursor.java index 0ab8ff946da50..f294c7af7e43a 100644 --- a/community/kernel/src/main/java/org/neo4j/kernel/impl/transaction/log/PhysicalTransactionCursor.java +++ b/community/kernel/src/main/java/org/neo4j/kernel/impl/transaction/log/PhysicalTransactionCursor.java @@ -48,11 +48,6 @@ public PhysicalTransactionCursor( T channel, LogEntryReader entryReader ) thr new LogEntryCursor( (LogEntryReader) entryReader, channel ); } - protected List commandList() - { - return new ArrayList<>(); - } - @Override public CommittedTransactionRepresentation get() { @@ -81,7 +76,7 @@ public boolean next() throws IOException LogEntryStart startEntry = entry.as(); LogEntryCommit commitEntry; - List entries = commandList(); + List entries = new ArrayList<>(); while ( true ) { if ( !logEntryCursor.next() ) diff --git a/community/kernel/src/test/java/org/neo4j/kernel/impl/transaction/log/TransactionLogAppendAndRotateStressIT.java b/community/kernel/src/test/java/org/neo4j/kernel/impl/transaction/log/TransactionLogAppendAndRotateStressIT.java index 3108983a9a496..a151722123c76 100644 --- a/community/kernel/src/test/java/org/neo4j/kernel/impl/transaction/log/TransactionLogAppendAndRotateStressIT.java +++ b/community/kernel/src/test/java/org/neo4j/kernel/impl/transaction/log/TransactionLogAppendAndRotateStressIT.java @@ -60,7 +60,7 @@ import org.neo4j.test.TargetDirectory; import org.neo4j.test.TargetDirectory.TestDirectory; -import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; import static org.junit.rules.RuleChain.outerRule; @@ -162,28 +162,26 @@ private static void assertWholeTransactionsIn( LogFile logFile, long logVersion { VersionAwareLogEntryReader entryReader = new VersionAwareLogEntryReader<>(); LogEntry entry = null; - int state = 0; + boolean inTx = false; int transactions = 0; while ( (entry = entryReader.readLogEntry( reader )) != null ) { - switch ( state ) + if ( !inTx ) // Expects start entry { - case 0: // Expects start entry assertTrue( entry instanceof LogEntryStart ); - state = 1; - break; - case 1: // Expects command/commit entry + inTx = true; + } + else // Expects command/commit entry + { assertTrue( entry instanceof LogEntryCommand || entry instanceof LogEntryCommit ); if ( entry instanceof LogEntryCommit ) { - state = 0; + inTx = false; transactions++; } - break; - default: throw new IllegalArgumentException(); } } - assertEquals( 0, state ); + assertFalse( inTx ); assertTrue( transactions > 0 ); } }