Esempio n. 1
0
        private static bool TryReadAdObjects()
        {
            ADOperationResult adoperationResult = DiagnosticsAggregationServicelet.GetLocalServer();

            if (!adoperationResult.Succeeded)
            {
                Exception exception = adoperationResult.Exception;
                DiagnosticsAggregationServicelet.EventLog.LogEvent(MSExchangeDiagnosticsAggregationEventLogConstants.Tuple_DiagnosticsAggregationServiceletLoadFailed, null, new object[]
                {
                    exception
                });
                DiagnosticsAggregationServicelet.Log.Log(DiagnosticsAggregationEvent.ServiceletError, "Getting Local server failed. Details {0}", new object[]
                {
                    exception
                });
                ExTraceGlobals.DiagnosticsAggregationTracer.TraceError <Exception>(0L, "Encountered an error while getting local server object. Details {0}.", exception);
                return(false);
            }
            ADOperationResult adoperationResult2 = DiagnosticsAggregationServicelet.GetTransportSettings();

            if (!adoperationResult2.Succeeded)
            {
                Exception exception2 = adoperationResult2.Exception;
                DiagnosticsAggregationServicelet.EventLog.LogEvent(MSExchangeDiagnosticsAggregationEventLogConstants.Tuple_DiagnosticsAggregationServiceletLoadFailed, null, new object[]
                {
                    exception2
                });
                DiagnosticsAggregationServicelet.Log.Log(DiagnosticsAggregationEvent.ServiceletError, "Getting transportsettings failed. Details {0}", new object[]
                {
                    exception2
                });
                ExTraceGlobals.DiagnosticsAggregationTracer.TraceError <Exception>(0L, "Encountered an error while getting TransportSettings configuration. Details {0}.", exception2);
                return(false);
            }
            return(true);
        }
Esempio n. 2
0
        private bool TryHostDiagnosticsWebService(bool rehosting, out ServiceHost host)
        {
            host = null;
            Exception ex = null;
            int       diagnosticsAggregationServicePort = DiagnosticsAggregationServicelet.TransportSettings.DiagnosticsAggregationServicePort;

            try
            {
                host = new ServiceHost(typeof(DiagnosticsAggregationServiceImpl), new Uri[0]);
                string text = string.Format(CultureInfo.InvariantCulture, DiagnosticsAggregationHelper.DiagnosticsAggregationEndpointFormat, new object[]
                {
                    "localhost",
                    diagnosticsAggregationServicePort
                });
                host.AddServiceEndpoint(typeof(IDiagnosticsAggregationService), DiagnosticsAggregationServicelet.GetTcpBinding(), text);
                this.AddMetadataEndpointInDebugBuild(host);
                host.Open();
                DiagnosticsAggregationServicelet.Log.Log(DiagnosticsAggregationEvent.Information, string.Format(CultureInfo.InvariantCulture, "listening at {0}", new object[]
                {
                    text
                }), new object[0]);
            }
            catch (InvalidOperationException ex2)
            {
                ex = ex2;
            }
            catch (CommunicationException ex3)
            {
                ex = ex3;
            }
            catch (TimeoutException ex4)
            {
                ex = ex4;
            }
            finally
            {
                if (ex != null && host != null)
                {
                    WcfUtils.DisposeWcfClientGracefully(host, false);
                }
            }
            if (ex != null)
            {
                ExTraceGlobals.DiagnosticsAggregationTracer.TraceError <Exception>(0L, "HostService Failed {0}.", ex);
                if (rehosting)
                {
                    DiagnosticsAggregationServicelet.EventLog.LogEvent(MSExchangeDiagnosticsAggregationEventLogConstants.Tuple_DiagnosticsAggregationRehostingFailed, null, new object[]
                    {
                        diagnosticsAggregationServicePort,
                        ex
                    });
                }
                else
                {
                    DiagnosticsAggregationServicelet.EventLog.LogEvent(MSExchangeDiagnosticsAggregationEventLogConstants.Tuple_DiagnosticsAggregationServiceletLoadFailed, null, new object[]
                    {
                        ex
                    });
                }
                DiagnosticsAggregationServicelet.Log.Log(DiagnosticsAggregationEvent.ServiceletError, ex.ToString(), new object[0]);
                return(false);
            }
            return(true);
        }
