Beispiel #1
0
        // Token: 0x06000313 RID: 787 RVA: 0x00011B78 File Offset: 0x0000FD78
        internal static AmDbStateInfo ReplaceProperty(AmDbStateInfo oldStateInfo, AmDbStateInfo.PropertyNames propName, string propValue)
        {
            bool          isPropExist = false;
            string        str         = oldStateInfo.ToString();
            StringBuilder sb          = new StringBuilder(500);

            AmDbStateInfo.ParseNameValuePairs(str, delegate(string name, string value)
            {
                if (AmDbStateInfo.IsMatching(name, propName))
                {
                    if (!isPropExist)
                    {
                        AmDbStateInfo.AppendNameValue(sb, propName.ToString(), propValue);
                        isPropExist = true;
                        return;
                    }
                }
                else
                {
                    AmDbStateInfo.AppendNameValue(sb, name, value);
                }
            });
            if (!isPropExist)
            {
                AmDbStateInfo.AppendNameValue(sb, propName.ToString(), propValue);
            }
            return(AmDbStateInfo.Parse(oldStateInfo.DatabaseGuid, sb.ToString()));
        }
        // Token: 0x060002DA RID: 730 RVA: 0x0000FFC0 File Offset: 0x0000E1C0
        protected override void RunInternal()
        {
            Exception lastException = AmHelper.HandleKnownExceptions(delegate(object param0, EventArgs param1)
            {
                this.CheckIfOperationIsAllowedOnCurrentRole();
                AmDbStateInfo amDbStateInfo = AmSystemManager.Instance.Config.DbState.Read(base.Database.Guid);
                if (!amDbStateInfo.IsAdminDismounted)
                {
                    AmTrace.Debug("AmDbDismountAdminDismountedOperation skipped since database is not marked as admin dismounted anymore", new object[0]);
                    return;
                }
                MountStatus storeDatabaseMountStatus = AmStoreHelper.GetStoreDatabaseMountStatus(null, base.Database.Guid);
                if (storeDatabaseMountStatus == MountStatus.Mounted)
                {
                    AmDbAction amDbAction = base.PrepareDbAction(this.ActionCode);
                    ReplayCrimsonEvents.DismountingAdminDismountRequestedDatabase.Log <string, Guid, AmServerName>(base.Database.Name, base.Database.Guid, amDbStateInfo.ActiveServer);
                    amDbAction.Dismount(UnmountFlags.None);
                    return;
                }
                AmTrace.Debug("AmDbDismountAdminDismountedOperation skipped since database is not mounted (db={0}, mountStatus={1})", new object[]
                {
                    base.Database.Name,
                    storeDatabaseMountStatus
                });
            });

            base.LastException = lastException;
        }
Beispiel #3
0
        internal static bool WriteStateSyncMountStatus(AmConfig amConfig, AmDbStateInfo stateInfo, Guid databaseGuid, AmServerName activeServer, MountStatus mountStatus)
        {
            bool flag = false;

            if (mountStatus == MountStatus.Mounted)
            {
                stateInfo.UpdateActiveServerAndIncrementFailoverSequenceNumber(activeServer);
                stateInfo.LastMountedServer         = activeServer;
                stateInfo.IsAdminDismounted         = false;
                stateInfo.MountStatus               = mountStatus;
                stateInfo.IsAutomaticActionsAllowed = true;
                stateInfo.LastMountedTime           = DateTime.UtcNow;
                flag = true;
            }
            else if (stateInfo.IsEntryExist)
            {
                stateInfo.MountStatus = mountStatus;
                if (stateInfo.IsMountSucceededAtleastOnce)
                {
                    stateInfo.UpdateActiveServerAndIncrementFailoverSequenceNumber(activeServer);
                    stateInfo.LastMountedServer = activeServer;
                }
                flag = true;
            }
            if (flag && AmDbAction.WriteState(amConfig, stateInfo, false))
            {
                AmDatabaseStateTracker databaseStateTracker = AmSystemManager.Instance.DatabaseStateTracker;
                if (databaseStateTracker != null)
                {
                    databaseStateTracker.UpdateActive(databaseGuid, activeServer);
                }
            }
            return(flag);
        }
        // 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);
        }
        internal Dictionary <Guid, AmDbStateInfo> GetAllDbStatesFromClusdb(IClusterDB clusdb)
        {
            Dictionary <Guid, AmDbStateInfo> dictionary = new Dictionary <Guid, AmDbStateInfo>();

            if (!DistributedStore.Instance.IsKeyExist("ExchangeActiveManager\\DbState", null))
            {
                return(dictionary);
            }
            IEnumerable <Tuple <string, RegistryValueKind> > valueInfos = clusdb.GetValueInfos("ExchangeActiveManager\\DbState");

            if (valueInfos != null)
            {
                foreach (Tuple <string, RegistryValueKind> tuple in valueInfos)
                {
                    string item  = tuple.Item1;
                    string value = clusdb.GetValue <string>("ExchangeActiveManager\\DbState", item, string.Empty);
                    Guid   guid;
                    if (!string.IsNullOrEmpty(value) && Guid.TryParse(item, out guid))
                    {
                        AmDbStateInfo value2 = AmDbStateInfo.Parse(guid, value);
                        dictionary.Add(guid, value2);
                    }
                }
            }
            return(dictionary);
        }
