Skip to content

Commit

Permalink
Further simplifications of recovery code
Browse files Browse the repository at this point in the history
and some comment typos fixed
  • Loading branch information
tinwelint committed Sep 13, 2016
1 parent 7407869 commit c6e6ce8
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 20 deletions.
Expand Up @@ -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.
Expand Down
Expand Up @@ -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<>() );
}
Expand Down
Expand Up @@ -48,11 +48,6 @@ public PhysicalTransactionCursor( T channel, LogEntryReader<T> entryReader ) thr
new LogEntryCursor( (LogEntryReader<ReadableClosablePositionAwareChannel>) entryReader, channel );
}

protected List<StorageCommand> commandList()
{
return new ArrayList<>();
}

@Override
public CommittedTransactionRepresentation get()
{
Expand Down Expand Up @@ -81,7 +76,7 @@ public boolean next() throws IOException
LogEntryStart startEntry = entry.as();
LogEntryCommit commitEntry;

List<StorageCommand> entries = commandList();
List<StorageCommand> entries = new ArrayList<>();
while ( true )
{
if ( !logEntryCursor.next() )
Expand Down
Expand Up @@ -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;
Expand Down Expand Up @@ -162,28 +162,26 @@ private static void assertWholeTransactionsIn( LogFile logFile, long logVersion
{
VersionAwareLogEntryReader<ReadableLogChannel> 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 );
}
}
Expand Down

0 comments on commit c6e6ce8

Please sign in to comment.