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); }
public async Task ExecuteAsync(bool restart) { var fileSystemStorage = new FileStorageFactory( new Uri("http://localhost/"), Directory.GetCurrentDirectory(), verbose: false); var front = new DurableCursor( new Uri("http://localhost/cursor.json"), fileSystemStorage.Create(), DateTime.MinValue); if (restart) { await front.LoadAsync(CancellationToken.None); front.Value = DateTime.MinValue; await front.SaveAsync(CancellationToken.None); } var back = MemoryCursor.CreateMax(); await _collector.RunAsync(front, back, CancellationToken.None); }
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); }