Example #1
0
        /// <summary>
        /// Analyzes transactions found in log file(s) specified by {@code storeDirOrLogFile} calling methods on the supplied
        /// <seealso cref="Monitor"/> for each encountered data item.
        /// </summary>
        /// <param name="fileSystem"> <seealso cref="FileSystemAbstraction"/> to find the files on. </param>
        /// <param name="storeDirOrLogFile"> <seealso cref="File"/> pointing either to a directory containing transaction log files, or directly
        /// pointing to a single transaction log file to analyze. </param>
        /// <param name="invalidLogEntryHandler"> <seealso cref="InvalidLogEntryHandler"/> to pass in to the internal <seealso cref="LogEntryReader"/>. </param>
        /// <param name="monitor"> <seealso cref="Monitor"/> receiving call-backs for all <seealso cref="Monitor.transaction(LogEntry[]) transactions"/>,
        /// <seealso cref="Monitor.checkpoint(CheckPoint, LogPosition) checkpoints"/> and <seealso cref="Monitor.logFile(File, long) log file transitions"/>
        /// encountered during the analysis. </param>
        /// <exception cref="IOException"> on I/O error. </exception>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public static void analyze(org.neo4j.io.fs.FileSystemAbstraction fileSystem, java.io.File storeDirOrLogFile, org.neo4j.kernel.impl.transaction.log.entry.InvalidLogEntryHandler invalidLogEntryHandler, Monitor monitor) throws java.io.IOException
        public static void Analyze(FileSystemAbstraction fileSystem, File storeDirOrLogFile, InvalidLogEntryHandler invalidLogEntryHandler, Monitor monitor)
        {
            File                firstFile;
            LogVersionBridge    bridge;
            ReadAheadLogChannel channel;
            LogEntryReader <ReadableClosablePositionAwareChannel> entryReader;
            LogPositionMarker positionMarker;

            if (storeDirOrLogFile.Directory)
            {
                // Use natural log version bridging if a directory is supplied
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.neo4j.kernel.impl.transaction.log.files.LogFiles logFiles = org.neo4j.kernel.impl.transaction.log.files.LogFilesBuilder.logFilesBasedOnlyBuilder(storeDirOrLogFile, fileSystem).build();
                LogFiles logFiles = LogFilesBuilder.logFilesBasedOnlyBuilder(storeDirOrLogFile, fileSystem).build();
                bridge = new ReaderLogVersionBridgeAnonymousInnerClass(logFiles, monitor, channel);
                long lowestLogVersion = logFiles.LowestLogVersion;
                if (lowestLogVersion < 0)
                {
                    throw new System.InvalidOperationException(format("Transaction logs at '%s' not found.", storeDirOrLogFile));
                }
                firstFile = logFiles.GetLogFileForVersion(lowestLogVersion);
                monitor.LogFile(firstFile, lowestLogVersion);
            }
            else
            {
                // Use no bridging, simply reading this single log file if a file is supplied
                firstFile = storeDirOrLogFile;
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.neo4j.kernel.impl.transaction.log.files.LogFiles logFiles = org.neo4j.kernel.impl.transaction.log.files.LogFilesBuilder.logFilesBasedOnlyBuilder(storeDirOrLogFile, fileSystem).build();
                LogFiles logFiles = LogFilesBuilder.logFilesBasedOnlyBuilder(storeDirOrLogFile, fileSystem).build();
                monitor.LogFile(firstFile, logFiles.GetLogVersion(firstFile));
                bridge = NO_MORE_CHANNELS;
            }

            channel        = new ReadAheadLogChannel(openVersionedChannel(fileSystem, firstFile), bridge);
            entryReader    = new VersionAwareLogEntryReader <ReadableClosablePositionAwareChannel>(new RecordStorageCommandReaderFactory(), invalidLogEntryHandler);
            positionMarker = new LogPositionMarker();
            using (TransactionLogEntryCursor cursor = new TransactionLogEntryCursor(new LogEntryCursor(entryReader, channel)))
            {
                channel.GetCurrentPosition(positionMarker);
                while (cursor.Next())
                {
                    LogEntry[] tx = cursor.Get();
                    if (tx.Length == 1 && tx[0].Type == CHECK_POINT)
                    {
                        monitor.Checkpoint(tx[0].As(), positionMarker.NewPosition());
                    }
                    else
                    {
                        monitor.Transaction(tx);
                    }
                }
            }
        }
Example #2
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: protected java.io.IOException unknownCommandType(byte commandType, org.neo4j.storageengine.api.ReadableChannel channel) throws java.io.IOException
        protected internal virtual IOException UnknownCommandType(sbyte commandType, ReadableChannel channel)
        {
            string message = "Unknown command type[" + commandType + "]";

            if (channel is PositionAwareChannel)
            {
                PositionAwareChannel logChannel = ( PositionAwareChannel )channel;
                LogPositionMarker    position   = new LogPositionMarker();
                logChannel.GetCurrentPosition(position);
                message += " near " + position.NewPosition();
            }
            return(new IOException(message));
        }
Example #3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldReturnUnspecifiedIfNothingHasBeenMarked()
        public virtual void ShouldReturnUnspecifiedIfNothingHasBeenMarked()
        {
            // given
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.neo4j.kernel.impl.transaction.log.LogPositionMarker marker = new org.neo4j.kernel.impl.transaction.log.LogPositionMarker();
            LogPositionMarker marker = new LogPositionMarker();

            // when
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.neo4j.kernel.impl.transaction.log.LogPosition logPosition = marker.newPosition();
            LogPosition logPosition = marker.NewPosition();

            // given
            assertEquals(LogPosition.UNSPECIFIED, logPosition);
        }
Example #4
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldReturnTheMarkedPosition()
        public virtual void ShouldReturnTheMarkedPosition()
        {
            // given
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.neo4j.kernel.impl.transaction.log.LogPositionMarker marker = new org.neo4j.kernel.impl.transaction.log.LogPositionMarker();
            LogPositionMarker marker = new LogPositionMarker();

            // when
            marker.Mark(1, 2);
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.neo4j.kernel.impl.transaction.log.LogPosition logPosition = marker.newPosition();
            LogPosition logPosition = marker.NewPosition();

            // given
            assertEquals(new LogPosition(1, 2), logPosition);
        }
Example #5
0
 public override LogPositionMarker GetCurrentPosition(LogPositionMarker positionMarker)
 {
     positionMarker.Unspecified();
     return(positionMarker);
 }