protected void Initialize(ConsistencyMode adConsistencyMode) { ITopologyConfigurationSession topologyConfigurationSession = DirectorySessionFactory.Default.CreateTopologyConfigurationSession(adConsistencyMode, ADSessionSettings.FromRootOrgScopeSet(), 92, "Initialize", "f:\\15.00.1497\\sources\\dev\\cluster\\src\\Replay\\Service\\NoncachingReplayAdObjectLookup.cs"); this.AdSession = topologyConfigurationSession; IADToplogyConfigurationSession adSession = ADSessionFactory.CreateWrapper(topologyConfigurationSession); this.DagLookup = new SimpleAdObjectLookup <IADDatabaseAvailabilityGroup>(adSession); this.DatabaseLookup = new SimpleAdObjectLookup <IADDatabase>(adSession); this.ServerLookup = new SimpleAdObjectLookup <IADServer>(adSession); this.MiniServerLookup = new SimpleMiniServerLookup(adSession); }
internal static ADObjectId TryGetServerIdByFqdn(IFindMiniServer findMiniServer, string fqdn) { if (!string.IsNullOrEmpty(fqdn)) { IADServer iadserver = findMiniServer.FindMiniServerByFqdn(fqdn); if (iadserver != null) { return(iadserver.Id); } } return(null); }
// Token: 0x06001E72 RID: 7794 RVA: 0x0008A730 File Offset: 0x00088930 protected void Initialize(ConsistencyMode adConsistencyMode) { ITopologyConfigurationSession topologyConfigurationSession = DirectorySessionFactory.Default.CreateTopologyConfigurationSession(adConsistencyMode, ADSessionSettings.FromRootOrgScopeSet(), 101, "Initialize", "f:\\15.00.1497\\sources\\dev\\cluster\\src\\Replay\\Service\\ReplayAdObjectLookup.cs"); IADToplogyConfigurationSession adSession = ADSessionFactory.CreateWrapper(topologyConfigurationSession); TimeSpan timeToLive = TimeSpan.FromSeconds((double)RegistryParameters.AdObjectCacheHitTtlInSec); TimeSpan timeToNegativeLive = TimeSpan.FromSeconds((double)RegistryParameters.AdObjectCacheMissTtlInSec); this.AdSession = topologyConfigurationSession; this.DagLookup = new AdObjectLookupCache <IADDatabaseAvailabilityGroup>(adSession, timeToLive, timeToNegativeLive); this.DatabaseLookup = new AdObjectLookupCache <IADDatabase>(adSession, timeToLive, timeToNegativeLive); this.ServerLookup = new AdObjectLookupCache <IADServer>(adSession, timeToLive, timeToNegativeLive); this.MiniServerLookup = new MiniServerLookupCache(adSession, timeToLive, timeToNegativeLive); }
public static ActiveManager CreateCustomActiveManager(bool cacheRpcRequests, IFindAdObject <IADDatabaseAvailabilityGroup> dagLookup, IFindAdObject <IADServer> serverLookup, IFindMiniServer miniServerLookup, IFindAdObject <IADClientAccessArray> casLookup, IFindMiniClientAccessServerOrArray miniCasArrayLookup, IFindAdObject <IADDatabase> databaseLookup, ITopologyConfigurationSession adSession, bool isService) { if (adSession == null) { adSession = DirectorySessionFactory.Default.CreateTopologyConfigurationSession(ConsistencyMode.PartiallyConsistent, ADSessionSettings.FromRootOrgScopeSet(), 1200, "CreateCustomActiveManager", "f:\\15.00.1497\\sources\\dev\\data\\src\\storage\\ActiveManager\\ActiveManager.cs"); } IADToplogyConfigurationSession adSession2 = ADSessionFactory.CreateWrapper(adSession); dagLookup = (dagLookup ?? new SimpleAdObjectLookup <IADDatabaseAvailabilityGroup>(adSession2)); serverLookup = (serverLookup ?? new SimpleAdObjectLookup <IADServer>(adSession2)); miniServerLookup = (miniServerLookup ?? new SimpleMiniServerLookup(adSession2)); casLookup = (casLookup ?? new SimpleAdObjectLookup <IADClientAccessArray>(adSession2)); miniCasArrayLookup = (miniCasArrayLookup ?? new SimpleMiniClientAccessServerOrArrayLookup(adSession)); databaseLookup = (databaseLookup ?? new SimpleAdObjectLookup <IADDatabase>(adSession2)); return(new ActiveManager(cacheRpcRequests, dagLookup, serverLookup, miniServerLookup, casLookup, miniCasArrayLookup, databaseLookup, adSession, isService)); }
private ActiveManager(bool enableRpcCaching, IFindAdObject <IADDatabaseAvailabilityGroup> dagLookup, IFindAdObject <IADServer> serverLookup, IFindMiniServer miniServerLookup, IFindAdObject <IADClientAccessArray> casLookup, IFindMiniClientAccessServerOrArray miniCasArrayLookup, IFindAdObject <IADDatabase> databaseLookup, ITopologyConfigurationSession adSession, bool isService) { ExTraceGlobals.ActiveManagerClientTracer.TraceDebug <bool>((long)this.GetHashCode(), "Active Manager is instantiated (cacheEnabled={0})", enableRpcCaching); if (adSession == null) { throw new ArgumentNullException("adSession"); } IADToplogyConfigurationSession adSession2 = ADSessionFactory.CreateWrapper(adSession); this.m_isCacheEnabled = enableRpcCaching; this.m_adSession = adSession; this.m_disposeTracker = this.GetDisposeTracker(); if (this.m_isCacheEnabled) { this.m_dagLookup = (dagLookup ?? new AdObjectLookupCache <IADDatabaseAvailabilityGroup>(adSession2, AdObjectLookupCache <IADDatabaseAvailabilityGroup> .TimeToLive, AdObjectLookupCache <IADDatabaseAvailabilityGroup> .TimeToNegativeLive, ActiveManager.s_cacheLockTimeout, AdObjectLookupCache <IADDatabaseAvailabilityGroup> .AdOperationTimeout)); this.m_casLookup = (casLookup ?? new AdObjectLookupCache <IADClientAccessArray>(adSession2, AdObjectLookupCache <IADClientAccessArray> .TimeToLive, AdObjectLookupCache <IADClientAccessArray> .TimeToNegativeLive, ActiveManager.s_cacheLockTimeout, AdObjectLookupCache <IADClientAccessArray> .AdOperationTimeout)); this.m_miniServerLookup = (miniServerLookup ?? new MiniServerLookupCache(adSession2, MiniServerLookupCache.TimeToLive, MiniServerLookupCache.TimeToNegativeLive, ActiveManager.s_cacheLockTimeout, MiniServerLookupCache.AdOperationTimeout)); this.m_miniCasArrayLookup = (miniCasArrayLookup ?? new MiniClientAccessServerOrArrayLookupCache(this.m_adSession, MiniClientAccessServerOrArrayLookupCache.TimeToLive, MiniClientAccessServerOrArrayLookupCache.TimeToNegativeLive, ActiveManager.s_cacheLockTimeout, MiniClientAccessServerOrArrayLookupCache.AdOperationTimeout)); this.m_databaseLookup = (databaseLookup ?? new AdObjectLookupCache <IADDatabase>(adSession2, AdObjectLookupCache <IADDatabase> .TimeToLive, AdObjectLookupCache <IADDatabase> .TimeToNegativeLive, ActiveManager.s_cacheLockTimeout, AdObjectLookupCache <IADDatabase> .AdOperationTimeout)); if (!isService) { this.EnableMinimization(); } } else { this.m_dagLookup = (dagLookup ?? new SimpleAdObjectLookup <IADDatabaseAvailabilityGroup>(adSession2)); this.m_casLookup = (casLookup ?? new SimpleAdObjectLookup <IADClientAccessArray>(adSession2)); this.m_miniServerLookup = (miniServerLookup ?? new SimpleMiniServerLookup(adSession2)); this.m_miniCasArrayLookup = (miniCasArrayLookup ?? new SimpleMiniClientAccessServerOrArrayLookup(this.m_adSession)); this.m_databaseLookup = (databaseLookup ?? new SimpleAdObjectLookup <IADDatabase>(adSession2)); } this.CacheUpdateInterval = new TimeSpan(0, 0, 60); this.m_isRunningInService = isService; }
internal static DatabaseLocationInfo GetServerNameForDatabaseInternal(IADDatabase database, NetworkCredential networkCredential, IFindAdObject <IADDatabaseAvailabilityGroup> dagLookup, IFindMiniServer findMiniServer, ActiveManagerClientPerfmonInstance perfCounters, bool throwOnErrors, bool isService) { Guid guid = database.Guid; string serverFqdn = null; string lastMountedServerFqdn = null; bool isDatabaseHighlyAvailable = false; DateTime mountedTime = DateTime.MinValue; DatabaseLocationInfoResult requestResult = DatabaseLocationInfoResult.Unknown; ServerVersion serverVersion = null; if (ActiveManagerImplementation.TestHookHangGsfdForMilliseconds > 0) { ExTraceGlobals.ActiveManagerClientTracer.TraceDebug <int>(0L, "TestHook is hanging GetServerNameForDatabaseInternal for {0} milliseconds", ActiveManagerImplementation.TestHookHangGsfdForMilliseconds); Thread.Sleep(ActiveManagerImplementation.TestHookHangGsfdForMilliseconds); } if (Interlocked.Increment(ref ActiveManagerImplementation.NumberOfConcurrentRPCthreads) <= 3000) { try { if (!ActiveManagerImplementation.IsActiveManagerRpcSupported(database)) { ExTraceGlobals.ActiveManagerClientTracer.TraceDebug <string>(0L, "Database {0} doesn't support RPC's for ActiveManager", database.Name); } else { try { ActiveManagerImplementation.s_perfCounters.GetServerForDatabaseClientRpcCalls.Increment(); AmDbStatusInfo2 amDbStatusInfo = AmRpcClientHelper.RpcchGetServerForDatabase(database, networkCredential, dagLookup, findMiniServer, perfCounters, isService, out serverVersion); isDatabaseHighlyAvailable = (amDbStatusInfo.IsHighlyAvailable != 0); serverFqdn = amDbStatusInfo.MasterServerFqdn; lastMountedServerFqdn = amDbStatusInfo.LastMountedServerFqdn; mountedTime = amDbStatusInfo.MountedTime; requestResult = DatabaseLocationInfoResult.Success; } catch (AmDatabaseNeverMountedException innerException) { ExTraceGlobals.ActiveManagerClientTracer.TraceDebug <string>(0L, "Database {0} was never mounted on any of the servers (defaulting to owner server)", string.Empty); if (throwOnErrors) { throw new ServerForDatabaseNotFoundException(database.Name, guid.ToString(), innerException); } } catch (AmServerException ex) { ExTraceGlobals.ActiveManagerClientTracer.TraceDebug <string>(0L, "Encountered AM Server exception: {0} (defaulting to owner server)", ex.Message); if (throwOnErrors) { throw new ServerForDatabaseNotFoundException(database.Name, guid.ToString(), ex); } } catch (AmServerTransientException ex2) { ExTraceGlobals.ActiveManagerClientTracer.TraceDebug <string>(0L, "Encountered AM Server exception: {0} (defaulting to owner server)", ex2.Message); if (throwOnErrors) { throw new ServerForDatabaseNotFoundException(database.Name, guid.ToString(), ex2); } } } goto IL_1CF; } finally { Interlocked.Decrement(ref ActiveManagerImplementation.NumberOfConcurrentRPCthreads); } } Interlocked.Decrement(ref ActiveManagerImplementation.NumberOfConcurrentRPCthreads); ExTraceGlobals.ActiveManagerClientTracer.TraceDebug <int>(0L, "Maximum number ({0}) of concurrent RPC threads reached.", 3000); if (throwOnErrors) { throw new ServerForDatabaseNotFoundException(database.Name, guid.ToString(), new TooManyActiveManagerClientRPCsException(3000)); } IL_1CF: return(new DatabaseLocationInfo(serverFqdn, null, lastMountedServerFqdn, null, null, null, database.Name, false, database.Recovery, Guid.Empty, mountedTime, null, null, serverVersion, MailboxRelease.None, requestResult, isDatabaseHighlyAvailable)); }
internal static void GetServerInformationForDatabaseInternal(IADDatabase database, DatabaseLocationInfo minimalLocationInfo, IFindMiniServer findMiniServer) { Guid guid = database.Guid; string lastMountedServerFqdn = minimalLocationInfo.LastMountedServerFqdn; IADServer iadserver = null; ADObjectId adobjectId = null; string serverFqdn = minimalLocationInfo.ServerFqdn; if (serverFqdn != null) { iadserver = findMiniServer.FindMiniServerByFqdn(serverFqdn); } else { ExTraceGlobals.ActiveManagerClientTracer.TraceDebug <string>(0L, "GetServerInformationForDatabaseInternal({0}) is falling back to database.Server from AD, which may be stale.", database.Name); iadserver = findMiniServer.ReadMiniServerByObjectId(database.Server); } if (iadserver == null) { throw new UnableToFindServerForDatabaseException(database.Name, guid.ToString()); } ADObjectId serverSiteFromMiniServer = ActiveManagerUtil.GetServerSiteFromMiniServer(iadserver); string fqdn = iadserver.Fqdn; if (iadserver.IsExchange2007OrLater && (serverSiteFromMiniServer == null || string.IsNullOrEmpty(fqdn) || (iadserver.IsExchange2007OrLater && !iadserver.IsMailboxServer))) { throw new UnableToFindServerForDatabaseException(database.Name, guid.ToString()); } if (string.Equals(lastMountedServerFqdn, serverFqdn, StringComparison.OrdinalIgnoreCase)) { adobjectId = iadserver.Id; } else { adobjectId = ActiveManagerImplementation.TryGetServerIdByFqdn(findMiniServer, lastMountedServerFqdn); } if (adobjectId == null) { ExTraceGlobals.ActiveManagerClientTracer.TraceDebug <ADObjectId>(0L, "lastMountedServer was null. Setting to the current server ({0}).", iadserver.Id); adobjectId = iadserver.Id; } DatabaseLocationInfoResult requestResult = DatabaseLocationInfoResult.Success; IADServer iadserver2 = null; if (iadserver.Id.Equals(adobjectId)) { iadserver2 = iadserver; } else { try { iadserver2 = findMiniServer.ReadMiniServerByObjectId(adobjectId); } catch (ADTransientException arg) { ActiveManagerImplementation.Tracer.TraceDebug <ADTransientException>(0L, "ReadMiniServer() threw an ADTransientException: {0}", arg); } } IADToplogyConfigurationSession adSession = findMiniServer.AdSession; IADSite iadsite = ActiveManagerImplementation.RetrieveLocalSite(adSession); if (iadsite == null) { ExTraceGlobals.ActiveManagerClientTracer.TraceDebug(0L, "GetServerForDatabase detected an Unknown state! adSession.GetLocalSite() is null."); requestResult = DatabaseLocationInfoResult.Unknown; } else if (iadserver2 == null) { ExTraceGlobals.ActiveManagerClientTracer.TraceDebug <ADObjectId>(0L, "GetServerForDatabase detected an Unknown state! lastMountedServerId ({0}) could not be resolved.", adobjectId); requestResult = DatabaseLocationInfoResult.Unknown; } else if (!iadserver.Id.Equals(adobjectId)) { ADObjectId serverSiteFromMiniServer2 = ActiveManagerUtil.GetServerSiteFromMiniServer(iadserver2); if (serverSiteFromMiniServer == serverSiteFromMiniServer2 || (serverSiteFromMiniServer != null && serverSiteFromMiniServer.Equals(serverSiteFromMiniServer2))) { ExTraceGlobals.ActiveManagerClientTracer.TraceDebug(0L, "GetServerForDatabase detected InTransitSameSite! masterServer (name={0},site={1}), lastMountedServer (name={2},site={3}.", new object[] { iadserver.Id, serverSiteFromMiniServer, adobjectId, serverSiteFromMiniServer2 }); requestResult = DatabaseLocationInfoResult.InTransitSameSite; } else { ExTraceGlobals.ActiveManagerClientTracer.TraceDebug(0L, "GetServerForDatabase detected InTransitCrossSite! masterServer (name={0},site={1}), lastMountedServer (name={2},site={3}.", new object[] { iadserver.Id, serverSiteFromMiniServer, adobjectId, serverSiteFromMiniServer2 }); requestResult = DatabaseLocationInfoResult.InTransitCrossSite; } } else if (!iadsite.Id.Equals(serverSiteFromMiniServer)) { ExTraceGlobals.ActiveManagerClientTracer.TraceDebug <ADObjectId, ADObjectId>(0L, "GetServerForDatabase detected a SiteViolation! GetLocalSite().Id != serverSiteId ({0} != {1}).", iadsite.Id, serverSiteFromMiniServer); requestResult = DatabaseLocationInfoResult.SiteViolation; } string exchangeLegacyDN = iadserver.ExchangeLegacyDN; ServerVersion adminDisplayVersion = iadserver.AdminDisplayVersion; Guid objectGuid = iadserver.Id.ObjectGuid; string exchangeLegacyDN2 = iadserver2.ExchangeLegacyDN; iadserver2 = null; ExTraceGlobals.ActiveManagerClientTracer.TraceDebug <Guid>(0L, "GetServerInformationForDatabaseInternal: Updating the location information for {0} in place.", guid); ADObjectId mailboxPublicFolderDatabase = database.MailboxPublicFolderDatabase; minimalLocationInfo.UpdateInPlace(fqdn, exchangeLegacyDN, minimalLocationInfo.LastMountedServerFqdn, exchangeLegacyDN2, database.ExchangeLegacyDN, database.RpcClientAccessServerLegacyDN, database.Name, database.IsPublicFolderDatabase, database.Recovery, (mailboxPublicFolderDatabase != null) ? mailboxPublicFolderDatabase.ObjectGuid : Guid.Empty, minimalLocationInfo.MountedTime, new Guid?(objectGuid), serverSiteFromMiniServer, adminDisplayVersion, iadserver.MailboxRelease, requestResult, minimalLocationInfo.IsDatabaseHighlyAvailable); }