Example #1
0
 public static void Invoke(TimeSpan slowResponseTime, TimeSpan sleepInterval, int maxRetryCount, Action retryableAction, Predicate <Exception> isRetriableException, Action <Exception, int> onRetry, Action <Exception, int> onMaxRetry, Action <TimeSpan> onSlowResponse, Action <Exception> onUnhandledException)
 {
     RetryHelper.Invoke(slowResponseTime, sleepInterval, maxRetryCount, retryableAction, isRetriableException, onRetry, onMaxRetry, onSlowResponse, onUnhandledException, RetryHelper.DefaultIsStoreUnavailablePredicate);
 }
Example #2
0
        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);
        }
Example #3
0
 public static T Invoke <T>(TimeSpan slowResponseTime, TimeSpan sleepInterval, int maxRetryCount, Func <T> action, Predicate <Exception> isRetriableException, Action <Exception, int> onRetry, Action <Exception, int> onMaxRetry, Action <TimeSpan> onSlowResponse, Action <Exception> onUnhandledException)
 {
     return(RetryHelper.Invoke <T>(slowResponseTime, sleepInterval, maxRetryCount, action, isRetriableException, onRetry, onMaxRetry, onSlowResponse, onUnhandledException, RetryHelper.DefaultIsStoreUnavailablePredicate));
 }