Ejemplo n.º 1
0
        // Token: 0x060000AB RID: 171 RVA: 0x00004F20 File Offset: 0x00003120
        protected override void RunInternal()
        {
            IADToplogyConfigurationSession iadtoplogyConfigurationSession = ADSessionFactory.CreateIgnoreInvalidRootOrgSession(true);
            IADServer iadserver = iadtoplogyConfigurationSession.FindServerByName(this.m_nodeName.NetbiosName);

            if (iadserver == null)
            {
                throw new ServerNotFoundException(this.m_nodeName.NetbiosName);
            }
            IADDatabase[] array = iadtoplogyConfigurationSession.GetAllDatabases(iadserver).ToArray <IADDatabase>();
            if (array.Length <= 0)
            {
                AmTrace.Info("Server '{0}' does not have any databases that needs to be marked as dismounted", new object[]
                {
                    this.m_nodeName
                });
                return;
            }
            AmDbActionCode actionCode = new AmDbActionCode(AmDbActionInitiator.Automatic, this.m_reasonCode, AmDbActionCategory.SyncState);

            foreach (IADDatabase db in array)
            {
                AmDbClusterDatabaseSyncOperation operation = new AmDbClusterDatabaseSyncOperation(db, actionCode);
                this.m_clusDbSyncRequests++;
                base.EnqueueDatabaseOperation(operation);
            }
            base.StartDatabaseOperations();
        }
        // Token: 0x0600008D RID: 141 RVA: 0x00004904 File Offset: 0x00002B04
        private bool IsActiveOnServer(IADDatabase db, AmServerName movingFromServer, out LocalizedString skipReason)
        {
            bool          result        = false;
            AmDbStateInfo amDbStateInfo = this.m_amConfig.DbState.Read(db.Guid);

            if (amDbStateInfo.IsEntryExist)
            {
                if (AmServerName.IsEqual(movingFromServer, amDbStateInfo.ActiveServer))
                {
                    result     = true;
                    skipReason = LocalizedString.Empty;
                }
                else
                {
                    AmTrace.Info("IsActiveOnServer: Excluding database {0} from moving since it is not active on {1} (active={2})", new object[]
                    {
                        db.Name,
                        movingFromServer,
                        amDbStateInfo.ActiveServer
                    });
                    skipReason = ReplayStrings.DbMoveSkippedBecauseNotActive(db.Name, movingFromServer.NetbiosName, amDbStateInfo.ActiveServer.NetbiosName);
                }
            }
            else
            {
                AmTrace.Error("IsActiveOnServer: Failed to find db state info from clusdb (db={0})", new object[]
                {
                    db.Name
                });
                skipReason = ReplayStrings.DbMoveSkippedBecauseNotFoundInClusDb(db.Name);
            }
            return(result);
        }
        // Token: 0x0600005E RID: 94 RVA: 0x00003118 File Offset: 0x00001318
        private bool ShouldConsiderMdbStatus(AmMdbStatusServerInfo serverInfo, MdbStatus[] mdbStatuses)
        {
            bool flag = false;

            if (mdbStatuses != null)
            {
                if (RegistryParameters.IsTransientFailoverSuppressionEnabled)
                {
                    if (serverInfo.IsNodeUp)
                    {
                        flag = true;
                    }
                    else if (serverInfo.IsReplayRunning)
                    {
                        flag = true;
                    }
                }
                else
                {
                    flag = serverInfo.IsNodeUp;
                }
            }
            AmTrace.Info("ShouldConsiderMdbStatus: ServerName: {0}, IsConsider: {1}, IsStoreRunning: {2}, MountedDbCount: {3}, IsNodeUp: {4}, IsReplayRunning: {5}, IsTimedout: {6}", new object[]
            {
                serverInfo.ServerName,
                flag,
                serverInfo.IsStoreRunning,
                (mdbStatuses != null) ? mdbStatuses.Length : -1,
                serverInfo.IsNodeUp,
                serverInfo.IsReplayRunning,
                serverInfo.TimeOut
            });
            return(flag);
        }
