コード例 #1
0
ファイル: Paging.cs プロジェクト: trisadmeslek/ravendb
        public void Add(PagingOperationType operation, string action, string details, long numberOfResults, int pageSize, long duration, long totalDocumentsSizeInBytes)
        {
            var now    = SystemTime.UtcNow;
            var update = _pagingUpdates[(int)operation];

            if (now - update < TimeSpan.FromSeconds(15))
            {
                return;
            }

            _pagingUpdates[(int)operation] = now;
            _pagingQueue.Enqueue(new PagingInformation(operation, action, details, numberOfResults, pageSize, duration, now, totalDocumentsSizeInBytes));

            while (_pagingQueue.Count > 50)
            {
                _pagingQueue.TryDequeue(out _);
            }

            if (_pagingTimer != null)
            {
                return;
            }

            lock (_locker)
            {
                if (_pagingTimer != null)
                {
                    return;
                }

                _pagingTimer = new Timer(UpdatePaging, null, TimeSpan.FromMinutes(1), TimeSpan.FromMinutes(1));
            }
        }
コード例 #2
0
ファイル: Paging.cs プロジェクト: trisadmeslek/ravendb
        private PerformanceHint GetPagingPerformanceHint(string id, PagingOperationType type)
        {
            using (_notificationsStorage.Read(id, out NotificationTableValue ntv))
            {
                PagingPerformanceDetails details;
                if (ntv == null || ntv.Json.TryGet(nameof(PerformanceHint.Details), out BlittableJsonReaderObject detailsJson) == false || detailsJson == null)
                {
                    details = new PagingPerformanceDetails();
                }
                else
                {
                    details = DocumentConventions.DefaultForServer.Serialization.DefaultConverter.FromBlittable <PagingPerformanceDetails>(detailsJson, id);
                }

                switch (type)
                {
                case PagingOperationType.Documents:
                case PagingOperationType.Queries:
                    return(PerformanceHint.Create(_database, $"Page size too big ({type.ToString().ToLower()})", "We have detected that some of the requests are returning excessive amount of documents. Consider using smaller page sizes or streaming operations.", PerformanceHintType.Paging, NotificationSeverity.Warning, type.ToString(), details));

                case PagingOperationType.Revisions:
                    return(PerformanceHint.Create(_database, "Page size too big (revisions)", "We have detected that some of the requests are returning excessive amount of revisions. Consider using smaller page sizes.", PerformanceHintType.Paging, NotificationSeverity.Warning, type.ToString(), details));

                case PagingOperationType.CompareExchange:
                    return(PerformanceHint.Create(_database, "Page size too big (compare exchange)", "We have detected that some of the requests are returning excessive amount of compare exchange values. Consider using smaller page sizes.", PerformanceHintType.Paging, NotificationSeverity.Warning, type.ToString(), details));

                default:
                    throw new ArgumentOutOfRangeException(nameof(type), type, null);
                }
            }
        }
コード例 #3
0
        protected void AddPagingPerformanceHint(PagingOperationType operation, string action, string details, long numberOfResults, int pageSize, long duration)
        {
            if (numberOfResults <= Database.Configuration.PerformanceHints.MaxNumberOfResults)
            {
                return;
            }

            Database.NotificationCenter.Paging.Add(operation, action, details, numberOfResults, pageSize, duration);
        }
コード例 #4
0
        protected void AddPagingPerformanceHint(PagingOperationType operation, string action, HttpContext httpContext, int numberOfResults, int pageSize, TimeSpan duration)
        {
            if (numberOfResults <= Database.Configuration.PerformanceHints.MaxNumberOfResults)
            {
                return;
            }

            Database.NotificationCenter.Paging.Add(operation, action, httpContext.Request.QueryString.Value, numberOfResults, pageSize, duration);
        }
コード例 #5
0
ファイル: Paging.cs プロジェクト: trisadmeslek/ravendb
 public PagingInformation(PagingOperationType type, string action, string details, long numberOfResults, int pageSize, long duration, DateTime occurrence, long totalDocumentsSizeInBytes)
 {
     Type                      = type;
     Action                    = action;
     Details                   = details;
     NumberOfResults           = numberOfResults;
     PageSize                  = pageSize;
     Duration                  = duration;
     Occurrence                = occurrence;
     TotalDocumentsSizeInBytes = totalDocumentsSizeInBytes;
 }