Exemple #1
0
        /// <summary>
		/// Returns name of Cache from the property string.
		/// </summary>
		/// <param name="properties">properties map</param>
		/// <returns>cache name.</returns>
		static internal CacheInfo GetCacheInfo(string propstring)
		{
			PropsConfigReader pr = new PropsConfigReader(propstring);
			CacheInfo inf = GetCacheInfo(pr.Properties);
			inf.ConfigString = propstring;
			return inf;
		}
Exemple #2
0
        /// <summary>
        /// Returns name of Cache from the property string.
        /// </summary>
        /// <param name="properties">properties map</param>
        /// <returns>cache name.</returns>
        static internal CacheInfo GetCacheInfo(string propstring)
        {
            PropsConfigReader pr  = new PropsConfigReader(propstring);
            CacheInfo         inf = GetCacheInfo(pr.Properties);

            inf.ConfigString = propstring;
            return(inf);
        }
Exemple #3
0
        private string GetChangedConfigForTemp(string cacheId, string oldProps, string updatedProps)
        {
            if (oldProps != null)
            {
                PropsConfigReader pcr = new PropsConfigReader(oldProps);
                IDictionary cacheConfig = pcr.Properties;
                if (cacheConfig != null)
                {
                    Hashtable configTable = new Hashtable();
                    cacheConfig.Add("id", cacheId);
                    configTable.Add("configuration", cacheConfig);
                    CacheServerConfig[] configDomList = ConfigConverter.ToDom(configTable);
                    if (configDomList != null && configDomList.Length > 0)
                    {
                        CacheServerConfig oldConfig = configDomList.GetValue(0) as CacheServerConfig;
                        if (oldConfig != null)
                        {
                            if (oldConfig.Cluster != null && oldConfig.Cluster.Channel != null && oldConfig.Cluster.Channel != null)
                            {
                                int retries = oldConfig.Cluster.Channel.ConnectionRetries;
                                int retryInterval = oldConfig.Cluster.Channel.ConnectionRetryInterval;

                                int indexOfTcpConfig = updatedProps.ToLower().IndexOf("tcp(");

                                if (indexOfTcpConfig > -1)
                                {
                                    string str = "connection_retries=" + retries + ";connection_retry_interval=" + retryInterval + ";";
                                    updatedProps = updatedProps.Insert(indexOfTcpConfig + 4, str);
                                }
                            }
                        }
                    }

                }
            }
            return updatedProps;
        }
Exemple #4
0
		/// <summary>
		/// Creates a cache object by parsing configuration string passed as parameter.
		/// </summary>
		/// <param name="propertyString">property string provided by the user </param>
		/// <param name="itemAdded">item added handler</param>
		/// <param name="itemRemoved">item removed handler</param>
		/// <param name="itemUpdated">item updated handler</param>
		/// <param name="cacheMiss">cache miss handler</param>
		/// <param name="cacheCleared">cache cleared handler</param>
		/// <returns>return the Cache object</returns>
		static public Cache CreateFromPropertyString(string propertyString,
                                            CustomRemoveCallback customRemove,
                                            CustomUpdateCallback customUpdate)
		{
			ConfigReader propReader = new PropsConfigReader(propertyString);
			return CreateFromProperties(propReader.Properties, customRemove,customUpdate);
		}
Exemple #5
0
		///// <summary>
		///// Creates a cache object by parsing configuration string passed as parameter.
		///// </summary>
		///// <param name="propertyString">property string provided by the user </param>
		///// <returns>return the Cache object</returns>
		static public Cache CreateFromPropertyString(string propertyString)
		{
			ConfigReader propReader = new PropsConfigReader(propertyString);
			return CreateFromProperties(propReader.Properties, null, null);
		}
