Beispiel #1
0
        /// <summary>
        /// Look for new report folders and add them to the publicly available thread-safe queue
        /// </summary>
        public void CheckForNewReports()
        {
            try
            {
                var NewReportPath        = "";
                var ReportsInLandingZone = new ReportIdSet();

                // Check the landing zones for new reports
                DirectoryInfo DirInfo = new DirectoryInfo(LandingZone);

                // Couldn't find a landing zone, skip and try again later.
                // Crash receiver will recreate them if needed.
                if (!DirInfo.Exists)
                {
                    CrashReporterProcessServicer.WriteFailure("LandingZone not found: " + LandingZone);
                    return;
                }

                // Add any new reports
                foreach (var SubDirInfo in DirInfo.GetDirectories())
                {
                    try
                    {
                        if (Directory.Exists(SubDirInfo.FullName))
                        {
                            NewReportPath = SubDirInfo.FullName;
                            ReportsInLandingZone.Add(NewReportPath);
                            if (!ReportsInLandingZoneLastTimeWeChecked.Contains(NewReportPath))
                            {
                                EnqueueNewReport(NewReportPath);
                            }
                        }
                    }
                    catch (System.Exception Ex)
                    {
                        CrashReporterProcessServicer.WriteException("CheckForNewReportsInner: " + Ex.ToString());
                        ReportProcessor.MoveReportToInvalid(NewReportPath, "NEWRECORD_FAIL_" + DateTime.Now.Ticks);
                    }
                }
                //CrashReporterProcessServicer.WriteEvent( string.Format( "ReportsInLandingZone={0}, ReportsInLandingZoneLastTimeWeChecked={1}", ReportsInLandingZone.Count, ReportsInLandingZoneLastTimeWeChecked.Count ) );
                ReportsInLandingZoneLastTimeWeChecked = ReportsInLandingZone;
            }
            catch (Exception Ex)
            {
                CrashReporterProcessServicer.WriteException("CheckForNewReportsOuter: " + Ex.ToString());
            }
        }