Beispiel #6
0
        internal static void SyncDatabaseOwningServerAndLegacyDn(IADDatabase db, AmDbActionCode actionCode)
        {
            AmConfig      config        = AmSystemManager.Instance.Config;
            AmDbStateInfo amDbStateInfo = config.DbState.Read(db.Guid);
            AmServerName  amServerName  = new AmServerName(db.Server.Name);
            AmServerName  amServerName2;

            if (amDbStateInfo.IsActiveServerValid)
            {
                amServerName2 = amDbStateInfo.ActiveServer;
            }
            else
            {
                amServerName2 = amServerName;
            }
            AmTrace.Debug("Synchronizing AD properties of database {0} (initialOwningServer:{1}, newActiveServer:{2})", new object[]
            {
                db.Name,
                amServerName,
                amServerName2
            });
            bool flag = SharedDependencies.WritableADHelper.SetDatabaseLegacyDnAndOwningServer(db.Guid, amDbStateInfo.LastMountedServer, amServerName2, false);

            if (flag)
            {
                ReplayCrimsonEvents.DatabaseAdPropertiesSynchronized.Log <string, Guid, AmServerName, AmServerName>(db.Name, db.Guid, amServerName, amServerName2);
                return;
            }
            AmTrace.Debug("Ignored ad sync request database {0}", new object[]
            {
                db.Name
            });
        }
Beispiel #7
0
        internal bool Write(AmDbStateInfo state, bool isBestEffort)
        {
            bool result = false;

            try
            {
                ActiveManagerServerPerfmon.DatabaseStateInfoWrites.Increment();
                ActiveManagerServerPerfmon.DatabaseStateInfoWritesPerSec.Increment();
                this.WriteInternal(state.DatabaseGuid.ToString(), state.ToString(), state.ActiveServer);
                result = true;
            }
            catch (ClusterException ex)
            {
                AmTrace.Error("Attempt write persistent database state for Database '{0}' failed with error: {1}", new object[]
                {
                    state.DatabaseGuid,
                    ex
                });
                if (!isBestEffort)
                {
                    throw;
                }
            }
            return(result);
        }
Beispiel #8
0
        public static bool HasDatabaseBeenMounted(Guid dbGuid, AmConfig amConfig, out AmServerName masterServerName, out AmServerName lastMountedServerName)
        {
            AmDbStateInfo amDbStateInfo = amConfig.DbState.Read(dbGuid);

            masterServerName      = amDbStateInfo.ActiveServer;
            lastMountedServerName = amDbStateInfo.LastMountedServer;
            return(amDbStateInfo.IsActiveServerValid);
        }
