Exemple #1
0
        private List <AmServerName> DetermineServersToContact()
        {
            Guid        guid = this.Database.Guid;
            IADDatabase db   = this.Database;

            IADDatabaseCopy[] databaseCopies = AmBestCopySelectionHelper.GetDatabaseCopies(guid, ref db);
            if (db != null)
            {
                this.Database = db;
            }
            AmConfig amConfig = AmSystemManager.Instance.Config;

            if (amConfig.IsUnknown)
            {
                AmTrace.Error("AmMultiNodeRpcNotifier: DB {0}: Invalid AM configuration", new object[]
                {
                    db.Name
                });
                throw new AmInvalidConfiguration(amConfig.LastError ?? string.Empty);
            }
            IAmBcsErrorLogger errorLogger = new AmBcsSingleCopyFailureLogger();
            AmBcsServerChecks checksToRun = AmBcsServerChecks.ClusterNodeUp;

            if (this.ActionCode.IsAutomaticOperation)
            {
                checksToRun |= AmBcsServerChecks.DebugOptionDisabled;
            }
            IEnumerable <AmServerName> source = from dbCopy in databaseCopies
                                                where this.ValidateServer(new AmServerName(dbCopy.HostServerName), db, amConfig, checksToRun, errorLogger)
                                                select new AmServerName(dbCopy.HostServerName);

            return(source.ToList <AmServerName>());
        }
Exemple #2
0
 public void ChangeActiveServerForThirdParty(string newActiveServerName, TimeSpan lockTimeout)
 {
     using (AmDatabaseOperationLock.Lock(base.DatabaseGuid, AmDbLockReason.Move, new TimeSpan?(lockTimeout)))
     {
         if (!base.State.IsAdminDismounted)
         {
             throw new ChangeActiveServerException(base.DatabaseGuid, newActiveServerName, ReplayStrings.TPRChangeFailedBecauseNotDismounted);
         }
         AmServerName activeServer = base.State.ActiveServer;
         AmServerName amServerName = new AmServerName(newActiveServerName);
         if (activeServer.Equals(amServerName))
         {
             throw new ChangeActiveServerException(base.DatabaseGuid, newActiveServerName, ReplayStrings.TPRChangeFailedBecauseAlreadyActive(activeServer.ToString()));
         }
         IAmBcsErrorLogger     errorLogger           = new AmBcsSingleCopyFailureLogger();
         AmBcsServerChecks     checks                = AmBcsServerChecks.DebugOptionDisabled | AmBcsServerChecks.ClusterNodeUp | AmBcsServerChecks.DatacenterActivationModeStarted | AmBcsServerChecks.AutoActivationAllowed;
         LocalizedString       empty                 = LocalizedString.Empty;
         AmBcsServerValidation amBcsServerValidation = new AmBcsServerValidation(amServerName, activeServer, base.Database, base.Config, errorLogger, null);
         if (!amBcsServerValidation.RunChecks(checks, ref empty))
         {
             AmTrace.Error("ChangeActiveServerForThirdParty: DB {0}: ValidateServer() returned error: {1}", new object[]
             {
                 base.DatabaseName,
                 empty
             });
             throw new ChangeActiveServerException(base.DatabaseGuid, newActiveServerName, ReplayStrings.TPRChangeFailedServerValidation(base.DatabaseName, newActiveServerName, empty));
         }
         base.WriteStateMountSkipped(amServerName);
         this.UpdateAdProperties(true, activeServer);
         ReplayCrimsonEvents.TPRChangeActiveServerSucceeded.Log <string, Guid, AmServerName, AmServerName>(base.DatabaseName, base.DatabaseGuid, activeServer, amServerName);
     }
 }