Exemplo n.º 1
0
 private void UpdateAdProperties(bool isOperationSuccess, AmServerName initialActiveServer)
 {
     if (!AmServerName.IsNullOrEmpty(base.State.ActiveServer))
     {
         bool isForceUpdate = !AmServerName.IsEqual(initialActiveServer, base.State.ActiveServer);
         if (isOperationSuccess || isForceUpdate)
         {
             base.DbTrace.Debug("Issuing async SetDatabaseLegacyDnAndOwningServer", new object[0]);
             ThreadPool.QueueUserWorkItem(delegate(object param0)
             {
                 Exception ex = SharedHelper.RunADOperationEx(delegate(object param0, EventArgs param1)
                 {
                     SharedDependencies.WritableADHelper.SetDatabaseLegacyDnAndOwningServer(this.DatabaseGuid, initialActiveServer, this.State.ActiveServer, isForceUpdate);
                 });
                 if (ex != null)
                 {
                     this.DbTrace.Error("SetDatabaseLegacyDnAndOwningServer failed: {0}", new object[]
                     {
                         ex
                     });
                 }
             });
             return;
         }
     }
     else
     {
         AmTrace.Error("Skipped updating ad properties for database {0} since active server is empty", new object[]
         {
             base.DatabaseName
         });
     }
 }
Exemplo n.º 2
0
        public static HungNodesInfo GetNodesHungInClusDbUpdate()
        {
            HungNodesInfo result  = null;
            TimeSpan      timeout = TimeSpan.FromSeconds((double)RegistryParameters.OpenClusterTimeoutInSec);

            using (AmCluster amCluster = AmCluster.OpenByName(AmServerName.LocalComputerName, timeout, string.Empty))
            {
                int          num = 0;
                AmServerName currentGumLockOwnerInfo = amCluster.GetCurrentGumLockOwnerInfo(out num);
                if (!AmServerName.IsNullOrEmpty(currentGumLockOwnerInfo))
                {
                    Thread.Sleep(RegistryParameters.ClusdbHungNodesConfirmDurationInMSec);
                    string context = string.Format("GUM={0}", num);
                    using (AmCluster amCluster2 = AmCluster.OpenByName(currentGumLockOwnerInfo, timeout, context))
                    {
                        using (IAmClusterNode amClusterNode = amCluster2.OpenNode(currentGumLockOwnerInfo))
                        {
                            int  num2          = 0;
                            long hungNodesMask = amClusterNode.GetHungNodesMask(out num2);
                            if (num != num2)
                            {
                                throw new HungDetectionGumIdChangedException(num, num2, currentGumLockOwnerInfo.ToString(), hungNodesMask);
                            }
                            result = new HungNodesInfo(num, currentGumLockOwnerInfo, hungNodesMask);
                        }
                    }
                }
            }
            return(result);
        }
Exemplo n.º 3
0
        // Token: 0x06000816 RID: 2070 RVA: 0x000272D8 File Offset: 0x000254D8
        internal void GenerateMapiExceptionIfRequired(Guid dbGuid, AmServerName serverName)
        {
            if (!this.IsEnabled)
            {
                return;
            }
            int num = 0;

            this.ReadDbOperationProperty <int>(dbGuid, serverName, "GenerateMapiError", out num, 0);
            if (num == 0)
            {
                return;
            }
            AmTrace.Debug("AmInject: GenerateMapiError enabled for {0},{1}", new object[]
            {
                dbGuid,
                AmServerName.IsNullOrEmpty(serverName) ? "<null>" : serverName.NetbiosName
            });
            int  num2  = 0;
            int  num3  = 0;
            bool flag  = this.ReadDbOperationProperty <int>(dbGuid, serverName, "MapiHResult", out num2, 0);
            bool flag2 = this.ReadDbOperationProperty <int>(dbGuid, serverName, "MapiLowLevelError", out num3, 0);

            if (flag && flag2)
            {
                AmTrace.Debug("AmInject: Generating mapi exception (hr={0}, ec={1})", new object[]
                {
                    num2,
                    num3
                });
                MapiExceptionHelper.ThrowIfError(string.Format("Database operation failed with Mapi error. (hr={0}, ec={1})", num2, num3), num2, num3);
            }
        }