Beispiel #2
0
        /// <summary>
        /// Look for new report folders and add them to the publicly available thread-safe queue.
        /// </summary>
        public int CheckForNewReports()
        {
            try
            {
                if (QueueCount >= Config.Default.MinDesiredMemoryQueueSize)
                {
                    CrashReporterProcessServicer.WriteEvent(string.Format(
                                                                "CheckForNewReports: {0} skipped busy queue size {1} in {2}", QueueName, QueueCount, LandingZone));
                }
                else
                {
                    var NewReportPath        = "";
                    var ReportsInLandingZone = new ReportIdSet();

                    CrashReporterProcessServicer.StatusReporter.AlertOnLowDisk(LandingZone, Config.Default.DiskSpaceAlertPercent);

                    DirectoryInfo[] DirectoriesInLandingZone;
                    if (GetCrashesFromLandingZone(out DirectoriesInLandingZone))
                    {
                        LastQueueSizeOnDisk = DirectoriesInLandingZone.Length;

                        int EnqueuedCount = 0;
                        CrashReporterProcessServicer.WriteEvent(string.Format("CheckForNewReports: {0} reports in disk landing zone {1}",
                                                                              DirectoriesInLandingZone.Length, LandingZone));

                        // Add any new reports
                        for (int DirIndex = 0; DirIndex < DirectoriesInLandingZone.Length && QueueCount < Config.Default.MaxMemoryQueueSize; DirIndex++)
                        {
                            var SubDirInfo = DirectoriesInLandingZone[DirIndex];
                            try
                            {
                                if (Directory.Exists(SubDirInfo.FullName))
                                {
                                    NewReportPath = SubDirInfo.FullName;
                                    ReportsInLandingZone.Add(NewReportPath);
                                    if (!ReportsInLandingZoneLastTimeWeChecked.Contains(NewReportPath))
                                    {
                                        if (EnqueueNewReport(NewReportPath))
                                        {
                                            EnqueuedCount++;
                                        }
                                    }
                                }
                            }
                            catch (Exception Ex)
                            {
                                CrashReporterProcessServicer.WriteException("CheckForNewReportsInner: " + Ex, Ex);
                                ReportProcessor.MoveReportToInvalid(NewReportPath, "NEWRECORD_FAIL_" + DateTime.Now.Ticks);
                            }
                        }

                        ReportsInLandingZoneLastTimeWeChecked = ReportsInLandingZone;

                        CrashReporterProcessServicer.WriteEvent(string.Format(
                                                                    "CheckForNewReports: {0} enqueued to queue size {1} from {2}", EnqueuedCount, QueueCount, LandingZone));
                        CrashReporterProcessServicer.WriteEvent(string.Format("CheckForNewReports: Enqueue rate {0:N1}/minute from {1}",
                                                                              EnqueueCounter.EventsPerSecond * 60, LandingZone));
                    }
                    else
                    {
                        LastQueueSizeOnDisk = 0;
                    }
                }
            }
            catch (Exception Ex)
            {
                CrashReporterProcessServicer.WriteException("CheckForNewReportsOuter: " + Ex, Ex);
            }

            return(GetTotalWaitingCount());
        }
        /// <summary>
        /// Look for new report folders and add them to the publicly available thread-safe queue.
        /// </summary>
        public override int CheckForNewReports()
        {
            try
            {
                if (QueueCount >= SkipQueueRefreshMin)
                {
                    CrashReporterProcessServicer.WriteEvent(string.Format("CheckForNewReports: skipped busy queue size {0} in {1}", QueueCount, LandingZone));
                    return(LastQueueSizeOnDisk);
                }

                var NewReportPath        = "";
                var ReportsInLandingZone = new ReportIdSet();

                // Check the landing zones for new reports
                DirectoryInfo DirInfo = new DirectoryInfo(LandingZone);

                // Couldn't find a landing zone, skip and try again later.
                // Crash receiver will recreate them if needed.
                if (!DirInfo.Exists)
                {
                    CrashReporterProcessServicer.WriteFailure("LandingZone not found: " + LandingZone);
                    return(LastQueueSizeOnDisk);
                }

                var DirectoriesInLandingZone = DirInfo.GetDirectories().OrderBy(dirinfo => dirinfo.CreationTimeUtc).ToArray();
                LastQueueSizeOnDisk = DirectoriesInLandingZone.Length;

                int EnqueuedCount = 0;
                CrashReporterProcessServicer.WriteEvent(string.Format("CheckForNewReports: {0} reports in {1}", DirectoriesInLandingZone.Length, LandingZone));

                // Add any new reports
                for (int DirIndex = 0; DirIndex < DirectoriesInLandingZone.Length && QueueCount < QueueMax; DirIndex++)
                {
                    var SubDirInfo = DirectoriesInLandingZone[DirIndex];
                    try
                    {
                        if (Directory.Exists(SubDirInfo.FullName))
                        {
                            NewReportPath = SubDirInfo.FullName;
                            ReportsInLandingZone.Add(NewReportPath);
                            if (!ReportsInLandingZoneLastTimeWeChecked.Contains(NewReportPath))
                            {
                                EnqueueNewReport(NewReportPath);
                                EnqueuedCount++;
                            }
                        }
                    }
                    catch (System.Exception Ex)
                    {
                        CrashReporterProcessServicer.WriteException("CheckForNewReportsInner: " + Ex.ToString());
                        ReportProcessor.MoveReportToInvalid(NewReportPath, "NEWRECORD_FAIL_" + DateTime.Now.Ticks);
                    }
                }
                //CrashReporterProcessServicer.WriteEvent( string.Format( "ReportsInLandingZone={0}, ReportsInLandingZoneLastTimeWeChecked={1}", ReportsInLandingZone.Count, ReportsInLandingZoneLastTimeWeChecked.Count ) );
                ReportsInLandingZoneLastTimeWeChecked = ReportsInLandingZone;
                CrashReporterProcessServicer.WriteEvent(string.Format("CheckForNewReports: {0} enqueued to queue size {1} from {2}", EnqueuedCount, QueueCount, LandingZone));
                CrashReporterProcessServicer.WriteEvent(string.Format("CheckForNewReports: Enqueue rate {0:N1}/minute from {1}", EnqueueCounter.EventsPerSecond * 60, LandingZone));
            }
            catch (Exception Ex)
            {
                CrashReporterProcessServicer.WriteException("CheckForNewReportsOuter: " + Ex.ToString());
            }

            return(LastQueueSizeOnDisk);
        }