private void CreateInternalCache2(IDictionary properties) { if (properties == null) throw new ArgumentNullException("properties"); try { String cacheScheme = Convert.ToString(properties["name"]).Trim(); if (Name.Length < 1) _cacheInfo.Name = cacheScheme; //Initialize the performance counters, if enabled. bool bEnableCounter = true; if (properties.Contains("perf-counters")) { Hashtable perfCountersProps = properties["perf-counters"] as Hashtable; if (perfCountersProps != null) { if (perfCountersProps.Contains("enabled")) bEnableCounter = Convert.ToBoolean(perfCountersProps["enabled"]); } } _context.ExpiryMgr = new ExpirationManager(properties, _context); IDictionary clusterProps = null; if (properties.Contains("cluster")) { clusterProps = properties["cluster"] as IDictionary; if (clusterProps.Contains("topology")) _cacheInfo.ClassName = Convert.ToString(clusterProps["topology"]).Trim(); } else { _cacheInfo.ClassName = "local"; } _context.AsyncProc.Start(); if (_cacheInfo.ClassName.CompareTo("local") == 0) { LocalCacheImpl cache = new LocalCacheImpl(); cache.Internal = CacheBase.Synchronized(new LocalCache(properties, cache, properties, this, _context)); _context.CacheImpl = cache; } else { throw new ConfigurationException("Specified cache class '" + _cacheInfo.ClassName + "' is not available in this edition of "+_cacheserver+"."); } _cacheType = _cacheInfo.ClassName; // Start the expiration manager if the cache was created sucessfully! if (_context.CacheImpl != null) { _context.ExpiryMgr.Start(); if (bEnableCounter) { _context.PerfStatsColl.InitializePerfCounters(this._inProc); } } else { _context.ExpiryMgr.Dispose(); } } catch (ConfigurationException e) { _context.NCacheLog.Error("Cache.CreateInternalCache()", e.ToString()); _context.CacheImpl = null; Dispose(); throw; } catch (Exception e) { _context.NCacheLog.Error("Cache.CreateInternalCache()", e.ToString()); _context.CacheImpl = null; Dispose(); throw new ConfigurationException("Configuration Error: " + e.ToString(), e); } }
private void CreateInternalCache(IDictionary properties, bool isStartingAsMirror, bool twoPhaseInitialization) { if (properties == null) throw new ArgumentNullException("properties"); try { if (!properties.Contains("class")) throw new ConfigurationException("Missing configuration attribute 'class'"); String cacheScheme = Convert.ToString(properties["class"]); if (!properties.Contains("cache-classes")) throw new ConfigurationException("Missing configuration section 'cache-classes'"); IDictionary cacheClasses = (IDictionary)properties["cache-classes"]; if (!cacheClasses.Contains(cacheScheme.ToLower())) throw new ConfigurationException("Can not find cache class '" + cacheScheme + "'"); IDictionary schemeProps = (IDictionary)cacheClasses[cacheScheme.ToLower()]; if (!schemeProps.Contains("type")) throw new ConfigurationException("Can not find the type of cache, invalid configuration for cache class '" + cacheScheme + "'"); if (Name.Length < 1) _cacheInfo.Name = cacheScheme; //Initialize the performance counters, if enabled. bool bEnableCounter = true; if (properties.Contains("perf-counters")) { Hashtable perfCountersProps = properties["perf-counters"] as Hashtable; if (perfCountersProps != null) { if (perfCountersProps.Contains("enabled")) bEnableCounter = Convert.ToBoolean(perfCountersProps["enabled"]); } } bool isClusterable = true; _context.ExpiryMgr = new ExpirationManager(schemeProps, _context); _cacheInfo.ClassName = Convert.ToString(schemeProps["type"]).ToLower(); _context.AsyncProc.Start(); #if !CLIENT if (_cacheInfo.ClassName.CompareTo("replicated-server") == 0) { if (isClusterable) { _context.CacheImpl = new ReplicatedServerCache(cacheClasses, schemeProps, this, _context, this); _context.CacheImpl.Initialize(cacheClasses, schemeProps, twoPhaseInitialization); } } else if (_cacheInfo.ClassName.CompareTo("partitioned-server") == 0 ) { if (isClusterable) { _context.CacheImpl = new PartitionedServerCache(cacheClasses, schemeProps, this, _context, this); _context.CacheImpl.Initialize(cacheClasses, schemeProps, twoPhaseInitialization); } } else #endif { if (_cacheInfo.ClassName.CompareTo("local-cache") == 0) { LocalCacheImpl cache = new LocalCacheImpl(); cache.Internal = CacheBase.Synchronized(new IndexedLocalCache(cacheClasses, cache, schemeProps, this, _context)); _context.CacheImpl = cache; } else { throw new ConfigurationException("Specified cache class '" + _cacheInfo.ClassName + "' is not available in this edition of " + _cacheserver + "."); } } _cacheType = _cacheInfo.ClassName; // Start the expiration manager if the cache was created sucessfully! if (_context.CacheImpl != null) { /// there is no need to do expirations on the Async replica's; /// Expired items are removed fromreplica by the respective active partition. if (!isStartingAsMirror) _context.ExpiryMgr.Start(); if (bEnableCounter) { _context.PerfStatsColl.InitializePerfCounters((isStartingAsMirror ? !isStartingAsMirror : this._inProc)); } } else { _context.ExpiryMgr.Dispose(); } } catch (ConfigurationException e) { _context.NCacheLog.Error("Cache.CreateInternalCache()", e.ToString()); _context.CacheImpl = null; Dispose(); throw; } catch (Exception e) { _context.NCacheLog.Error("Cache.CreateInternalCache()", e.ToString()); _context.CacheImpl = null; Dispose(); throw new ConfigurationException("Configuration Error: " + e.ToString(), e); } }