Beispiel #1
0
        /// <summary>
        /// Runs the DLE using a custom names for RAW/STAGING.  Pass in the load to execute and the files/directories to process
        /// in the batch.
        /// </summary>
        /// <param name="lmd"></param>
        /// <param name="payload"></param>
        /// <returns>The exit code of the data load after it completes</returns>
        private ExitCodeType RunDLE(LoadMetadata lmd, object payload)
        {
            var catalogueRepository = (CatalogueRepository)lmd.Repository;

            //ensures that RAW/STAGING always have unique names
            _configuration = new HICDatabaseConfiguration(lmd, _namer);
            _configuration.UpdateButDoNotDiff = new Regex("^MessageGuid");

            var logManager = catalogueRepository.GetDefaultLogManager();

            logManager.CreateNewLoggingTaskIfNotExists(lmd.GetDistinctLoggingTask());

            // Create the pipeline to pass into the DataLoadProcess object
            var dataLoadFactory = new HICDataLoadFactory(lmd, _configuration, new HICLoadConfigurationFlags(),
                                                         catalogueRepository, logManager);

            var stagingCreator = _namer as ICreateAndDestroyStagingDuringLoads;

            if (stagingCreator != null)
            {
                stagingCreator.CreateStaging(lmd.GetDistinctLiveDatabaseServer());
            }

            var listener = new NLogThrowerDataLoadEventListener(NLog.LogManager.GetCurrentClassLogger());

            IDataLoadExecution execution = dataLoadFactory.Create(listener);

            IExternalDatabaseServer raw = catalogueRepository.GetServerDefaults().GetDefaultFor(PermissableDefaults.RAWDataLoadServer);

            DiscoveredServer liveDb = lmd.GetDistinctLiveDatabaseServer();

            //do we want to try to cut down the time it takes to do RAW=>STAGING by using INSERT INTO  instead of running anonymisation/migration pipeline
            if (_useInsertIntoForRawMigration)
            {
                //if it is on the same server swap out the migration engine for INSERT INTO
                if (raw == null || (raw.Server != null && raw.Server.Equals(liveDb.Name) && raw.DatabaseType == liveDb.DatabaseType))
                {
                    listener.OnNotify(this, new NotifyEventArgs(ProgressEventType.Information, "SWAPPING RAW=>STAGING migration strategy to INSERT INTO"));
                    SwapMigrateRAWToStagingComponent(execution.Components);
                }
                else
                {
                    //Cannot use because different servers / DatabaseTypes.
                    listener.OnNotify(this, new NotifyEventArgs(ProgressEventType.Warning, "CANNOT SWAP RAW=>STAGING migration strategy to INSERT INTO because RAW is on '" + raw.Server + "' (" + raw.DatabaseType + ") and STAGING is on '" + liveDb.Name + "' (" + liveDb.DatabaseType + ")"));
                }
            }
            else
            {
                listener.OnNotify(this, new NotifyEventArgs(ProgressEventType.Information, "Flag is false for SWAP RAW=>STAGING migration strategy to INSERT INTO So won't do it"));
            }

            var procedure = new DataLoadProcess(_repositoryLocator, lmd, null, logManager, listener, execution, _configuration);

            ExitCodeType exitCode = procedure.Run(new GracefulCancellationToken(), payload);

            return(exitCode);
        }