public async Task ExecuteAsync(CancellationToken token)
        {
            var registrationCursors = CursorUtility.GetRegistrationCursors(_handlerFunc, _options);
            var backCursor          = new AggregateCursor(registrationCursors.Values);

            var frontCursorPair = CursorUtility.GetComparerCursor(_storageFactory);

            _logger.LogInformation("Using cursor: {CursurUrl}", frontCursorPair.Key);
            var frontCursor = frontCursorPair.Value;

            var container = _storageAccount
                            .CreateCloudBlobClient()
                            .GetContainerReference(_options.Value.StorageContainer);
            await container.CreateIfNotExistsAsync();

            await container.SetPermissionsAsync(new BlobContainerPermissions { PublicAccess = BlobContainerPublicAccessType.Blob });

            await frontCursor.LoadAsync(token);

            await backCursor.LoadAsync(token);

            _logger.LogInformation(
                "The cursors have been loaded. Front: {FrontCursor}. Back: {BackCursor}.",
                frontCursor.Value,
                backCursor.Value);

            // Run the collector.
            await _collector.RunAsync(
                frontCursor,
                backCursor,
                token);
        }
        private async Task ExecuteAsync(CancellationToken token)
        {
            // Initialize the cursors.
            ReadCursor backCursor;

            if (_options.Value.DependencyCursorUrls != null &&
                _options.Value.DependencyCursorUrls.Any())
            {
                _logger.LogInformation("Depending on cursors: {DependencyCursorUrls}", _options.Value.DependencyCursorUrls);
                backCursor = new AggregateCursor(_options
                                                 .Value
                                                 .DependencyCursorUrls.Select(r => new HttpReadCursor(new Uri(r), _handlerFunc)));
            }
            else
            {
                _logger.LogInformation("Depending on no cursors, meaning the job will process up to the latest catalog information.");
                backCursor = MemoryCursor.CreateMax();
            }

            var frontCursorStorage = _storageFactory.Create();
            var frontCursorUri     = frontCursorStorage.ResolveUri(CursorRelativeUri);
            var frontCursor        = new DurableCursor(frontCursorUri, frontCursorStorage, DateTime.MinValue);

            _logger.LogInformation("Using cursor: {CursurUrl}", frontCursorUri.AbsoluteUri);
            LogContainerUrl(HiveType.Legacy, c => c.LegacyStorageContainer);
            LogContainerUrl(HiveType.Gzipped, c => c.GzippedStorageContainer);
            LogContainerUrl(HiveType.SemVer2, c => c.SemVer2StorageContainer);

            // Optionally create the containers.
            if (_options.Value.CreateContainers)
            {
                await CreateContainerIfNotExistsAsync(c => c.LegacyStorageContainer);
                await CreateContainerIfNotExistsAsync(c => c.GzippedStorageContainer);
                await CreateContainerIfNotExistsAsync(c => c.SemVer2StorageContainer);
            }

            await frontCursor.LoadAsync(token);

            await backCursor.LoadAsync(token);

            _logger.LogInformation(
                "The cursors have been loaded. Front: {FrontCursor}. Back: {BackCursor}.",
                frontCursor.Value,
                backCursor.Value);

            // Run the collector.
            await _collector.RunAsync(
                frontCursor,
                backCursor,
                token);
        }
Exemple #3
0
        private async Task ExecuteAsync(CancellationToken token)
        {
            // Initialize the cursors.
            ReadCursor backCursor;

            if (_options.Value.DependencyCursorUrls != null &&
                _options.Value.DependencyCursorUrls.Any())
            {
                _logger.LogInformation("Depending on cursors:{DependencyCursorUrls}", _options.Value.DependencyCursorUrls);
                backCursor = new AggregateCursor(_options
                                                 .Value
                                                 .DependencyCursorUrls.Select(r => new HttpReadCursor(new Uri(r), _handlerFunc)));
            }
            else
            {
                _logger.LogInformation("Depending on no cursors, meaning the job will process up to the latest catalog information.");
                backCursor = MemoryCursor.CreateMax();
            }

            var frontCursorStorage = _storageFactory.Create();
            var frontCursorUri     = frontCursorStorage.ResolveUri(CursorRelativeUri);
            var frontCursor        = new DurableCursor(frontCursorUri, frontCursorStorage, DateTime.MinValue);

            // Log information about where state will be kept.
            _logger.LogInformation(
                "Using storage URL: {ContainerUrl}/{StoragePath}",
                CloudStorageAccount.Parse(_options.Value.StorageConnectionString)
                .CreateCloudBlobClient()
                .GetContainerReference(_options.Value.StorageContainer)
                .Uri
                .AbsoluteUri,
                _options.Value.NormalizeStoragePath());
            _logger.LogInformation("Using cursor: {CursurUrl}", frontCursorUri.AbsoluteUri);
            _logger.LogInformation("Using search service: {SearchServiceName}", _options.Value.SearchServiceName);
            _logger.LogInformation("Using search index: {IndexName}", _options.Value.SearchIndexName);
            _logger.LogInformation("Using hijack index: {IndexName}", _options.Value.HijackIndexName);

            // Optionally create the indexes.
            if (_options.Value.CreateContainersAndIndexes)
            {
                await _blobContainerBuilder.CreateIfNotExistsAsync();

                await _indexBuilder.CreateSearchIndexIfNotExistsAsync();

                await _indexBuilder.CreateHijackIndexIfNotExistsAsync();
            }

            await frontCursor.LoadAsync(token);

            await backCursor.LoadAsync(token);

            _logger.LogInformation(
                "The cursors have been loaded. Front: {FrontCursor}. Back: {BackCursor}.",
                frontCursor.Value,
                backCursor.Value);

            // Run the collector.
            await _collector.RunAsync(
                frontCursor,
                backCursor,
                token);
        }