Beispiel #9
0
        // Token: 0x06000442 RID: 1090 RVA: 0x00016A44 File Offset: 0x00014C44
        protected override AmDbStateInfo[] ReadAllInternal(bool isBestEffort)
        {
            List <AmDbStateInfo> list = new List <AmDbStateInfo>();

            try
            {
                IEnumerable <Tuple <string, object> > allValues = this.m_regDbHandle.GetAllValues(null);
                if (allValues != null)
                {
                    foreach (Tuple <string, object> tuple in allValues)
                    {
                        try
                        {
                            Guid          databaseGuid = new Guid(tuple.Item1);
                            string        entryStr     = (string)tuple.Item2;
                            AmDbStateInfo item         = AmDbStateInfo.Parse(databaseGuid, entryStr);
                            list.Add(item);
                        }
                        catch (InvalidCastException ex)
                        {
                            AmTrace.Error("ReadAllInternal invalid cast exception: {0}", new object[]
                            {
                                ex
                            });
                            if (!isBestEffort)
                            {
                                throw;
                            }
                        }
                        catch (FormatException ex2)
                        {
                            AmTrace.Error("ReadAllInternal format exception: {0}", new object[]
                            {
                                ex2
                            });
                            if (!isBestEffort)
                            {
                                throw;
                            }
                        }
                    }
                }
            }
            catch (ClusterException ex3)
            {
                AmTrace.Error("ReadAllInternal({0}): GetValueNames() failed with error {1}", new object[]
                {
                    isBestEffort,
                    ex3.Message
                });
                if (!isBestEffort)
                {
                    throw;
                }
            }
            return(list.ToArray());
        }
Beispiel #10
0
 private static AmDbStatusInfo2 ConvertToDbStatusInfo(AmDbStateInfo stateInfo)
 {
     if (!stateInfo.IsMountSucceededAtleastOnce)
     {
         AmTrace.Error("Database does not appear to be ever attempted for mount {0}", new object[]
         {
             stateInfo.DatabaseGuid
         });
         throw new AmDatabaseNeverMountedException();
     }
     return(new AmDbStatusInfo2(stateInfo.ActiveServer.Fqdn, 0, stateInfo.LastMountedServer.Fqdn, stateInfo.LastMountedTime));
 }
Beispiel #11
0
 // Token: 0x06000436 RID: 1078 RVA: 0x000165A8 File Offset: 0x000147A8
 protected override AmDbStateInfo[] ReadAllInternal(bool isBestEffort)
 {
     AmDbStateInfo[] array  = null;
     Guid[]          array2 = this.ReadDatabaseGuids(isBestEffort);
     if (array2 != null)
     {
         array = new AmDbStateInfo[array2.Length];
         for (int i = 0; i < array2.Length; i++)
         {
             array[i] = base.Read(array2[i], isBestEffort);
         }
     }
     return(array);
 }
Beispiel #12
0
        // Token: 0x06000310 RID: 784 RVA: 0x000119D8 File Offset: 0x0000FBD8
        public override string ToString()
        {
            StringBuilder stringBuilder = new StringBuilder(500);

            AmDbStateInfo.AppendNameValue(stringBuilder, "IsEntryExist", this.IsEntryExist.ToString());
            AmDbStateInfo.AppendNameValue(stringBuilder, AmDbStateInfo.PropertyNames.ActiveServer.ToString(), this.ActiveServer.NetbiosName);
            AmDbStateInfo.AppendNameValue(stringBuilder, AmDbStateInfo.PropertyNames.LastMountedServer.ToString(), this.LastMountedServer.NetbiosName);
            AmDbStateInfo.AppendNameValue(stringBuilder, AmDbStateInfo.PropertyNames.LastMountedTime.ToString(), this.LastMountedTime.ToString("s"));
            AmDbStateInfo.AppendNameValue(stringBuilder, AmDbStateInfo.PropertyNames.MountStatus.ToString(), this.MountStatus.ToString());
            AmDbStateInfo.AppendNameValue(stringBuilder, AmDbStateInfo.PropertyNames.IsAdminDismounted.ToString(), this.IsAdminDismounted.ToString());
            AmDbStateInfo.AppendNameValue(stringBuilder, AmDbStateInfo.PropertyNames.IsAutomaticActionsAllowed.ToString(), this.IsAutomaticActionsAllowed.ToString());
            AmDbStateInfo.AppendNameValue(stringBuilder, AmDbStateInfo.PropertyNames.FailoverSequenceNumber.ToString(), this.FailoverSequenceNumber.ToString());
            return(stringBuilder.ToString());
        }
