private DatabaseLocationInfo GetServerInformationForDatabase(Guid databaseId, IADDatabase database, DatabaseLocationInfo dbLocationInfo, GetServerForDatabaseFlags gsfdFlags, IPerformanceDataLogger perfLogger) { if (database != null && databaseId != database.Guid) { throw new ArgumentException("When passing in database, its GUID must match databaseId.", "database"); } ExTraceGlobals.ActiveManagerClientTracer.TraceFunction <Guid, DatabaseLocationInfo, int>((long)this.GetHashCode(), "Entering GetServerInformationForDatabase(Guid={0}, minimalLocationInfo={1}, Flags={2})", databaseId, dbLocationInfo, (int)gsfdFlags); this.DisposeCheck(); bool flag = (gsfdFlags & GetServerForDatabaseFlags.IgnoreAdSiteBoundary) != GetServerForDatabaseFlags.None; bool flag2 = (gsfdFlags & GetServerForDatabaseFlags.ReadThrough) != GetServerForDatabaseFlags.None; if (flag2 || dbLocationInfo.ServerLegacyDN == null) { if (database == null) { AdObjectLookupFlags flags = flag2 ? AdObjectLookupFlags.ReadThrough : AdObjectLookupFlags.None; using (new StopwatchPerformanceTracker("GetServerInformationForDatabaseGetDatabaseByGuidEx", perfLogger)) { database = this.GetDatabaseByGuidEx(databaseId, flags, perfLogger); } } ActiveManagerImplementation.GetServerInformationForDatabaseInternal(database, dbLocationInfo, this.m_miniServerLookup); } if (dbLocationInfo != null) { DatabaseLocationInfoResult databaseLocationInfoResult = dbLocationInfo.RequestResult; bool flag3 = false; if (flag && databaseLocationInfoResult == DatabaseLocationInfoResult.SiteViolation) { databaseLocationInfoResult = DatabaseLocationInfoResult.Success; flag3 = true; } if (flag && databaseLocationInfoResult == DatabaseLocationInfoResult.InTransitCrossSite) { databaseLocationInfoResult = DatabaseLocationInfoResult.InTransitSameSite; flag3 = true; } ExTraceGlobals.FaultInjectionTracer.TraceTest <DatabaseLocationInfoResult>(3831901501U, ref databaseLocationInfoResult); ExTraceGlobals.FaultInjectionTracer.TraceTest <bool>(2221288765U, ref flag3); if (flag3) { ExTraceGlobals.ActiveManagerClientTracer.TraceDebug <DatabaseLocationInfoResult, DatabaseLocationInfoResult>((long)this.GetHashCode(), "GetServerForDatabase(): At the caller's request, changing the location info's result from {0} to {1}.", dbLocationInfo.RequestResult, databaseLocationInfoResult); dbLocationInfo = DatabaseLocationInfo.CloneDatabaseLocationInfo(dbLocationInfo, databaseLocationInfoResult); } } if (ExTraceGlobals.ActiveManagerClientTracer.IsTraceEnabled(TraceType.DebugTrace)) { ExTraceGlobals.ActiveManagerClientTracer.TraceDebug <Guid, DatabaseLocationInfo>((long)this.GetHashCode(), "Database Location Info ({0}) = {1}", databaseId, dbLocationInfo); } ExTraceGlobals.ActiveManagerClientTracer.TraceFunction <Guid>((long)this.GetHashCode(), "Exiting GetServerInformationForDatabase(Guid={0})", databaseId); return(dbLocationInfo); }
public TADWrapperObject FindServerByFqdnWithException(string fqdn, out Exception exception) { ExAssert.RetailAssert(typeof(TADWrapperObject) == typeof(IADServer), "This function should only be called with Server objects!"); if (typeof(TADWrapperObject) != typeof(IADServer)) { throw new NotImplementedException("This only works for Server objects."); } exception = null; Exception ex = null; AdObjectLookupFlags flags = AdObjectLookupFlags.None; string shortName = MachineName.GetNodeNameFromFqdn(fqdn); TADWrapperObject result = this.LookupOrFindAdObject(shortName, () => SimpleAdObjectLookup <TADWrapperObject> .FindAdObjectByServerNameStatic(this.AdSession, shortName, out ex), flags); exception = ex; return(result); }
private IADDatabase GetDatabaseByGuidEx(Guid databaseId, AdObjectLookupFlags flags, IPerformanceDataLogger perfLogger) { return(ActiveManager.GetDatabaseByGuidEx(this.m_databaseLookup, databaseId, flags, perfLogger)); }
private static IADDatabase GetDatabaseByGuidEx(IFindAdObject <IADDatabase> databaseLookup, Guid databaseId, AdObjectLookupFlags flags, IPerformanceDataLogger perfLogger) { IADDatabase iaddatabase = databaseLookup.FindAdObjectByGuidEx(databaseId, flags, perfLogger); if (iaddatabase == null) { throw new DatabaseNotFoundException(databaseId.ToString()); } return(iaddatabase); }
public TADWrapperObject FindAdObjectByQueryEx(QueryFilter queryFilter, AdObjectLookupFlags flags) { return(SimpleAdObjectLookup <TADWrapperObject> .FindAdObjectWithQueryStatic(this.AdSession, queryFilter)); }
public TADWrapperObject FindAdObjectByGuidEx(Guid objectGuid, AdObjectLookupFlags flags, IPerformanceDataLogger perfLogger) { return(SimpleAdObjectLookup <TADWrapperObject> .FindAdObjectTypeByGuidStatic(this.AdSession, objectGuid, perfLogger)); }
public TADWrapperObject FindAdObjectByGuidEx(Guid objectGuid, AdObjectLookupFlags flags) { return(this.FindAdObjectByGuidEx(objectGuid, flags, NullPerformanceDataLogger.Instance)); }
private TADWrapperObject LookupOrFindAdObject(string identifyingName, AdObjectLookupCache <TADWrapperObject> .FindAdObjectCacheFailure objectLookupFunction, AdObjectLookupFlags flags) { ExTraceGlobals.ActiveManagerClientTracer.TraceFunction <string>(0L, "LookupOrFindAdObject({0})", identifyingName); AdObjectCacheEntry <TADWrapperObject> adObjectCacheEntry = null; bool flag = false; bool flag2 = (flags & AdObjectLookupFlags.ReadThrough) != AdObjectLookupFlags.None; bool flag3 = false; try { int num = 0; while (num < 2 && !flag) { flag = this.m_rwLock.TryEnterReadLock(AdObjectLookupCache <TADWrapperObject> .CacheLockTimeout); num++; } if (flag) { flag3 = this.m_cache.TryGetValue(identifyingName, out adObjectCacheEntry); bool flag4 = false; if (flag3) { flag4 = AdObjectLookupCache <TADWrapperObject> .ShouldExpireCacheEntry(adObjectCacheEntry); ExTraceGlobals.ActiveManagerClientTracer.TraceDebug((long)this.GetHashCode(), "LookupOrFindAdObject( {0} ) was found in the cache: {1}, and shouldExpireEntry={2}, flags={3}", new object[] { identifyingName, adObjectCacheEntry, flag4, flags }); } if (!flag3 || flag4) { flag2 = true; } } else { AdObjectLookupCache <TADWrapperObject> .Tracer.TraceError((long)this.GetHashCode(), "Timeout waiting for the read lock in AdObjectLookupCache.LookupOrFindAdObject()"); flag2 = true; } } finally { if (flag) { this.m_rwLock.ExitReadLock(); } } if (flag2) { bool flag5 = false; bool flag6 = false; TADWrapperObject updatedObject = default(TADWrapperObject); try { flag5 = this.CheckAndSetADLock(identifyingName); if (flag5) { InvokeWithTimeout.Invoke(delegate() { updatedObject = objectLookupFunction(); }, this.m_adOperationTimeout); } else if (!flag3 || AdObjectLookupCache <TADWrapperObject> .MaximumTimeToLiveExpired(adObjectCacheEntry)) { int num2 = 10; int num3 = 10; for (int i = 0; i < num3; i++) { Thread.Sleep(num2); bool flag7 = false; try { int num4 = 0; while (num4 < 2 && !flag7) { flag7 = this.m_rwLock.TryEnterReadLock(AdObjectLookupCache <TADWrapperObject> .CacheLockTimeout); num4++; } if (flag7) { flag3 = this.m_cache.TryGetValue(identifyingName, out adObjectCacheEntry); } } finally { if (flag7) { this.m_rwLock.ExitReadLock(); } } if (flag3 && !AdObjectLookupCache <TADWrapperObject> .MaximumTimeToLiveExpired(adObjectCacheEntry)) { if (AdObjectLookupCache <TADWrapperObject> .LogAdLatency) { StorageGlobals.EventLogger.LogEvent(StorageEventLogConstants.Tuple_ActiveManagerClientAnotherThreadCompleted, identifyingName, new object[] { identifyingName, num2 * i }); } AdObjectLookupCache <TADWrapperObject> .Tracer.TraceDebug <string>((long)this.GetHashCode(), "Another thread finished doing query for object {0}.", identifyingName); flag6 = true; break; } } if (!flag3 || AdObjectLookupCache <TADWrapperObject> .MaximumTimeToLiveExpired(adObjectCacheEntry)) { StorageGlobals.EventLogger.LogEvent(StorageEventLogConstants.Tuple_ActiveManagerClientAnotherThreadInADCallTimeout, identifyingName, new object[] { identifyingName, num2 * num3 }); AdObjectLookupCache <TADWrapperObject> .Tracer.TraceDebug <string, int>((long)this.GetHashCode(), "Another thread doing query for object {0}, however this thread didn't complete in {1} msec.", identifyingName, num2 *num3); updatedObject = objectLookupFunction(); } } else { if (AdObjectLookupCache <TADWrapperObject> .LogAdLatency) { StorageGlobals.EventLogger.LogEvent(StorageEventLogConstants.Tuple_ActiveManagerClientAnotherThreadInADCall, identifyingName, new object[] { identifyingName }); } AdObjectLookupCache <TADWrapperObject> .Tracer.TraceDebug <string>((long)this.GetHashCode(), "Another thread doing query for object {0}.", identifyingName); flag6 = true; } } catch (TimeoutException ex) { StorageGlobals.EventLogger.LogEvent(StorageEventLogConstants.Tuple_ErrorActiveManagerClientADTimeout, identifyingName, new object[] { identifyingName, this.m_adOperationTimeout }); AdObjectLookupCache <TADWrapperObject> .Tracer.TraceError <string>((long)this.GetHashCode(), "Timeout on ad query: {0}", ex.Message); flag6 = true; } finally { if (flag5) { this.ReleaseADLock(identifyingName); } } if (updatedObject != null && this.MinimizeObjects) { updatedObject.Minimize(); } adObjectCacheEntry = new AdObjectCacheEntry <TADWrapperObject>(updatedObject, this.m_timeToLive, this.m_timeToNegativeLive, this.m_maximumTimeToLive); bool flag8 = false; try { int num5 = 0; while (num5 < 2 && !flag8) { flag8 = this.m_rwLock.TryEnterWriteLock(AdObjectLookupCache <TADWrapperObject> .CacheLockTimeout); num5++; } if (flag8) { if (updatedObject == null && flag6) { AdObjectCacheEntry <TADWrapperObject> adObjectCacheEntry2 = null; flag3 = this.m_cache.TryGetValue(identifyingName, out adObjectCacheEntry2); if (flag3 && !AdObjectLookupCache <TADWrapperObject> .MaximumTimeToLiveExpired(adObjectCacheEntry2)) { adObjectCacheEntry = adObjectCacheEntry2; ExTraceGlobals.ActiveManagerClientTracer.TraceDebug <TADWrapperObject, AdObjectCacheEntry <TADWrapperObject> >((long)this.GetHashCode(), "New ad object was not found, but found possibly stale result '{0}' in the cache as {1}.", adObjectCacheEntry.AdObjectData, adObjectCacheEntry); } else { flag6 = false; } } if (!flag6) { this.m_cache[identifyingName] = adObjectCacheEntry; ExTraceGlobals.ActiveManagerClientTracer.TraceDebug <TADWrapperObject, AdObjectCacheEntry <TADWrapperObject> >((long)this.GetHashCode(), "Stored object '{0}' in the cache as {1}.", adObjectCacheEntry.AdObjectData, adObjectCacheEntry); } } else { AdObjectLookupCache <TADWrapperObject> .Tracer.TraceError((long)this.GetHashCode(), "Timeout waiting for write lock in AdObjectLookupCache.LookupOrFindAdObject()"); } } finally { if (flag8) { this.m_rwLock.ExitWriteLock(); } } } return(adObjectCacheEntry.AdObjectData); }
public TADWrapperObject FindAdObjectByQueryEx(QueryFilter queryFilter, AdObjectLookupFlags flags) { return(this.LookupOrFindAdObject(queryFilter.ToString(), () => SimpleAdObjectLookup <TADWrapperObject> .FindAdObjectWithQueryStatic(this.AdSession, queryFilter), flags)); }
public static LegacyDN FindClientAccessArrayOrServerFromSite(ADObjectId site, ADObjectId preferredServer, IFindAdObject <IADClientAccessArray> findClientAccessArray, IFindMiniClientAccessServerOrArray findMiniClientAccessServer, AdObjectLookupFlags adObjectLookupFlags) { if (site == null) { return(null); } QueryFilter queryFilter = new ComparisonFilter(ComparisonOperator.Equal, ServerSchema.ServerSite, site); IADClientAccessArray iadclientAccessArray = findClientAccessArray.FindAdObjectByQueryEx(QueryFilter.AndTogether(new QueryFilter[] { queryFilter, ClientAccessArray.PriorTo15ExchangeObjectVersionFilter }), adObjectLookupFlags); if (iadclientAccessArray != null) { return(LegacyDN.Parse(iadclientAccessArray.ExchangeLegacyDN)); } IADMiniClientAccessServerOrArray iadminiClientAccessServerOrArray = findMiniClientAccessServer.FindMiniClientAccessServerOrArrayWithClientAccess(site, preferredServer); if (iadminiClientAccessServerOrArray != null) { return(LegacyDN.Parse(iadminiClientAccessServerOrArray.ExchangeLegacyDN)); } return(null); }