Ejemplo n.º 1
0
        public async Task <ProjectionsInfo> CheckAndRebuildProjections(CancellationToken token)
        {
            var persistedProjectionsInfo = await this.LoadProjectionsInfo();

            var strategy        = this._targetContainer.Strategy;
            var memory          = new NonserializingMemoryStorageConfig();
            var memoryContainer = memory.CreateNuclear(strategy).Container;

            var generatedProjectionInfos = this.GeneratedProjectionInfosFromProjectors(token, memoryContainer, strategy);

            var partitionedProjections = PartitionedProjectionsInfo.Partition(persistedProjectionsInfo.Infos, generatedProjectionInfos, this._storage);

            this.PrintProjectionsStatus(partitionedProjections);

            await this.DeleteObsolete(partitionedProjections.Obsolete, this._targetContainer);

            await this.RebuildProjections(partitionedProjections.NeedRebuild, memoryContainer, token);

            if (partitionedProjections.NeedRebuild.Count > 0 || partitionedProjections.Obsolete.Count > 0)
            {
                var newProjectionsInfo = new ProjectionsInfo();
                newProjectionsInfo.Infos.UnionWith(partitionedProjections.ReadyForUse);
                newProjectionsInfo.Infos.UnionWith(partitionedProjections.NeedRebuild);
                await this._storage.SaveEntityAsync(this._name, newProjectionsInfo);

                persistedProjectionsInfo = newProjectionsInfo;
            }
            return(persistedProjectionsInfo);
        }
Ejemplo n.º 2
0
 private void PrintProjectionsStatus(PartitionedProjectionsInfo partitionedProjections)
 {
     partitionedProjections.ReadyForUse.SelectMany(pr => pr.ViewBuckets).ForEach(b => SystemObserver.Notify("[good]\t{0} is up to date", b));
     partitionedProjections.NeedRebuild.SelectMany(pr => pr.ViewBuckets).ForEach(b => SystemObserver.Notify("[warn]\t{0} needs rebuild", b));
     partitionedProjections.Obsolete.SelectMany(pr => pr.ViewBuckets).ForEach(b => SystemObserver.Notify("[warn]\t{0} is obsolete", b));
 }