Exemplo n.º 4
0
        // Token: 0x06000817 RID: 2071 RVA: 0x000273B0 File Offset: 0x000255B0
        internal bool ReadDbOperationProperty <T>(Guid dbGuid, AmServerName serverName, string propertyName, out T foundValue, T defaultValue)
        {
            string str   = "Software\\Microsoft\\Exchange\\ActiveManager\\FaultInject";
            string text  = str + "\\" + dbGuid.ToString();
            string text2 = string.Empty;

            if (!AmServerName.IsNullOrEmpty(serverName))
            {
                text2 = text + "\\" + serverName.NetbiosName;
            }
            bool flag = false;

            foundValue = defaultValue;
            if (!string.IsNullOrEmpty(text2))
            {
                flag = this.ReadProperty <T>(text2, propertyName, out foundValue, defaultValue);
            }
            if (!flag)
            {
                flag = this.ReadProperty <T>(text, propertyName, out foundValue, defaultValue);
            }
            if (!flag)
            {
                flag = this.ReadProperty <T>("Software\\Microsoft\\Exchange\\ActiveManager\\FaultInject", propertyName, out foundValue, defaultValue);
            }
            return(flag);
        }
 // Token: 0x06000729 RID: 1833 RVA: 0x000230DC File Offset: 0x000212DC
 private bool TargetHasBeenTried(ref LocalizedString error)
 {
     if (!AmServerName.IsNullOrEmpty(this.m_serverAlreadyTried))
     {
         AmTrace.Debug("BCS: Target server '{0}' has already been tried for database '{1}'.", new object[]
         {
             this.m_serverAlreadyTried.NetbiosName,
             this.m_bcsContext.GetDatabaseNameOrGuid()
         });
         error = ReplayStrings.AmBcsDatabaseCopyAlreadyTried(this.m_bcsContext.GetDatabaseNameOrGuid(), this.m_serverAlreadyTried.ToString());
         return(true);
     }
     return(false);
 }
        // Token: 0x0600049E RID: 1182 RVA: 0x00018D14 File Offset: 0x00016F14
        internal static MdbStatus GetMdbStatus(AmServerName serverName, Guid mdbGuid, string clientTypeId, TimeSpan?timeout, out Exception exception)
        {
            MdbStatus result = null;

            exception = null;
            string text = AmServerName.IsNullOrEmpty(serverName) ? null : serverName.Fqdn;

            try
            {
                using (IListMDBStatus storeListMDBStatusInstance = Dependencies.GetStoreListMDBStatusInstance(text, clientTypeId))
                {
                    MdbStatus[] array = storeListMDBStatusInstance.ListMdbStatus(new Guid[]
                    {
                        mdbGuid
                    }, timeout);
                    if (array != null && array.Length > 0)
                    {
                        result = array[0];
                    }
                }
            }
            catch (MapiPermanentException ex)
            {
                AmTrace.Error("Caught exception in GetMdbStatus({0}, {1}): {2}", new object[]
                {
                    text,
                    mdbGuid,
                    ex.Message
                });
                exception = ex;
            }
            catch (MapiRetryableException ex2)
            {
                AmTrace.Error("Caught exception in GetMdbStatus({0}, {1}): {2}", new object[]
                {
                    text,
                    mdbGuid,
                    ex2.Message
                });
                exception = ex2;
            }
            return(result);
        }
        // Token: 0x060004A0 RID: 1184 RVA: 0x00018F04 File Offset: 0x00017104
        internal static bool IsStoreRunning(AmServerName serverName)
        {
            bool   flag = false;
            string text = AmServerName.IsNullOrEmpty(serverName) ? null : serverName.Fqdn;

            using (IStoreRpc newStoreControllerInstance = Dependencies.GetNewStoreControllerInstance(text))
            {
                LocalizedException ex;
                flag = newStoreControllerInstance.TestStoreConnectivity(newStoreControllerInstance.ConnectivityTimeout, out ex);
                if (!flag)
                {
                    AmTrace.Error("Ignoring exception in IsStoreRunning({0}): {1}", new object[]
                    {
                        text,
                        ex.Message
                    });
                }
            }
            return(flag);
        }
Exemplo n.º 8
0
        public static Dictionary <int, AmServerName> GenerateHungNodeMap(long hungNodesMask)
        {
            Dictionary <int, AmServerName> dictionary = new Dictionary <int, AmServerName>(64);

            foreach (int num in AmClusterNode.GetNodeIdsFromNodeMask(hungNodesMask))
            {
                AmServerName nameById = AmClusterNode.GetNameById(num);
                if (!AmServerName.IsNullOrEmpty(nameById))
                {
                    dictionary[num] = nameById;
                }
                else
                {
                    AmTrace.Error("Failed to map nodeId {0} to node name", new object[]
                    {
                        num
                    });
                }
            }
            return(dictionary);
        }
Exemplo n.º 9
0
 private void CheckIfMoveApplicableForDatabase(AmServerName activeServer, AmServerName moveFromServer, AmDbActionCode actionCode)
 {
     if (base.Database.ReplicationType != ReplicationType.Remote)
     {
         AmTrace.Debug("Move ignored for database {0} since it is not replicated.", new object[]
         {
             base.DatabaseName
         });
         throw new AmDbMoveOperationNotSupportedException(base.DatabaseName);
     }
     if (!AmServerName.IsNullOrEmpty(moveFromServer))
     {
         if (!AmServerName.IsEqual(activeServer, moveFromServer))
         {
             AmTrace.Diagnostic("Move ignored for database {0} since the master server is different from the server that originally initiated the failover. (master={1}, movedInitiatedFrom={2})", new object[]
             {
                 base.DatabaseName,
                 activeServer,
                 moveFromServer
             });
             throw new AmDbMoveOperationNoLongerApplicableException(base.DatabaseName, moveFromServer.NetbiosName, activeServer.NetbiosName);
         }
         if (actionCode.Reason == AmDbActionReason.TimeoutFailure)
         {
             bool flag = AmStoreHelper.IsMounted(moveFromServer, base.DatabaseGuid);
             if (flag)
             {
                 throw new AmDbMoveOperationOnTimeoutFailureCancelled(base.DatabaseName, moveFromServer.NetbiosName);
             }
         }
     }
     if (base.Config.DagConfig.MemberServers.Length < 2)
     {
         AmTrace.Diagnostic("Move ignored for database {0} since according to active manager there is just one server in the DAG)", new object[]
         {
             base.DatabaseName
         });
         throw new AmDbMoveOperationNotSupportedException(base.DatabaseName);
     }
 }