Beispiel #13
0
        // Token: 0x06000314 RID: 788 RVA: 0x00011D04 File Offset: 0x0000FF04
        internal static AmDbStateInfo Parse(Guid databaseGuid, string entryStr)
        {
            AmDbStateInfo stateInfo = new AmDbStateInfo(databaseGuid);

            stateInfo.IsEntryExist = true;
            AmDbStateInfo.ParseNameValuePairs(entryStr, delegate(string name, string value)
            {
                if (AmDbStateInfo.IsMatching(name, AmDbStateInfo.PropertyNames.ActiveServer))
                {
                    stateInfo.ActiveServer = new AmServerName(SharedHelper.GetNodeNameFromFqdn(value));
                    return;
                }
                if (AmDbStateInfo.IsMatching(name, AmDbStateInfo.PropertyNames.LastMountedServer))
                {
                    stateInfo.LastMountedServer = new AmServerName(SharedHelper.GetNodeNameFromFqdn(value));
                    return;
                }
                if (AmDbStateInfo.IsMatching(name, AmDbStateInfo.PropertyNames.LastMountedTime))
                {
                    DateTime lastMountedTime;
                    DateTime.TryParseExact(value, DateTimeFormatInfo.InvariantInfo.SortableDateTimePattern, DateTimeFormatInfo.InvariantInfo, DateTimeStyles.RoundtripKind, out lastMountedTime);
                    stateInfo.LastMountedTime = lastMountedTime;
                    return;
                }
                if (AmDbStateInfo.IsMatching(name, AmDbStateInfo.PropertyNames.MountStatus))
                {
                    MountStatus mountStatus;
                    EnumUtility.TryParse <MountStatus>(value, out mountStatus, MountStatus.Dismounted);
                    stateInfo.MountStatus = mountStatus;
                    return;
                }
                if (AmDbStateInfo.IsMatching(name, AmDbStateInfo.PropertyNames.IsAdminDismounted))
                {
                    stateInfo.IsAdminDismounted = bool.Parse(value);
                    return;
                }
                if (AmDbStateInfo.IsMatching(name, AmDbStateInfo.PropertyNames.IsAutomaticActionsAllowed))
                {
                    stateInfo.IsAutomaticActionsAllowed = bool.Parse(value);
                    return;
                }
                if (AmDbStateInfo.IsMatching(name, AmDbStateInfo.PropertyNames.FailoverSequenceNumber))
                {
                    stateInfo.FailoverSequenceNumber = long.Parse(value);
                }
            });
            return(stateInfo);
        }
Beispiel #14
0
        internal static AmDbStatusInfo2 GetServerForDatabase(Guid mdbGuid)
        {
            AmConfig config = AmSystemManager.Instance.Config;

            if (config.IsUnknown)
            {
                AmTrace.Error("GetSFD: Invalid configuration (db={0})", new object[]
                {
                    mdbGuid
                });
                throw new AmInvalidConfiguration(config.LastError);
            }
            AmDbStateInfo stateInfo = config.DbState.Read(mdbGuid);

            return(AmServerDbStatusInfoCache.ConvertToDbStatusInfo(stateInfo));
        }
