public LocalViewResponse GetLocalView(LocalViewRequest request)
        {
            LocalViewResponse response = null;

            this.ServiceRequest(delegate
            {
                Stopwatch stopwatch = new Stopwatch();
                stopwatch.Start();
                ExTraceGlobals.DiagnosticsAggregationTracer.TraceFunction <string, string, string>(0L, "GetLocalView called. ClientMachineName={0}; ClientProcessName={1}; ClientProcessId={2}", (request.ClientInformation == null) ? string.Empty : request.ClientInformation.ClientMachineName, (request.ClientInformation == null) ? string.Empty : request.ClientInformation.ClientProcessName, (request.ClientInformation == null) ? string.Empty : request.ClientInformation.ClientProcessId.ToString());
                this.log.LogOperationFromClient(DiagnosticsAggregationEvent.LocalViewRequestReceived, request.ClientInformation, null, "");
                DiagnosticsAggregationServiceImpl.VerifyParameterIsNotNull(request, "request");
                DiagnosticsAggregationServiceImpl.VerifyParameterIsNotNullOrEmpty(request.RequestType, "request.RequestType");
                RequestType requestType;
                bool flag = Enum.TryParse <RequestType>(request.RequestType, out requestType);
                if (!flag || requestType != RequestType.Queues)
                {
                    throw DiagnosticsAggregationServiceImpl.NewUnsupportedParameterFault(request.RequestType, "request.RequestType");
                }
                ServerQueuesSnapshot localServerQueues = this.localQueuesDataProvider.GetLocalServerQueues();
                if (localServerQueues.IsEmpty())
                {
                    throw DiagnosticsAggregationServiceImpl.NewFault(ErrorCode.LocalQueueDataNotAvailable, localServerQueues.LastError);
                }
                string message;
                if (this.LocalQueueDataTooOld(localServerQueues.TimeStampOfQueues, out message))
                {
                    throw DiagnosticsAggregationServiceImpl.NewFault(ErrorCode.LocalQueueDataTooOld, message);
                }
                response = new LocalViewResponse(localServerQueues.GetServerSnapshotStatus());
                response.QueueLocalViewResponse = new QueueLocalViewResponse(new List <LocalQueueInfo>(localServerQueues.Queues), localServerQueues.TimeStampOfQueues);
                stopwatch.Stop();
                this.log.LogOperationFromClient(DiagnosticsAggregationEvent.LocalViewResponseSent, request.ClientInformation, new TimeSpan?(stopwatch.Elapsed), "");
            }, "GetLocalView", request.ClientInformation);
            return(response);
        }