Exemplo n.º 10
0
        public AmServerName FindNextBestCopy()
        {
            AmServerName amServerName = null;
            AmBcsChecks  amBcsChecks  = AmBcsChecks.None;

            try
            {
                this.Initialize();
                List <AmBcsChecks> list = new List <AmBcsChecks>
                {
                    AmBcsChecks.ManagedAvailabilityAllHealthy,
                    AmBcsChecks.ManagedAvailabilityUptoNormalHealthy,
                    AmBcsChecks.ManagedAvailabilityAllBetterThanSource,
                    AmBcsChecks.ManagedAvailabilitySameAsSource
                };
                if (!this.m_bcsContext.ActionCode.IsAutomaticManagedAvailabilityFailover)
                {
                    list.Add(AmBcsChecks.None);
                }
                else
                {
                    amBcsChecks = AmBcsChecks.ManagedAvailabilityInitiatorBetterThanSource;
                }
                if (this.m_bcsContext.DatabaseNeverMounted)
                {
                    AmTrace.Debug("FindNextBestCopy: Database '{0}' has never been mounted. Running non-status related checks.", new object[]
                    {
                        this.m_bcsContext.GetDatabaseNameOrGuid()
                    });
                    if (amServerName == null)
                    {
                        amServerName = this.RunPhaseN(AmBcsChecks.IsPassiveCopy);
                    }
                }
                else
                {
                    if (this.m_bcsContext.ActionCode.IsAdminMoveOperation)
                    {
                        AmBcsChecks amBcsChecks2 = AmBcsChecks.IsHealthyOrDisconnected | AmBcsChecks.IsCatalogStatusHealthy | AmBcsChecks.CopyQueueLength | AmBcsChecks.ReplayQueueLength | AmBcsChecks.IsPassiveCopy | AmBcsChecks.IsSeedingSource | AmBcsChecks.TotalQueueLengthMaxAllowed | AmBcsChecks.ActivationEnabled | AmBcsChecks.MaxActivesUnderPreferredLimit;
                        AmBcsChecks amBcsChecks3 = AmBcsChecks.IsHealthyOrDisconnected | AmBcsChecks.CopyQueueLength | AmBcsChecks.ReplayQueueLength | AmBcsChecks.IsCatalogStatusCrawling | AmBcsChecks.IsPassiveCopy | AmBcsChecks.IsSeedingSource | AmBcsChecks.TotalQueueLengthMaxAllowed | AmBcsChecks.ActivationEnabled | AmBcsChecks.MaxActivesUnderPreferredLimit;
                        using (List <AmBcsChecks> .Enumerator enumerator = list.GetEnumerator())
                        {
                            while (enumerator.MoveNext())
                            {
                                AmBcsChecks amBcsChecks4 = enumerator.Current;
                                AmBcsChecks amBcsChecks5 = amBcsChecks4 | amBcsChecks;
                                if (amServerName == null)
                                {
                                    AmBcsChecks amBcsChecks6 = amBcsChecks2 | amBcsChecks5;
                                    AmTrace.Debug("FindNextBestCopy: IsAdminMoveOperation='true', so first attempting '{0}' checks.", new object[]
                                    {
                                        amBcsChecks6
                                    });
                                    amServerName = this.RunPhaseN(amBcsChecks6);
                                }
                                if (amServerName == null)
                                {
                                    AmBcsChecks amBcsChecks7 = amBcsChecks3 | amBcsChecks5;
                                    AmTrace.Debug("FindNextBestCopy: IsAdminMoveOperation='true', so second attempting '{0}' checks.", new object[]
                                    {
                                        amBcsChecks7
                                    });
                                    amServerName = this.RunPhaseN(amBcsChecks7);
                                }
                                if (amServerName != null)
                                {
                                    break;
                                }
                            }
                            goto IL_2FA;
                        }
                    }
                    if (this.m_bcsContext.ActionCode.Reason == AmDbActionReason.CatalogFailureItem)
                    {
                        AmTrace.Debug("FindNextBestCopy: Catalog induced failover, so a healthy catalog must be found", new object[0]);
                        using (List <AmBcsChecks> .Enumerator enumerator2 = list.GetEnumerator())
                        {
                            while (enumerator2.MoveNext())
                            {
                                AmBcsChecks amBcsChecks8 = enumerator2.Current;
                                if (amServerName == null)
                                {
                                    amServerName = this.RunPhaseN(AmBcsChecks.IsHealthyOrDisconnected | AmBcsChecks.IsCatalogStatusHealthy | AmBcsChecks.CopyQueueLength | AmBcsChecks.ReplayQueueLength | AmBcsChecks.IsPassiveCopy | AmBcsChecks.IsSeedingSource | AmBcsChecks.TotalQueueLengthMaxAllowed | AmBcsChecks.ActivationEnabled | AmBcsChecks.MaxActivesUnderPreferredLimit | amBcsChecks8);
                                }
                                if (amServerName == null)
                                {
                                    amServerName = this.RunPhaseN(AmBcsChecks.IsHealthyOrDisconnected | AmBcsChecks.IsCatalogStatusHealthy | AmBcsChecks.ReplayQueueLength | AmBcsChecks.IsPassiveCopy | AmBcsChecks.IsSeedingSource | AmBcsChecks.TotalQueueLengthMaxAllowed | AmBcsChecks.ActivationEnabled | AmBcsChecks.MaxActivesUnderPreferredLimit | amBcsChecks8);
                                }
                                if (amServerName == null)
                                {
                                    amServerName = this.RunPhaseN(AmBcsChecks.IsHealthyOrDisconnected | AmBcsChecks.IsCatalogStatusHealthy | AmBcsChecks.CopyQueueLength | AmBcsChecks.IsPassiveCopy | AmBcsChecks.TotalQueueLengthMaxAllowed | AmBcsChecks.ActivationEnabled | AmBcsChecks.MaxActivesUnderHighestLimit | amBcsChecks8);
                                }
                                if (amServerName == null)
                                {
                                    amServerName = this.RunPhaseN(AmBcsChecks.IsHealthyOrDisconnected | AmBcsChecks.IsCatalogStatusHealthy | AmBcsChecks.IsPassiveCopy | AmBcsChecks.TotalQueueLengthMaxAllowed | AmBcsChecks.ActivationEnabled | AmBcsChecks.MaxActivesUnderHighestLimit | amBcsChecks8);
                                }
                                if (amServerName != null)
                                {
                                    break;
                                }
                            }
                            goto IL_2FA;
                        }
                    }
                    foreach (AmBcsChecks amBcsChecks9 in list)
                    {
                        AmBcsChecks amBcsChecks10 = amBcsChecks9 | amBcsChecks;
                        if (amServerName == null)
                        {
                            amServerName = this.RunPhaseN(AmBcsChecks.IsHealthyOrDisconnected | AmBcsChecks.IsCatalogStatusHealthy | AmBcsChecks.CopyQueueLength | AmBcsChecks.ReplayQueueLength | AmBcsChecks.IsPassiveCopy | AmBcsChecks.IsSeedingSource | AmBcsChecks.TotalQueueLengthMaxAllowed | AmBcsChecks.ActivationEnabled | AmBcsChecks.MaxActivesUnderPreferredLimit | amBcsChecks10);
                        }
                        if (amServerName == null)
                        {
                            amServerName = this.RunPhaseN(AmBcsChecks.IsHealthyOrDisconnected | AmBcsChecks.CopyQueueLength | AmBcsChecks.ReplayQueueLength | AmBcsChecks.IsCatalogStatusCrawling | AmBcsChecks.IsPassiveCopy | AmBcsChecks.IsSeedingSource | AmBcsChecks.TotalQueueLengthMaxAllowed | AmBcsChecks.ActivationEnabled | AmBcsChecks.MaxActivesUnderPreferredLimit | amBcsChecks10);
                        }
                        if (amServerName == null)
                        {
                            amServerName = this.RunPhaseN(AmBcsChecks.IsHealthyOrDisconnected | AmBcsChecks.IsCatalogStatusHealthy | AmBcsChecks.ReplayQueueLength | AmBcsChecks.IsPassiveCopy | AmBcsChecks.IsSeedingSource | AmBcsChecks.TotalQueueLengthMaxAllowed | AmBcsChecks.ActivationEnabled | AmBcsChecks.MaxActivesUnderPreferredLimit | amBcsChecks10);
                        }
                        if (amServerName == null)
                        {
                            amServerName = this.RunPhaseN(AmBcsChecks.IsHealthyOrDisconnected | AmBcsChecks.ReplayQueueLength | AmBcsChecks.IsCatalogStatusCrawling | AmBcsChecks.IsPassiveCopy | AmBcsChecks.IsSeedingSource | AmBcsChecks.TotalQueueLengthMaxAllowed | AmBcsChecks.ActivationEnabled | AmBcsChecks.MaxActivesUnderPreferredLimit | amBcsChecks10);
                        }
                        if (amServerName == null)
                        {
                            amServerName = this.RunPhaseN(AmBcsChecks.IsHealthyOrDisconnected | AmBcsChecks.ReplayQueueLength | AmBcsChecks.IsPassiveCopy | AmBcsChecks.IsSeedingSource | AmBcsChecks.TotalQueueLengthMaxAllowed | AmBcsChecks.ActivationEnabled | AmBcsChecks.MaxActivesUnderHighestLimit | amBcsChecks10);
                        }
                        if (amServerName == null)
                        {
                            amServerName = this.RunPhaseN(AmBcsChecks.IsHealthyOrDisconnected | AmBcsChecks.IsCatalogStatusHealthy | AmBcsChecks.CopyQueueLength | AmBcsChecks.IsPassiveCopy | AmBcsChecks.TotalQueueLengthMaxAllowed | AmBcsChecks.ActivationEnabled | AmBcsChecks.MaxActivesUnderHighestLimit | amBcsChecks10);
                        }
                        if (amServerName == null)
                        {
                            amServerName = this.RunPhaseN(AmBcsChecks.IsHealthyOrDisconnected | AmBcsChecks.CopyQueueLength | AmBcsChecks.IsCatalogStatusCrawling | AmBcsChecks.IsPassiveCopy | AmBcsChecks.TotalQueueLengthMaxAllowed | AmBcsChecks.ActivationEnabled | AmBcsChecks.MaxActivesUnderHighestLimit | amBcsChecks10);
                        }
                        if (amServerName == null)
                        {
                            amServerName = this.RunPhaseN(AmBcsChecks.IsHealthyOrDisconnected | AmBcsChecks.IsCatalogStatusHealthy | AmBcsChecks.IsPassiveCopy | AmBcsChecks.TotalQueueLengthMaxAllowed | AmBcsChecks.ActivationEnabled | AmBcsChecks.MaxActivesUnderHighestLimit | amBcsChecks10);
                        }
                        if (amServerName == null)
                        {
                            amServerName = this.RunPhaseN(AmBcsChecks.IsHealthyOrDisconnected | AmBcsChecks.IsCatalogStatusCrawling | AmBcsChecks.IsPassiveCopy | AmBcsChecks.TotalQueueLengthMaxAllowed | AmBcsChecks.ActivationEnabled | AmBcsChecks.MaxActivesUnderHighestLimit | amBcsChecks10);
                        }
                        if (amServerName == null && amBcsChecks10 == AmBcsChecks.None)
                        {
                            amServerName = this.RunPhaseN(AmBcsChecks.IsHealthyOrDisconnected | AmBcsChecks.IsPassiveCopy | AmBcsChecks.TotalQueueLengthMaxAllowed | AmBcsChecks.MaxActivesUnderHighestLimit | amBcsChecks10);
                        }
                        if (amServerName != null)
                        {
                            break;
                        }
                    }
                }
                IL_2FA :;
            }
            finally
            {
                if (!AmServerName.IsNullOrEmpty(amServerName))
                {
                    this.AddAttemptedServer(amServerName);
                }
            }
            if (this.m_attemptedServers == null || this.m_attemptedServers.Count == 0)
            {
                AmTrace.Error("FindNextBestCopy: Database '{0}' has no possible copies for activation.", new object[]
                {
                    this.m_bcsContext.GetDatabaseNameOrGuid()
                });
                if (this.Context.ErrorLogger.GetLastException() == null)
                {
                    Exception ex = new AmDbNotMountedNoViableServersException(this.m_bcsContext.GetDatabaseNameOrGuid());
                    this.m_lastException = new AmBcsSelectionException(ex.Message, ex);
                }
            }
            return(amServerName);
        }
        // Token: 0x0600005D RID: 93 RVA: 0x00002EBC File Offset: 0x000010BC
        protected Dictionary <Guid, DatabaseInfo> GenerateDatabaseInfoMap()
        {
            Dictionary <Guid, DatabaseInfo> dictionary = new Dictionary <Guid, DatabaseInfo>();
            List <AmServerName>             servers    = this.GetServers();
            IADConfig adconfig = Dependencies.ADConfig;

            foreach (AmServerName amServerName in servers)
            {
                IADServer server = adconfig.GetServer(amServerName);
                if (server == null)
                {
                    AmTrace.Debug("Startup mount could not find server named {0} in AD", new object[]
                    {
                        amServerName
                    });
                }
                else
                {
                    IEnumerable <IADDatabase> databasesOnServer = adconfig.GetDatabasesOnServer(server);
                    if (databasesOnServer != null)
                    {
                        using (IEnumerator <IADDatabase> enumerator2 = databasesOnServer.GetEnumerator())
                        {
                            while (enumerator2.MoveNext())
                            {
                                IADDatabase  iaddatabase = enumerator2.Current;
                                DatabaseInfo databaseInfo;
                                if (!dictionary.TryGetValue(iaddatabase.Guid, out databaseInfo))
                                {
                                    AmDbStateInfo amDbStateInfo = this.m_amConfig.DbState.Read(iaddatabase.Guid);
                                    if (amDbStateInfo == null)
                                    {
                                        AmTrace.Error("Skipping database {0} since AmDbStateInfo is null", new object[]
                                        {
                                            iaddatabase.Name
                                        });
                                        continue;
                                    }
                                    if (this.IsSelectOnlyActives && !AmServerName.IsNullOrEmpty(amDbStateInfo.ActiveServer) && !amDbStateInfo.ActiveServer.Equals(amServerName))
                                    {
                                        AmTrace.Debug("Skipping database {0} since it is not active on {1}.", new object[]
                                        {
                                            iaddatabase.Name,
                                            amServerName
                                        });
                                        continue;
                                    }
                                    if (iaddatabase.Servers == null || iaddatabase.Servers.Length == 0 || iaddatabase.DatabaseCopies == null || iaddatabase.DatabaseCopies.Length == 0)
                                    {
                                        AmTrace.Error("Skipping database {0} since no copies were found.", new object[]
                                        {
                                            iaddatabase.Name
                                        });
                                        ReplayCrimsonEvents.AmBatchMounterIgnoresInvalidDatabase.LogPeriodic <Guid, string>(iaddatabase.Guid, TimeSpan.FromMinutes(30.0), iaddatabase.Guid, iaddatabase.Name);
                                        continue;
                                    }
                                    databaseInfo = new DatabaseInfo(iaddatabase, amDbStateInfo);
                                    dictionary[iaddatabase.Guid] = databaseInfo;
                                }
                                databaseInfo.StoreStatus[amServerName] = null;
                            }
                            continue;
                        }
                    }
                    AmTrace.Debug("Skipping server {0} for automounting since it does not have any database copies", new object[]
                    {
                        amServerName
                    });
                }
            }
            return(dictionary);
        }