Ejemplo n.º 4
0
        private bool RunChecksWrapper(AmBcsChecks checks, out AmServerName selectedCopy, AmServerName targetServer, RpcDatabaseCopyStatus2 copyStatus)
        {
            LocalizedString empty = LocalizedString.Empty;

            selectedCopy = null;
            AmBcsChecks amBcsChecks;
            bool        flag = this.RunChecks(this.m_bcsContext.SourceServerName, targetServer, copyStatus, checks, out amBcsChecks, ref empty);

            if (flag)
            {
                AmTrace.Info("BCS: DatabaseCopy '{0}' on server '{1}' passed checks: {2}", new object[]
                {
                    this.m_bcsContext.GetDatabaseNameOrGuid(),
                    targetServer,
                    checks
                });
                selectedCopy = targetServer;
                ReplayCrimsonEvents.BcsDbNodeChecksPassed.Log <string, Guid, AmServerName, AmBcsChecks>(this.m_bcsContext.GetDatabaseNameOrGuid(), this.m_bcsContext.DatabaseGuid, targetServer, amBcsChecks);
            }
            else
            {
                AmTrace.Error("BCS: DatabaseCopy '{0}' on server '{1}' failed checks: {2}", new object[]
                {
                    this.m_bcsContext.GetDatabaseNameOrGuid(),
                    targetServer,
                    checks
                });
            }
            return(flag);
        }
Ejemplo n.º 5
0
        // Token: 0x06000079 RID: 121 RVA: 0x00003F04 File Offset: 0x00002104
        protected override void RunInternal()
        {
            HashSet <AmServerName> hashSet = new HashSet <AmServerName>();

            this.mdbStatusFetcher = base.StartMdbStatusFetcher();
            Dictionary <Guid, DatabaseInfo> dictionary = null;

            dictionary = this.GenerateDatabaseInfoMapFromPrevious();
            this.mdbStatusFetcher.WaitUntilStatusIsReady();
            foreach (DatabaseInfo databaseInfo in dictionary.Values)
            {
                if (!databaseInfo.Database.AutoDagExcludeFromMonitoring)
                {
                    AmServerName item = new AmServerName(databaseInfo.Database.Server.Name);
                    if (!hashSet.Contains(item))
                    {
                        hashSet.Add(item);
                    }
                }
                else
                {
                    AmTrace.Info("Database '{0}' has the AutoDagExcludeFromMonitoring flag set hence excluding it from remote store monitoring resultset", new object[]
                    {
                        databaseInfo.Database.Name
                    });
                }
            }
            if (hashSet.Count > 0)
            {
                this.RaiseStoreNotificationEvent(hashSet);
            }
            Dictionary <AmServerName, MdbStatus[]> mdbStatusMap = this.mdbStatusFetcher.MdbStatusMap;

            if (mdbStatusMap == null)
            {
                ReplayEventLogConstants.Tuple_PeriodicOperationFailedRetrievingStatuses.LogEvent(null, new object[]
                {
                    "AmPeriodicDatabaseStateRestorer"
                });
                return;
            }
            base.MergeDatabaseInfoWithMdbStatus(dictionary, mdbStatusMap, this.mdbStatusFetcher.ServerInfoMap);
            this.DetermineDatabaseOperations(dictionary);
            base.EnqueueGeneratedOperations(dictionary);
        }
 // Token: 0x06000089 RID: 137 RVA: 0x00004658 File Offset: 0x00002858
 protected void MoveDatabases(AmDbActionCode actionCode, IADDatabase[] dbList)
 {
     if (dbList == null || dbList.Length <= 0)
     {
         AmTrace.Info("Server '{0}' does not have any databases that need to be moved", new object[]
         {
             this.m_nodeName
         });
         return;
     }
     if (!this.m_amConfig.DagConfig.IsThirdPartyReplEnabled)
     {
         ThreadPoolThreadCountHelper.IncreaseForDatabaseOperations(dbList.Length);
         this.MoveDatabasesNormally(actionCode, dbList);
         return;
     }
     this.SendThirdPartyNotifications(dbList);
 }
