Example #1
0
		/// <summary>
		/// Returns name of Cache from the property map.
		/// </summary>
		/// <param name="properties">properties map</param>
		/// <returns>cache name.</returns>
		static private CacheInfo GetCacheInfo(IDictionary properties)
		{
			if(!properties.Contains("cache"))
				throw new ConfigurationException("Missing configuration attribute 'cache'");

			CacheInfo inf = new CacheInfo();
			IDictionary cacheConfig = (IDictionary)properties[ "cache" ];

			string schemeName = "";
			if(cacheConfig.Contains("name"))
				inf.Name = Convert.ToString(cacheConfig["name"]).Trim();

			if(!cacheConfig.Contains("class"))
				throw new ConfigurationException("Missing configuration attribute 'class'");
				
			schemeName = Convert.ToString(cacheConfig[ "class" ]);
			if(inf.Name.Length < 1)
				inf.Name = schemeName;

			if(!cacheConfig.Contains("cache-classes"))
				throw new ConfigurationException("Missing configuration section 'cache-classes'");
			IDictionary cacheClasses = (IDictionary)cacheConfig[ "cache-classes" ];
			
			if(!cacheClasses.Contains(schemeName.ToLower()))
                throw new ConfigurationException("Cannot find cache class '" + schemeName + "'");
			IDictionary schemeProps = (IDictionary)cacheClasses[ schemeName.ToLower() ];

			if(!schemeProps.Contains("type"))
                throw new ConfigurationException("Cannot find the type of cache, invalid configuration for cache class '" + schemeName + "'");

			inf.ClassName = Convert.ToString(schemeProps["type"]);
			return inf;
		}
Example #2
0
        /// <summary>
        /// Start the cache logging functionality.
        /// </summary>
        internal static NewTrace Initialize(IDictionary properties, CacheRuntimeContext context, CacheInfo cacheInfo, bool isStartedAsMirror, bool inproc)
        {
            NewTrace nTrace = new NewTrace();

            if (properties.Contains("enabled"))
            {
                bool enabled = Convert.ToBoolean(properties["enabled"]);

                if (!enabled)
                {
                    nTrace.IsFatalEnabled = nTrace.IsErrorEnabled = false;
                    nTrace.IsWarnEnabled  = nTrace.isInfoEnabled = false;
                    nTrace.IsDebugEnabled = false;
                    return(nTrace);
                }
            }

            try
            {
                string cache_name = cacheInfo.Name;
                if (cacheInfo.CurrentPartitionId != null && cacheInfo.CurrentPartitionId != string.Empty)
                {
                    cache_name += "-" + cacheInfo.CurrentPartitionId;
                }

                if (isStartedAsMirror)
                {
                    cache_name += "-" + "replica";
                }

                if (inproc && !isStartedAsMirror)
                {
                    cache_name += "." + System.Diagnostics.Process.GetCurrentProcess().Id;
                }
                nTrace.SetOutputStream(cache_name, Log.GetLogPath());
            }
            catch (Exception e)
            {
                AppUtil.LogEvent("NCache", "Failed to open log. " + e, System.Diagnostics.EventLogEntryType.Error, EventCategories.Error, EventID.GeneralError);
            }

            if (properties.Contains("usehptime"))
            {
                nTrace.UseHPTime = Convert.ToBoolean(properties["usehptime"]);
            }

            if (properties.Contains("trace-errors"))
            {
                nTrace.IsErrorEnabled        = Convert.ToBoolean(properties["trace-errors"]);
                nTrace.IsCriticalInfoEnabled = Convert.ToBoolean(properties["trace-errors"]);
            }

            if (properties.Contains("trace-warnings"))
            {
                nTrace.IsWarnEnabled = Convert.ToBoolean(properties["trace-warnings"]);
            }

            if (properties.Contains("trace-debug"))
            {
                nTrace.IsInfoEnabled = Convert.ToBoolean(properties["trace-debug"]);
            }

            nTrace.IsFatalEnabled = nTrace.IsErrorEnabled;
            nTrace.IsDebugEnabled = nTrace.IsWarnEnabled = nTrace.IsInfoEnabled;


            return(nTrace);
        }
Example #3
0
 /// <summary>
 /// Overlaoded constructor, used internally by Cache Manager.
 /// </summary>
 /// <param name="configString">property string used to create cache.</param>
 protected internal Cache(string configString, CacheRenderer renderer)
 {
     _context.CacheRoot = this;
     _cacheInfo = ConfigHelper.GetCacheInfo(configString);
     _context.Render = renderer;
 }
Example #4
0
 /// <summary>
 /// Start the cache logging functionality.
 /// </summary>
 internal static NewTrace Initialize(IDictionary properties, CacheRuntimeContext context, CacheInfo cacheInfo)
 {
     return(Initialize(properties, context, cacheInfo, false, false));
 }
Example #5
0
        /// <summary>
        /// Overlaoded constructor, used internally by Cache Manager.
        /// </summary>
        /// <param name="configString">property string used to create cache.</param>

        protected internal Cache(string configString)
        {
            _context.CacheRoot = this;
            _cacheInfo = ConfigHelper.GetCacheInfo(configString);
        }