Exemplo n.º 12
0
        internal void Move(MountFlags mountFlags, UnmountFlags dismountFlags, DatabaseMountDialOverride mountDialoverride, AmServerName fromServer, AmServerName targetServer, bool tryOtherHealthyServers, AmBcsSkipFlags skipValidationChecks, string moveComment, string componentName, ref AmDbOperationDetailedStatus moveStatus)
        {
            moveStatus = new AmDbOperationDetailedStatus(this.Database);
            Exception    ex   = null;
            bool         flag = true;
            AmServerName initialSourceServer = null;
            Stopwatch    stopwatch           = new Stopwatch();

            stopwatch.Start();
            string initialActive = string.Empty;
            AmDbOperationDetailedStatus tempStatus = moveStatus;

            try
            {
                using (AmDatabaseOperationLock.Lock(this.DatabaseGuid, AmDbLockReason.Move, null))
                {
                    ex = AmHelper.HandleKnownExceptions(delegate(object param0, EventArgs param1)
                    {
                        initialActive = this.GetSafeActiveServer();
                        ReplayCrimsonEvents.ToplevelMoveInitiated.LogGeneric(this.PrepareStartupArgs(new object[]
                        {
                            mountFlags,
                            dismountFlags,
                            mountDialoverride,
                            AmServerName.IsNullOrEmpty(fromServer) ? initialActive : fromServer.Fqdn,
                            targetServer,
                            tryOtherHealthyServers,
                            skipValidationChecks,
                            moveComment,
                            componentName
                        }));
                        initialSourceServer = this.State.ActiveServer;
                        this.EnsureAutomaticActionIsAllowed();
                        this.ClearFailureAttemptIfAdminAction(this.DatabaseGuid);
                        this.MoveInternal(mountFlags, dismountFlags, mountDialoverride, fromServer, targetServer, tryOtherHealthyServers, skipValidationChecks, componentName, ref tempStatus);
                    });
                    this.WriteStateClearIfInProgressStatus(true);
                    flag = false;
                }
            }
            catch (AmDbLockConflictException ex2)
            {
                ex = ex2;
            }
            finally
            {
                stopwatch.Stop();
                moveStatus = tempStatus;
                if (flag || ex != null)
                {
                    string text = (ex != null) ? ex.Message : ReplayStrings.UnknownError;
                    ReplayCrimsonEvents.ToplevelMoveFailed.LogGeneric(this.PrepareCompletionArgs(new object[]
                    {
                        initialActive,
                        stopwatch.Elapsed,
                        text,
                        moveComment
                    }));
                    if (AmServerName.IsNullOrEmpty(targetServer))
                    {
                        ReplayEventLogConstants.Tuple_AmDatabaseMoveUnspecifiedServerFailed.LogEvent(null, new object[]
                        {
                            this.DatabaseName,
                            initialSourceServer,
                            text,
                            moveComment
                        });
                    }
                    else
                    {
                        ReplayEventLogConstants.Tuple_AmDatabaseMoveFailed.LogEvent(null, new object[]
                        {
                            this.DatabaseName,
                            initialActive,
                            targetServer,
                            text,
                            moveComment
                        });
                    }
                }
                else
                {
                    ReplayCrimsonEvents.ToplevelMoveSuccess.LogGeneric(this.PrepareCompletionArgs(new object[]
                    {
                        initialActive,
                        stopwatch.Elapsed,
                        moveComment
                    }));
                    ReplayEventLogConstants.Tuple_AmDatabaseMoved.LogEvent(null, new object[]
                    {
                        this.DatabaseName,
                        initialActive,
                        moveStatus.FinalDbState.ActiveServer,
                        moveComment
                    });
                }
            }
            if (ex != null)
            {
                throw ex;
            }
        }
