public ChunkedPhase( IStageIdentity stageIdentity, IGenerationPhaseIdentity phaseIdentity, IReadOnlyLargeCollection <TKey> chunkKeys, IAsyncFactory <TKey, IDisposableValue <TChunk> > chunkFactory, IChunkProcessor <TChunk> chunkProcessor, GenerationOptions options = null) : base(options?.CancellationToken ?? DefaultCancellationToken) { Contracts.Requires.That(stageIdentity != null); Contracts.Requires.That(phaseIdentity != null); Contracts.Requires.That(chunkKeys != null); Contracts.Requires.That(chunkFactory != null); Contracts.Requires.That(chunkProcessor != null); this.StageIdentity = stageIdentity; this.PhaseIdentity = phaseIdentity; this.chunkKeys = chunkKeys; this.chunkFactory = chunkFactory; this.chunkProcessor = chunkProcessor; this.Progress = this.progress.AsObservable(); var dataflowOptions = new ExecutionDataflowBlockOptions() { MaxDegreeOfParallelism = options?.MaxDegreeOfParallelism ?? DefaultMaxDegreeOfParallelism, CancellationToken = this.CancellationToken, }; this.processChunks = new ActionBlock <TKey>(this.ProcessChunk, dataflowOptions); this.chunksCompleted = new AsyncLongCountdownEvent(this.ProgressTotalCount); }
/// <summary> /// Initializes a new instance of the <see cref="StageGenerationException" /> class. /// </summary> /// <param name="stage">The stage.</param> /// <param name="phase">The phase.</param> public StageGenerationException(IStageIdentity stage, IGenerationPhaseIdentity phase) { Contracts.Requires.That(stage != null); Contracts.Requires.That(phase != null); this.StageIdentity = stage; this.PhaseIdentity = phase; }
/// <summary> /// Initializes a new instance of the <see cref="StageGenerationException"/> class. /// </summary> /// /// <param name="stage">The stage.</param> /// <param name="phase">The phase.</param> /// <param name="message">The error message that explains the reason for the exception.</param> /// <param name="innerException"> /// The exception that is the cause of the current exception, or a null reference /// if no inner exception is specified. /// </param> public StageGenerationException( IStageIdentity stage, IGenerationPhaseIdentity phase, string message, Exception innerException) : base(message, innerException) { Contracts.Requires.That(stage != null); Contracts.Requires.That(phase != null); this.StageIdentity = stage; this.PhaseIdentity = phase; }
public GenerationPhaseProgress( IStageIdentity stage, IGenerationPhaseIdentity phase, string message, long countCompleted, long totalCount) : base(countCompleted, totalCount) { Contracts.Requires.That(stage != null); Contracts.Requires.That(phase != null); Contracts.Requires.That(!message.IsNullOrWhiteSpace()); this.StageIdentity = stage; this.PhaseIdentity = phase; this.Message = message; }
public ChunkedBatchingPhase( IStageIdentity stageIdentity, IGenerationPhaseIdentity phaseIdentity, IReadOnlyLargeCollection <TKey> chunkKeys, IAsyncFactory <TKey, TPersistable> chunkFactory, IChunkStore <TKey, TPersistable> chunkStore, int maxBatchedChunks, BatchGenerationOptions options = null) : base(options?.CancellationToken ?? DefaultCancellationToken) { Contracts.Requires.That(stageIdentity != null); Contracts.Requires.That(phaseIdentity != null); Contracts.Requires.That(chunkKeys != null); Contracts.Requires.That(chunkFactory != null); Contracts.Requires.That(chunkStore != null); Contracts.Requires.That(maxBatchedChunks > 0); this.StageIdentity = stageIdentity; this.PhaseIdentity = phaseIdentity; this.chunkKeys = chunkKeys; this.chunkFactory = chunkFactory; this.chunkStore = chunkStore; this.Progress = this.progress.AsObservable(); var dataflowOptions = new ExecutionDataflowBlockOptions() { MaxDegreeOfParallelism = options?.MaxDegreeOfParallelism ?? DefaultMaxDegreeOfParallelism, BoundedCapacity = maxBatchedChunks, CancellationToken = this.CancellationToken, }; this.generateChunks = new TransformBlock <TKey, TPersistable>( chunkIndex => this.chunkFactory.CreateAsync(chunkIndex), dataflowOptions); this.saveChunks = BatchActionBlock.Create <TPersistable>( this.SaveChunks, maxBatchedChunks, options?.Batching ?? DefaultBatching, dataflowOptions); var linkOptions = new DataflowLinkOptions() { PropagateCompletion = true }; this.generateChunks.LinkTo(this.saveChunks, linkOptions); this.chunksCompleted = new AsyncLongCountdownEvent(this.ProgressTotalCount); }