示例#1
0
 public override void DisposeWebServiceClient(IDiagnosticsAggregationService client)
 {
     if (client != null)
     {
         WcfUtils.DisposeWcfClientGracefully((DiagnosticsAggregationServiceClient)client, false);
     }
 }
示例#2
0
        private void OnGetLocalViewCompleted(IAsyncResult ar)
        {
            GroupQueuesDataProvider.GetLocalViewAsyncState getLocalViewAsyncState = (GroupQueuesDataProvider.GetLocalViewAsyncState)ar.AsyncState;
            DiagnosticsAggregationServiceClient            client = getLocalViewAsyncState.Client;
            ADObjectId        server       = getLocalViewAsyncState.Server;
            Stopwatch         stopwatch    = getLocalViewAsyncState.Stopwatch;
            LocalViewResponse response     = null;
            string            errorMessage = null;

            try
            {
                response = client.EndGetLocalView(ar);
            }
            catch (FaultException <DiagnosticsAggregationFault> faultException)
            {
                errorMessage = faultException.Detail.ToString();
            }
            catch (CommunicationException ex)
            {
                errorMessage = ex.Message;
            }
            catch (TimeoutException ex2)
            {
                errorMessage = ex2.Message;
            }
            finally
            {
                WcfUtils.DisposeWcfClientGracefully(client, false);
            }
            stopwatch.Stop();
            this.UpdateSnapshotForServer(server, getLocalViewAsyncState.RequestSessionId, stopwatch.Elapsed, response, errorMessage);
        }
示例#3
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);
        }
示例#4
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.");
        }
示例#5
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;
                 }
             }
         }
     }
 }