Exemplo n.º 13
0
        protected override void MountInternal(MountFlags storeMountFlags, AmMountFlags amMountFlags, DatabaseMountDialOverride mountDialOverride, ref AmDbOperationDetailedStatus mountStatus)
        {
            Exception ex = null;
            int       natSkippedServersCount = 0;
            int       num  = 0;
            bool      flag = true;

            if (ThirdPartyManager.IsThirdPartyReplicationEnabled)
            {
                flag = false;
            }
            if (base.ActionCode.IsAdminOperation)
            {
                if (base.State.IsActiveServerValid)
                {
                    flag = false;
                }
                else
                {
                    AmTrace.Debug("Mount issued for the first time on this database. We will try all the available servers. (db={0})", new object[]
                    {
                        base.DatabaseName
                    });
                }
            }
            AmServerName amServerName = base.State.ActiveServer;

            if (AmServerName.IsNullOrEmpty(amServerName))
            {
                amServerName = new AmServerName(base.Database.Server.Name);
            }
            AmBcsSkipFlags skipValidationChecks = AmBcsSkipFlags.SkipAll;

            if (flag)
            {
                skipValidationChecks = AmBcsSkipFlags.None;
            }
            IBestCopySelector    bestCopySelector   = this.ConstructBestCopySelector(flag, skipValidationChecks, null, amServerName, amServerName, mountDialOverride, null);
            AmDbNodeAttemptTable dbNodeAttemptTable = AmSystemManager.Instance.DbNodeAttemptTable;

            if (base.ActionCode.IsAdminOperation)
            {
                dbNodeAttemptTable.ClearFailedTime(base.DatabaseGuid);
            }
            AmServerName       sourceServer       = amServerName;
            AmAcllReturnStatus amAcllReturnStatus = null;
            AmServerName       amServerName2      = bestCopySelector.FindNextBestCopy();

            while (amServerName2 != null)
            {
                num++;
                base.DbTrace.Debug("Attempting mount on server {0}", new object[]
                {
                    amServerName2
                });
                this.AttemptMountOnServer(amServerName2, sourceServer, storeMountFlags, amMountFlags, UnmountFlags.SkipCacheFlush, mountDialOverride, AmBcsSkipFlags.None, flag, ref natSkippedServersCount, ref amAcllReturnStatus, out ex);
                base.DbTrace.Debug("AttemptMountOnServer returned AcllStatus: {0}", new object[]
                {
                    amAcllReturnStatus
                });
                sourceServer = base.State.ActiveServer;
                if (ex == null)
                {
                    break;
                }
                bestCopySelector.ErrorLogger.ReportServerFailure(amServerName2, "CopyHasBeenTriedCheck", ex.Message);
                if (ex is AmRoleChangedWhileOperationIsInProgressException || ex is AmMountTimeoutException)
                {
                    break;
                }
                amServerName2 = bestCopySelector.FindNextBestCopy();
                base.CurrentAttemptNumber++;
            }
            this.CheckActionResultsAndUpdateAdProperties(amServerName, null, bestCopySelector, ex, num, natSkippedServersCount);
        }