Beispiel #15
0
        // Token: 0x0600007A RID: 122 RVA: 0x00004034 File Offset: 0x00002234
        protected Dictionary <Guid, DatabaseInfo> GenerateDatabaseInfoMapFromPrevious()
        {
            Dictionary <Guid, DatabaseInfo> dictionary = new Dictionary <Guid, DatabaseInfo>();

            foreach (DatabaseInfo databaseInfo in this.m_prevDbMap.Values)
            {
                IADDatabase   database      = databaseInfo.Database;
                AmDbStateInfo stateInfo     = this.m_amConfig.DbState.Read(database.Guid);
                DatabaseInfo  databaseInfo2 = new DatabaseInfo(database, stateInfo);
                foreach (AmServerName key in databaseInfo.StoreStatus.Keys)
                {
                    databaseInfo2.StoreStatus[key] = null;
                }
                dictionary[database.Guid] = databaseInfo2;
            }
            return(dictionary);
        }
        // Token: 0x0600008C RID: 140 RVA: 0x0000479C File Offset: 0x0000299C
        private void SendThirdPartyNotifications(IADDatabase[] dbList)
        {
            this.m_derivedManagesAllDone = true;
            int num = 0;

            try
            {
                this.m_tprMoveList = new List <AmActiveThirdPartyMove>();
                LocalizedString empty = LocalizedString.Empty;
                foreach (IADDatabase iaddatabase in dbList)
                {
                    if (this.IsActiveOnServer(iaddatabase, this.m_nodeName, out empty))
                    {
                        AmDbStateInfo          amDbStateInfo = this.m_amConfig.DbState.Read(iaddatabase.Guid);
                        bool                   mountDesired  = !amDbStateInfo.IsAdminDismounted;
                        AmActiveThirdPartyMove item          = new AmActiveThirdPartyMove(iaddatabase, this.m_nodeName.Fqdn, mountDesired);
                        this.m_tprMoveList.Add(item);
                        this.m_moveRequests++;
                    }
                }
                foreach (AmActiveThirdPartyMove amActiveThirdPartyMove in this.m_tprMoveList)
                {
                    amActiveThirdPartyMove.Notify(new WaitCallback(this.TPRMoveCompletion));
                    num++;
                }
            }
            finally
            {
                lock (this.m_tprLocker)
                {
                    if (num < this.m_moveRequests)
                    {
                        this.m_moveRequests -= num;
                    }
                    if (this.m_tprNotificationsAcknowledged == this.m_moveRequests)
                    {
                        base.MarkAllDone();
                    }
                }
            }
        }
Beispiel #17
0
        internal AmDbStatusInfo2 GetEntry(Guid databaseGuid)
        {
            AmConfig config = AmSystemManager.Instance.Config;

            if (config.IsUnknown)
            {
                AmTrace.Error("GetSFD: Invalid configuration (db={0})", new object[]
                {
                    databaseGuid
                });
                throw new AmInvalidConfiguration(config.LastError);
            }
            string text = config.DbState.ReadStateString(databaseGuid);

            AmServerDbStatusInfoCache.StringStatusInfoPair stringStatusInfoPair = null;
            AmDbStatusInfo2 amDbStatusInfo = null;

            lock (this.m_locker)
            {
                this.m_cacheMap.TryGetValue(databaseGuid, out stringStatusInfoPair);
            }
            if (stringStatusInfoPair != null && text != null && string.Equals(text, stringStatusInfoPair.RawStateString))
            {
                amDbStatusInfo = stringStatusInfoPair.StatusInfo;
            }
            else
            {
                AmDbStateInfo stateInfo = AmDbStateInfo.Parse(databaseGuid, text);
                amDbStatusInfo       = AmServerDbStatusInfoCache.ConvertToDbStatusInfo(stateInfo);
                stringStatusInfoPair = new AmServerDbStatusInfoCache.StringStatusInfoPair(text, amDbStatusInfo);
                lock (this.m_locker)
                {
                    AmTrace.Debug("Updating cache for database {0}.", new object[]
                    {
                        databaseGuid
                    });
                    this.m_cacheMap[databaseGuid] = stringStatusInfoPair;
                }
            }
            return(amDbStatusInfo);
        }
Beispiel #18
0
        internal AmDbStateInfo Read(Guid dbGuid, bool isBestEffort)
        {
            AmDbStateInfo result = new AmDbStateInfo(dbGuid);
            string        empty  = string.Empty;

            try
            {
                bool flag = this.ReadInternal(dbGuid.ToString(), out empty);
                if (flag && !string.IsNullOrEmpty(empty))
                {
                    result = AmDbStateInfo.Parse(dbGuid, empty);
                }
            }
            catch (FormatException ex)
            {
                AmTrace.Error("Failed to parse the state info string '{1}' for Database '{0}'. Error: {2}", new object[]
                {
                    dbGuid,
                    empty,
                    ex
                });
                if (!isBestEffort)
                {
                    throw new AmInvalidDbStateException(dbGuid, empty, ex);
                }
            }
            catch (ClusterException ex2)
            {
                AmTrace.Error("Attempt read persistent database state for Database '{0}' failed with error: {1}", new object[]
                {
                    dbGuid,
                    ex2
                });
                if (!isBestEffort)
                {
                    throw;
                }
            }
            return(result);
        }
