コード例 #1
0
        /// <summary>
        /// Initialize a registered cache given by the ID.
        /// </summary>
        /// <param name="cacheId">A string identifier of configuration.</param>
        static public ArrayList GetCacheConfig(string cacheId, string filePath, bool inProc)
        {
            try
            {
                XmlConfigReader configReader = new XmlConfigReader(filePath, cacheId);
                ArrayList propsList = configReader.PropertiesList;
                ArrayList configsList = CacheConfig.GetConfigs(propsList, DEF_TCP_PORT);

                foreach (CacheConfig config in configsList)
                {
                    if (!inProc) inProc = config.UseInProc;
                    break;
                }

                if (inProc)
                {

                    return configsList;
                }
                return null;
            }

            catch (ManagementException)
            {
                throw;
            }
            catch (Exception e)
            {
                throw new ManagementException(e.Message, e);
            }
        }
コード例 #2
0
        /// <summary>
        /// Initialize a registered cache given by the ID.
        /// </summary>
        /// <param name="cacheId">A string identifier of configuration.</param>
        static public CacheServerConfig GetConfigDom(string cacheId, string filePath, bool inProc)
        {
            try
            {
                XmlConfigReader configReader = new XmlConfigReader(filePath, cacheId);
                CacheServerConfig config = configReader.GetConfigDom();

                if (config == null)
                {
                    return config;
                }

                if (!inProc)
                {
                    inProc = config.InProc;
                }

                if (inProc)
                {

                    return config;
                }
                return null;
            }

            catch (ManagementException)
            {
                throw;
            }
            catch (Exception e)
            {
                throw new ManagementException(e.Message, e);
            }
        }
コード例 #3
0
ファイル: CacheFactory.cs プロジェクト: javithalion/NCache
		/// <summary>
		/// Creates a cache object by reading in cofiguration parameters from a .NET XML file.
		/// </summary>
		/// <param name="configFileName">Name and/or path of the configuration file.</param>
		/// <param name="configSection">Name and/or ID of the section in the configuration file.</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 CreateFromXmlConfig(string configFileName, 
											string configSection,
                                            CustomRemoveCallback customRemove,
                                            CustomUpdateCallback customUpdate)
		{
			ConfigReader xmlReader = new XmlConfigReader(configFileName, configSection);
			return CreateFromProperties(xmlReader.Properties,customRemove,customUpdate);
		}
コード例 #4
0
ファイル: CacheFactory.cs プロジェクト: javithalion/NCache
		/// <summary>
		/// Creates a cache object by reading in cofiguration parameters from a .NET XML file.
		/// </summary>
		/// <param name="configFileName">Name and/or path of the configuration file.</param>
		/// <param name="configSection">Name and/or ID of the section in the configuration file.</param>
		/// <returns>return the Cache object</returns>
		static public Cache CreateFromXmlConfig(string configFileName, string configSection)
		{
			ConfigReader xmlReader = new XmlConfigReader(configFileName, configSection);
			return CreateFromProperties(xmlReader.Properties, null,null);
		}
コード例 #5
0
        /// <summary>
        /// Loads and returns all cache configurations from the configuration file.
        /// </summary>
        static public CacheConfig[] GetConfiguredCaches2()
        {
            if (FileName.Length == 0)
            {
                throw new ManagementException("Can not locate cache configuration file. Installation might be corrupt.");
            }
            try
            {
                XmlConfigReader xcr = new XmlConfigReader("", "");
                IDictionary propMap = null;

                propMap = xcr.GetProperties2(CacheConfigManager.FileName);

                ArrayList configList = new ArrayList();

                IDictionaryEnumerator ide = propMap.GetEnumerator();
                while (ide.MoveNext())
                {
                    IDictionary properties = (IDictionary)ide.Value;
                    configList.Add(CacheConfig.FromProperties2(properties));
                }

                CacheConfig[] configs = new CacheConfig[configList.Count];
                for (int i = 0; i < configList.Count; i++)
                {
                    configs[i] = configList[i] as CacheConfig;
                }

                return configs;
            }
            catch (ManagementException)
            {
                throw;
            }
            catch (Exception e)
            {
                throw new ManagementException(e.Message, e);
            }
        }
コード例 #6
0
        static public CacheServerConfig GetUpdatedCacheConfig(string cacheId, string partId, string newNode, ref ArrayList affectedNodes, bool isJoining)
        {
            if (FileName.Length == 0)
                throw new ManagementException("Can not locate cache configuration file. Installation might be corrupt");
            
            try
            {
                XmlConfigReader configReader = new XmlConfigReader(FileName, cacheId);
                CacheServerConfig config = configReader.GetConfigDom();
                
                string list = config.Cluster.Channel.InitialHosts.ToLower();
                string[] nodes = list.Split(',');

                if (isJoining)
                {
                    foreach (string node in nodes)
                    {
                        string[] nodename = node.Split('[');
                        affectedNodes.Add(nodename[0]);
                    }

                    if (list.IndexOf(newNode) == -1)
                    {
                        list = list + "," + newNode + "[" + config.Cluster.Channel.TcpPort + "]";
                    }
                }
                else
                {
                    foreach (string node in nodes)
                    {
                        string[] nodename = node.Split('[');
                        if (nodename[0] != newNode)
                        {
                            affectedNodes.Add(nodename[0]);
                        }
                    }

                    list = string.Empty;
                    foreach (string node in affectedNodes)
                    {
                        if (list.Length == 0) 
                            list = node + "[" + config.Cluster.Channel.TcpPort + "]";
                        else
                            list = list + "," + node + "[" + config.Cluster.Channel.TcpPort + "]";
                    }
                }

                config.Cluster.Channel.InitialHosts = list;

                return config;
            }
            catch (ManagementException)
            {
                throw;
            }
            catch (Exception e)
            {
                throw new ManagementException(e.Message, e);
            }
        }
コード例 #7
0
 /// <summary>
 /// Initialize a registered cache given by the ID.
 /// </summary>
 /// <param name="cacheId">A string identifier of configuration.</param>
 static public CacheConfig GetCacheConfig(string cacheId)
 {
     if (FileName.Length == 0)
     {
         throw new ManagementException("Can not locate cache configuration file. Installation might be corrupt");
     }
     try
     {
         XmlConfigReader configReader = new XmlConfigReader(FileName, cacheId);
         return CacheConfig.FromProperties(configReader.Properties);
     }
     catch (ManagementException)
     {
         throw;
     }
     catch (Exception e)
     {
         throw new ManagementException(e.Message, e);
     }
 }
コード例 #8
0
        /// <summary>
        /// Initialize a registered cache given by the ID.
        /// </summary>
        /// <param name="cacheId">A string identifier of configuration.</param>
        static public ArrayList GetCacheConfig(string cacheId, bool inProc)
        {
            if (FileName.Length == 0)
            {
                throw new ManagementException("Can not locate cache configuration file. Installation might be corrupt");
            }
            try
            {
                XmlConfigReader configReader = new XmlConfigReader(FileName, cacheId);
                ArrayList propsList = configReader.PropertiesList;
                ArrayList configsList = CacheConfig.GetConfigs(propsList);

                foreach (CacheConfig config in configsList)
                {
                    if (!inProc) inProc = config.UseInProc;
                    break;
                }

                if (inProc)
                {

                    return configsList;
                }
                return null;
               
            }

            catch (ManagementException)
            {
                throw;
            }
            catch (Exception e)
            {
                throw new ManagementException(e.Message, e);
            }
        }