Esempio n. 3
0
        private void HostService()
        {
            ExTraceGlobals.DiagnosticsAggregationTracer.TraceDebug(0L, "DiagnosticsAggregationServicelet HostService started.");
            DiagnosticsAggregationServicelet.log.Start(DiagnosticsAggregationServicelet.config);
            if (!DiagnosticsAggregationServicelet.TryReadAdObjects())
            {
                return;
            }
            ServiceHost serviceHost = null;

            try
            {
                this.RegisterForChangeNotifications();
                if (!this.TryHostDiagnosticsWebService(false, out serviceHost))
                {
                    return;
                }
                this.StartPeriodicDagAggregation();
                while (!base.StopEvent.WaitOne(TimeSpan.FromMinutes(1.0)))
                {
                    if (DiagnosticsAggregationServicelet.transportSettingsChanged)
                    {
                        DiagnosticsAggregationServicelet.transportSettingsChanged = false;
                        TransportConfigContainer transportConfigContainer = DiagnosticsAggregationServicelet.TransportSettings;
                        if (DiagnosticsAggregationServicelet.GetTransportSettings() != ADOperationResult.Success)
                        {
                            DiagnosticsAggregationServicelet.Log.Log(DiagnosticsAggregationEvent.ServiceletError, "Fetching transport settings failed", new object[0]);
                        }
                        else if (transportConfigContainer.DiagnosticsAggregationServicePort != DiagnosticsAggregationServicelet.TransportSettings.DiagnosticsAggregationServicePort)
                        {
                            DiagnosticsAggregationServicelet.Log.Log(DiagnosticsAggregationEvent.Information, "Webservice port is changed from {0} to {1}. Hosting the webservice with the new bindings.", new object[]
                            {
                                transportConfigContainer.DiagnosticsAggregationServicePort,
                                DiagnosticsAggregationServicelet.TransportSettings.DiagnosticsAggregationServicePort
                            });
                            ServiceHost serviceHost2 = null;
                            if (this.TryHostDiagnosticsWebService(true, out serviceHost))
                            {
                                ServiceHost client = serviceHost;
                                serviceHost = serviceHost2;
                                WcfUtils.DisposeWcfClientGracefully(client, false);
                            }
                            else
                            {
                                DiagnosticsAggregationServicelet.Log.Log(DiagnosticsAggregationEvent.ServiceletError, "Hosting the webservice with new bindings did not succeed.", new object[0]);
                            }
                        }
                        else
                        {
                            DiagnosticsAggregationServicelet.Log.Log(DiagnosticsAggregationEvent.Information, "Webservice port did not change.", new object[0]);
                        }
                    }
                }
            }
            finally
            {
                if (DiagnosticsAggregationServicelet.groupQueuesDataProvider != null)
                {
                    DiagnosticsAggregationServicelet.groupQueuesDataProvider.Stop();
                }
                if (DiagnosticsAggregationServicelet.localQueuesDataProvider != null)
                {
                    DiagnosticsAggregationServicelet.localQueuesDataProvider.Stop();
                }
                WcfUtils.DisposeWcfClientGracefully(serviceHost, false);
                this.UnregisterADNotifications();
                DiagnosticsAggregationServicelet.log.Stop();
            }
            ExTraceGlobals.DiagnosticsAggregationTracer.TraceDebug(0L, "HostService Stopped.");
        }
