public object Clone() { Mapping map = new Mapping(); map.PrivateIP = _privateIp; map.PrivatePort = _privatePort; map.PublicIP = _publicIP; map.PublicPort = _publicPort; return map; }
public ServerMapping(Hashtable mappings) { IEnumerator itor = mappings.GetEnumerator(); while (itor.MoveNext()) { DictionaryEntry entry = (DictionaryEntry)itor.Current; Hashtable values = (Hashtable)entry.Value; Mapping _mapping = new Mapping(); _mapping.PrivateIP = values["private-ip"] as string; _mapping.PrivatePort = Convert.ToInt32(values["private-port"]); _mapping.PublicIP = values["public-ip"] as string; _mapping.PublicPort = Convert.ToInt32(values["public-port"]); actualMappingList.Add(_mapping); } }
public static Mapping[] MappingToArray(Dictionary<string, Mapping> updatedMappingDictionary) { if (updatedMappingDictionary != null) { Mapping[] mappingArray = new Mapping[updatedMappingDictionary.Count]; int index = 0; foreach (Mapping node in updatedMappingDictionary.Values) { mappingArray[index] = new Mapping(); mappingArray[index] = node; index++; } return mappingArray; } else return null; }
public static Mapping[] GetUpdatedMappingList(Mapping[] oldMapping, Mapping[] newMapping) { Dictionary<string, Mapping> updatedMappingDictionary = new Dictionary<string, Mapping>(); foreach (Mapping mapping in newMapping) { if (mapping != null) { updatedMappingDictionary.Add(mapping.PrivateIP, mapping); } } foreach (Mapping mapping in oldMapping) { if (mapping != null) { if (!(updatedMappingDictionary.ContainsKey(mapping.PrivateIP))) { updatedMappingDictionary.Add(mapping.PrivateIP, mapping); } } } return MappingToArray(updatedMappingDictionary); }
private Mapping GenerateMapping(string mappingKey, string portKey, string ipKey) { try { string mappingString = System.Configuration.ConfigurationSettings.AppSettings[mappingKey]; string port = System.Configuration.ConfigurationSettings.AppSettings[portKey]; string ip = System.Configuration.ConfigurationSettings.AppSettings[ipKey]; if (!(String.IsNullOrEmpty(mappingString) || String.IsNullOrEmpty(port) || String.IsNullOrEmpty(ip))) { string[] mappingAddress = mappingString.Split(':'); if (mappingAddress.Length == 2) { Mapping mapping = new Mapping(); mapping.PublicIP = mappingAddress[0]; mapping.PublicPort = Convert.ToInt32(mappingAddress[1]); mapping.PrivateIP = ip; mapping.PrivatePort = Convert.ToInt32(port); return mapping; } } } catch (Exception ex) { AppUtil.LogEvent("NCache", "GetServerMappingForConfig: Unable to generate mapping from "+mappingKey+". Exception: " + ex.Message, EventLogEntryType.Error, EventCategories.Error, EventID.GeneralError); } return null; }
public ServerMapping(Mapping[] serverMapping) { MappingServers = serverMapping; }
private static CacheServerList GetSeversPriorityList() { Dictionary <int, Alachisoft.NCache.Management.ClientConfiguration.Dom.CacheServer> serversPriorityList = new Dictionary <int, Alachisoft.NCache.Management.ClientConfiguration.Dom.CacheServer>(); Alachisoft.NCache.Management.ClientConfiguration.Dom.CacheServer server = new Alachisoft.NCache.Management.ClientConfiguration.Dom.CacheServer(); if (config != null) { List <Address> hosts = config.CacheDeployment.Servers.GetAllConfiguredNodes(); Alachisoft.NCache.Management.ICacheServer cs; NCacheRPCService cache = new NCacheRPCService(""); int priority = 0; int port = -1; foreach (Address addr in hosts) { try { string address = addr.IpAddress.ToString(); if (_managementIPMapping != null) { if (_managementIPMapping.ContainsKey(address)) { Mapping endPoint = _managementIPMapping[address]; address = endPoint.PublicIP; port = endPoint.PublicPort; } } server = new Alachisoft.NCache.Management.ClientConfiguration.Dom.CacheServer(); string tempClientServerName = ""; cache.ServerName = address; if (port != -1) { cache.Port = port; } cs = cache.GetCacheServer(new TimeSpan(0, 0, 0, 30)); Management.Management.BindedIpMap bindedIps = cs.BindedIp(); if (bindedIps.Map.Contains(Alachisoft.NCache.Management.CacheServer.Channel.SocketServer)) { tempClientServerName = bindedIps.Map[Alachisoft.NCache.Management.CacheServer.Channel.SocketServer].ToString(); } if (!string.IsNullOrEmpty(tempClientServerName)) { server.ServerName = tempClientServerName; } else { server.ServerName = addr.IpAddress.ToString(); } server.Priority = priority; serversPriorityList.Add(priority, server); priority++; } catch (Exception ex) { Console.Error.WriteLine("Error while adding server :" + cache.ServerName + ":" + cache.Port + "\nException : " + ex.Message); } } } if (serversPriorityList.Count < 1) { server.ServerName = _server; server.Priority = 0; serversPriorityList.Add(0, server); } return(new CacheServerList(serversPriorityList)); }