/// <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(); CultureInfo cultureInfo = Thread.CurrentThread.CurrentCulture; 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); } }
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); } }