public SharepointValidationResult ValidateLocation(string location) { ArgumentValidator.ThrowIfNullOrWhiteSpace("location", location); if (SourceValidator.IsWideScope(location)) { base.LogOneEntry(ExecutionLog.EventType.Verbose, "Skipping validation for wide scoped location '{0}", new object[] { location }); return(new SharepointValidationResult { IsTopLevelSiteCollection = false, IsValid = true, SharepointSource = new SharepointSource(location, location, Guid.Empty, Guid.Empty) }); } SharepointValidationResult result = null; try { if (this.validateUsingSearch) { result = this.ValidateLocationBySearch(location); } else { result = this.ValidateLocationByLoad(location); } } catch (Exception ex) { base.LogOneEntry(ExecutionLog.EventType.Error, ex, "Unexpected Exception occurred when Validating the location {0}. ValidatingUsingSearch: {1}", new object[] { location, this.validateUsingSearch }); EventNotificationItem.Publish(ExchangeComponent.UnifiedComplianceSourceValidation.Name, "SharepointValidatorUnexpectedError", base.Client.ToString(), string.Format("Unexpected exception occured when validating the sites(using search:{0}). Exception:{1}", this.validateUsingSearch, ex), ResultSeverityLevel.Error, false); throw; } return(result); }
public void WriteClassificationEngineTimeoutInValidation(int traceSourceHashCode, OrganizationId currentOrganizationId, int validationTimeout) { string organizationId = (!object.ReferenceEquals(currentOrganizationId, null)) ? currentOrganizationId.ToString() : string.Empty; string timeout = validationTimeout.ToString(CultureInfo.InvariantCulture); Task.Factory.StartNew(delegate() { ExManagementApplicationLogger.LogEvent(ManagementEventLogConstants.Tuple_ClassificationEngineTimeout, new string[] { organizationId, timeout }); }); string eventMessage = string.Format("MCE timed-out when trying to validate a classification rule collection for organization '{0}'. The operation timeout was {1} ms.", organizationId, timeout); Task.Factory.StartNew(delegate() { EventNotificationItem.Publish(ClassificationDefinitionsDiagnosticsReporter.ServiceName, "ClassificationManagement", "MceTimeoutIssue", eventMessage, ResultSeverityLevel.Error, false); }); this.dlpTracer.TraceError((long)traceSourceHashCode, eventMessage); }
public void WriteClassificationEngineUnexpectedFailureInValidation(int traceSourceHashCode, OrganizationId currentOrganizationId, int engineErrorCode) { string organizationId = (!object.ReferenceEquals(currentOrganizationId, null)) ? currentOrganizationId.ToString() : string.Empty; string hexEngineErrorCode = engineErrorCode.ToString("X8"); Task.Factory.StartNew(delegate() { ExManagementApplicationLogger.LogEvent(ManagementEventLogConstants.Tuple_ClassificationEngineFailure, new string[] { organizationId, string.Format("0x{0}", hexEngineErrorCode) }); }); string eventMessage = string.Format("MCE returned an error when trying to validate a classification rule collection for organization '{0}'. Error code returned was 0x{1}.", organizationId, hexEngineErrorCode); Task.Factory.StartNew(delegate() { EventNotificationItem.Publish(ClassificationDefinitionsDiagnosticsReporter.ServiceName, "ClassificationManagement", "MceFailureIssue", eventMessage, ResultSeverityLevel.Error, false); }); this.dlpTracer.TraceError((long)traceSourceHashCode, eventMessage); }
public void WriteCorruptRulePackageDiagnosticsInformation(int traceSourceHashCode, OrganizationId currentOrganizationId, string offendingRulePackageObjectDn, Exception underlyingException) { string organizationId = currentOrganizationId.ToString(); string exceptionDetails = underlyingException.ToString(); Task.Factory.StartNew(delegate() { ExManagementApplicationLogger.LogEvent(ManagementEventLogConstants.Tuple_CorruptClassificationRuleCollection, new string[] { organizationId, offendingRulePackageObjectDn, exceptionDetails }); }); string eventMessage = string.Format("A corrupted classification rule collection has been identified under organization: '{0}'. Source object DN: {1}. Error details: {2}", organizationId, offendingRulePackageObjectDn, exceptionDetails); Task.Factory.StartNew(delegate() { EventNotificationItem.Publish(ClassificationDefinitionsDiagnosticsReporter.ServiceName, "ClassificationManagement", "CorruptClassificationRuleCollection", eventMessage, ResultSeverityLevel.Warning, false); }); this.dlpTracer.TraceError((long)traceSourceHashCode, eventMessage); }
public MultiValuedProperty <BindingMetadata> ValidateRecipients(MultiValuedProperty <string> recipients) { ArgumentValidator.ThrowIfNull("recipients", recipients); base.LogOneEntry(ExecutionLog.EventType.Verbose, "Executing ValidateRecipients", new object[0]); MultiValuedProperty <BindingMetadata> result; try { result = this.ValidateRecipientsImpl(recipients); } catch (ExValidatorException exception) { base.LogOneEntry(ExecutionLog.EventType.Error, exception, "Exception occured when Validating recipients", new object[0]); throw; } catch (ManagementObjectNotFoundException exception2) { base.LogOneEntry(ExecutionLog.EventType.Error, exception2, "Exception occured when Validating recipients", new object[0]); throw; } catch (ManagementObjectAmbiguousException exception3) { base.LogOneEntry(ExecutionLog.EventType.Error, exception3, "Exception occured when Validating recipients", new object[0]); throw; } catch (Exception ex) { EventNotificationItem.Publish(ExchangeComponent.UnifiedComplianceSourceValidation.Name, "ExchangeValidatorUnexpectedError", base.Client.ToString(), string.Format("Unexpected exception occured when validating the recipients. Exception:{0}", ex), ResultSeverityLevel.Error, false); base.LogOneEntry(ExecutionLog.EventType.Error, ex, "Unexcepted exception occured when Validating recipients", new object[0]); throw; } finally { base.LogOneEntry(ExecutionLog.EventType.Verbose, "Finished ValidateRecipients", new object[0]); } return(result); }
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(); } } }
internal NotificationAction NotifyLowDiskSpace(IADDatabase db, IMonitoringADConfig adConfig) { DatabaseRedundancyValidator databaseRedundancyValidator = new DatabaseRedundancyValidator(db, 1, this.m_statusLookup, adConfig, null, true); IHealthValidationResult healthValidationResult = databaseRedundancyValidator.Run(); CopyStatusClientCachedEntry targetCopyStatus = healthValidationResult.TargetCopyStatus; if (targetCopyStatus == null || targetCopyStatus.CopyStatus == null || targetCopyStatus.Result != CopyStatusRpcResult.Success || targetCopyStatus.CopyStatus.DiskTotalSpaceBytes == 0UL) { return(NotificationAction.None); } double num = (double)RegistryParameters.SpaceMonitorLowSpaceThresholdInMB / 1024.0; double num2 = targetCopyStatus.CopyStatus.DiskFreeSpaceBytes / 1024.0 / 1024.0 / 1024.0; double num3 = 0.0; double num4 = 0.0; string text = SpaceMonitor.FindVolume(new DirectoryInfo(db.EdbFilePath.PathName)); string text2 = SpaceMonitor.FindVolume(new DirectoryInfo(db.LogFolderPath.PathName)); if (!string.IsNullOrEmpty(text) && !string.IsNullOrEmpty(text2) && !text.Equals(text2, StringComparison.OrdinalIgnoreCase) && db.EdbFilePath.IsLocalFull) { ulong num5 = 0UL; ulong num6 = 0UL; DiskHelper.GetFreeSpace(db.EdbFilePath.PathName, out num5, out num6); num3 = num5 / 1024UL / 1024UL / 1024UL; num4 = num6 / 1024UL / 1024UL / 1024UL; } bool flag = false; string text3 = string.Empty; if (num2 <= num) { text3 = string.Format("'{0}' is low on log volume space [{1}]. Current={2:0.##} GB, Threshold={3:0.##} GB", new object[] { db.Name, text2, num2, num }); flag = true; } if (num3 != 0.0 && num4 <= num) { text3 += string.Format("{0}'{1}' is low on EDB volume space [{2}]. Current={3:0.##} GB, Threshold={4:0.##} GB", new object[] { Environment.NewLine, db.Name, text, num4, num }); flag = true; } if (flag) { if (SpaceMonitor.LastNotificationHistory.ContainsKey(db.Name) && DateTime.UtcNow - SpaceMonitor.LastNotificationHistory[db.Name] < SpaceMonitor.NotificationFrequency) { SpaceMonitor.Tracer.TraceDebug((long)this.GetHashCode(), "SpaceMonitor.ProcessDatabase: Database '{0}' is low on space but notification throttling is hit. LastNotify={1}, Throttling={2}mins, Message={3}", new object[] { db.Name, SpaceMonitor.LastNotificationHistory.ContainsKey(db.Name) ? "Never" : SpaceMonitor.LastNotificationHistory[db.Name].ToString(), SpaceMonitor.NotificationFrequency.TotalMinutes, text3 }); return(NotificationAction.None); } Exception ex; if (BitlockerUtil.IsFilePathOnEncryptingVolume(db.LogFolderPath.PathName, out ex)) { SpaceMonitor.Tracer.TraceDebug <string>((long)this.GetHashCode(), "SpaceMonitor.ProcessDatabase: Database '{0}' is currently encrypting. Do not raise alert.", db.Name); return(NotificationAction.None); } if (ex != null) { string text4 = string.Format("IsFilePathOnEncryptingVolume({0}) failed: {1}", db.LogFolderPath.PathName, ex.Message); ReplayCrimsonEvents.BitlockerQueryFailed.LogPeriodic <string, Exception>(Environment.MachineName, DiagCore.DefaultEventSuppressionInterval, text4, ex); } EventNotificationItem eventNotificationItem = new EventNotificationItem("MSExchangeDagMgmt", "EdbAndLogVolSpace", db.Name.ToUpper(), text3, text3, ResultSeverityLevel.Critical); eventNotificationItem.Publish(false); if (SpaceMonitor.LastNotificationHistory.ContainsKey(db.Name)) { SpaceMonitor.LastNotificationHistory[db.Name] = DateTime.UtcNow; } else { SpaceMonitor.LastNotificationHistory.Add(db.Name, DateTime.UtcNow); } return(NotificationAction.RedRaised); } else { text3 = string.Format("{0} Status is OK - EdbFreeSpace={1:0.##} GB [{2}], LogFreeSpace={3:0.##} GB [{4}], Threshold={5:0.##} GB", new object[] { db.Name, num4, text, num2, text2, num }); if (SpaceMonitor.LastNotificationHistory.ContainsKey(db.Name) && SpaceMonitor.LastNotificationHistory[db.Name] != DateTime.MinValue) { EventNotificationItem eventNotificationItem2 = new EventNotificationItem("MSExchangeDagMgmt", "EdbAndLogVolSpace", db.Name.ToUpper(), text3, text3, ResultSeverityLevel.Informational); eventNotificationItem2.Publish(false); SpaceMonitor.LastNotificationHistory[db.Name] = DateTime.MinValue; return(NotificationAction.GreenRaised); } SpaceMonitor.Tracer.TraceDebug((long)this.GetHashCode(), "SpaceMonitor.ProcessDatabase: Database '{0}' has enough space but red notification was never raised. LastNotify={1}, Throttling={2}mins, Message={3}", new object[] { db.Name, SpaceMonitor.LastNotificationHistory.ContainsKey(db.Name) ? SpaceMonitor.LastNotificationHistory[db.Name].ToString() : "Never", SpaceMonitor.NotificationFrequency.TotalMinutes, text3 }); return(NotificationAction.None); } }
// Token: 0x0600011A RID: 282 RVA: 0x00008870 File Offset: 0x00006A70 private void Initialize(Server server, ObjectSecurity adminSecurity) { ExTraceGlobals.ServiceTracer.TraceDebug((long)this.GetHashCode(), "MsExchangeLogSearch service is entering Initialize"); bool flag = false; LogSearchService.LogSearchServiceStartState logSearchServiceStartState = LogSearchService.LogSearchServiceStartState.Init; try { this.sessionManager = new LogSessionManager(); this.sessionManager.Start(); logSearchServiceStartState = LogSearchService.LogSearchServiceStartState.SessionManagerStartup; if (server.IsHubTransportServer) { EHALogSearchComponent.Start(server.Name); } if (LogSearchAppConfig.Instance.HealthMonitoringLog == null) { ExTraceGlobals.ServiceTracer.TraceError((long)this.GetHashCode(), "Health monitoring log could not be initialized, service will be stopped"); } else { this.healthLog = new HealthMonitoringLog(); this.healthLog.Configure(LogSearchAppConfig.Instance.HealthMonitoringLog); logSearchServiceStartState = LogSearchService.LogSearchServiceStartState.HealthMonitoringLogStartup; this.ConfigureTransportSyncComponent(server); logSearchServiceStartState = LogSearchService.LogSearchServiceStartState.SyncHealthLogStartup; if (server.MessageTrackingLogPath != null && !string.IsNullOrEmpty(server.MessageTrackingLogPath.PathName)) { this.messageTrackingLog = new Log(MessageTrackingSchema.MessageTrackingEvent, server.MessageTrackingLogPath.ToString(), "MSGTRK", server.Name, "LOG", LogSearchIndexingParameters.MessageTrackingIndexPercentageByPrefix); this.messageTrackingLog.Config(server.MessageTrackingLogPath.ToString()); this.messageTrackingLog.Start(); this.sessionManager.RegisterLog("MSGTRK", this.messageTrackingLog); logSearchServiceStartState = LogSearchService.LogSearchServiceStartState.MessageTrackingLogStartup; } else if (!server.IsClientAccessServer) { LogSearchService.logger.LogEvent(MSExchangeTransportLogSearchEventLogConstants.Tuple_LogSearchNullOrEmptyLogPath, null, new object[0]); EventNotificationItem.Publish(ExchangeComponent.Transport.Name, "TransportLogSearch", null, "The Microsoft Exchange Transport Log Search service failed because the parameter that sets the location of the message tracking logs was set to an invalid value.", ResultSeverityLevel.Warning, false); } ActiveDirectoryRights accessMask = ActiveDirectoryRights.GenericRead; bool flag2 = !server.IsHubTransportServer && !server.IsMailboxServer; LogSearchService.logSearchServer = (LogSearchServer)RpcServerBase.RegisterServer(typeof(LogSearchServer), adminSecurity, accessMask, flag2); ExTraceGlobals.ServiceTracer.TraceDebug <bool>((long)this.GetHashCode(), "RPC is registered. LocalRpcOnly = {0}", flag2); LogSearchService.logSearchServer.SessionManager = this.sessionManager; flag = true; } } finally { if (!flag) { if (this.sessionManager != null) { this.sessionManager.Stop(); this.sessionManager = null; } if (this.messageTrackingLog != null) { this.messageTrackingLog.Stop(); this.messageTrackingLog = null; } if (this.healthLog != null) { this.healthLog.Dispose(); this.healthLog = null; } switch (logSearchServiceStartState) { case LogSearchService.LogSearchServiceStartState.Init: { string text = "MsExchangeLogSearch services Initialize failure because session manager startup failed"; ExTraceGlobals.ServiceTracer.TraceError((long)this.GetHashCode(), text); LogSearchService.logger.LogEvent(MSExchangeTransportLogSearchEventLogConstants.Tuple_LogSearchServiceStartFailureInit, null, new object[0]); EventNotificationItem.Publish(ExchangeComponent.Transport.Name, "TransportLogSearch", null, text, ResultSeverityLevel.Error, false); break; } case LogSearchService.LogSearchServiceStartState.SessionManagerStartup: { string text = "MsExchangeLogSearch services Initialize failure because message tracking log failed"; ExTraceGlobals.ServiceTracer.TraceError((long)this.GetHashCode(), text); LogSearchService.logger.LogEvent(MSExchangeTransportLogSearchEventLogConstants.Tuple_LogSearchServiceStartFailureSessionManager, null, new object[0]); EventNotificationItem.Publish(ExchangeComponent.Transport.Name, "TransportLogSearch", null, text, ResultSeverityLevel.Error, false); break; } case LogSearchService.LogSearchServiceStartState.MessageTrackingLogStartup: { string text = "MsExchangeLogSearch services Initialize failure because RPC server startup failed"; ExTraceGlobals.ServiceTracer.TraceError((long)this.GetHashCode(), text); LogSearchService.logger.LogEvent(MSExchangeTransportLogSearchEventLogConstants.Tuple_LogSearchServiceStartFailureMTGLog, null, new object[0]); EventNotificationItem.Publish(ExchangeComponent.Transport.Name, "TransportLogSearch", null, text, ResultSeverityLevel.Error, false); break; } } } } }
// Token: 0x06001456 RID: 5206 RVA: 0x0007565D File Offset: 0x0007385D public static void PostInferenceDataCollectionNotification(string notificationName, string additionalInfo) { EventNotificationItem.Publish(ExchangeComponent.Inference.Name, ExchangeComponent.Inference.Name, string.Format("{0}/{1}", notificationName, additionalInfo), notificationName, ResultSeverityLevel.Informational, true); }
internal void SetHealthRed(string monitor, string msg, Exception exception) { FaultInjection.FaultInjectionTracer.TraceTest(64160U); this.TraceException(msg, exception); EventNotificationItem.Publish(this.ComponentName, monitor, null, msg, ResultSeverityLevel.Error, false); }
internal void ReadLog() { LogFileInfo logFileInfo = null; int num = 0; try { if (this.batchQueue.IsFull) { num = Tools.RandomizeTimeSpan(this.config.ReaderSleepTime, this.config.ReaderSleepTimeRandomRange); string text = string.Format("The queue for log prefix {0} is full. Reader will not parse it until the queue is no longer full.", this.instance); ExTraceGlobals.ReaderTracer.TraceWarning((long)this.GetHashCode(), text); EventLogger.Logger.LogEvent(LogUploaderEventLogConstants.Tuple_LogReaderQueueFull, this.instance, new object[] { this.instance }); long num2 = DateTime.UtcNow.Ticks - this.lastTimeWhenQeueFull; if (num2 > 1800000000L) { this.lastTimeWhenQeueFull = DateTime.UtcNow.Ticks; ServiceLogger.LogWarning(ServiceLogger.Component.LogReader, (LogUploaderEventLogConstants.Message) 2147487654U, text, this.instance, ""); } } else { logFileInfo = this.logMonitor.GetLogForReaderToProcess(); if (logFileInfo == null) { num = Tools.RandomizeTimeSpan(this.config.ReaderSleepTime, this.config.ReaderSleepTimeRandomRange); } else { this.ProcessLog(logFileInfo); } } } catch (FileNotFoundException ex) { EventLogger.Logger.LogEvent(LogUploaderEventLogConstants.Tuple_LogReaderLogMissing, ex.Message, new object[] { Thread.CurrentThread.Name, ex }); ServiceLogger.LogError(ServiceLogger.Component.LogReader, (LogUploaderEventLogConstants.Message) 2147487659U, ex.Message, this.instance, ""); this.logMonitor.ReaderCompletedProcessingLog(logFileInfo); return; } catch (IOException ex2) { string text2 = (logFileInfo == null) ? "unknown log" : logFileInfo.FullFileName; string text3 = string.Format("Caught an IOException when reading log {0}. Exception: {1}", text2, ex2); ExTraceGlobals.LogMonitorTracer.TraceError((long)this.GetHashCode(), text3); EventLogger.Logger.LogEvent(LogUploaderEventLogConstants.Tuple_ReadLogCaughtIOException, logFileInfo.FullFileName, new object[] { logFileInfo.FullFileName, ex2 }); ServiceLogger.LogError(ServiceLogger.Component.LogReader, (LogUploaderEventLogConstants.Message) 3221229485U, text3, this.instance, text2); if (!ex2.Message.Contains("Insufficient system resources exist to complete the requested service")) { throw; } this.logMonitor.ReaderCompletedProcessingLog(logFileInfo); } catch (NotSupportedException ex3) { EventLogger.Logger.LogEvent(LogUploaderEventLogConstants.Tuple_UnsupportedLogVersion, "UnSupportedLogVersion", new object[] { logFileInfo.FullFileName, ex3 }); ServiceLogger.LogError(ServiceLogger.Component.LogMonitor, (LogUploaderEventLogConstants.Message) 3221229488U, ex3.Message, this.instance, logFileInfo.FullFileName); EventNotificationItem.Publish(ExchangeComponent.Name, "UnsupportedLogVersion", null, ex3.Message, ResultSeverityLevel.Error, false); throw ex3; } catch (Exception ex4) { if (!(ex4 is ThreadAbortException) || !this.cancellationContext.StopToken.IsCancellationRequested) { string text4 = (logFileInfo == null) ? "unknown log" : logFileInfo.FullFileName; string text5 = string.Format("{0} processing {1} catches an exception: {2}", Thread.CurrentThread.Name, text4, ex4); ExTraceGlobals.ReaderTracer.TraceError((long)this.GetHashCode(), text5); EventLogger.Logger.LogEvent(LogUploaderEventLogConstants.Tuple_LogReaderUnknownError, null, new object[] { Thread.CurrentThread.Name, text4, ex4 }); EventNotificationItem.Publish(ExchangeComponent.Name, "LogReaderUnknownError", null, text5, ResultSeverityLevel.Error, false); this.perfCounterInstance.TotalLogReaderUnknownErrors.Increment(); ServiceLogger.LogError(ServiceLogger.Component.LogReader, (LogUploaderEventLogConstants.Message) 3221229474U, text5, this.instance, text4); throw; } Thread.ResetAbort(); ServiceLogger.LogInfo(ServiceLogger.Component.DatabaseWriter, LogUploaderEventLogConstants.Message.LogMonitorRequestedStop, Thread.CurrentThread.Name + " received thread abort event", this.instance, ""); } if (num > 0 && this.cancellationContext.StopToken.WaitHandle.WaitOne(num)) { this.cancellationContext.StopWaitHandle.Set(); } }
internal void ProcessLog(LogFileInfo log) { FileStream fileStream = null; ServiceLogger.LogDebug(ServiceLogger.Component.LogReader, LogUploaderEventLogConstants.Message.LogReaderStartedParsingLog, string.Format("reprocessing or begin to process, isActive {0} +++++++++", log.IsActive), this.instance, log.FullFileName); if (log.Status == ProcessingStatus.NeedProcessing) { log.Status = ProcessingStatus.InProcessing; PerfCountersInstanceCache.GetInstance(this.instance).TotalNewLogsBeginProcessing.Increment(); ExTraceGlobals.ReaderTracer.TraceDebug <string, string>((long)this.GetHashCode(), "{0} started parsing log {1}", Thread.CurrentThread.Name, log.FullFileName); EventLogger.Logger.LogEvent(LogUploaderEventLogConstants.Tuple_LogReaderStartedParsingLog, log.FileName, new object[] { this.id, log.FullFileName }); ServiceLogger.LogInfo(ServiceLogger.Component.LogReader, LogUploaderEventLogConstants.Message.LogReaderStartedParsingLog, null, this.instance, log.FullFileName); } try { string defaultLogVersion; fileStream = this.OpenLogWithRetry(log.FullFileName, out defaultLogVersion); if (fileStream == null) { if (!this.isStopRequested) { string text = string.Format("Failed to open log file {0}", log.FullFileName); ExTraceGlobals.ReaderTracer.TraceError((long)this.GetHashCode(), text); EventLogger.Logger.LogEvent(LogUploaderEventLogConstants.Tuple_LogReaderFileOpenFailed, log.FullFileName, new object[] { log.FullFileName }); EventNotificationItem.Publish(ExchangeComponent.Name, "FailToOpenLogFile", null, text, ResultSeverityLevel.Error, false); ServiceLogger.LogError(ServiceLogger.Component.LogReader, (LogUploaderEventLogConstants.Message) 3221229475U, text, this.instance, log.FullFileName); } } else { if (string.IsNullOrWhiteSpace(defaultLogVersion)) { defaultLogVersion = this.logMonitorHelper.GetDefaultLogVersion(); ExTraceGlobals.ReaderTracer.TraceWarning <string, string>((long)this.GetHashCode(), "Failed to figure out version of log file {0}. Use default version {1} instead.", log.FullFileName, defaultLogVersion); EventLogger.Logger.LogEvent(LogUploaderEventLogConstants.Tuple_FailedToGetVersionFromLogHeader, log.FullFileName, new object[] { log.FullFileName, defaultLogVersion }); ServiceLogger.LogError(ServiceLogger.Component.LogReader, (LogUploaderEventLogConstants.Message) 2147487660U, null, this.instance, log.FullFileName); } CsvTable logSchema = this.logMonitorHelper.GetLogSchema(new Version(defaultLogVersion)); CsvFieldCache csvFieldCache = new CsvFieldCache(logSchema, fileStream, 32768); int num = 0; this.logHeaderEndOffset = csvFieldCache.Position; ExTraceGlobals.ReaderTracer.TraceDebug <string, long>((long)this.GetHashCode(), "The end offset of the header of {0} is {1}.", log.FullFileName, this.logHeaderEndOffset); bool flag = false; while (!flag) { if (this.CheckServiceStopRequest("ProcessLog()")) { return; } LogFileRange logFileRange = log.WatermarkFileObj.GetBlockToReprocess(); if (logFileRange == null) { logFileRange = log.WatermarkFileObj.GetNewBlockToProcess(); flag = true; if (logFileRange == null) { break; } } if (num == 0) { long startOffset = logFileRange.StartOffset; this.inputBuffer = new InputBuffer <T>(this.config.BatchSizeInBytes, startOffset, log, this.batchQueue, this.logPrefix, this.logMonitorHelper, this.messageBatchFlushInterval, this.cancellationContext, this.config.InputBufferMaximumBatchCount, this.instance); } bool isFirstBlock = num == 0; this.inputBuffer.BeforeDataBlockIsProcessed(logFileRange, isFirstBlock); this.ProcessBlock(csvFieldCache, logFileRange, log); this.inputBuffer.AfterDataBlockIsProcessed(); if (this.isStopRequested) { return; } num++; } this.EnqueueLastBatchParsed(); log.LastProcessedTime = DateTime.UtcNow; if (!log.IsActive) { log.Status = ProcessingStatus.ReadyToWriteToDatabase; ExTraceGlobals.ReaderTracer.TraceInformation <string>(0, (long)this.GetHashCode(), "Finished parsing log {0}", log.FullFileName); EventLogger.Logger.LogEvent(LogUploaderEventLogConstants.Tuple_LogReaderFinishedParsingLog, log.FullFileName, new object[] { log.FullFileName }); ServiceLogger.LogInfo(ServiceLogger.Component.LogReader, LogUploaderEventLogConstants.Message.LogReaderFinishedParsingLog, null, this.instance, log.FullFileName); } } } finally { ServiceLogger.LogDebug(ServiceLogger.Component.LogReader, LogUploaderEventLogConstants.Message.LogReaderFinishedParsingLog, string.Format("Finished parsing for this round, isActive {0} +++++++++", log.IsActive), this.instance, log.FullFileName); this.logMonitor.ReaderCompletedProcessingLog(log); this.Cleanup(fileStream); } }