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 ActiveManagerClientPerfmonInstance(string instanceName, ActiveManagerClientPerfmonInstance autoUpdateTotalInstance) : base(instanceName, "MSExchange Active Manager Client") { bool flag = false; List <ExPerformanceCounter> list = new List <ExPerformanceCounter>(); try { this.GetServerForDatabaseClientCalls = new ExPerformanceCounter(base.CategoryName, "Client-side Calls", instanceName, true, null, new ExPerformanceCounter[0]); list.Add(this.GetServerForDatabaseClientCalls); this.GetServerForDatabaseClientCallsPerSec = new ExPerformanceCounter(base.CategoryName, "Client-side Calls/Sec", instanceName, true, null, new ExPerformanceCounter[0]); list.Add(this.GetServerForDatabaseClientCallsPerSec); this.GetServerForDatabaseClientCacheHits = new ExPerformanceCounter(base.CategoryName, "Client-side Cache Hits", instanceName, true, null, new ExPerformanceCounter[0]); list.Add(this.GetServerForDatabaseClientCacheHits); this.GetServerForDatabaseClientCacheMisses = new ExPerformanceCounter(base.CategoryName, "Client-side Cache Misses", instanceName, true, null, new ExPerformanceCounter[0]); list.Add(this.GetServerForDatabaseClientCacheMisses); this.GetServerForDatabaseClientCallsWithReadThrough = new ExPerformanceCounter(base.CategoryName, "Client-side Calls ReadThrough", instanceName, true, null, new ExPerformanceCounter[0]); list.Add(this.GetServerForDatabaseClientCallsWithReadThrough); this.GetServerForDatabaseClientRpcCalls = new ExPerformanceCounter(base.CategoryName, "Client-side RPC Calls", instanceName, true, null, new ExPerformanceCounter[0]); list.Add(this.GetServerForDatabaseClientRpcCalls); this.GetServerForDatabaseClientUniqueDatabases = new ExPerformanceCounter(base.CategoryName, "Unique databases queried", instanceName, true, null, new ExPerformanceCounter[0]); list.Add(this.GetServerForDatabaseClientUniqueDatabases); this.GetServerForDatabaseClientUniqueServers = new ExPerformanceCounter(base.CategoryName, "Unique servers queried", instanceName, true, null, new ExPerformanceCounter[0]); list.Add(this.GetServerForDatabaseClientUniqueServers); this.GetServerForDatabaseClientLocationCacheEntries = new ExPerformanceCounter(base.CategoryName, "Location cache entries", instanceName, true, null, new ExPerformanceCounter[0]); list.Add(this.GetServerForDatabaseClientLocationCacheEntries); this.CacheUpdateTimeInSec = new ExPerformanceCounter(base.CategoryName, "Location cache update time", instanceName, true, null, new ExPerformanceCounter[0]); list.Add(this.CacheUpdateTimeInSec); this.GetServerForDatabaseClientServerInformationCacheHits = new ExPerformanceCounter(base.CategoryName, "Server-Information Cache Hits", instanceName, true, null, new ExPerformanceCounter[0]); list.Add(this.GetServerForDatabaseClientServerInformationCacheHits); this.GetServerForDatabaseClientServerInformationCacheMisses = new ExPerformanceCounter(base.CategoryName, "Server-Information Cache Misses", instanceName, true, null, new ExPerformanceCounter[0]); list.Add(this.GetServerForDatabaseClientServerInformationCacheMisses); this.GetServerForDatabaseClientServerInformationCacheEntries = new ExPerformanceCounter(base.CategoryName, "Server-Information Cache Entries", instanceName, true, null, new ExPerformanceCounter[0]); list.Add(this.GetServerForDatabaseClientServerInformationCacheEntries); this.CalculatePreferredHomeServerCalls = new ExPerformanceCounter(base.CategoryName, "CalculatePreferredHomeServer Calls", instanceName, true, null, new ExPerformanceCounter[0]); list.Add(this.CalculatePreferredHomeServerCalls); this.CalculatePreferredHomeServerCallsPerSec = new ExPerformanceCounter(base.CategoryName, "CalculatePreferredHomeServer Calls/Sec", instanceName, true, null, new ExPerformanceCounter[0]); list.Add(this.CalculatePreferredHomeServerCallsPerSec); this.CalculatePreferredHomeServerRedirects = new ExPerformanceCounter(base.CategoryName, "CalculatePreferredHomeServer Redirects", instanceName, true, null, new ExPerformanceCounter[0]); list.Add(this.CalculatePreferredHomeServerRedirects); this.CalculatePreferredHomeServerRedirectsPerSec = new ExPerformanceCounter(base.CategoryName, "CalculatePreferredHomeServer Redirects/Sec", instanceName, true, null, new ExPerformanceCounter[0]); list.Add(this.CalculatePreferredHomeServerRedirectsPerSec); this.GetServerForDatabaseWCFLatency = new ExPerformanceCounter(base.CategoryName, "Average WCF calls latency", instanceName, true, null, new ExPerformanceCounter[0]); list.Add(this.GetServerForDatabaseWCFLatency); this.GetServerForDatabaseWCFLatencyTimeBase = new ExPerformanceCounter(base.CategoryName, "Average WCF calls latency time base", instanceName, true, null, new ExPerformanceCounter[0]); list.Add(this.GetServerForDatabaseWCFLatencyTimeBase); this.GetServerForDatabaseWCFLocalLatency = new ExPerformanceCounter(base.CategoryName, "Average WCF calls to the local server latency", instanceName, true, null, new ExPerformanceCounter[0]); list.Add(this.GetServerForDatabaseWCFLocalLatency); this.GetServerForDatabaseWCFLocalLatencyTimeBase = new ExPerformanceCounter(base.CategoryName, "Average WCF calls to the local server time base", instanceName, true, null, new ExPerformanceCounter[0]); list.Add(this.GetServerForDatabaseWCFLocalLatencyTimeBase); this.GetServerForDatabaseWCFLocalDomainLocalSiteLatency = new ExPerformanceCounter(base.CategoryName, "Average WCF calls to a remote server in the local site latency", instanceName, true, null, new ExPerformanceCounter[0]); list.Add(this.GetServerForDatabaseWCFLocalDomainLocalSiteLatency); this.GetServerForDatabaseWCFLocalDomainLocalSiteLatencyTimeBase = new ExPerformanceCounter(base.CategoryName, "Average WCF calls to a remote server in the local site latency time base", instanceName, true, null, new ExPerformanceCounter[0]); list.Add(this.GetServerForDatabaseWCFLocalDomainLocalSiteLatencyTimeBase); this.GetServerForDatabaseWCFLocalDomainRemoteSiteLatency = new ExPerformanceCounter(base.CategoryName, "Average WCF calls to a remote server in the remote site latency", instanceName, true, null, new ExPerformanceCounter[0]); list.Add(this.GetServerForDatabaseWCFLocalDomainRemoteSiteLatency); this.GetServerForDatabaseWCFLocalDomainRemoteSiteLatencyTimeBase = new ExPerformanceCounter(base.CategoryName, "Average WCF calls to a remote server in the remote site latency time base", instanceName, true, null, new ExPerformanceCounter[0]); list.Add(this.GetServerForDatabaseWCFLocalDomainRemoteSiteLatencyTimeBase); this.GetServerForDatabaseWCFRemoteDomainLatency = new ExPerformanceCounter(base.CategoryName, "Average WCF calls to a remote server in a remote domain latency", instanceName, true, null, new ExPerformanceCounter[0]); list.Add(this.GetServerForDatabaseWCFRemoteDomainLatency); this.GetServerForDatabaseWCFRemoteDomainLatencyTimeBase = new ExPerformanceCounter(base.CategoryName, "Average WCF calls to a remote server in a remote domain latency time base", instanceName, true, null, new ExPerformanceCounter[0]); list.Add(this.GetServerForDatabaseWCFRemoteDomainLatencyTimeBase); this.GetServerForDatabaseWCFCalls = new ExPerformanceCounter(base.CategoryName, "WCF calls", instanceName, true, null, new ExPerformanceCounter[0]); list.Add(this.GetServerForDatabaseWCFCalls); this.GetServerForDatabaseWCFCallsPerSec = new ExPerformanceCounter(base.CategoryName, "WCF Calls/Sec", instanceName, true, null, new ExPerformanceCounter[0]); list.Add(this.GetServerForDatabaseWCFCallsPerSec); this.GetServerForDatabaseWCFLocalCalls = new ExPerformanceCounter(base.CategoryName, "WCF calls to local server", instanceName, true, null, new ExPerformanceCounter[0]); list.Add(this.GetServerForDatabaseWCFLocalCalls); this.GetServerForDatabaseWCFLocalCallsPerSec = new ExPerformanceCounter(base.CategoryName, "WCF Calls/Sec to local server", instanceName, true, null, new ExPerformanceCounter[0]); list.Add(this.GetServerForDatabaseWCFLocalCallsPerSec); this.GetServerForDatabaseWCFLocalDomainLocalSiteCalls = new ExPerformanceCounter(base.CategoryName, "WCF calls to a remote server in local domain and local site", instanceName, true, null, new ExPerformanceCounter[0]); list.Add(this.GetServerForDatabaseWCFLocalDomainLocalSiteCalls); this.GetServerForDatabaseWCFLocalDomainLocalSiteCallsPerSec = new ExPerformanceCounter(base.CategoryName, "WCF Calls/Sec to a remote server in local domain and local site", instanceName, true, null, new ExPerformanceCounter[0]); list.Add(this.GetServerForDatabaseWCFLocalDomainLocalSiteCallsPerSec); this.GetServerForDatabaseWCFLocalDomainRemoteSiteCalls = new ExPerformanceCounter(base.CategoryName, "WCF calls to a remote server in remote site", instanceName, true, null, new ExPerformanceCounter[0]); list.Add(this.GetServerForDatabaseWCFLocalDomainRemoteSiteCalls); this.GetServerForDatabaseWCFLocalDomainRemoteSiteCallsPerSec = new ExPerformanceCounter(base.CategoryName, "WCF Calls/Sec to a remote server in remote site", instanceName, true, null, new ExPerformanceCounter[0]); list.Add(this.GetServerForDatabaseWCFLocalDomainRemoteSiteCallsPerSec); this.GetServerForDatabaseWCFRemoteDomainCalls = new ExPerformanceCounter(base.CategoryName, "WCF calls to a remote server in a remote domain", instanceName, true, null, new ExPerformanceCounter[0]); list.Add(this.GetServerForDatabaseWCFRemoteDomainCalls); this.GetServerForDatabaseWCFRemoteDomainCallsPerSec = new ExPerformanceCounter(base.CategoryName, "WCF Calls/Sec to a remote server in a remote domain", instanceName, true, null, new ExPerformanceCounter[0]); list.Add(this.GetServerForDatabaseWCFRemoteDomainCallsPerSec); this.GetServerForDatabaseWCFErrors = new ExPerformanceCounter(base.CategoryName, "WCF calls returning an error", instanceName, true, null, new ExPerformanceCounter[0]); list.Add(this.GetServerForDatabaseWCFErrors); this.GetServerForDatabaseWCFErrorsPerSec = new ExPerformanceCounter(base.CategoryName, "WCF Calls/Sec returning an error", instanceName, true, null, new ExPerformanceCounter[0]); list.Add(this.GetServerForDatabaseWCFErrorsPerSec); this.GetServerForDatabaseWCFTimeouts = new ExPerformanceCounter(base.CategoryName, "WCF calls timing out", instanceName, true, null, new ExPerformanceCounter[0]); list.Add(this.GetServerForDatabaseWCFTimeouts); this.GetServerForDatabaseWCFTimeoutsPerSec = new ExPerformanceCounter(base.CategoryName, "WCF Calls/Sec timing out", instanceName, true, null, new ExPerformanceCounter[0]); list.Add(this.GetServerForDatabaseWCFTimeoutsPerSec); long num = this.GetServerForDatabaseClientCalls.RawValue; num += 1L; flag = true; } finally { if (!flag) { foreach (ExPerformanceCounter exPerformanceCounter in list) { exPerformanceCounter.Close(); } } } this.counters = list.ToArray(); }