Ejemplo n.º 1
0
            private UrlStatistics GetStatistics(HttpRequest request, int code)
            {
                string url = request.GetSourceBaseUrl();

                if (!mStats.TryGetValue(url, out UrlStatistics result))
                {
                    if (mStats.Count >= mGateway.MaxStatsUrls)
                    {
                        return(null);
                    }
                    if (code >= 400)
                    {
                        return(null);
                    }
                    result      = new UrlStatistics(request.GetSourceBaseUrl());
                    result.Path = request.GetSourcePath();
                    result.Ext  = request.Ext;
                    if (mStats.TryAdd(url, result))
                    {
                        mPaths[url] = url;
                        System.Threading.Interlocked.Increment(ref mVersion);
                    }
                    else
                    {
                        mStats.TryGetValue(url, out result);
                    }
                }
                return(result);
            }
Ejemplo n.º 2
0
        public UrlStatistics GetUrlStatistics(string url, HttpRequest request, int code)
        {
            var id    = GetUrlCode(url);
            var stats = urlStatisticsDictionary.GetStatistics(id);

            if (stats == null)
            {
                if (code == 404)
                {
                    return(null);
                }
                lock (urlStatisticsDictionary)
                {
                    if (mUrlStatisticsCount >= Gateway.MaxStatsUrls)
                    {
                        return(null);
                    }
                    stats = urlStatisticsDictionary.GetStatistics(id);
                    if (stats == null)
                    {
                        stats      = new UrlStatistics(url);
                        stats.Path = request.Path;
                        urlStatisticsDictionary.SetStatistics(id, stats);
                        System.Threading.Interlocked.Increment(ref mUrlStatisticsCount);
                    }
                }
            }
            return(stats);
        }
Ejemplo n.º 3
0
        public UrlStatistics GetUrlStatistics(string url)
        {
            var id    = GetUrlCode(url);
            var stats = urlStatisticsDictionary.GetStatistics(id);

            if (stats == null)
            {
                lock (urlStatisticsDictionary)
                {
                    stats = urlStatisticsDictionary.GetStatistics(id);
                    if (stats == null)
                    {
                        stats = new UrlStatistics(url);
                        urlStatisticsDictionary.SetStatistics(id, stats);
                        System.Threading.Interlocked.Increment(ref mUrlStatisticsCount);
                    }
                }
            }
            return(stats);
        }
Ejemplo n.º 4
0
            public void SetStatistics(ulong url, UrlStatistics agent)
            {
                ConcurrentDictionary <ulong, UrlStatistics> keyValuePairs = mDictionarys[(int)(url % (uint)mDictionarys.Count)];

                keyValuePairs[url] = agent;
            }