Beispiel #1
0
        public async Task <(IEnumerable <string> NewFileNames, IEnumerable <IFileInfo> CollectionFileInfos)> CollectDataAsync(CollectorMode collectorMode, DataCollectionConfig dataCollectionConfig, CancellationToken cancellationToken)
        {
            try
            {
                (IEnumerable <string> NewFileNames, IEnumerable <IFileInfo> CollectionFileInfos)result;

                _logger.LogInformation("Started processing data '{dataCollectionName}'", dataCollectionConfig.DataCollectionName);

                var watch = System.Diagnostics.Stopwatch.StartNew();
                try
                {
                    result = await _dataCollector.CollectDataAsync(collectorMode, dataCollectionConfig, cancellationToken);

                    result = (result.NewFileNames.ToList(), result.CollectionFileInfos.ToList());
                }
                finally
                {
                    watch.Stop();
                }

                _logger.LogInformation("Finished processing data '{dataCollectionName}'. Elapsed time: {elapsed}", dataCollectionConfig.DataCollectionName, watch.Elapsed);

                return(result);
            }
            catch (Exception e)
            {
                _logger.LogCritical("Error processing data '{dataCollectionName}': {errorMessage}", dataCollectionConfig.DataCollectionName, e.GetAggregateMessages());
                throw;
            }
        }
        private async Task <IEnumerable <string> > CollectGroupAsync(string groupName, CollectorMode collectorMode, IEnumerable <DataCollectionConfig> dataCollectionsConfig, CancellationToken cancellationToken)
        {
            var result = new List <string>();

            foreach (var dataCollectionConfig in dataCollectionsConfig)
            {
                try
                {
                    var(newFileNames, collectionFileInfos) = await _dataCollector.CollectDataAsync(collectorMode, dataCollectionConfig, cancellationToken);

                    if (collectorMode == CollectorMode.Collect)
                    {
                        await _dataCollector.GarbageCollectDataAsync(dataCollectionConfig, newFileNames, collectionFileInfos, cancellationToken);
                    }
                }
                catch
                {
                    result.Add(dataCollectionConfig.DataCollectionName);
                    // Give other DataCollections a chance
                }
            }

            return(result);
        }