public InfluxHealthCheck(InfluxConnectionSetting setting)
 {
     _logger = LogManager.GetLogger(this);
     _client = new HttpClient()
     {
         BaseAddress = new Uri($"http://{setting.Server}:{setting.Port}"), Timeout = TimeSpan.FromSeconds(setting.Timeout)
     };
 }
 public InfluxBulkInsertProcessor(InfluxConnectionSetting setting, InfluxInsertProtocol protocol)
 {
     _logger = LogManager.GetLogger(this);
     if (protocol == InfluxInsertProtocol.Http)
     {
         _bulkInsert = new InfluxHttpBulkInsert(setting);
         _logger.LogInformation("InfluxBulkInsertProcessor use http.");
     }
     else
     {
         _bulkInsert = new InfluxUdpBulkInsert(setting);
         _logger.LogInformation("InfluxBulkInsertProcessor use udp.");
     }
     _healthCheck = new InfluxHealthCheck(setting);
 }
Example #3
0
        public InfluxUdpBulkInsert([NotNull] InfluxConnectionSetting setting)
        {
            if (string.IsNullOrEmpty(setting.Server))
            {
                throw new ArgumentException(nameof(setting.Server));
            }

            if (setting.Port == 0)
            {
                throw new ArgumentException(nameof(setting.Port));
            }

            _client = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
            var endPoint = new IPEndPoint(IPAddress.Parse(setting.Server), setting.Port);

            _client.Connect(endPoint);
            BitchSize = setting.BitchSize;
            _logger   = LogManager.GetLogger(this);
            _logger.LogInformation("Udp bulk insert initialization success.");
        }
        public InfluxHttpBulkInsert([NotNull] InfluxConnectionSetting setting)
        {
            if (string.IsNullOrEmpty(setting.Server))
            {
                throw new ArgumentException(nameof(setting.Server));
            }

            if (string.IsNullOrEmpty(setting.Database))
            {
                throw new ArgumentException(nameof(setting.Database));
            }

            if (setting.Port == 0)
            {
                throw new ArgumentException(nameof(setting.Port));
            }

            if (setting.BitchSize > 5000)
            {
                throw new ArgumentException("max BitchSize is 5000 form http protocol.", nameof(setting.BitchSize));
            }

            _logger = LogManager.GetLogger(this);
            _client = new HttpClient()
            {
                BaseAddress = new Uri($"http://{setting.Server}:{setting.Port}"), Timeout = TimeSpan.FromSeconds(setting.Timeout)
            };
            BitchSize = setting.BitchSize;
            if (string.IsNullOrEmpty(setting.UserName) && string.IsNullOrEmpty(setting.Password))
            {
                _writePath = $"/write?db={setting.Database}";
            }
            else
            {
                _writePath = $"/write?db={setting.Database}&u={setting.UserName}&p={setting.Password}";
            }

            _logger.LogInformation("Http bulk insert initialization success.");
        }