Example #1
0
 private static void InitializePerfCounterInstance(string applicationName, bool hasMultiInstance)
 {
     Microsoft.Exchange.Diagnostics.Components.Data.Directory.ExTraceGlobals.FaultInjectionTracer.RegisterExceptionInjectionCallback(new ExceptionInjectionCallback(ADFaultInjectionUtils.DirectoryTracerCallback));
     Microsoft.Exchange.Diagnostics.Components.Directory.TopologyService.ExTraceGlobals.FaultInjectionTracer.RegisterExceptionInjectionCallback(new ExceptionInjectionCallback(ADFaultInjectionUtils.TopologyServiceTracerCallback));
     if (Globals.IsPerfCounterInstanceInitialized(applicationName, hasMultiInstance))
     {
         return;
     }
     lock (Globals.locker)
     {
         if (!Globals.IsPerfCounterInstanceInitialized(applicationName, hasMultiInstance))
         {
             if (applicationName == "UNKNOWN" && !Globals.isExchangeTestExecutable)
             {
                 string format = "The process '{0}' (PID = {1}) has been initialized as Unknown Multiple instance type un-expectedly. \r\n Reasons of this exception: 1. For any product executables, which will be shipped out of box, they should never use AD driver functionality without initializing its performance counter instance since we can NOT show a intuitive Perf Counter instance name here.\r\n 2. We don't need the validation for test assembly because we don't care for its performance counter naming; however, we definitely want to make sure it is under our control, so that we don't miss any out of box product DLLs/EXEs.\r\n What to do to avoid this exception: For any newly added Exchange test executables which utilize AD perf, please add the executable name of the process into exclusion list in Microsoft.Exchange.Data.Directory.Globals.CheckExchangeTestExecutables.";
                 throw new InvalidOperationException(string.Format(format, Globals.processProcessName ?? string.Empty, Globals.processId));
             }
             Microsoft.Exchange.Diagnostics.Components.Data.Directory.ExTraceGlobals.PerfCountersTracer.TraceDebug(0L, "Initializing the DSAccess Perf Counter of the process '{0}' (PID = {1}) as {2} with application name '{3}'.", new object[]
             {
                 Globals.processProcessName ?? string.Empty,
                 Globals.processId,
                 hasMultiInstance ? InstanceType.Multiple : InstanceType.Single,
                 applicationName ?? string.Empty
             });
             Globals.DSAccessPerfCounterInitializationWithRetry(Globals.processProcessName, applicationName, hasMultiInstance);
             if (hasMultiInstance)
             {
                 Globals.InstanceType   = InstanceType.Multiple;
                 Globals.CurrentAppName = applicationName;
             }
             else
             {
                 Globals.InstanceType = InstanceType.Single;
             }
         }
     }
 }