示例#1
0
 private void DoParallelMarkHistoryApplied(PublicStagingTablesBuilder b, ParallelOptions pOptions)
 {
     Parallel.ForEach(b.GetTables(), pOptions, (table, loopState) =>
     {
         if (!loopState.IsExceptional)
         {
             MarkHistoryRowsAsApplied(table.Name);
         }
     });
 }
示例#2
0
 private void DoParallelProcessingFillWeeks(PublicStagingTablesBuilder b, ParallelOptions pOptions)
 {
     Parallel.ForEach(b.GetTables(), pOptions, (table, loopState) =>
     {
         if (!loopState.IsExceptional)
         {
             var cols = b.GetColumnNames(table.Name);
             if (cols.Contains("weeks") && cols.Contains("federated_event_id") && !table.Name.Equals("CT_EVENT"))
             {
                 FillWeeksCol(table);
             }
         }
     });
 }
示例#3
0
        private void GenerateMappings()
        {
            var b = PublicStagingTablesBuilder.Get();

            foreach (var table in b.GetTables())
            {
                Debug.Assert(table.Name.StartsWith("CT_"));

                var publicTableName = GetPublicTableName(table.Name);

                var publicTable = Find(publicTableName);
                _mappings.Add(new TableMapping {
                    PublicStagingTable = table, PublicTable = publicTable
                });
            }
        }
示例#4
0
        private void CheckAllChangesApplied()
        {
            // throw if any rows in the staging tables are as yet untransformed (i.e. they're still there)...

            var b        = PublicStagingTablesBuilder.Get();
            var pOptions = new ParallelOptions {
                MaxDegreeOfParallelism = _configuration.MaxDegreeOfParallelism
            };

            Parallel.ForEach(b.GetTables(), pOptions, (table, loopState) =>
            {
                var sql = $"select count(1) from {table.QualifiedName}";
                DatabaseUtils.GetSingleResult(PublicConnectionString, sql, Timeouts.PublicDatabase, r =>
                {
                    var recCount = (int)r[0];
                    if (recCount > 0)
                    {
                        throw new ApplicationException($"{recCount} staging rows not yet applied: {table.Name}");
                    }
                });
            });
        }
示例#5
0
        private RowCountAndDuration DoParallelProcessingCreateStage(PublicStagingTablesBuilder b, ParallelOptions pOptions)
        {
            RowCountAndDuration result = new RowCountAndDuration();

            object locker = new object();

            Parallel.ForEach(b.GetTables(), pOptions, (table, loopState) =>
            {
                if (!loopState.IsExceptional)
                {
                    var p = new PublicStagingEtlProcess(
                        table, AdminConnectionString, PublicConnectionString, Timeouts.PublicDatabase, _configuration.Pipelines);

                    p.Execute();

                    var errors = p.GetAllErrors().ToArray();

                    if (errors.Any())
                    {
                        loopState.Stop();

                        string msg = $"Errors occurred during execution of public staging process: {table.Name}";
                        _log.Error(msg);

                        // throw the first exception
                        throw new ApplicationException(msg, errors[0]);
                    }

                    lock (locker)
                    {
                        result += p.Stats;
                    }
                }
            });

            return(result);
        }
示例#6
0
        public void PopulateStage(Guid adminAppKey)
        {
            OnProgressEvent(new VertoProgressEventArgs {
                ProgressString = "Populating public stage", Section = ProcessingSection.StagingPublic
            });
            _log.Debug("Populating public stage");

            CheckPreconditions(adminAppKey);

            var b = PublicStagingTablesBuilder.Get();

            var pOptions = new ParallelOptions {
                MaxDegreeOfParallelism = _configuration.MaxDegreeOfParallelism
            };
            var stats = DoParallelProcessingCreateStage(b, pOptions);

            DoParallelProcessingFillWeeks(b, pOptions);

            if (stats.RowCount > 0)
            {
                // only mark as applied _after_ the PUBLIC staging schema has been successfully populated...
                DoParallelMarkHistoryApplied(b, pOptions);
            }
        }