// Token: 0x0600007B RID: 123 RVA: 0x00004774 File Offset: 0x00002974 private bool TryOpenAndProcessLogFile(out bool isAlreadyProcessed) { isAlreadyProcessed = false; FileStream fileStream = null; bool result; try { object obj; if (!this.TryCheckAlreadyProcessed(out isAlreadyProcessed)) { result = false; } else if (isAlreadyProcessed) { result = true; } else if (!IOHelper.TryIOOperation(new IOHelper.FileIOOperation(this.OpenLogFile), out obj)) { result = false; } else if (obj == null) { result = true; } else { CsvFieldCache cursor = ((LogFileInfo.OpenLogFileResult)obj).Cursor; fileStream = ((LogFileInfo.OpenLogFileResult)obj).FileStream; if (this.isActive && this.activeOffset != 0L) { cursor.Seek(this.activeOffset); } long position = cursor.Position; while (cursor.MoveNext(false)) { if (this.ProcessRow != null) { ReadOnlyRow readOnlyRow = new ReadOnlyRow(cursor, position); ProcessRowEventArgs args = new ProcessRowEventArgs(readOnlyRow); this.ProcessRow(this, args); } position = cursor.Position; } this.activeOffset = cursor.Position; this.length = cursor.Length; result = true; } } finally { if (fileStream != null) { fileStream.Close(); } } return(result); }
// Token: 0x0600009E RID: 158 RVA: 0x00005200 File Offset: 0x00003400 private List <uint> GetOffsetsForDataFast(string searchData) { uint hashCode = (uint)searchData.GetHashCode(); LogIndex.IndexRecord item = new LogIndex.IndexRecord(hashCode, 0U); int num = this.indexData.BinarySearch(item, LogIndex.IndexRecordComparer.Default); if (num < 0) { num = ~num; } List <uint> list = new List <uint>(); for (int i = num; i < this.indexData.Count; i++) { LogIndex.IndexRecord indexRecord = this.indexData[i]; uint offset = indexRecord.Offset; uint hashCode2 = indexRecord.HashCode; if (hashCode2 != hashCode) { break; } object obj; if (!IOHelper.TryIOOperation(() => CsvFieldCache.OpenLogFile(this.logFilePath), out obj) || obj == null) { ExTraceGlobals.ServiceTracer.TraceError <string>((long)this.GetHashCode(), "Search failed, unable to open file: {0}", this.logFilePath); throw new LogSearchException(LogSearchErrorCode.LOGSEARCH_E_RPC_SERVER_UNAVAILABLE); } FileStream fileStream = (FileStream)obj; try { CsvFieldCache csvFieldCache = new CsvFieldCache(this.table, fileStream, 32768); if (offset != 0U) { csvFieldCache.Seek((long)((ulong)offset)); } long position = csvFieldCache.Position; while (csvFieldCache.MoveNext(false) && position - (long)((ulong)offset) <= (long)LogIndex.ClusterRange) { object field = csvFieldCache.GetField(this.columnIdToIndex); if (field == null) { break; } uint hashCode3; if (this.normalizeMethod != null) { hashCode3 = (uint)this.normalizeMethod((string)field).GetHashCode(); } else { hashCode3 = (uint)field.GetHashCode(); } if (hashCode3 == hashCode) { if (position > (long)((ulong)-1)) { break; } list.Add((uint)position); } position = csvFieldCache.Position; } } finally { if (fileStream != null) { fileStream.Close(); } } } return(list); }
internal void ProcessBlock(CsvFieldCache cursor, LogFileRange block, LogFileInfo log) { bool flag = false; if (cursor.Position < block.StartOffset) { cursor.Seek(block.StartOffset); } long num = cursor.Position; while (cursor.Position < block.EndOffset) { if (this.CheckServiceStopRequest("ProcessBlock()")) { return; } try { flag = cursor.MoveNext(true); if (!flag) { if (cursor.AtEnd && !log.IsActive) { this.inputBuffer.AddInvalidRowToSkip(num, cursor.Position); block.EndOffset = cursor.Position; num = cursor.Position; } break; } ReadOnlyRow readOnlyRow = new ReadOnlyRow(cursor, num); this.inputBuffer.LineReceived(readOnlyRow); num = readOnlyRow.EndPosition; } catch (Exception ex) { if (RetryHelper.IsSystemFatal(ex)) { throw; } string text = string.Format("Log={0} blockRange=({1},{2}) cursorOffset={3} rowEnd={4} logSize={5} \nException:{6}", new object[] { log.FullFileName, block.StartOffset, block.EndOffset, cursor.Position, num, log.Size, ex }); string periodicKey = string.Format("{0}_{1}_{2}", log.FileName, block.StartOffset, block.EndOffset); EventLogger.Logger.LogEvent(LogUploaderEventLogConstants.Tuple_CsvParserFailedToParseLogLine, periodicKey, new object[] { text }); ServiceLogger.LogError(ServiceLogger.Component.LogReader, (LogUploaderEventLogConstants.Message) 3221229487U, string.Format("Detail={0}", text), this.instance, log.FullFileName); flag = false; break; } } if (cursor.Position == block.EndOffset) { block.ProcessingStatus = ProcessingStatus.ReadyToWriteToDatabase; } if (!flag) { if (cursor.AtEnd) { if (block.EndOffset == 9223372036854775807L) { block.EndOffset = cursor.Position; } } else if (this.logHeaderEndOffset != block.EndOffset) { string text2 = string.Format("Failed to read line from file {0} at position {1}", log.FullFileName, num); ExTraceGlobals.ReaderTracer.TraceError((long)this.GetHashCode(), text2); EventLogger.Logger.LogEvent(LogUploaderEventLogConstants.Tuple_LogReaderReadFailed, log.FullFileName + "_" + num.ToString(), new object[] { log.FullFileName, num }); ServiceLogger.LogError(ServiceLogger.Component.LogReader, (LogUploaderEventLogConstants.Message) 3221229476U, text2, this.instance, log.FullFileName); } } long incrementValue = num - block.StartOffset; if (Tools.IsRawProcessingType <T>()) { this.perfCounterInstance.RawReaderParsedBytes.IncrementBy(incrementValue); } else { this.perfCounterInstance.ReaderParsedBytes.IncrementBy(incrementValue); } log.WatermarkFileObj.UpdateLastReaderParsedEndOffset(num); }