Skip to content

Commit

Permalink
More logging for LastCommittedIndexFinder
Browse files Browse the repository at this point in the history
  • Loading branch information
martinfurmanski committed Mar 8, 2018
1 parent 9e18a49 commit e66ac59
Showing 1 changed file with 14 additions and 9 deletions.
Expand Up @@ -48,31 +48,36 @@ public LastCommittedIndexFinder( TransactionIdStore transactionIdStore,


public long getLastCommittedIndex() public long getLastCommittedIndex()
{ {
long lastCommittedIndex; long lastConsensusIndex;
long lastTxId = transactionIdStore.getLastCommittedTransactionId(); long lastTxId = transactionIdStore.getLastCommittedTransactionId();
log.info( "Last transaction id in metadata store %d", lastTxId );


byte[] lastHeaderFound = null; CommittedTransactionRepresentation lastTx = null;
try ( IOCursor<CommittedTransactionRepresentation> transactions = try ( IOCursor<CommittedTransactionRepresentation> transactions =
transactionStore.getTransactions( lastTxId ) ) transactionStore.getTransactions( lastTxId ) )
{ {
while ( transactions.next() ) while ( transactions.next() )
{ {
CommittedTransactionRepresentation committedTransactionRepresentation = transactions.get(); lastTx = transactions.get();
lastHeaderFound = committedTransactionRepresentation.getStartEntry().getAdditionalHeader();
} }
} }
catch ( Exception e ) catch ( Exception e )
{ {
throw new RuntimeException( e ); throw new RuntimeException( e );
} }


if ( lastHeaderFound == null ) if ( lastTx == null )
{ {
throw new RuntimeException( "We must have at least one transaction telling us where we are at in the consensus log." ); throw new RuntimeException( "We must have at least one transaction telling us where we are at in the consensus log." );
} }


lastCommittedIndex = decodeLogIndexFromTxHeader( lastHeaderFound ); log.info( "Start id of last committed transaction in transaction log %d", lastTx.getStartEntry().getLastCommittedTxWhenTransactionStarted() );
log.info( "Last committed index %d", lastCommittedIndex ); log.info( "Last committed transaction id in transaction log %d", lastTx.getCommitEntry().getTxId() );
return lastCommittedIndex;
byte[] lastHeaderFound = lastTx.getStartEntry().getAdditionalHeader();
lastConsensusIndex = decodeLogIndexFromTxHeader( lastHeaderFound );

log.info( "Last committed consensus log index committed into tx log %d", lastConsensusIndex );
return lastConsensusIndex;
} }
} }

0 comments on commit e66ac59

Please sign in to comment.