diff --git a/kernel/src/main/java/org/neo4j/kernel/impl/transaction/xaframework/LogExtractor.java b/kernel/src/main/java/org/neo4j/kernel/impl/transaction/xaframework/LogExtractor.java index 66a5cdeb1..ec52e292c 100644 --- a/kernel/src/main/java/org/neo4j/kernel/impl/transaction/xaframework/LogExtractor.java +++ b/kernel/src/main/java/org/neo4j/kernel/impl/transaction/xaframework/LogExtractor.java @@ -348,51 +348,6 @@ private static interface LogEntryCollector int getIdentifier(); } - private static class KnownIdentifierCollector implements LogEntryCollector - { - private final int identifier; - private LogEntry.Start startEntry; - - KnownIdentifierCollector( int identifier ) - { - this.identifier = identifier; - } - - public int getIdentifier() - { - return identifier; - } - - public LogEntry collect( LogEntry entry, LogBuffer target ) throws IOException - { - if ( entry.getIdentifier() == identifier ) - { - if ( entry instanceof LogEntry.Start ) - { - startEntry = (Start) entry; - } - if ( target != null ) - { - LogIoUtils.writeLogEntry( entry, target ); - } - return entry; - } - return null; - } - - @Override - public boolean hasInFutureQueue() - { - return false; - } - - @Override - public LogEntry.Start getLastStartEntry() - { - return startEntry; - } - } - private static class KnownTxIdCollector implements LogEntryCollector { private final Map> transactions = new HashMap>(); @@ -546,11 +501,22 @@ public String toString() public static LogExtractor from( final String storeDir ) throws IOException { - // 2 is a "magic" first tx :) - return from( storeDir, 2 ); + return from( storeDir, NIONEO_COMMAND_FACTORY ); } public static LogExtractor from( final String storeDir, long startTxId ) throws IOException + { + return from( storeDir, NIONEO_COMMAND_FACTORY, startTxId ); + } + + public static LogExtractor from( final String storeDir, XaCommandFactory commandFactory ) throws IOException + { + // 2 is a "magic" first tx :) + return from( storeDir, commandFactory, 2 ); + } + + public static LogExtractor from( final String storeDir, XaCommandFactory commandFactory, + long startTxId ) throws IOException { LogLoader loader = new LogLoader() { @@ -623,18 +589,24 @@ public long getLastCommittedTxId() { throw new UnsupportedOperationException(); } - }; - - XaCommandFactory commandFactory = new XaCommandFactory() - { + @Override - public XaCommand readCommand( ReadableByteChannel byteChannel, - ByteBuffer buffer ) throws IOException + public String toString() { - return Command.readCommand( null, byteChannel, buffer ); + return getClass().getSimpleName() + "[" + storeDir + "]"; } }; return new LogExtractor( new LogPositionCache(), loader, commandFactory, startTxId, Long.MAX_VALUE ); } + + public static final XaCommandFactory NIONEO_COMMAND_FACTORY = new XaCommandFactory() + { + @Override + public XaCommand readCommand( ReadableByteChannel byteChannel, + ByteBuffer buffer ) throws IOException + { + return Command.readCommand( null, byteChannel, buffer ); + } + }; } diff --git a/kernel/src/main/java/org/neo4j/kernel/impl/util/CompareTxStreams.java b/kernel/src/main/java/org/neo4j/kernel/impl/util/CompareTxStreams.java index c6d13eaf0..596a645f3 100644 --- a/kernel/src/main/java/org/neo4j/kernel/impl/util/CompareTxStreams.java +++ b/kernel/src/main/java/org/neo4j/kernel/impl/util/CompareTxStreams.java @@ -28,12 +28,13 @@ public class CompareTxStreams { public static void main( String[] args ) throws IOException { - LogExtractor extractor1 = null; - LogExtractor extractor2 = null; + compareLogStreams( LogExtractor.from( args[0] ), LogExtractor.from( args[1] ) ); + } + + protected static void compareLogStreams( LogExtractor extractor1, LogExtractor extractor2 ) throws IOException + { try { - extractor1 = LogExtractor.from( args[0] ); - extractor2 = LogExtractor.from( args[1] ); boolean branchingDetected = false; long lastTx = 1; while ( true )