Exemple #6
0
	    /// <summary>
        /// This overload is used to call the Internal method that actually creates the cache.
        /// </summary>
        /// <param name="propertyString"></param>
        /// <returns></returns>
        static public Cache CreateFromPropertyString(string propertyString,CacheServerConfig config, bool isStartedAsMirror, bool twoPhaseInitialization)
        {
            ConfigReader propReader = new PropsConfigReader(propertyString);
            return CreateFromProperties(propReader.Properties,config, null, null, isStartedAsMirror,twoPhaseInitialization);
        }
Exemple #7
0
		static private void PrintDetailedCacheInfo(Cache cache, string partId, bool printConf, bool xmlSyntax)
		{
			CacheStatistics s = cache.Statistics;
            long MaxSize=0;
            string schemeName = s.ClassName.ToLower(CultureInfo.CurrentCulture);
			bool running = cache.IsRunning;

			Console.WriteLine("Cache-ID:       {0}", cache.Name);
            
            if (partId != null && partId != string.Empty)
                Console.WriteLine("Partition-ID:   {0}", partId);

			Console.WriteLine("Scheme:         {0}", schemeName);
			Console.WriteLine("Status:         {0}", cache.IsRunning ? "Running":"Stopped");
			if(running)
			{
				if(s is ClusterCacheStatistics)
				{
					System.Text.StringBuilder nodes = new System.Text.StringBuilder();

					ClusterCacheStatistics cs = s as ClusterCacheStatistics;
                  
					Console.WriteLine("Cluster size:   {0}", cs.Nodes.Count);
                    
                    MaxSize = (cs.LocalNode.Statistics.MaxSize/1024)/1024;

                    
                    foreach (NodeInfo n in cs.Nodes)
                    {
                      nodes.Append("                ").Append(n.Address).Append("\n");
                    }
                    Console.Write("{0}", nodes.ToString());

                    if (partId != null && partId != string.Empty)
                    {
                        if (cs.SubgroupNodes != null && cs.SubgroupNodes.Contains(partId.ToLower()))
                        {
                            nodes = new System.Text.StringBuilder();
                            ArrayList groupNodes = cs.SubgroupNodes[partId.ToLower()] as ArrayList;
                            Console.WriteLine("Partition size: {0}", groupNodes.Count);
                           
                            foreach (Address address in groupNodes)
                            {
                                nodes.Append("                ").Append(address).Append("\n");
                            }
                        }
                        Console.Write("{0}", nodes.ToString());
                    }
				}
				Console.WriteLine("UpTime:         {0}", s.UpTime);

                if(s.MaxSize != 0)
                Console.WriteLine("Capacity:       {0} MB", ((  s.MaxSize / 1024) / 1024));
                else
                Console.WriteLine("Capacity:       {0} MB", MaxSize);

                Console.WriteLine("Count:          {0}", s.Count);
			}
			if(printConf)
			{
				try
				{
					if(xmlSyntax)
					{
						PropsConfigReader pr = new PropsConfigReader(cache.ConfigString);
						Console.WriteLine("Configuration:\n{0}", ConfigReader.ToPropertiesXml(pr.Properties, true));
					}
					else
					{
						Console.WriteLine("Configuration:\n{0}", cache.ConfigString);
					}
				}
				catch(ConfigurationException){}
			}
			Console.WriteLine("");
		}
Exemple #8
0
 /// <summary>
 /// Start the cache functionality.
 /// </summary>
 protected internal virtual void Start(CacheRenderer renderer, bool isStartingAsMirror, bool twoPhaseInitialization)
 {
     try
     {
         if (IsRunning)
         {
             Stop();
         }
         ConfigReader propReader = new PropsConfigReader(ConfigString);
         _context.Render = renderer;
         if (renderer != null)
         {
             renderer.OnClientConnected += new CacheRenderer.ClientConnected(OnClientConnected);
             renderer.OnClientDisconnected += new CacheRenderer.ClientDisconnected(OnClientDisconnected);
         }
         Initialize(propReader.Properties, false, isStartingAsMirror, twoPhaseInitialization);
     }
     catch (Exception exception)
     {
        throw;
     }
 }