Exemplo n.º 1
0
        private void UpdateWatermark(T batch)
        {
            string         fullLogName   = batch.FullLogName;
            IWatermarkFile watermarkFile = this.logManager.FindWatermarkFileObject(fullLogName);

            if (watermarkFile != null)
            {
                watermarkFile.WriteWatermark(batch.LogRanges);
                return;
            }
            string message = string.Format("DatabaseWriter failed to get a watermark instance for {0}", fullLogName);

            ExTraceGlobals.WriterTracer.TraceError((long)this.GetHashCode(), message);
            EventLogger.Logger.LogEvent(LogUploaderEventLogConstants.Tuple_MissingWatermark, fullLogName, new object[]
            {
                fullLogName
            });
            Tools.DebugAssert(false, "WatermarkFile.GetInstanceBasedOnLogName " + fullLogName);
        }
Exemplo n.º 2
0
        internal void DequeueAndWriteOneItem()
        {
            string         text          = string.Empty;
            IWatermarkFile watermarkFile = null;

            try
            {
                T t = this.queue.Dequeue(this.cancellationContext);
                if (t != null)
                {
                    this.perfCounterInstance.BatchQueueLength.Decrement();
                    text          = t.FullLogName;
                    watermarkFile = this.logManager.FindWatermarkFileObject(text);
                    if (ExTraceGlobals.WriterTracer.IsTraceEnabled(TraceType.DebugTrace))
                    {
                        StringBuilder stringBuilder = new StringBuilder();
                        foreach (LogFileRange logFileRange in t.LogRanges)
                        {
                            string value = string.Format("({0}, {1}) ", logFileRange.StartOffset, logFileRange.EndOffset);
                            stringBuilder.Append(value);
                        }
                        string message = string.Format("For log {0}, writer {1} get batch that has {2} ranges: {3}", new object[]
                        {
                            text,
                            this.id,
                            t.LogRanges.Count,
                            stringBuilder.ToString()
                        });
                        ExTraceGlobals.WriterTracer.TraceDebug((long)this.GetHashCode(), message);
                    }
                    this.WriteBatch(t);
                }
                else if (!this.CheckServiceStopRequest("DequeueAndWriteOneItem()"))
                {
                    Tools.DebugAssert(this.cancellationContext.StopToken.IsCancellationRequested, "If Enqueue is not cancelled, it should always get a batch back");
                }
            }
            catch (FaultException ex)
            {
                ExTraceGlobals.WriterTracer.TraceError <string, string>((long)this.GetHashCode(), "Writer failed to write data through web service DAL when processing log {0}. Check the event log on the FFO web service role. The exception is: {1}.", text, ex.Message);
                EventLogger.Logger.LogEvent(LogUploaderEventLogConstants.Tuple_WebServiceWriteException, ex.Message, new object[]
                {
                    text,
                    ex.ToString()
                });
                ServiceLogger.LogError(ServiceLogger.Component.DatabaseWriter, (LogUploaderEventLogConstants.Message) 3221489634U, ex.Message, this.instance, text);
            }
            catch (CommunicationException ex2)
            {
                ExTraceGlobals.WriterTracer.TraceError <string, string>((long)this.GetHashCode(), "Writer failed to write data through web service DAL when processing log {0}. The exception is: {1}.", text, ex2.Message);
                EventLogger.Logger.LogEvent(LogUploaderEventLogConstants.Tuple_WebServiceWriteException, ex2.Message, new object[]
                {
                    text,
                    ex2.ToString()
                });
                ServiceLogger.LogError(ServiceLogger.Component.DatabaseWriter, (LogUploaderEventLogConstants.Message) 3221489633U, ex2.Message, this.instance, text);
            }
            catch (ADTopologyEndpointNotFoundException ex3)
            {
                ExTraceGlobals.WriterTracer.TraceError <string, string>((long)this.GetHashCode(), "Writer caught an ADTopologyEndpointNotFoundException when processing log {0}. Details is: {1}", text, ex3.Message);
                EventLogger.Logger.LogEvent(LogUploaderEventLogConstants.Tuple_ADTopologyEndpointNotFound, ex3.Message, new object[]
                {
                    text,
                    ex3.Message
                });
                ServiceLogger.LogError(ServiceLogger.Component.DatabaseWriter, (LogUploaderEventLogConstants.Message) 3221489629U, ex3.Message, this.instance, text);
            }
            catch (Exception ex4)
            {
                if (!(ex4 is ThreadAbortException) || !this.cancellationContext.StopToken.IsCancellationRequested)
                {
                    string text2 = string.Format("Writer caught an exception when processing log {0}: {1}", text, ex4);
                    ExTraceGlobals.WriterTracer.TraceError((long)this.GetHashCode(), text2);
                    EventLogger.Logger.LogEvent(LogUploaderEventLogConstants.Tuple_DatabaseWriterUnknownException, ex4.Message, new object[]
                    {
                        text,
                        ex4
                    });
                    EventNotificationItem.Publish(ExchangeComponent.Name, "UnexpectedWriterError", null, text2, ResultSeverityLevel.Error, false);
                    this.perfCounterInstance.TotalUnexpectedWriterErrors.Increment();
                    ServiceLogger.LogError(ServiceLogger.Component.DatabaseWriter, (LogUploaderEventLogConstants.Message) 3221489617U, text2, this.instance, text);
                    throw;
                }
                Thread.ResetAbort();
                ServiceLogger.LogInfo(ServiceLogger.Component.DatabaseWriter, LogUploaderEventLogConstants.Message.LogMonitorRequestedStop, Thread.CurrentThread.Name + " received thread abort event", this.instance, "");
            }
            finally
            {
                if (watermarkFile != null)
                {
                    watermarkFile.InMemoryCountDecrease();
                }
            }
        }