public bool ValidateParameters() { if (string.IsNullOrEmpty(CacheName)) { OutputProvider.WriteErrorLine("Error: Cache name not specified."); return(false); } if (string.IsNullOrEmpty(AssemblyPath)) { OutputProvider.WriteErrorLine("Error: Assembly path not specified."); return(false); } if (string.IsNullOrEmpty(Class)) { OutputProvider.WriteErrorLine("Error: Class name not specified."); return(false); } if (string.IsNullOrEmpty(Name)) { OutputProvider.WriteErrorLine("Error: Provider name not specified."); return(false); } ToolsUtil.PrintLogo(OutputProvider, printLogo, TOOLNAME); return(true); }
public bool ValidateParameters() { _bridgeService.Port = Port; _bridgeService.ServerName = Server; if (Port == -1) { _bridgeService.Port = _bridgeService.UseTcp ? BridgeConfigurationManager.NCacheTcpPort : BridgeConfigurationManager.NCacheHttpPort; } //validate BridgeID if (string.IsNullOrEmpty(BridgeId)) { OutputProvider.WriteErrorLine("Error: BridgeID not specified."); return(false); } if (string.IsNullOrEmpty(Server)) { OutputProvider.WriteErrorLine("Error: Bridge server is not specified."); return(false); } //validate Server if (string.IsNullOrEmpty(DeleteBridgeNode)) { OutputProvider.WriteErrorLine("Error: Server to be removed is not specified."); return(false); } ToolsUtil.PrintLogo(OutputProvider, printLogo, TOOLNAME); return(true); }
public bool ValidateParameters() { try { if (CacheName == String.Empty || CacheName == null) { OutputProvider.WriteErrorLine("Error: Cache name not specified."); return(false); } if (!string.IsNullOrEmpty(Server)) { string[] servers = Server.Split(new char[] { ',' }); for (int i = 0; i < servers.Length; i++) { if (!ToolsUtil.IsValidIP(servers[i])) { OutputProvider.WriteErrorLine("Error: Invalid Server IP. {0}", servers[i]); return(false); } } } } catch (Exception ex) { OutputProvider.WriteLine("Exception occured while parsing input parameters. Please verify all given parameters are in correct format."); OutputProvider.WriteLine(ex.Message); return(false); } ToolsUtil.PrintLogo(OutputProvider, printLogo, TOOLNAME); return(true); }
public bool ValidateParameters() { if (string.IsNullOrEmpty(BridgeId)) { OutputProvider.WriteErrorLine("Error: Bridge-id not specified."); return(false); } if (string.IsNullOrEmpty(CacheName)) { OutputProvider.WriteErrorLine("Error: Cache-id not specified."); return(false); } bool multipleServers = false; if (CacheServer != null || CacheServer != string.Empty) { _serverList = CacheServer.Split(','); if (_serverList.Length > 1 || (_serverList[0].Contains(":"))) { multipleServers = true; } } VerifyCacheServer(multipleServers); ToolsUtil.PrintLogo(OutputProvider, printLogo, TOOLNAME); return(true); }
public bool ValidateParameters() { _bridgeService.Port = Port; _bridgeService.ServerName = BridgeServer; if (Port == -1) { _bridgeService.Port = _bridgeService.UseTcp ? BridgeConfigurationManager.NCacheTcpPort : BridgeConfigurationManager.NCacheHttpPort; } if (string.IsNullOrEmpty(BridgeId)) { OutputProvider.WriteErrorLine("Error: Bridge-id not specified."); return(false); } if (string.IsNullOrEmpty(CacheName)) { OutputProvider.WriteErrorLine("Error: Cache-id not specified."); return(false); } ToolsUtil.PrintLogo(OutputProvider, printLogo, TOOLNAME); return(true); }
/// <summary> /// Sets the application level parameters to those specified at the command line. /// </summary> /// <param name="args">array of command line parameters</param> public bool ValidateParameters() { if (Name != null && Name.Length > 0) { CachesList = new ArrayList(); CachesList.AddRange(Name); } NCache = new NCacheRPCService(""); NCache.ServerName = Server; if (String.IsNullOrEmpty(NCache.ServerName)) { NCache.ServerName = System.Environment.MachineName; } NCache.Port = Port; if (NCache.Port == -1) { NCache.Port = NCache.UseTcp ? CacheConfigManager.NCacheTcpPort : CacheConfigManager.HttpPort; } if (CachesList.Count == 0) { OutputProvider.WriteErrorLine("Error: cache name not specified."); } if (CachesList.Count > 1) { _partId = string.Empty; } ToolsUtil.PrintLogo(OutputProvider, printLogo, TOOLNAME); return(true); }
public void VerifyLicense() { ToolsUtil.PrintLogo(OutputProvider, printLogo, TOOLNAME); string ipAddress = "this machine"; ServerLicenseInfo serverLicenseInfo; try { if (string.IsNullOrEmpty(Server)) { serverLicenseInfo = new ServerLicenseInfo(); } else { NCache = new NCacheRPCService(""); NCache.Port = Port; NCache.ServerName = Server; ipAddress = Server; ICacheServer nCacheServer = null; nCacheServer = NCache.GetCacheServer(new TimeSpan(0, 0, 0, 30)); if (nCacheServer != null) { serverLicenseInfo = nCacheServer.GetServerLicenseInfo(); } else { serverLicenseInfo = new ServerLicenseInfo(); } } OutputProvider.WriteLine("This product is registered to "); OutputProvider.WriteLine("User: "******"Email: " + serverLicenseInfo._email); OutputProvider.WriteLine("Company: " + serverLicenseInfo._companyName); OutputProvider.WriteLine("Edition: " + "NCache OpenSource "); if (LicenseManager.LicenseMode(null) == LicenseManager.LicenseType.UnRegistered) { OutputProvider.WriteLine("\nThe machine does not have a valid registration information. Please register this machine with a FREE installation key.You can get free installation key from http://www.alachisoft.com/activate/RequestKey.php?Edition=NC-OSS-50-4x&Version=5.0&Source=Register-NCache"); OutputProvider.WriteLine("\nIf you are using this machine as NCache client, then you don't need to register NCache on this machine. Only cache server machines are required to be registered"); } else { OutputProvider.WriteLine(""); OutputProvider.WriteLine("Licensed to use FREE of cost. Use As-is without support."); } } catch (Exception ex) { OutputProvider.WriteLine(ex.ToString()); return; } OutputProvider.WriteLine("\n"); }
public bool ValidateParameters() { if (string.IsNullOrEmpty(Name)) { OutputProvider.WriteErrorLine("\nError: Cache name not specified."); return(false); } ToolsUtil.PrintLogo(OutputProvider, printLogo, TOOLNAME); return(true); }
public bool ValidateParameters() { if (string.IsNullOrEmpty(CacheName)) { OutputProvider.WriteErrorLine("\nError: Cache name not specified."); return(false); } if (string.IsNullOrEmpty(AssemblyPath)) { OutputProvider.WriteErrorLine("\nError: Assembly Path not specified."); return(false); } if (string.IsNullOrEmpty(Class)) { OutputProvider.WriteErrorLine("\nError: Class name not specified."); return(false); } if (string.IsNullOrEmpty(LuceneType)) { OutputProvider.WriteErrorLine("\nError: Lucene Type not specified."); return(false); } if (string.IsNullOrEmpty(Analyzer)) { OutputProvider.WriteErrorLine("\nError: Analyzer not specified."); return(false); } if (string.IsNullOrEmpty(TermVector)) { OutputProvider.WriteErrorLine("\nError: Term Vector not specified."); return(false); } if (string.IsNullOrEmpty(Pattern)) { OutputProvider.WriteErrorLine("\nError: Pattern not specified."); return(false); } if (string.IsNullOrEmpty(StopWords)) { OutputProvider.WriteErrorLine("\nError: Stop Words not specified."); return(false); } ToolsUtil.PrintLogo(OutputProvider, printLogo, TOOLNAME); return(true); }
public bool ValidateParameters() { //validate BridgeID if (string.IsNullOrEmpty(BridgeId)) { OutputProvider.WriteErrorLine("Error: BridgeID not specified."); return(false); } if (string.IsNullOrEmpty(Server)) { OutputProvider.WriteErrorLine("Error: Bridge server is not specified."); return(false); } ToolsUtil.PrintLogo(OutputProvider, printLogo, TOOLNAME); return(true); }
public void VerifyLicense() { ToolsUtil.PrintLogo(OutputProvider, printLogo, TOOLNAME); string ipAddress = "this machine"; ServerLicenseInfo serverLicenseInfo; try { if (string.IsNullOrEmpty(Server)) { serverLicenseInfo = new ServerLicenseInfo(); } else { NCache = new NCacheRPCService(""); NCache.Port = Port; NCache.ServerName = Server; ipAddress = Server; ICacheServer nCacheServer = null; nCacheServer = NCache.GetCacheServer(new TimeSpan(0, 0, 0, 30)); if (nCacheServer != null) { serverLicenseInfo = nCacheServer.GetServerLicenseInfo(); } else { serverLicenseInfo = new ServerLicenseInfo(); } } OutputProvider.WriteLine("This product is registered to "); OutputProvider.WriteLine("User: "******"Email: " + serverLicenseInfo._email); OutputProvider.WriteLine("Company: " + serverLicenseInfo._companyName); OutputProvider.WriteLine("Edition: " + "NCache OpenSource "); OutputProvider.WriteLine(""); OutputProvider.WriteLine("Licensed to use FREE of cost. Use As-is without support."); } catch (Exception ex) { OutputProvider.WriteLine(ex.ToString()); return; } OutputProvider.WriteLine("\n"); }
public void VerifyLicense() { try { ToolsUtil.PrintLogo(OutputProvider, printLogo, TOOLNAME); PrintUserInfo(OutputProvider); OutputProvider.WriteLine("\n"); OutputProvider.WriteLine("Edition Installed: NCache 4.9 OpenSource Edition.\n"); OutputProvider.WriteLine("Licensed to use FREE of cost. Use As-is without support.\n"); } catch (Exception ex) { OutputProvider.WriteLine(ex.ToString()); return; } }
public bool ValidateParameters() { try { if (CacheName == String.Empty || CacheName == null) { OutputProvider.WriteErrorLine("Error: Cache name not specified."); return(false); } } catch (Exception ex) { OutputProvider.WriteLine("Exception occured while parsing input parameters. Please verify all given parameters are in correct format."); OutputProvider.WriteLine(ex.Message); return(false); } ToolsUtil.PrintLogo(OutputProvider, printLogo, TOOLNAME); return(true); }
/// <summary> /// Validate all parameters in property string. /// </summary> public bool ValidateParameters() { if (string.IsNullOrEmpty(Class)) { OutputProvider.WriteErrorLine("\nError: Class name not specified."); return(false); } if (string.IsNullOrEmpty(AssemblyPath)) { OutputProvider.WriteErrorLine("\nError: Assembly path not specified."); return(false); } if (!OutputFile.Equals(string.Empty) && !(Path.GetExtension(OutputFile).Equals(".txt") || Path.GetExtension(OutputFile).Equals(".xml"))) { OutputProvider.WriteErrorLine("\nError: Extension for the file specified is not valid."); return(false); } ToolsUtil.PrintLogo(OutputProvider, printLogo, TOOLNAME); return(true); }
public bool ValidateParameters() { if ((!ReadThru) && (!WriteThru)) { OutputProvider.WriteErrorLine("Error: ReadThru/WriteThru not specified."); return(false); } if (!string.IsNullOrEmpty(OutputFile)) { string path = Path.GetExtension(OutputFile); if (!(path.Contains(".txt") || path.Contains(".xml"))) { OutputProvider.WriteErrorLine("Invalid file. Please specify path of .xml or .txt file."); return(false); } } ToolsUtil.PrintLogo(OutputProvider, printLogo, TOOLNAME); return(true); }
public bool ValidateParameters() { _bridgeService.Port = Port; _bridgeService.ServerName = BridgeServer; if (Port == -1) { _bridgeService.Port = _bridgeService.UseTcp ? BridgeConfigurationManager.NCacheTcpPort : BridgeConfigurationManager.NCacheHttpPort; } if (string.IsNullOrEmpty(BridgeId)) { OutputProvider.WriteErrorLine("Error: Bridge-id not specified."); return(false); } if (string.IsNullOrEmpty(CacheName)) { OutputProvider.WriteErrorLine("Error: Cache-id not specified."); return(false); } bool multipleServers = false; if (CacheServer != null || CacheServer != string.Empty) { _serverList = CacheServer.Split(','); if (_serverList.Length > 1 || (_serverList[0].Contains(":"))) { multipleServers = true; } } VerifyCacheServer(multipleServers); ToolsUtil.PrintLogo(OutputProvider, printLogo, TOOLNAME); return(true); }
public bool ValidateParameters() { try { NCache.Port = Port; } catch (FormatException) { } catch (OverflowException) { } if (Port > 1) { NCache.Port = NCache.UseTcp ? CacheConfigManager.NCacheTcpPort : CacheConfigManager.HttpPort; } bool validAction = false; if (!string.IsNullOrEmpty(Action)) { if (Action.ToLower() == "start") { validAction = true; } if (Action.ToLower() == "stop") { validAction = true; } } if (IsUsage || !validAction) { return(false); } ToolsUtil.PrintLogo(OutputProvider, printLogo, TOOLNAME); return(true); }
public void ListCaches() { ToolsUtil.PrintLogo(OutputProvider, printLogo, TOOLNAME); OutputProvider.WriteLine("Licensed to use FREE of cost. Use As-is without support.\n"); if (Port != -1) { NCache.Port = Port; } if (Server != null && !Server.Equals("")) { NCache.ServerName = Server; } string getBindIp = string.Empty; try { ICacheServer cacheServer = null; try { cacheServer = NCache.GetCacheServer(new TimeSpan(0, 0, 0, 30)); } catch (Exception e) { OutputProvider.WriteErrorLine("Error: NCache service could not be contacted on server."); return; } getBindIp = cacheServer.GetBindIP(); OutputProvider.WriteLine("Listing registered caches on server {0}:{1}\n", getBindIp, NCache.Port); if (cacheServer != null) { Alachisoft.NCache.Common.Monitoring.ConfiguredCacheInfo[] caches = cacheServer.GetAllConfiguredCaches(); if (caches.Length > 0) { if (!Detail) { OutputProvider.WriteLine("{0,-25} {1,-35} {2,-15}", "Cache-Name", "Topology", "Status(PID)"); OutputProvider.WriteLine("{0,-25} {1,-35} {2,-15}", "----------", "--------", "-----------"); } if (caches.Length > 0) { for (int i = 0; i < caches.Length; i++) { Alachisoft.NCache.Common.Monitoring.ConfiguredCacheInfo cacheInfo = caches[i]; if (!Detail) { PrintCacheInfo(cacheInfo.Topology.ToString(), cacheInfo.CacheId, cacheInfo.IsRunning, cacheInfo.ProcessID); } else { try { PrintDetailedCacheInfo(cacheServer.GetCacheStatistics2(cacheInfo.CacheId), cacheInfo.Topology.ToString(), null, cacheInfo.IsRunning, cacheInfo.CacheId, cacheInfo.CachePropString, cacheInfo.ProcessID.ToString()); } catch (Exception e) { if (e.Message != null && e.Message.Contains("No connection could be made because the target machine actively refused it")) { PrintDetailedCacheInfo(null, cacheInfo.Topology.ToString(), null, false, cacheInfo.CacheId, cacheInfo.CachePropString, "0"); } else { OutputProvider.WriteErrorLine("Error: {0}", e.Message); OutputProvider.WriteErrorLine(e.ToString()); } } } } } } else { OutputProvider.WriteLine("There are no registered caches on {0}", NCache.ServerName); } } } catch (Exception e) { OutputProvider.WriteErrorLine("Error: {0}", e.Message); OutputProvider.WriteErrorLine(e.ToString()); } finally { NCache.Dispose(); } OutputProvider.WriteLine((Detail)?"": Environment.NewLine); }
protected void CacheClientStatistics() { ArrayList clients = null; List <ICacheServer> cacheServers = new List <ICacheServer>(); bool isServiceRunning = true; if (!ValidateParameters()) { return; } if (Clients != null && !Clients.Equals("")) { clients = GetClients(Clients); } else { clients = new ArrayList(); NCacheRPCService nCache = new NCacheRPCService(""); clients.Add(nCache.ServerName); } foreach (var client in clients) { NCacheRPCService nCache = new NCacheRPCService(client.ToString()); try { ICacheServer cacheServer = nCache.GetCacheServer(new TimeSpan(0, 0, 0, 30)); //NodeStatus status = GetCacheStatistics(_nCache); ClientList.Add(cacheServer.GetBindIP()); cacheServers.Add(cacheServer); } catch (Exception ex) { if (ex.Message.ToUpper().Contains("service".ToUpper())) { OutputProvider.WriteErrorLine("NCache Service could not be contacted on server " + client); isServiceRunning = false; } else { cacheServers.Add(null); } } } if (!(Format.Equals("csv", StringComparison.OrdinalIgnoreCase) || Format.Equals("tabular", StringComparison.OrdinalIgnoreCase))) { throw new ArgumentException("Invalid Format type"); } if (Continuous && MaxSamples > 0) { throw new Exception("The Continuous parameter and the MaxSamples parameter cannot be used in the same command."); } _perfmonCounters = CreateCounterList(); if (Continuous && Format.Equals("csv", StringComparison.OrdinalIgnoreCase)) { FetchAndDisplayContinousulyCSV(cacheServers); } else if (Continuous && Format.Equals("tabular", StringComparison.OrdinalIgnoreCase)) { Util.ToolsUtil.PrintLogo(OutputProvider, printLogo, TOOLNAME); FetchAndDisplayContinousuly(cacheServers); } else if (MaxSamples > 0) { if (Format.Equals("tabular", StringComparison.OrdinalIgnoreCase)) { ToolsUtil.PrintLogo(OutputProvider, printLogo, TOOLNAME); FetchAndDisplayMax(cacheServers); } else if (Format.Equals("csv", StringComparison.OrdinalIgnoreCase)) { FetchAndDisplayMaxCSV(cacheServers); } } if (!Continuous && MaxSamples == 0) { if (isServiceRunning) { try { SortedDictionary <string, string[]> CountList = FetchCounters(cacheServers); if (Format.Equals("csv", StringComparison.OrdinalIgnoreCase)) { DisplayinCSVFormat(CountList); } else if (Format.Equals("tabular", StringComparison.OrdinalIgnoreCase)) { Util.ToolsUtil.PrintLogo(OutputProvider, printLogo, TOOLNAME); DisplayTimeStamp(); DisplayCounters(CountList); } } catch (ArgumentOutOfRangeException ex) { OutputProvider.WriteErrorLine(ex); } catch (Exception ex) { OutputProvider.WriteErrorLine(ex); } } } }
public void CacheServerStatistics() { ArrayList servers = null; bool isPOR = false; bool isRegistered = true; List <ICacheServer> cacheServers = new List <ICacheServer>(); if (!ValidateParameters()) { return; } if (Servers != null && !Servers.Equals("")) { servers = GetServers(Servers); } else { servers = new ArrayList(); NCacheRPCService nCache = new NCacheRPCService(""); servers.Add(nCache.ServerName); } foreach (var server in servers) { NCacheRPCService nCache = new NCacheRPCService(server.ToString()); try { ICacheServer cacheServer = nCache.GetCacheServer(new TimeSpan(0, 0, 0, 30)); serverList.Add(cacheServer.GetBindIP()); NodeStatus status = GetCacheStatistics(nCache); if (status.isRegistered == false) { throw new Exception("The specified cache is not registered on server " + server); } isPOR = status.Topology == Topology.POR; cacheServers.Add(cacheServer); //array of it ICacheServer } catch (Exception ex) { if (ex.Message.Contains("The specified cache is not registered")) { OutputProvider.WriteErrorLine(ex.Message); isRegistered = false; } else if (ex.Message.ToUpper().Contains("service".ToUpper())) { OutputProvider.WriteErrorLine("NCache Service could not be contacted on server " + server); isRegistered = false; } } } if (isRegistered) { _mainCounters = GetAllCounters(false); if (isPOR) { _replicaCounters = GetAllCounters(true); } if (!(Format.Equals("csv", StringComparison.OrdinalIgnoreCase) || Format.Equals("tabular", StringComparison.OrdinalIgnoreCase))) { throw new ArgumentException("Invalid Format type"); } if (Continuous && MaxSamples > 0) { throw new Exception("The Continuous parameter and the MaxSamples parameter cannot be used in the same command."); } if (Continuous && Format.Equals("csv", StringComparison.OrdinalIgnoreCase)) { FetchAndDisplayContinousulyCSV(cacheServers, isPOR); } else if (Continuous && Format.Equals("tabular", StringComparison.OrdinalIgnoreCase)) { ToolsUtil.PrintLogo(OutputProvider, printLogo, TOOLNAME); FetchAndDisplayContinousuly(cacheServers, isPOR); } else if (MaxSamples > 0) { if (Format.Equals("tabular", StringComparison.OrdinalIgnoreCase)) { ToolsUtil.PrintLogo(OutputProvider, printLogo, TOOLNAME); FetchAndDisplayMax(cacheServers, isPOR); } else if (Format.Equals("csv", StringComparison.OrdinalIgnoreCase)) { FetchAndDisplayMaxCSV(cacheServers, isPOR); } } if (!Continuous && MaxSamples == 0) { try { SortedDictionary <string, string[]> CountList = FetchCounters(cacheServers, isPOR); if (Format.Equals("csv", StringComparison.OrdinalIgnoreCase)) { DisplayinCSVFormat(CountList, isPOR); } else if (Format.Equals("tabular", StringComparison.OrdinalIgnoreCase)) { ToolsUtil.PrintLogo(OutputProvider, printLogo, TOOLNAME); DisplayTimeStamp(); DisplayCounters(CountList, isPOR); } } catch (ArgumentOutOfRangeException ex) { OutputProvider.WriteErrorLine(ex); } catch (Exception ex) { OutputProvider.WriteErrorLine(ex); } } } OutputProvider.WriteLine("\n"); }