/// <summary> /// Opens a <seealso cref="LogEntryCursor"/> for requested file /// </summary> /// <param name="fileSystem"> to find {@code file} in. </param> /// <param name="file"> file to open </param> /// <param name="readerLogVersionBridge"> log version bridge to use </param> //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: public static org.neo4j.kernel.impl.transaction.log.LogEntryCursor openLogEntryCursor(org.neo4j.io.fs.FileSystemAbstraction fileSystem, java.io.File file, org.neo4j.kernel.impl.transaction.log.LogVersionBridge readerLogVersionBridge) throws java.io.IOException public static LogEntryCursor OpenLogEntryCursor(FileSystemAbstraction fileSystem, File file, LogVersionBridge readerLogVersionBridge) { LogVersionedStoreChannel channel = OpenVersionedChannel(fileSystem, file); ReadableLogChannel logChannel = new ReadAheadLogChannel(channel, readerLogVersionBridge); LogEntryReader <ReadableClosablePositionAwareChannel> logEntryReader = new VersionAwareLogEntryReader <ReadableClosablePositionAwareChannel>(); return(new LogEntryCursor(logEntryReader, logChannel)); }
/// <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); } } } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldReadFromSingleChannel() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldReadFromSingleChannel() { // GIVEN File file = file(0); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final byte byteValue = (byte) 5; sbyte byteValue = ( sbyte )5; //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final short shortValue = (short) 56; short shortValue = ( short )56; const int intValue = 32145; const long longValue = 5689456895869L; const float floatValue = 12.12345f; const double doubleValue = 3548.45748D; //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final byte[] byteArrayValue = new byte[] {1, 2, 3, 4, 5, 6, 7, 8, 9}; sbyte[] byteArrayValue = new sbyte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9 }; WriteSomeData(file, element => { element.put(byteValue); element.putShort(shortValue); element.putInt(intValue); element.putLong(longValue); element.putFloat(floatValue); element.putDouble(doubleValue); element.put(byteArrayValue); return(true); }); StoreChannel storeChannel = FileSystemRule.get().open(file, OpenMode.READ); PhysicalLogVersionedStoreChannel versionedStoreChannel = new PhysicalLogVersionedStoreChannel(storeChannel, -1, ( sbyte )-1); using (ReadAheadLogChannel channel = new ReadAheadLogChannel(versionedStoreChannel, NO_MORE_CHANNELS, 16)) { // THEN assertEquals(byteValue, channel.Get()); assertEquals(shortValue, channel.Short); assertEquals(intValue, channel.Int); assertEquals(longValue, channel.Long); assertEquals(floatValue, channel.Float, 0.1f); assertEquals(doubleValue, channel.Double, 0.1d); sbyte[] bytes = new sbyte[byteArrayValue.Length]; channel.Get(bytes, byteArrayValue.Length); assertArrayEquals(byteArrayValue, bytes); } }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: static void filterTransactionLogFile(org.neo4j.io.fs.FileSystemAbstraction fileSystem, java.io.File file, final LogHook<org.neo4j.kernel.impl.transaction.log.entry.LogEntry> filter) throws java.io.IOException //JAVA TO C# CONVERTER WARNING: 'final' parameters are ignored unless the option to convert to C# 7.2 'in' parameters is selected: internal static void FilterTransactionLogFile(FileSystemAbstraction fileSystem, File file, LogHook <LogEntry> filter) { filter.File(file); using (StoreChannel @in = fileSystem.Open(file, OpenMode.READ)) { LogHeader logHeader = readLogHeader(ByteBuffer.allocate(LOG_HEADER_SIZE), @in, true, file); PhysicalLogVersionedStoreChannel inChannel = new PhysicalLogVersionedStoreChannel(@in, logHeader.LogVersion, logHeader.LogFormatVersion); ReadableLogChannel inBuffer = new ReadAheadLogChannel(inChannel); LogEntryReader <ReadableLogChannel> entryReader = new VersionAwareLogEntryReader <ReadableLogChannel>(); LogEntry entry; while ((entry = entryReader.ReadLogEntry(inBuffer)) != null) { filter.test(entry); } } }
public ReaderLogVersionBridgeAnonymousInnerClass(LogFiles logFiles, Org.Neo4j.tools.dump.TransactionLogAnalyzer.Monitor monitor, ReadAheadLogChannel channel) : base(logFiles) { this._monitor = monitor; this._channel = channel; this._logFiles = logFiles; }