Exemple #1
0
        public override void GetKeyList(int bucketId, bool startLogging, out ClusteredArrayList keyList)
        {
            try
            {
                _rwBucketsLock.EnterWriteLock();
                if (startLogging)
                {
                    _logMgr.StartLogging(bucketId, LogMode.LogBeforeAfterActualOperation);
                }

                keyList = new ClusteredArrayList();
                if (_keyList != null)
                {
                    if (_keyList.Contains(bucketId))
                    {
                        BucketStatistcs bucketStats = _keyList[bucketId] as BucketStatistcs;
                        keyList = bucketStats.GetCacheKeys();
                    }
                }
            }
            finally
            {
                _rwBucketsLock.ExitWriteLock();
            }
        }
Exemple #2
0
        private void IncrementBucketStats(string cacheKeyOrMessageId, int bucketId, long dataSize, bool isMessage, string topic)
        {
            lock (_bucketStatsMutex)
            {
                if (_stats.LocalBuckets != null && _stats.LocalBuckets.Contains(bucketId))
                {
                    if (isMessage)
                    {
                        ((BucketStatistics)_stats.LocalBuckets[bucketId]).IncrementTopicStats(topic, dataSize);
                    }
                    else
                    {
                        ((BucketStatistics)_stats.LocalBuckets[bucketId]).Increment(dataSize);
                    }
                }
            }

            if (_keyList == null)
            {
                _keyList = new HashVector();
            }
            if (_keyList != null)
            {
                HashVector      keys;
                BucketStatistcs bucketStats = null;
                bool            isKeyExist  = false;

#if NET40
                try
                {
                    _keyListLock.Enter();
#else
                lock (_keyListLock)
                {
#endif
                    if (!_keyList.Contains(bucketId))
                    {
                        bucketStats        = new BucketStatistcs(bucketId);
                        _keyList[bucketId] = bucketStats;

                        if (isMessage)
                        {
                            bucketStats.AddMessage(topic, cacheKeyOrMessageId);
                        }
                        else
                        {
                            bucketStats.AddCacheKey(cacheKeyOrMessageId);
                        }

                        _inMemorySize += bucketStats.InMemorySize;
                        isKeyExist     = true;
                    }
                    else
                    {
                    }
#if NET40
                }
                finally
                {
                    _keyListLock.Exit();
                }
#else
                }
#endif
                if (isKeyExist)
                {
                    return;
                }

                bucketStats = (BucketStatistcs)_keyList[bucketId];
                long oldSize = bucketStats.InMemorySize;

                lock (bucketStats)
                {
                    if (isMessage)
                    {
                        bucketStats.AddMessage(topic, cacheKeyOrMessageId);
                    }
                    else
                    {
                        bucketStats.AddCacheKey(cacheKeyOrMessageId);
                    }
                }

                long newSize = bucketStats.InMemorySize;
                long tmpsize = _inMemorySize;

                _inMemorySize = tmpsize + (newSize - oldSize);
            }