Example #1
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);
     }
 }
Example #2
0
        private bool ValidateServer(AmServerName serverName, IADDatabase db, AmConfig amConfig, AmBcsServerChecks checksToRun, IAmBcsErrorLogger errorLogger)
        {
            if (serverName.IsLocalComputerName)
            {
                return(true);
            }
            LocalizedString       empty = LocalizedString.Empty;
            AmBcsServerValidation amBcsServerValidation = new AmBcsServerValidation(serverName, null, db, amConfig, errorLogger, null);
            bool flag = amBcsServerValidation.RunChecks(checksToRun, ref empty);

            if (!flag)
            {
                AmTrace.Error("AmMultiNodeRpcNotifier: DB {0}: ValidateServer() returned error: {1}", new object[]
                {
                    db.Name,
                    empty
                });
            }
            return(flag);
        }
Example #3
0
        // Token: 0x060006D2 RID: 1746 RVA: 0x00020998 File Offset: 0x0001EB98
        public bool RunChecks(AmBcsServerChecks checks, ref LocalizedString error)
        {
            bool flag = true;

            error = LocalizedString.Empty;
            if (flag && AmBcsServerValidation.ShouldRunCheck(checks, AmBcsServerChecks.DebugOptionDisabled))
            {
                flag = this.CheckDebugOption(ref error);
            }
            if (flag && AmBcsServerValidation.ShouldRunCheck(checks, AmBcsServerChecks.DatacenterActivationModeStarted))
            {
                flag = this.IsServerStartedForDACMode(ref error);
            }
            if (flag && AmBcsServerValidation.ShouldRunCheck(checks, AmBcsServerChecks.ClusterNodeUp))
            {
                flag = this.IsClusterNodeUp(ref error);
            }
            if (flag && AmBcsServerValidation.ShouldRunCheck(checks, AmBcsServerChecks.AutoActivationAllowed))
            {
                flag = this.IsAutoActivationAllowed(ref error);
            }
            return(flag);
        }