Ejemplo n.º 7
0
        // Token: 0x06000437 RID: 1079 RVA: 0x000165F0 File Offset: 0x000147F0
        protected override bool ReadInternal(string guidStr, out string stateInfoStr)
        {
            bool   result = false;
            object obj    = null;

            try
            {
                obj = this.m_regDbHandle.GetValue(guidStr);
                if (obj == null)
                {
                    AmTrace.Info("Subkeys count = {0}", new object[]
                    {
                        this.m_regDbHandle.SubKeyCount
                    });
                }
            }
            catch (IOException ex)
            {
                int hrforException = Marshal.GetHRForException(ex);
                AmTrace.Error("ReadInternal({0}): m_regDbHandle.GetValue failed with error {1} (hr={2})", new object[]
                {
                    guidStr,
                    ex.Message,
                    hrforException
                });
                if (hrforException != 1018)
                {
                    throw new AmRegistryException("m_regDbHandle.GetValue", ex);
                }
                throw;
            }
            if (obj != null)
            {
                stateInfoStr = (string)obj;
                result       = true;
            }
            else
            {
                stateInfoStr = null;
            }
            return(result);
        }
        // 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);
        }
Ejemplo n.º 9
0
        // Token: 0x06000495 RID: 1173 RVA: 0x00018778 File Offset: 0x00016978
        internal static void Mount(Guid mdbGuid, MountFlags flags)
        {
            bool flag = false;

            using (IStoreRpc newStoreControllerInstance = Dependencies.GetNewStoreControllerInstance(null))
            {
                Stopwatch stopwatch = new Stopwatch();
                stopwatch.Start();
                bool isCheckDbStatus = true;
                bool flag2           = false;
                for (;;)
                {
                    ReplayCrimsonEvents.MountStoreRpcInitiated.Log <Guid, MountFlags>(mdbGuid, flags);
                    Exception ex = null;
                    try
                    {
                        try
                        {
                            newStoreControllerInstance.MountDatabase(Guid.Empty, mdbGuid, (int)flags);
                            AmTrace.Info("rpcAdmin.MountDatabase({0}) successful.", new object[]
                            {
                                mdbGuid
                            });
                            isCheckDbStatus = false;
                            flag2           = true;
                            break;
                        }
                        catch (MapiExceptionMountInProgress mapiExceptionMountInProgress)
                        {
                            ex = mapiExceptionMountInProgress;
                            AmTrace.Error("rpcAdmin.MountDatabase({0}) encountered {1}.", new object[]
                            {
                                mdbGuid,
                                mapiExceptionMountInProgress.Message
                            });
                            if (!flag)
                            {
                                ReplayCrimsonEvents.MountDelayedUntilPreviousOperationIsComplete.Log <Guid, string>(mdbGuid, mapiExceptionMountInProgress.Message);
                                flag = true;
                            }
                            if (stopwatch.Elapsed > AmStoreHelper.defaultMapiConflictTimeout)
                            {
                                throw;
                            }
                            if (AmHelper.SleepUntilShutdown(AmStoreHelper.defaultMapiConflictRetryInterval))
                            {
                                AmTrace.Debug("shutdown requested - hence not retrying mount for database {0}", new object[]
                                {
                                    mdbGuid
                                });
                                throw;
                            }
                        }
                        catch (MapiPermanentException ex2)
                        {
                            ex = ex2;
                            throw;
                        }
                        catch (MapiRetryableException ex3)
                        {
                            ex = ex3;
                            throw;
                        }
                        continue;
                    }
                    finally
                    {
                        if (flag2)
                        {
                            ReplayCrimsonEvents.MountStoreRpcSucceeded.Log <Guid>(mdbGuid);
                        }
                        else if (ex == null || !(ex is MapiExceptionMountInProgress))
                        {
                            ReplayCrimsonEvents.MountStoreRpcFailed.Log <Guid, string, Exception>(mdbGuid, (ex != null) ? ex.Message : null, ex);
                        }
                        AmStoreHelper.UpdateIsMountedCounterNoDatabaseCache(mdbGuid, null, flag2, isCheckDbStatus);
                    }
                    break;
                }
            }
        }
