Esempio n. 1
0
 /// <summary>
 /// Runs a command on the admin database.
 /// </summary>
 /// <param name="commandResultType">The type to use for the command result.</param>
 /// <param name="commandName">The name of the command to run.</param>
 /// <returns>The result of the command.</returns>
 public virtual object RunAdminCommandAs(
     Type commandResultType,
     string commandName
     )
 {
     return(AdminDatabase.RunCommandAs(commandResultType, commandName));
 }
Esempio n. 2
0
 /// <summary>
 /// Runs a command on the admin database.
 /// </summary>
 /// <param name="commandResultType">The type to use for the command result.</param>
 /// <param name="command">The command to run.</param>
 /// <returns>The result of the command.</returns>
 public virtual object RunAdminCommandAs(
     Type commandResultType,
     IMongoCommand command
     )
 {
     return(AdminDatabase.RunCommandAs(commandResultType, command));
 }
Esempio n. 3
0
 private void CheckForChangeInConsolidationConfig(AdminDatabase adminDb, PublicDatabase publicDb, ConsolidationParams consolidation)
 {
     if (adminDb.ConsolidationConfigChanged(consolidation) && publicDb.TablesExist())
     {
         throw new ApplicationException("Consolidation configuration has changed. Please rebuild the data store by deleting ADMIN and PUBLIC databases");
     }
 }
Esempio n. 4
0
 private void TruncateOnForcedRebuild(AdminDatabase adminDb, PublicDatabase publicDb)
 {
     if (_configuration.ForceRebuild)
     {
         adminDb.TruncateIfForcedRebuild();
         publicDb.TruncateIfForcedRebuild();
     }
 }
Esempio n. 5
0
        /// <summary>
        /// Gets the names of the databases on this server.
        /// </summary>
        /// <returns>A list of database names.</returns>
        public virtual IEnumerable <string> GetDatabaseNames()
        {
            var result        = AdminDatabase.RunCommand("listDatabases");
            var databaseNames = new List <string>();

            foreach (BsonDocument database in result.Response["databases"].AsBsonArray.Values)
            {
                string databaseName = database["name"].AsString;
                databaseNames.Add(databaseName);
            }
            databaseNames.Sort();
            return(databaseNames);
        }
Esempio n. 6
0
        public void Execute()
        {
            OnProgressEvent(new VertoProgressEventArgs {
                ProgressString = "Executing controller", Section = ProcessingSection.Root
            });

            var adminDb = new AdminDatabase(_configuration);

            adminDb.ProgressEvent += AdminDbProgressEvent;

            var publicDb = new PublicDatabase(_configuration);

            publicDb.ProgressEvent += PublicDbProgressEvent;

            try
            {
                TruncateOnForcedRebuild(adminDb, publicDb);

                CheckForChangeInConsolidationConfig(adminDb, publicDb, _configuration.Consolidation);
                CheckForIdenticalAppKeys(publicDb, adminDb.ApplicationKey);

                // the order of these tasks is important!
                adminDb.ExtractToStage();
                adminDb.UpdateHistory();
                adminDb.AddHistoryFederationIds(new[] { RowStatus.Deleted }, 1);  // perform _before_ we federate
                adminDb.FederateResources();
                adminDb.ConsolidateResources();
                adminDb.AddHistoryFederationIds(new[] { RowStatus.Updated, RowStatus.Inserted }, 2);

                publicDb.PopulateStage(adminDb.ApplicationKey);
                publicDb.TransformStage();
            }
            finally
            {
                adminDb.FinishUp();
                OnProgressEvent(new VertoProgressEventArgs {
                    ProgressString = "Closing controller", Section = ProcessingSection.Root
                });
            }
        }
Esempio n. 7
0
 /// <summary>
 /// Runs a command on the admin database.
 /// </summary>
 /// <typeparam name="TCommandResult">The type to use for the command result.</typeparam>
 /// <param name="commandName">The name of the command to run.</param>
 /// <returns>The result of the command (as a <typeparamref name="TCommandResult"/>).</returns>
 public virtual TCommandResult RunAdminCommandAs <TCommandResult>(
     string commandName
     ) where TCommandResult : CommandResult, new()
 {
     return(AdminDatabase.RunCommandAs <TCommandResult>(commandName));
 }
Esempio n. 8
0
 /// <summary>
 /// Runs a command on the admin database.
 /// </summary>
 /// <typeparam name="TCommandResult">The type to use for the command result.</typeparam>
 /// <param name="command">The command to run.</param>
 /// <returns>The result of the command (as a <typeparamref name="TCommandResult"/>).</returns>
 public virtual TCommandResult RunAdminCommandAs <TCommandResult>(
     IMongoCommand command
     ) where TCommandResult : CommandResult, new()
 {
     return(AdminDatabase.RunCommandAs <TCommandResult>(command));
 }