Example #4
0
        // Token: 0x060006F5 RID: 1781 RVA: 0x0002140C File Offset: 0x0001F60C
        private List <AmServerName> DetermineServersToContact()
        {
            AmServerName sourceServerName = this.m_bcsContext.SourceServerName;
            IADDatabase  database         = this.m_bcsContext.Database;
            AmConfig     amConfig         = this.m_amConfig;

            this.PopulateDatabaseCopiesIfNecessary();
            List <AmServerName> list = new List <AmServerName>(this.m_dbCopies.Length);
            string            name   = database.Name;
            LocalizedString   empty  = LocalizedString.Empty;
            AmBcsServerChecks serverValidationChecks = AmBcsServerValidation.GetServerValidationChecks(this.m_bcsContext.ActionCode, false);

            foreach (IADDatabaseCopy iaddatabaseCopy in this.m_dbCopies)
            {
                AmServerName          amServerName          = new AmServerName(iaddatabaseCopy.HostServerName);
                AmBcsServerValidation amBcsServerValidation = new AmBcsServerValidation(amServerName, sourceServerName, database, amConfig, this.m_bcsContext.ErrorLogger, null);
                if (amBcsServerValidation.RunChecks(serverValidationChecks, ref empty))
                {
                    list.Add(amServerName);
                }
            }
            return(list);
        }
        // Token: 0x06000728 RID: 1832 RVA: 0x00022C0C File Offset: 0x00020E0C
        public AmServerName FindNextBestCopy()
        {
            AmServerName    amServerName = null;
            LocalizedString error        = LocalizedString.Empty;
            bool            flag         = false;
            AmBcsChecks     amBcsChecks  = AmBcsChecks.None;

            if (!this.m_fInitialized)
            {
                this.m_bcsWatch.Start();
                try
                {
                    if (this.m_bcsContext.ShouldLogSubactionEvent)
                    {
                        ReplayCrimsonEvents.BcsInitiated.LogGeneric(this.m_bcsContext.PrepareSubaction(new object[]
                        {
                            this.BestCopySelectionType,
                            false
                        }));
                    }
                    bool fDbNeverMounted = false;
                    this.m_perfTracker.RunTimedOperation(BcsOperation.HasDatabaseBeenMounted, delegate
                    {
                        fDbNeverMounted = !AmBestCopySelectionHelper.HasDatabaseBeenMounted(this.m_bcsContext.DatabaseGuid, this.m_amConfig);
                        this.m_bcsContext.DatabaseNeverMounted = fDbNeverMounted;
                    });
                    AmBcsServerValidation serverValidator = new AmBcsServerValidation(this.m_targetServerName, this.m_bcsContext.SourceServerName, this.m_bcsContext.Database, this.m_amConfig, this.m_bcsContext.ErrorLogger, null);
                    AmBcsServerChecks     serverChecks    = AmBcsServerValidation.GetServerValidationChecks(this.m_bcsContext.ActionCode, true);
                    bool serverChecksPassed = false;
                    this.m_perfTracker.RunTimedOperation(BcsOperation.DetermineServersToContact, delegate
                    {
                        serverChecksPassed = serverValidator.RunChecks(serverChecks, ref error);
                    });
                    if (!serverChecksPassed)
                    {
                        goto IL_39C;
                    }
                    if (!fDbNeverMounted && !this.m_bcsContext.ActionCode.IsMountOrRemountOperation)
                    {
                        List <AmServerName> serversToContact = new List <AmServerName>(2);
                        serversToContact.Add(this.m_targetServerName);
                        if (!AmServerName.IsEqual(this.m_bcsContext.SourceServerName, this.m_targetServerName) && (this.m_bcsContext.SkipValidationChecks & AmBcsSkipFlags.SkipActiveCopyChecks) == AmBcsSkipFlags.None)
                        {
                            serversToContact.Add(this.m_bcsContext.SourceServerName);
                        }
                        this.m_perfTracker.RunTimedOperation(BcsOperation.GetCopyStatusRpc, delegate
                        {
                            this.ConstructBcsStatusTable(serversToContact);
                        });
                        AmBcsServerFailureLogger amBcsServerFailureLogger = this.m_bcsContext.ErrorLogger as AmBcsServerFailureLogger;
                        string concatenatedErrorString = amBcsServerFailureLogger.GetConcatenatedErrorString();
                        if (concatenatedErrorString != null)
                        {
                            error = new LocalizedString(concatenatedErrorString);
                            goto IL_39C;
                        }
                    }
                    this.m_fInitialized = true;
                }
                finally
                {
                    this.m_bcsWatch.Stop();
                    this.m_perfTracker.RecordDuration(BcsOperation.BcsOverall, this.m_bcsWatch.Elapsed);
                    this.m_perfTracker.LogEvent();
                }
            }
            if (this.TargetHasBeenTried(ref error))
            {
                this.m_bcsContext.ErrorLogger.ReportServerFailure(this.m_targetServerName, "CopyHasBeenTriedCheck", error, false);
            }
            else
            {
                if (this.m_bcsContext.ActionCode.IsMountOrRemountOperation)
                {
                    amBcsChecks = AmBcsChecks.None;
                    AmTrace.Debug("BCS: FindNextBestCopy: Skipping validation checks for Database '{0}' on server '{1}'.", new object[]
                    {
                        this.m_bcsContext.GetDatabaseNameOrGuid(),
                        this.m_targetServerName
                    });
                }
                else if (this.m_bcsContext.DatabaseNeverMounted)
                {
                    amBcsChecks = AmBcsChecks.IsPassiveCopy;
                    AmTrace.Debug("BCS: FindNextBestCopy: Database '{0}' has never been mounted. Running non-status related checks.", new object[]
                    {
                        this.m_bcsContext.GetDatabaseNameOrGuid()
                    });
                }
                else
                {
                    if (!this.CheckActiveForMove(ref error))
                    {
                        goto IL_39C;
                    }
                    amBcsChecks = (AmBcsChecks.IsHealthyOrDisconnected | AmBcsChecks.IsCatalogStatusHealthy | AmBcsChecks.CopyQueueLength | AmBcsChecks.ReplayQueueLength | AmBcsChecks.IsPassiveCopy | AmBcsChecks.IsSeedingSource | AmBcsChecks.TotalQueueLengthMaxAllowed | AmBcsChecks.MaxActivesUnderPreferredLimit);
                }
                RpcDatabaseCopyStatus2 copyStatus = null;
                this.m_bcsContext.StatusTable.TryGetValue(this.m_targetServerName, out copyStatus);
                AmBcsCopyValidation amBcsCopyValidation = new AmBcsCopyValidation(this.m_bcsContext.DatabaseGuid, this.m_bcsContext.GetDatabaseNameOrGuid(), amBcsChecks, this.m_bcsContext.SourceServerName, this.m_targetServerName, copyStatus, this.m_bcsContext.ErrorLogger, this.m_bcsContext.SkipValidationChecks, this.m_bcsContext.ComponentStateWrapper);
                flag        = amBcsCopyValidation.RunChecks(ref error);
                amBcsChecks = amBcsCopyValidation.CompletedChecks;
            }
IL_39C:
            if (flag)
            {
                AmTrace.Info("BCS: FindNextBestCopy: DatabaseCopy: '{0}\\{1}' passed validation checks.", new object[]
                {
                    this.m_bcsContext.GetDatabaseNameOrGuid(),
                    this.m_targetServerName.NetbiosName
                });
                amServerName = this.m_targetServerName;
                this.m_serverAlreadyTried = this.m_targetServerName;
                ReplayCrimsonEvents.BcsDbMoveChecksPassed.Log <string, Guid, AmServerName, AmBcsChecks>(this.m_bcsContext.GetDatabaseNameOrGuid(), this.m_bcsContext.DatabaseGuid, amServerName, amBcsChecks);
            }
            else
            {
                AmTrace.Error("BCS: FindNextBestCopy: DatabaseCopy: '{0}\\{1}'. Checks returned error: {2}", new object[]
                {
                    this.m_bcsContext.GetDatabaseNameOrGuid(),
                    this.m_targetServerName.NetbiosName,
                    error
                });
                AmBcsServerFailureLogger amBcsServerFailureLogger2 = this.m_bcsContext.ErrorLogger as AmBcsServerFailureLogger;
                string concatenatedErrorString2 = amBcsServerFailureLogger2.GetConcatenatedErrorString();
                this.m_lastException = new AmBcsSingleCopyValidationException(concatenatedErrorString2);
                ReplayCrimsonEvents.BcsDbMoveChecksFailed.Log <string, Guid, AmServerName, AmBcsChecks, LocalizedString>(this.m_bcsContext.GetDatabaseNameOrGuid(), this.m_bcsContext.DatabaseGuid, this.m_targetServerName, amBcsChecks, error);
            }
            return(amServerName);
        }