Beispiel #19
0
        // Token: 0x060001E5 RID: 485 RVA: 0x0000C754 File Offset: 0x0000A954
        private Dictionary <AmServerName, AmDatabaseStateTracker.ServerInfo> GenerateServerInfoMapFromClusdb()
        {
            IEnumerable <IADDatabase> allDatabasesInDag = this.GetAllDatabasesInDag();
            Dictionary <AmServerName, AmDatabaseStateTracker.ServerInfo> result = new Dictionary <AmServerName, AmDatabaseStateTracker.ServerInfo>();

            if (allDatabasesInDag != null)
            {
                foreach (IADDatabase iaddatabase in allDatabasesInDag)
                {
                    AmDbStateInfo amDbStateInfo = AmSystemManager.Instance.Config.DbState.Read(iaddatabase.Guid);
                    if (amDbStateInfo != null && amDbStateInfo.IsEntryExist)
                    {
                        this.UpdateActiveInternal(result, iaddatabase.Guid, amDbStateInfo.ActiveServer);
                    }
                    else
                    {
                        AmDatabaseStateTracker.Tracer.TraceError <string>(0L, "GenerateServerInfoMapFromClusdb() could not find state for database '{0}' in ClusDB", iaddatabase.Name);
                    }
                }
            }
            return(result);
        }
Beispiel #20
0
        internal static void DismountIfMismounted(IADDatabase db, AmDbActionCode actionCode, List <AmServerName> mismountedNodes)
        {
            AmConfig config = AmSystemManager.Instance.Config;

            if (config.Role == AmRole.Unknown)
            {
                throw new AmInvalidConfiguration(config.LastError);
            }
            AmDbStateInfo amDbStateInfo = config.DbState.Read(db.Guid);

            if (amDbStateInfo.IsEntryExist)
            {
                using (List <AmServerName> .Enumerator enumerator = mismountedNodes.GetEnumerator())
                {
                    while (enumerator.MoveNext())
                    {
                        AmServerName amServerName = enumerator.Current;
                        if (!AmServerName.IsEqual(amServerName, amDbStateInfo.ActiveServer))
                        {
                            ReplayCrimsonEvents.DismountingMismountedDatabase.Log <string, Guid, AmServerName>(db.Name, db.Guid, amServerName);
                            AmStoreHelper.RemoteDismount(amServerName, db.Guid, UnmountFlags.SkipCacheFlush, false);
                        }
                        else
                        {
                            AmTrace.Warning("Ignoring force dismount for {0} since it is the current active {1}", new object[]
                            {
                                db.Name,
                                amServerName
                            });
                        }
                    }
                    return;
                }
            }
            AmTrace.Warning("DismountIfMismounted skipped since the database {0} was never mounted", new object[]
            {
                db.Name
            });
        }
Beispiel #21
0
        // Token: 0x0600019C RID: 412 RVA: 0x00009E04 File Offset: 0x00008004
        internal static MountStatus GetDatabaseMountStatus(Guid dbGuid, out string activeServer)
        {
            AmConfig config = AmSystemManager.Instance.Config;

            activeServer = string.Empty;
            if (config.IsUnknown)
            {
                AmTrace.Warning("GetDatabaseMountStatus: returning Unknown since AM role is Unknown", new object[0]);
                return(MountStatus.Unknown);
            }
            AmDbStateInfo amDbStateInfo = config.DbState.Read(dbGuid);

            if (amDbStateInfo.IsEntryExist)
            {
                activeServer = amDbStateInfo.ActiveServer.NetbiosName;
                return(amDbStateInfo.MountStatus);
            }
            AmTrace.Debug("GetDatabaseMountStatus: returning Dismounted since we failed to find the AmDbStateInfo for {0}, it could be a brand new db", new object[]
            {
                dbGuid.ToString()
            });
            return(MountStatus.Dismounted);
        }
