Beispiel #1
0
        private async Task CleanInactiveRecentPopularityDetailByPackageReports(CloudBlobContainer destinationContainer, DateTime reportGenerationTime)
        {
            Logger.LogDebug("Getting list of inactive packages.");
            var packageIds = await ReportDataCollector.ListInactivePackageIdReports(
                OpenSqlConnectionAsync <StatisticsDbConfiguration>,
                reportGenerationTime,
                _sqlCommandTimeoutSeconds);

            Logger.LogInformation("Found {InactivePackageCount} inactive packages.", packageIds.Count);

            // Collect the list of reports
            var subContainer = "recentpopularity/";

            Logger.LogDebug("Collecting list of package detail reports");
            var reports = destinationContainer.ListBlobs(subContainer + _recentPopularityDetailByPackageReportBaseName)
                          .OfType <CloudBlockBlob>()
                          .Select(b => b.Name);

            var reportSet = new HashSet <string>(reports);

            Logger.LogInformation("Collected {PackageDetailReportCount} package detail reports", reportSet.Count);

            Parallel.ForEach(packageIds, new ParallelOptions {
                MaxDegreeOfParallelism = 8
            }, async id =>
            {
                string reportName = _recentPopularityDetailByPackageReportBaseName + id;
                string blobName   = subContainer + reportName + ReportNames.Extension;
                if (reportSet.Contains(blobName))
                {
                    var blob = destinationContainer.GetBlockBlobReference(blobName);
                    Logger.LogDebug("{ReportName}: Deleting empty report from {BlobUri}", reportName, blob.Uri.AbsoluteUri);

                    await blob.DeleteIfExistsAsync();

                    Logger.LogInformation("{ReportName}: Deleted empty report from {BlobUri}", reportName, blob.Uri.AbsoluteUri);
                }
            });
        }
Beispiel #2
0
        private async Task CleanInactiveRecentPopularityDetailByPackageReports(CloudBlobContainer destinationContainer, DateTime reportGenerationTime)
        {
            Trace.TraceInformation("Getting list of inactive packages.");
            var packageIds = await ReportDataCollector.ListInactivePackageIdReports(_statisticsDatabase, reportGenerationTime);

            Trace.TraceInformation("Found {0} inactive packages.", packageIds.Count);

            // Collect the list of reports
            var subContainer = "recentpopularity/";

            Trace.TraceInformation("Collecting list of package detail reports");
            var reports = destinationContainer.ListBlobs(subContainer + _recentPopularityDetailByPackageReportBaseName)
                          .OfType <CloudBlockBlob>()
                          .Select(b => b.Name);

            var reportSet = new HashSet <string>(reports);

            Trace.TraceInformation("Collected {0} package detail reports", reportSet.Count);

            Parallel.ForEach(packageIds, new ParallelOptions {
                MaxDegreeOfParallelism = 8
            }, async id =>
            {
                string reportName = _recentPopularityDetailByPackageReportBaseName + id;
                string blobName   = subContainer + reportName + ".json";
                if (reportSet.Contains(blobName))
                {
                    var blob = destinationContainer.GetBlockBlobReference(blobName);
                    Trace.TraceInformation("{0}: Deleting empty report from {1}", reportName, blob.Uri.AbsoluteUri);

                    await blob.DeleteIfExistsAsync();

                    Trace.TraceInformation("{0}: Deleted empty report from {1}", reportName, blob.Uri.AbsoluteUri);
                }
            });
        }