コード例 #1
0
        public void UnregisterFirstLevelCache(IWritableCache firstLevelCache, CacheFactoryDirective cacheFactoryDirective, bool foreignThreadAware, String name)
        {
            // cacheFactoryDirective and foreignThreadAware will be intentionally ignored at unregister

            unboundWriteLock.Lock();
            try
            {
                CheckCachesForCleanup();
                int      cacheId  = firstLevelCache.CacheId;
                FlcEntry flcEntry = DictionaryExtension.ValueOrDefault(allFLCs, cacheId);
                if (flcEntry == null)
                {
                    throw new Exception("CacheId is not mapped to a valid cache instance");
                }
                IWritableCache existingChildCache = flcEntry.GetFirstLevelCache();
                if (existingChildCache == null)
                {
                    throw new Exception("Fatal error occured. Reference lost to cache");
                }
                if (existingChildCache != firstLevelCache)
                {
                    throw new Exception("Fatal error occured. CacheId invalid - it is not mapped to the specified cache instance");
                }
                allFLCs.Remove(cacheId);
                foreignThreadAware    = flcEntry.IsForeignThreadAware();
                cacheFactoryDirective = flcEntry.GetCacheFactoryDirective();

                LogFLC(firstLevelCache, cacheFactoryDirective, foreignThreadAware, name, flcEntry, false);
                firstLevelCache.CacheId = 0;
            }
            finally
            {
                unboundWriteLock.Unlock();
            }
        }
コード例 #2
0
        protected void LogFLC(IWritableCache firstLevelCache, CacheFactoryDirective cacheFactoryDirective, bool foreignThreadAware, String name,
                              FlcEntry flcEntry, bool isRegister)
        {
            if (!Log.DebugEnabled)
            {
                return;
            }
            StringBuilder sb = new StringBuilder();

            if (isRegister)
            {
                sb.Append("Registered");
            }
            else
            {
                sb.Append("Unregistered");
            }
            sb.Append(" FLC");
            if (name != null)
            {
                sb.Append(" '").Append(name).Append("'");
            }
            sb.Append(" with id: ").Append(firstLevelCache.CacheId);
            if (firstLevelCache.Privileged)
            {
                sb.Append(", privileged");
            }
            else
            {
                sb.Append(", non-privileged");
            }
            if (CacheFactoryDirective.SubscribeTransactionalDCE.Equals(flcEntry.GetCacheFactoryDirective()))
            {
                sb.Append(", transactional");
                if (foreignThreadAware)
                {
                    sb.Append(", multithreaded");
                }
                else
                {
                    Thread thread = flcEntry.GetOwningThread();
                    sb.Append(", to thread ").Append(thread.ManagedThreadId).Append(':').Append(thread.Name);
                }
            }
            else if (CacheFactoryDirective.SubscribeGlobalDCE.Equals(flcEntry.GetCacheFactoryDirective()))
            {
                sb.Append(", non-transactional");
                if (foreignThreadAware)
                {
                    sb.Append(", multithreaded");
                }
                else
                {
                    Thread thread = flcEntry.GetOwningThread();
                    sb.Append(", to thread ").Append(thread.ManagedThreadId).Append(':').Append(thread.Name);
                }
            }
            else
            {
                sb.Append(", traced");
            }
            Log.Debug(sb.ToString());
        }