public Object Clone() { ServerMapping mapp = new ServerMapping(); mapp.actualMappingList = actualMappingList; return(mapp); }
public Object Clone() { ServerMapping mapp = new ServerMapping(); mapp.actualMappingList = actualMappingList; return mapp; }
public void Deserialize(Runtime.Serialization.IO.CompactReader reader) { _cacheId = reader.ReadObject() as string; _loadBalance = reader.ReadBoolean(); _isRegisteredLocal = reader.ReadBoolean(); //Needs to be intinalized at every read _serversPriorityList = new Dictionary<int, CacheServer>(); int lenght = reader.ReadInt32(); for (int i = 0; i < lenght; i++) { _serversPriorityList.Add(reader.ReadInt32(), reader.ReadObject() as CacheServer); } _serverName = reader.ReadObject() as string; _bindIp = reader.ReadObject() as string; _serverRuntimeContext = reader.ReadObject() as string == "1" ? RtContextValue.JVCACHE : RtContextValue.NCACHE; if (reader.ReadBoolean()) { _serverMapping = reader.ReadObject() as ServerMapping; } _enableClientLogs = reader.ReadBoolean(); _logLevel = reader.ReadObject() as string; _enableServerPriorities = reader.ReadBoolean(); }
/// <summary> /// The main entry point for the tool. /// </summary> public static void Run(string[] args) { try { object param = new AddClientNodeParam(); CommandLineArgumentParser.CommandLineParser(ref param, args); cParam = (AddClientNodeParam)param; if (cParam.IsUsage) { AssemblyUsage.PrintLogo(cParam.IsLogo); AssemblyUsage.PrintUsage(); return; } if (!ValidateParameters()) return; bool multipleServers = false; if (cParam.Server != null || cParam.Server != string.Empty) { _serverList = cParam.Server.Split(','); if (_serverList.Length > 1 || (_serverList[0].Contains(":"))) { multipleServers = true; } } tryNextServer: if (multipleServers) { string[] serverAddress = _serverList[index].Split(':'); if (serverAddress.Length == 2) { if (!IsValidIP(serverAddress[0])) { Console.Error.WriteLine("Error: Invalid Server IP."); return; } NCache.ServerName = serverAddress[0]; try { NCache.Port = Convert.ToInt32(serverAddress[1]); } catch (Exception) { throw new Exception("Invalid Port :" + serverAddress[1] + " specified for server : " + serverAddress[0] + "."); } } else if (serverAddress.Length == 1) { if (!IsValidIP(serverAddress[0])) { Console.Error.WriteLine("Error: Invalid Server IP."); return; } NCache.ServerName = serverAddress[0]; NCache.Port = cParam.Port; if (cParam.Port == -1) NCache.Port = NCache.UseTcp ? CacheConfigManager.NCacheTcpPort : CacheConfigManager.HttpPort; } else { throw new Exception("Invalid server Address specified, kindly specify as [IPAdress] or [IPAdress]:[Port]."); } } else { if (cParam.Port != -1) { NCache.Port = cParam.Port; } if (cParam.Server != null || cParam.Server != string.Empty) { NCache.ServerName = cParam.Server; } if (cParam.Port == -1) NCache.Port = NCache.UseTcp ? CacheConfigManager.NCacheTcpPort : CacheConfigManager.HttpPort; } try { _server = NCache.ServerName; cacheServer = NCache.GetCacheServer(new TimeSpan(0, 0, 0, 30)); } catch (Exception ex) { if (multipleServers) { if (index < _serverList.Length - 1) { Console.Error.WriteLine("Failed to connect to server : " + NCache.ServerName + ":"+NCache.Port+" \nTrying next server."); index++; goto tryNextServer; } } throw ex; } config = cacheServer.GetNewConfiguration(cParam.CacheId); //for getting server mappings if (cParam.AcquireServerMapping) { Alachisoft.NCache.Management.MappingConfiguration.Dom.MappingConfiguration mapping=cacheServer.GetServerMappingForClient(); if (mapping != null) { _clientIPMapping = mapping.ClientIPMapping; foreach (Mapping mappingServer in mapping.ManagementIPMapping.MappingServers) { if (mappingServer != null) { _managementIPMapping.Add(mappingServer.PrivateIP, mappingServer); } } } } if (config == null) { Console.Error.WriteLine("Error : The cache'{0}' does not exist on server {1}:{2} .", cParam.CacheId, NCache.ServerName, NCache.Port); return; } if (config.CacheSettings.CacheType == "clustered-cache") { Console.WriteLine("Adding client node '{0}' to cache '{1}' on server {2}:{3}.", cParam.ClientNode, cParam.CacheId, NCache.ServerName, NCache.Port); foreach (Address node in config.CacheDeployment.Servers.GetAllConfiguredNodes()) { currentServerNodes.Add(node.IpAddress.ToString()); } } else { Console.Error.WriteLine("Error: Client nodes cannot be added to local caches"); return; } if (config.CacheDeployment.ClientNodes != null) { foreach (ClientNode clientNode in config.CacheDeployment.ClientNodes.NodesList) { if (cParam.ClientNode.Equals(clientNode.Name)) { Console.Error.WriteLine("Error: " + clientNode.Name + " already part of \"" + cParam.CacheId + "\""); return; } currentClientNodes.Add(clientNode.Name); } } UpdateConfigs(); } catch (Exception ex) { Console.Error.WriteLine("Error: {0}", ex.Message); } }
public void Deserialize(Runtime.Serialization.IO.CompactReader reader) { _managementMapping = reader.ReadObject() as ServerMapping; _clientMapping = reader.ReadObject() as ServerMapping; }