Beispiel #22
0
        internal static bool WriteState(AmConfig cfg, AmDbStateInfo stateInfo, bool isBestEffort)
        {
            bool result = false;
            bool flag   = true;

            try
            {
                AmConfig config = AmSystemManager.Instance.Config;
                if (cfg != null && cfg.Role != config.Role)
                {
                    flag = false;
                    if (!isBestEffort)
                    {
                        throw new AmRoleChangedWhileOperationIsInProgressException(cfg.Role.ToString(), config.Role.ToString());
                    }
                }
                if (flag)
                {
                    cfg.DbState.Write(stateInfo);
                    result = true;
                }
            }
            catch (ClusterApiException ex)
            {
                AmTrace.Error("Error while trying to write state {0} to cluster database. (error={1})", new object[]
                {
                    stateInfo,
                    ex.Message
                });
                if (!isBestEffort)
                {
                    throw;
                }
            }
            return(result);
        }
Beispiel #23
0
 internal DatabaseInfo(IADDatabase db, AmDbStateInfo stateInfo)
 {
     this.Database    = db;
     this.StateInfo   = stateInfo;
     this.StoreStatus = new Dictionary <AmServerName, MdbStatusFlags?>();
 }
Beispiel #24
0
        // Token: 0x060007AD RID: 1965 RVA: 0x00025064 File Offset: 0x00023264
        private static bool IsAlreadyOnTarget(IADDatabase db, AmServerName targetServer, AmConfig amConfig)
        {
            AmDbStateInfo amDbStateInfo = amConfig.DbState.Read(db.Guid);

            return(amDbStateInfo != null && AmServerName.IsEqual(amDbStateInfo.ActiveServer, targetServer));
        }
Beispiel #25
0
 public void Write(AmDbStateInfo state)
 {
     this.Write(state, false);
 }
Beispiel #26
0
 internal static void AssertAreEqual(AmDbStateInfo stateA, AmDbStateInfo stateB)
 {
 }
Beispiel #27
0
        internal static void SyncClusterDatabaseState(IADDatabase db, AmDbActionCode actionCode)
        {
            AmConfig config = AmSystemManager.Instance.Config;

            if (config.IsUnknown)
            {
                AmTrace.Error("SyncClusterDatabaseState: Invalid configuration (db={0})", new object[]
                {
                    db
                });
                throw new AmInvalidConfiguration(config.LastError);
            }
            AmDbStateInfo amDbStateInfo = config.DbState.Read(db.Guid);
            AmServerName  amServerName;

            if (amDbStateInfo.IsActiveServerValid)
            {
                amServerName = amDbStateInfo.ActiveServer;
            }
            else
            {
                amServerName = new AmServerName(db.Server.Name);
            }
            MountStatus mountStatus = MountStatus.Dismounted;

            if ((config.IsStandalone || (config.IsPamOrSam && config.DagConfig.IsNodePubliclyUp(amServerName))) && AmStoreHelper.IsMounted(amServerName, db.Guid))
            {
                mountStatus = MountStatus.Mounted;
                AmSystemManager.Instance.DbNodeAttemptTable.ClearFailedTime(db.Guid);
            }
            MountStatus mountStatus2 = amDbStateInfo.MountStatus;

            if (mountStatus != mountStatus2 || !AmServerName.IsEqual(amDbStateInfo.LastMountedServer, amDbStateInfo.ActiveServer))
            {
                if (mountStatus != mountStatus2)
                {
                    AmTrace.Debug("Mounted state reported by STORE is different from persistent state. (Database:{0}, PersistentState: {1}, StoreIsReporting: {2})", new object[]
                    {
                        db.Name,
                        mountStatus2,
                        mountStatus
                    });
                }
                else
                {
                    AmTrace.Debug("State is in transit. (Database:{0}, LastMountedServer: {1},ActiveServer: {2})", new object[]
                    {
                        db.Name,
                        amDbStateInfo.LastMountedServer,
                        amDbStateInfo.ActiveServer
                    });
                }
                AmDbAction.WriteStateSyncMountStatus(config, amDbStateInfo, db.Guid, amServerName, mountStatus);
                ReplayCrimsonEvents.DatabaseMountStatusSynchronized.Log <string, Guid, MountStatus, MountStatus, AmServerName>(db.Name, db.Guid, mountStatus2, mountStatus, amServerName);
                return;
            }
            AmTrace.Debug("Ignored persistent state sync for {0} since nothing is out of sync", new object[]
            {
                db.Name
            });
        }
        // 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);
        }