public void Enqueue(Point[] points) { foreach (var config in _configBusiness.OpenDatabaseConfig()) { IFormatter formatter; try { var agent = _influxDbAgentLoader.GetAgent(config); var agentInfo = agent.GetAgentInfo(); formatter = agentInfo.Item1; _outputMessage("Send to " + config.Url + " ver " + agentInfo.Item2, OutputLevel.Information); } catch (InvalidOperationException) { var ifx = new InfluxDb("http://influx-capacitor.com", "-", "-", InfluxVersion.v09x); formatter = ifx.GetFormatter(); _outputMessage("Unknown client version, simulation output for version " + ifx.GetClientVersion() + ".", OutputLevel.Warning); } foreach (var point in points) { _outputMessage(formatter.PointToString(point), OutputLevel.Information); } } }
public InfluxDataSender(IInfluxDbAgentLoader influxDbAgentLoader, IDatabaseConfig databaseConfig, int maxQueueSize) { _databaseConfig = databaseConfig; _maxQueueSize = maxQueueSize; _maxSendBatchCount = 1000; _dropOnFail = false; _client = new Lazy <IInfluxDbAgent>(() => influxDbAgentLoader.GetAgent(databaseConfig)); }
public InfluxDataSender(IInfluxDbAgentLoader influxDbAgentLoader, IDatabaseConfig databaseConfig, int maxQueueSize) { _databaseConfig = databaseConfig; _maxQueueSize = maxQueueSize; _maxSendBatchCount = 1000; _dropOnFail = false; _client = new Lazy<IInfluxDbAgent>(() => influxDbAgentLoader.GetAgent(databaseConfig)); }
public SendBusiness(IConfigBusiness configBusiness, IInfluxDbAgentLoader influxDbAgentLoader) { var config = configBusiness.LoadFiles(); _timer = new Timer(1000 * config.Application.FlushSecondsInterval); _timer.Elapsed += Elapsed; _client = new Lazy<IInfluxDbAgent>(() => influxDbAgentLoader.GetAgent(config.Database)); }
public async override Task <bool> InvokeAsync(string paramList) { var configs = _configBusiness.OpenDatabaseConfig().ToArray(); if (!configs.Any() || configs.All(x => x.Url == Constants.NoConfigUrl)) { OutputWarning("No database configuration exists."); return(false); } foreach (var config in configs) { if (config.Url == Constants.NoConfigUrl) { continue; } OutputInformation("Url: {0}", config.Url); OutputInformation("Name: {0}", config.Name); OutputInformation("Username: {0}", config.Username); try { var client = _influxDbAgentLoader.GetAgent(config); OutputInformation("Connect: {0}", await client.CanConnect()); OutputInformation("Version: {0}", await client.VersionAsync()); } catch (InvalidOperationException) { OutputError("Unable to connect to database."); } OutputInformation(""); } return(true); }
protected async Task <string> GetServerUrlAsync(string paramList, int index, string defaultUrl) { var urlParam = GetParam(paramList, index++); var url = defaultUrl; IInfluxDbAgent client = null; if (!string.IsNullOrEmpty(url) && url != Constants.NoConfigUrl) { try { client = _influxDbAgentLoader.GetAgent(new InfluxDatabaseConfig(url, "root", "qwerty", "qwerty")); } catch (Exception exception) { OutputWarning(exception.Message); } } var connectionConfirmed = false; try { if (client != null) { connectionConfirmed = await client.CanConnect(); } } catch (Exception exception) { OutputError("{0}", exception.Message); } if (!connectionConfirmed) { OutputInformation("Enter the url to the InfluxDB to use."); OutputInformation("Provide the correct port, typically 8086. (Ex. http://tharga.net:8086)"); while (!connectionConfirmed) { try { url = QueryParam <string>("Url", urlParam); urlParam = null; client = _influxDbAgentLoader.GetAgent(new InfluxDatabaseConfig(url, "root", "qwerty", "qwert")); connectionConfirmed = await client.CanConnect(); } catch (CommandEscapeException) { return(null); } catch (Exception exception) { OutputError("{0}", exception.Message.Split('\n')[0]); } } _configBusiness.SaveDatabaseUrl(url); } OutputInformation("Connection to server {0} confirmed.", url); return(url); }