Esempio n. 4
0
 private static void OnLocalServerChanged(ADNotificationEventArgs args)
 {
     ExTraceGlobals.DiagnosticsAggregationTracer.TraceDebug(0L, "LocalServer changed");
     DiagnosticsAggregationServicelet.Log.Log(DiagnosticsAggregationEvent.Information, "LocalServer changed", new object[0]);
     DiagnosticsAggregationServicelet.GetLocalServer();
 }
 public DiagnosticsAggregationServiceImpl()
 {
     this.localQueuesDataProvider = DiagnosticsAggregationServicelet.GetLocalQueuesDataProvider();
     this.groupQueuesDataProvider = DiagnosticsAggregationServicelet.GetGroupQueuesDataProvider();
     this.log = DiagnosticsAggregationServicelet.Log;
 }
Esempio n. 6
0
 private void RefreshCurrentGroupServerToQueuesMap()
 {
     ADNotificationAdapter.TryRunADOperation(new ADOperation(this.RefreshCurrentGroupServers), 2);
     lock (this)
     {
         ADObjectId[] array = new ADObjectId[this.currentGroupServerToQueuesMap.Keys.Count];
         this.currentGroupServerToQueuesMap.Keys.CopyTo(array, 0);
         foreach (ADObjectId adobjectId in array)
         {
             if (!this.currentGroupServers.Contains(adobjectId))
             {
                 this.currentGroupServerToQueuesMap.Remove(adobjectId);
             }
         }
     }
     foreach (ADObjectId adobjectId2 in this.currentGroupServers)
     {
         string uri = string.Format(CultureInfo.InvariantCulture, DiagnosticsAggregationHelper.DiagnosticsAggregationEndpointFormat, new object[]
         {
             adobjectId2.Name,
             DiagnosticsAggregationServicelet.TransportSettings.DiagnosticsAggregationServicePort
         });
         Exception ex = null;
         DiagnosticsAggregationServiceClient diagnosticsAggregationServiceClient = null;
         try
         {
             diagnosticsAggregationServiceClient = new DiagnosticsAggregationServiceClient(DiagnosticsAggregationServicelet.GetTcpBinding(), new EndpointAddress(uri));
         }
         catch (UriFormatException ex2)
         {
             ex = ex2;
         }
         LocalViewRequest localViewRequest = new LocalViewRequest(RequestType.Queues);
         localViewRequest.QueueLocalViewRequest = new QueueLocalViewRequest();
         Stopwatch stopwatch = new Stopwatch();
         stopwatch.Start();
         GroupQueuesDataProvider.GetLocalViewAsyncState asyncState = new GroupQueuesDataProvider.GetLocalViewAsyncState
         {
             Client           = diagnosticsAggregationServiceClient,
             Server           = adobjectId2,
             Stopwatch        = stopwatch,
             RequestSessionId = localViewRequest.ClientInformation.SessionId
         };
         try
         {
             if (diagnosticsAggregationServiceClient != null)
             {
                 diagnosticsAggregationServiceClient.BeginGetLocalView(localViewRequest, new AsyncCallback(this.OnGetLocalViewCompleted), asyncState);
             }
         }
         catch (EndpointNotFoundException ex3)
         {
             ex = ex3;
         }
         catch (InsufficientMemoryException ex4)
         {
             ex = ex4;
         }
         catch (CommunicationException ex5)
         {
             ex = ex5;
         }
         catch (TimeoutException ex6)
         {
             ex = ex6;
         }
         if (ex != null)
         {
             WcfUtils.DisposeWcfClientGracefully(diagnosticsAggregationServiceClient, false);
             stopwatch.Stop();
             this.UpdateSnapshotForServer(adobjectId2, localViewRequest.ClientInformation.SessionId, stopwatch.Elapsed, null, ex.Message);
             if (ex is InsufficientMemoryException)
             {
                 lock (this)
                 {
                     this.log.Log(DiagnosticsAggregationEvent.OutOfResources, "running out of ephemeral ports, will stop making further web service requests", new object[0]);
                     break;
                 }
             }
         }
     }
 }