Exemplo n.º 14
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);
                }
            }
        }
Exemplo n.º 15
0
 internal static LatencyChecker.ClusDbHungAction AnalyzeAndSuggestActionForClusDbHang(LatencyChecker.ClusDbHungInfo hungInfo)
 {
     LatencyChecker.ClusDbHungAction clusDbHungAction = new LatencyChecker.ClusDbHungAction();
     clusDbHungAction.HungInfo    = hungInfo;
     clusDbHungAction.TakeAction  = false;
     clusDbHungAction.TargetNodes = hungInfo.HungNodes;
     clusDbHungAction.Reason      = "If you see this message, something is wrong...";
     if (hungInfo.HungNodeApiException != null)
     {
         if (hungInfo.HungNodeApiException is HungDetectionGumIdChangedException)
         {
             clusDbHungAction.TakeAction = false;
             clusDbHungAction.Reason     = "GumId changed.";
         }
         else if (hungInfo.HungNodeApiException is OpenClusterTimedoutException)
         {
             clusDbHungAction.TakeAction = true;
             OpenClusterTimedoutException ex = (OpenClusterTimedoutException)hungInfo.HungNodeApiException;
             clusDbHungAction.Reason = string.Format("OpenCluster timed-out for {0}", ex.ServerName);
         }
         else if (hungInfo.HungNodeApiException is ClusterException)
         {
             clusDbHungAction.TakeAction = false;
             clusDbHungAction.Reason     = "ClusterException was caught.";
         }
     }
     else
     {
         clusDbHungAction.TakeAction = true;
         clusDbHungAction.Reason     = "Hung node detected without any Exceptions caught.";
     }
     if (clusDbHungAction.TargetNodes == null || clusDbHungAction.TargetNodes.Length < 1)
     {
         clusDbHungAction.TakeAction = false;
         clusDbHungAction.Reason     = "No hung node detected, and Rpc timeout did not catch anything.";
         if (hungInfo.RpcFailedNodes != null && hungInfo.RpcFailedNodes.Length > 0)
         {
             AmServerName amServerName = null;
             foreach (AmServerName amServerName2 in hungInfo.RpcFailedNodes)
             {
                 AmNodeState amNodeState = AmNodeState.Unknown;
                 if (hungInfo.ClusterNodesStatus.TryGetValue(amServerName2.NetbiosName, out amNodeState) && amNodeState != AmNodeState.Unknown && amNodeState != AmNodeState.Down)
                 {
                     amServerName = amServerName2;
                     break;
                 }
             }
             if (amServerName != null)
             {
                 clusDbHungAction.TakeAction  = true;
                 clusDbHungAction.TargetNodes = new AmServerName[]
                 {
                     amServerName
                 };
                 clusDbHungAction.Reason = string.Format("Hung nodes detected via Rpc timeout. Node '{0}' chosen for action. Original list={1}", amServerName.NetbiosName, LatencyChecker.ConvertAmServerNamesToString(hungInfo.RpcFailedNodes));
             }
             else
             {
                 clusDbHungAction.TakeAction  = false;
                 clusDbHungAction.TargetNodes = null;
                 clusDbHungAction.Reason      = string.Format("No nodes in Rpc non-responsive list are UP according to cluster. Skipping reboot. Original list={0}", LatencyChecker.ConvertAmServerNamesToString(hungInfo.RpcFailedNodes));
             }
         }
         if (!clusDbHungAction.TakeAction && !AmServerName.IsNullOrEmpty(hungInfo.CurrentLockOwnerName))
         {
             clusDbHungAction.TakeAction  = true;
             clusDbHungAction.TargetNodes = new AmServerName[]
             {
                 hungInfo.CurrentLockOwnerName
             };
             clusDbHungAction.Reason = string.Format("Could not find any hung nodes, so taking restart/reboot action for the lock owner '{0}'", hungInfo.CurrentLockOwnerName.NetbiosName);
         }
     }
     ReplayCrimsonEvents.HungNodeAnalysisResult.Log <string>(clusDbHungAction.ToString());
     return(clusDbHungAction);
 }