Ejemplo n.º 10
0
        // Token: 0x06000498 RID: 1176 RVA: 0x000189B0 File Offset: 0x00016BB0
        internal static void RemoteDismount(AmServerName serverName, Guid mdbGuid, UnmountFlags flags, bool retryOnConflict)
        {
            bool      isCheckDbStatus = true;
            bool      isMounted       = true;
            Exception ex = null;

            try
            {
                AmTrace.Debug("RemoteDismount() starting for DB {0} on server {1}. UnmountFlags = {2}, retryOnConflict = {3}", new object[]
                {
                    mdbGuid,
                    serverName,
                    flags,
                    retryOnConflict
                });
                ReplayCrimsonEvents.DismountStoreRpcInitiated.Log <AmServerName, Guid, UnmountFlags, bool>(serverName, mdbGuid, flags, retryOnConflict);
                using (IStoreMountDismount storeMountDismountInstance = Dependencies.GetStoreMountDismountInstance(AmServerName.IsNullOrEmpty(serverName) ? null : serverName.Fqdn))
                {
                    if (!retryOnConflict)
                    {
                        storeMountDismountInstance.UnmountDatabase(Guid.Empty, mdbGuid, (int)flags);
                        isCheckDbStatus = false;
                        isMounted       = false;
                        AmTrace.Info("rpcAdmin.UnmountDatabase({0}) successful.", new object[]
                        {
                            mdbGuid
                        });
                    }
                    else
                    {
                        bool      flag      = false;
                        Stopwatch stopwatch = new Stopwatch();
                        stopwatch.Start();
                        for (;;)
                        {
                            try
                            {
                                storeMountDismountInstance.UnmountDatabase(Guid.Empty, mdbGuid, (int)flags);
                                isCheckDbStatus = false;
                                isMounted       = false;
                                AmTrace.Info("rpcAdmin.UnmountDatabase({0}) successful.", new object[]
                                {
                                    mdbGuid
                                });
                            }
                            catch (MapiRetryableException ex2)
                            {
                                AmTrace.Error("rpcAdmin.UnmountDatabase({0}) encountered {1}.", new object[]
                                {
                                    mdbGuid,
                                    ex2.Message
                                });
                                if (!(ex2 is MapiExceptionDismountInProgress))
                                {
                                    throw;
                                }
                                if (!flag)
                                {
                                    ReplayCrimsonEvents.DismountDelayedUntilPreviousOperationIsComplete.Log <Guid, string>(mdbGuid, ex2.Message);
                                    flag = true;
                                }
                                if (stopwatch.Elapsed > AmStoreHelper.defaultMapiConflictTimeout)
                                {
                                    throw;
                                }
                                if (AmHelper.SleepUntilShutdown(AmStoreHelper.defaultMapiConflictRetryInterval))
                                {
                                    AmTrace.Debug("shutdown requested - hence not retrying dismount for database {0}", new object[]
                                    {
                                        mdbGuid
                                    });
                                    throw;
                                }
                                continue;
                            }
                            break;
                        }
                    }
                }
            }
            catch (MapiPermanentException ex3)
            {
                ex = ex3;
                AmTrace.Debug("Dismount encountered exception {0}", new object[]
                {
                    ex3.Message
                });
                if (!AmStoreHelper.IsMapiExceptionDueToDatabaseDismounted(ex3))
                {
                    throw;
                }
            }
            catch (MapiRetryableException ex4)
            {
                ex = ex4;
                AmTrace.Debug("Dismount encountered exception {0}", new object[]
                {
                    ex4.Message
                });
                if (!AmStoreHelper.IsMapiExceptionDueToDatabaseDismounted(ex4))
                {
                    throw;
                }
            }
            finally
            {
                ReplayCrimsonEvents.DismountStoreRpcFinished.Log <AmServerName, Guid, string>(serverName, mdbGuid, (ex != null) ? ex.Message : "<none>");
                if (AmServerName.IsNullOrEmpty(serverName) || AmServerName.IsEqual(AmServerName.LocalComputerName, serverName))
                {
                    AmStoreHelper.UpdateIsMountedCounterNoDatabaseCache(mdbGuid, null, isMounted, isCheckDbStatus);
                }
            }
        }