コード例 #1
0
        /// <summary>
        /// Internal method that creates a cache policy. A HashMap containing the config parameters
        /// is passed to this method.
        /// </summary>
        public static IEvictionPolicy CreateEvictionPolicy(IDictionary properties, ILogger logger)
        {
            if (properties == null)
            {
                throw new ArgumentNullException("properties");
            }

            try
            {
                float evictRatio = 0;
                if (properties.Contains("evict-ratio"))
                {
                    CultureInfo thisCult = Thread.CurrentThread.CurrentCulture;     //get the currently applied culture.
                    Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US"); //change it to enUS
                    evictRatio = Convert.ToSingle(properties["evict-ratio"]);       //get the value out ...
                    Thread.CurrentThread.CurrentCulture = thisCult;                 //revert back the original culture.
                }

                IEvictionPolicy evictionPolicy = null;

                string scheme = "";

                scheme = Convert.ToString(properties["class"]);
                scheme = scheme.ToLower();


                IDictionary schemeProps = (IDictionary)properties[scheme];
                switch (scheme)
                {
                case "priority": evictionPolicy = new PriorityEvictionPolicy(schemeProps, evictRatio); break;
                }
                if (evictionPolicy == null)
                {
                    throw new ConfigurationException("Invalid Eviction Policy: " + scheme);
                }

                //return a thread safe eviction policy.
                return(evictionPolicy);
            }
            catch (ConfigurationException e)
            {
                throw;
            }
            catch (Exception e)
            {
                throw new ConfigurationException("EvictionPolicyFactory.CreateEvictionPolicy(): " + e.ToString());
            }
        }
コード例 #2
0
        /// <summary>
        /// Internal method that creates a cache policy. A HashMap containing the config parameters
        /// is passed to this method.
        /// </summary>
        public static IEvictionPolicy CreateEvictionPolicy(IDictionary properties)
        {
            if (properties == null)
            {
                throw new ArgumentNullException("properties");
            }

            try
            {
                float evictRatio = 0;
                if (properties.Contains("evict-ratio"))                             // for French Parsing error..
                {
                    CultureInfo thisCult = Thread.CurrentThread.CurrentCulture;     //get the currently applied culture.
                    Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US"); //change it to enUS
                    evictRatio = Convert.ToSingle(properties["evict-ratio"]);       //get the value out ...
                    Thread.CurrentThread.CurrentCulture = thisCult;                 //revert back the original culture.
                }

                IEvictionPolicy evictionPolicy = null;

                string scheme = "";

                string tempscheme = Convert.ToString(properties["class"]);
                if (tempscheme.ToLower().Equals("priority"))
                {
                    scheme = tempscheme;
                }
                else
                {
                    throw new ConfigurationException("Eviction Policy " + tempscheme + " Not Supported in this Edition of NCache.");
                }
                IDictionary schemeProps = (IDictionary)properties[scheme];
                evictionPolicy = new PriorityEvictionPolicy(schemeProps, evictRatio);

                //return a thread safe eviction policy.
                return(evictionPolicy);
            }
            catch (ConfigurationException e)
            {
                throw;
            }
            catch (Exception e)
            {
                throw new ConfigurationException("EvictionPolicyFactory.CreateEvictionPolicy(): " + e.ToString());
            }
        }
コード例 #3
0
		/// <summary>
		/// Internal method that creates a cache policy. A HashMap containing the config parameters 
		/// is passed to this method.
		/// </summary>
		public static IEvictionPolicy CreateEvictionPolicy(IDictionary properties)
		{
			if(properties == null)
				throw new ArgumentNullException("properties");

			try
			{
				float evictRatio = 0;
                if (properties.Contains("evict-ratio")) // for French Parsing error..
                {
                    CultureInfo thisCult = Thread.CurrentThread.CurrentCulture; //get the currently applied culture.
                    Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");//change it to enUS
                    evictRatio = Convert.ToSingle(properties["evict-ratio"]); //get the value out ...
                    Thread.CurrentThread.CurrentCulture = thisCult; //revert back the original culture.
                }
                
                IEvictionPolicy evictionPolicy = null;

                string scheme = "";
                
                string tempscheme = Convert.ToString(properties["class"]);
                if (tempscheme.ToLower().Equals("priority"))
                {
                    scheme = tempscheme;
                }
                else
                {
                    throw new ConfigurationException("Eviction Policy " + tempscheme + " Not Supported in this Edition of NCache.");
                }
                IDictionary schemeProps = (IDictionary)properties[scheme];
                evictionPolicy = new PriorityEvictionPolicy(schemeProps, evictRatio);

                //return a thread safe eviction policy.
                return evictionPolicy;
			}
			catch(ConfigurationException e)
			{
				throw;
			}			
			catch(Exception e)
			{
                throw new ConfigurationException("EvictionPolicyFactory.CreateEvictionPolicy(): " + e.ToString());
			}
		}
コード例 #4
0
        /// <summary>
        /// Internal method that creates a cache policy. A HashMap containing the config parameters
        /// is passed to this method.
        /// </summary>
        public static IEvictionPolicy CreateEvictionPolicy(IDictionary properties, ILogger logger)
        {
            if (properties == null)
            {
                throw new ArgumentNullException("properties");
            }

            try
            {
                float evictRatio = 0;
                if (properties.Contains("evict-ratio"))
                {
                    CultureInfo thisCult = Thread.CurrentThread.CurrentCulture;     //get the currently applied culture.
                    Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US"); //change it to enUS
                    evictRatio = Convert.ToSingle(properties["evict-ratio"]);       //get the value out ...
                    Thread.CurrentThread.CurrentCulture = thisCult;                 //revert back the original culture.
                }

                IEvictionPolicy evictionPolicy = null;

                string      scheme      = Convert.ToString(properties["class"]).ToLower();
                IDictionary schemeProps = (IDictionary)properties[scheme];

                evictionPolicy = new PriorityEvictionPolicy(schemeProps, evictRatio);

                if (evictionPolicy == null)
                {
                    throw new ConfigurationException("Invalid Eviction Policy: " + scheme);
                }

                FeatureUsageCollector.Instance.GetFeature(FeatureEnum.priority_eviction, FeatureEnum.eviction).UpdateUsageTime();
                return(evictionPolicy);
            }
            catch (ConfigurationException e)
            {
                throw;
            }
            catch (Exception e)
            {
                throw new ConfigurationException("EvictionPolicyFactory.CreateEvictionPolicy(): " + e.ToString());
            }
        }