Exemplo n.º 16
0
        // Token: 0x060004A3 RID: 1187 RVA: 0x00018FBC File Offset: 0x000171BC
        internal static bool GetAllDatabaseStatuses(AmServerName serverName, bool isBasicInformation, string clientTypeId, TimeSpan?timeout, out MdbStatus[] mdbStatuses, out Exception exception)
        {
            bool result = false;

            exception   = null;
            mdbStatuses = null;
            try
            {
                using (IListMDBStatus storeListMDBStatusInstance = Dependencies.GetStoreListMDBStatusInstance(AmServerName.IsNullOrEmpty(serverName) ? null : serverName.Fqdn, clientTypeId))
                {
                    mdbStatuses = storeListMDBStatusInstance.ListMdbStatus(isBasicInformation, timeout);
                    result      = true;
                }
            }
            catch (MapiPermanentException ex)
            {
                exception = ex;
                AmTrace.Error("GetAllDatabaseStatuses() exception: {0}", new object[]
                {
                    ex.Message
                });
            }
            catch (MapiRetryableException ex2)
            {
                exception = ex2;
                AmTrace.Error("GetAllDatabaseStatuses() exception: {0}", new object[]
                {
                    ex2.Message
                });
            }
            return(result);
        }
Exemplo n.º 17
0
 internal void Analyze()
 {
     this.OwningServer = new AmServerName(this.Database.Server.Name);
     this.ActiveServer = this.StateInfo.ActiveServer;
     if (AmServerName.IsNullOrEmpty(this.ActiveServer))
     {
         this.ActiveServer = this.OwningServer;
     }
     if (!AmServerName.IsEqual(this.ActiveServer, this.OwningServer))
     {
         this.IsAdPropertiesOutOfSync = true;
     }
     if (this.Database.Servers.Length > 1 && AmBestCopySelectionHelper.IsActivationDisabled(this.ActiveServer))
     {
         this.IsActiveOnDisabledServer = true;
     }
     this.MisMountedServerList = new List <AmServerName>();
     foreach (AmServerName amServerName in this.StoreStatus.Keys)
     {
         if ((this.StoreStatus[amServerName] & MdbStatusFlags.Online) == MdbStatusFlags.Online)
         {
             if (AmServerName.IsEqual(amServerName, this.ActiveServer))
             {
                 this.IsMountedOnActive = true;
             }
             else
             {
                 this.MisMountedServerList.Add(amServerName);
             }
         }
         else if ((this.StoreStatus[amServerName] & MdbStatusFlags.MountInProgress) == MdbStatusFlags.MountInProgress && AmServerName.IsEqual(amServerName, this.ActiveServer))
         {
             this.IsMountedOnActive = true;
         }
     }
     this.IsMismounted = (this.MisMountedServerList != null && this.MisMountedServerList.Count > 0);
     this.IsMountedButAdminRequestedDismount = false;
     if (this.IsMountedOnActive)
     {
         if (this.StateInfo.IsAdminDismounted)
         {
             this.IsMountedButAdminRequestedDismount = true;
         }
         if (!this.StateInfo.IsMounted)
         {
             this.IsClusterDatabaseOutOfSync = true;
         }
     }
     else if (this.StateInfo.IsMounted)
     {
         this.IsClusterDatabaseOutOfSync = true;
     }
     this.IsPeriodicMountRequired = true;
     if (!this.IsMountedOnActive)
     {
         bool flag = AmSystemManager.Instance.StoreStateMarker.IsStoreGracefullyStoppedOn(this.ActiveServer);
         if (!this.Database.MountAtStartup || this.StateInfo.IsAdminDismounted || !this.StateInfo.IsMountAttemptedAtleastOnce || flag)
         {
             this.IsPeriodicMountRequired = false;
             ReplayCrimsonEvents.PeriodicCheckerSkippedMount.LogPeriodic <string, Guid, AmServerName, bool, bool, bool, bool>(this.Database.Guid, TimeSpan.FromMinutes(30.0), this.Database.Name, this.Database.Guid, this.ActiveServer, this.Database.MountAtStartup, this.StateInfo.IsAdminDismounted, this.StateInfo.IsMountAttemptedAtleastOnce, flag);
         }
     }
     else
     {
         this.IsPeriodicMountRequired = false;
     }
     if (this.StateInfo.IsMountSucceededAtleastOnce && !AmServerName.IsEqual(this.StateInfo.LastMountedServer, this.StateInfo.ActiveServer))
     {
         this.IsClusterDatabaseOutOfSync = true;
     }
 }