Exemplo n.º 2
0
 private void UpdateSnapshotForServer(ADObjectId server, uint requestSessionId, TimeSpan operationDuration, LocalViewResponse response, string errorMessage)
 {
     lock (this)
     {
         ServerQueuesSnapshot serverQueuesSnapshot = null;
         bool flag2 = this.currentGroupServerToQueuesMap.TryGetValue(server, out serverQueuesSnapshot);
         if (flag2)
         {
             serverQueuesSnapshot = serverQueuesSnapshot.Clone();
         }
         else
         {
             serverQueuesSnapshot = new ServerQueuesSnapshot(server);
         }
         if (response == null)
         {
             serverQueuesSnapshot.UpdateFailure(errorMessage);
             this.log.LogOperationToServer(DiagnosticsAggregationEvent.LocalViewRequestSentFailed, requestSessionId, server.Name, new TimeSpan?(operationDuration), errorMessage);
         }
         else
         {
             serverQueuesSnapshot.UpdateSuccess(response);
             this.log.LogOperationToServer(DiagnosticsAggregationEvent.LocalViewResponseReceived, requestSessionId, server.Name, new TimeSpan?(operationDuration), "");
         }
         this.currentGroupServerToQueuesMap[server] = serverQueuesSnapshot;
     }
 }
        public AggregatedViewResponse GetAggregatedView(AggregatedViewRequest request)
        {
            ExTraceGlobals.DiagnosticsAggregationTracer.TraceFunction <string, string, string>(0L, "GetAggregatedView called. ClientMachineName={0}; ClientProcessName={1}; ClientProcessId={2}", (request.ClientInformation == null) ? string.Empty : request.ClientInformation.ClientMachineName, (request.ClientInformation == null) ? string.Empty : request.ClientInformation.ClientProcessName, (request.ClientInformation == null) ? string.Empty : request.ClientInformation.ClientProcessId.ToString());
            AggregatedViewResponse response = null;

            this.ServiceRequest(delegate
            {
                Stopwatch stopwatch = new Stopwatch();
                stopwatch.Start();
                this.log.LogOperationFromClient(DiagnosticsAggregationEvent.AggregatedViewRequestReceived, request.ClientInformation, null, "");
                DiagnosticsAggregationServiceImpl.VerifyParameterIsNotNull(request, "request");
                DiagnosticsAggregationServiceImpl.VerifyParameterIsNotNullOrEmpty(request.RequestType, "request.RequestType");
                RequestType requestType;
                bool flag = Enum.TryParse <RequestType>(request.RequestType, out requestType);
                if (!flag || requestType != RequestType.Queues)
                {
                    throw DiagnosticsAggregationServiceImpl.NewUnsupportedParameterFault(request.RequestType, "request.RequestType");
                }
                DiagnosticsAggregationServiceImpl.VerifyParameterIsNotNull(request.QueueAggregatedViewRequest, "request.QueueAggregatedViewRequest");
                IQueueFilter filter;
                if (!QueueFilter.TryParse(request.QueueAggregatedViewRequest.QueueFilter, out filter))
                {
                    throw DiagnosticsAggregationServiceImpl.NewInvalidParameterFault(request.QueueAggregatedViewRequest.QueueFilter, "request.QueueAggregatedViewRequest.QueueFilter");
                }
                DiagnosticsAggregationServiceImpl.VerifyParameterIsNotNullOrEmpty(request.QueueAggregatedViewRequest.GroupByKey, "request.QueueAggregatedViewRequest.GroupByKey");
                QueueDigestGroupBy groupByKey;
                if (!Enum.TryParse <QueueDigestGroupBy>(request.QueueAggregatedViewRequest.GroupByKey, out groupByKey))
                {
                    throw DiagnosticsAggregationServiceImpl.NewUnsupportedParameterFault(request.QueueAggregatedViewRequest.GroupByKey, "request.QueueAggregatedViewRequest.GroupByKey");
                }
                DiagnosticsAggregationServiceImpl.VerifyParameterIsNotNullOrEmpty(request.QueueAggregatedViewRequest.DetailsLevel, "request.QueueAggregatedViewRequest.DetailsLevel");
                DetailsLevel detailsLevel;
                if (!Enum.TryParse <DetailsLevel>(request.QueueAggregatedViewRequest.DetailsLevel, out detailsLevel))
                {
                    throw DiagnosticsAggregationServiceImpl.NewUnsupportedParameterFault(request.QueueAggregatedViewRequest.DetailsLevel, "request.QueueAggregatedViewRequest.DetailsLevel");
                }
                QueueAggregator queueAggregator = new QueueAggregator(groupByKey, detailsLevel, filter, new TimeSpan?(this.GetTimeSpanForQueueDataBeingCurrent()));
                bool flag2 = request.ServersToInclude != null && request.ServersToInclude.Count > 0;
                HashSet <string> hashSet = flag2 ? new HashSet <string>(request.ServersToInclude, StringComparer.InvariantCultureIgnoreCase) : new HashSet <string>();
                IDictionary <ADObjectId, ServerQueuesSnapshot> currentGroupServerToQueuesMap = this.groupQueuesDataProvider.GetCurrentGroupServerToQueuesMap();
                currentGroupServerToQueuesMap.Add(this.localQueuesDataProvider.GetLocalServerId(), this.localQueuesDataProvider.GetLocalServerQueues());
                List <ServerSnapshotStatus> list = new List <ServerSnapshotStatus>();
                foreach (KeyValuePair <ADObjectId, ServerQueuesSnapshot> keyValuePair in currentGroupServerToQueuesMap)
                {
                    ADObjectId key             = keyValuePair.Key;
                    ServerQueuesSnapshot value = keyValuePair.Value;
                    if (!flag2 || hashSet.Contains(key.ToString()))
                    {
                        string message;
                        if (value.IsEmpty())
                        {
                            value.SetAsFailed(DiagnosticsAggregationServiceImpl.NewFault(ErrorCode.LocalQueueDataNotAvailable, value.LastError).Detail.ToString());
                        }
                        else if (this.LocalQueueDataTooOld(value.TimeStampOfQueues, out message))
                        {
                            value.SetAsFailed(DiagnosticsAggregationServiceImpl.NewFault(ErrorCode.LocalQueueDataTooOld, message).Detail.ToString());
                        }
                        else
                        {
                            queueAggregator.AddLocalQueues(value.Queues, value.TimeStampOfQueues);
                        }
                        list.Add(value.GetServerSnapshotStatus());
                    }
                }
                response = new AggregatedViewResponse(list);
                response.QueueAggregatedViewResponse = new QueueAggregatedViewResponse(queueAggregator.GetResultSortedByMessageCount(request.ResultSize));
                stopwatch.Stop();
                this.log.LogOperationFromClient(DiagnosticsAggregationEvent.AggregatedViewResponseSent, request.ClientInformation, new TimeSpan?(stopwatch.Elapsed), "");
            }, "GetAggregatedView", request.ClientInformation);
            return(response);
        }