Exemplo n.º 1
0
        public void Enqueue(Point[] points)
        {
            if (!points.Any())
            {
                return;
            }

            if (_timer == null)
            {
                //TODO: Fire!
                //OnSendBusinessEvent(this, new SendBusinessEventArgs(null, "The engine that sends data to the database is not enabled. Probably becuse the FlushSecondsInterval has not been configured.", points.Length, OutputLevel.Error));
                return;
            }

            if (!_timer.Enabled)
            {
                _timer.Start();
            }

            //Prepare metadata information about the queue and add that to the points to be sent.
            if (_metadata)
            {
                var metaPoints = _dataSenders.Select(x => MetaDataBusiness.GetQueueCountPoints("Enqueue", x.TargetServer, x.TargetDatabase, x.QueueCount, points.Length + _dataSenders.Count, new SendResponse(null, null))).ToArray();
                points = points.Union(metaPoints).ToArray();
            }

            foreach (var dataSender in _dataSenders)
            {
                dataSender.Enqueue(points);
            }
        }
Exemplo n.º 2
0
        private void Elapsed(object sender, ElapsedEventArgs e)
        {
            try
            {
                var metaPoints = new List <Point>();

                foreach (var dataSender in _dataSenders)
                {
                    var previousQueueCount = dataSender.QueueCount;
                    _logger.Debug(string.Format("Starting to send {0} points to server {1} database {2}.", previousQueueCount, dataSender.TargetServer, dataSender.TargetDatabase));
                    var success        = dataSender.Send();
                    var postQueueCount = dataSender.QueueCount;
                    _logger.Debug(string.Format("Done sending {0} points to server {1} database {2}. Now {3} items in queue.", previousQueueCount, dataSender.TargetServer, dataSender.TargetDatabase, postQueueCount));

                    if (_metadata)
                    {
                        metaPoints.Add(MetaDataBusiness.GetQueueCountPoints("Send", dataSender.TargetServer, dataSender.TargetDatabase, previousQueueCount, postQueueCount - previousQueueCount + _dataSenders.Count, success));
                    }
                }

                if (_metadata)
                {
                    foreach (var dataSender in _dataSenders)
                    {
                        dataSender.Enqueue(metaPoints.ToArray());
                    }
                }
            }
            catch (Exception exception)
            {
                _logger.Error(exception);
                throw;
            }
        }
Exemplo n.º 3
0
        public void Enqueue(Point[] points)
        {
            if (!points.Any())
            {
                return;
            }

            if (_timer == null)
            {
                _logger.Error(string.Format("The engine that sends data to the database is not enabled. Probably becuse the FlushSecondsInterval has not been configured. Point count: {0}.", points.Length));
                return;
            }

            if (!_timer.Enabled)
            {
                _timer.Start();
            }

            //Prepare metadata information about the queue and add that to the points to be sent.
            if (_metadata)
            {
                var metaPoints = _dataSenders.Select(x => MetaDataBusiness.GetQueueCountPoints("Enqueue", x.TargetServer, x.TargetDatabase, x.QueueCount, points.Length + _dataSenders.Count, new SendResponse(null, null))).ToArray();
                points = points.Union(metaPoints).ToArray();
            }

            foreach (var dataSender in _dataSenders)
            {
                _logger.Debug(string.Format("Enqueueing {0} points to server {1} database {2}.", points.Length, dataSender.TargetServer, dataSender.TargetDatabase));
                dataSender.Enqueue(points);
            }
        }
Exemplo n.º 4
0
        public SendBusiness(IConfigBusiness configBusiness, IQueueEvents queueEvents)
        {
            var config = configBusiness.LoadFiles();

            foreach (var databaseConfig in config.Databases)
            {
                ISenderAgent senderAgent = null;
                try
                {
                    if (databaseConfig.IsEnabled)
                    {
                        senderAgent = databaseConfig.GetSenderAgent();
                    }
                }
                catch (Exception exception)
                {
                    queueEvents.OnExceptionEvent(exception);
                }

                if (senderAgent != null)
                {
                    var queueSettings    = new QueueSettings(config.Application.FlushSecondsInterval, false, config.Application.MaxQueueSize, config.Application.Metadata);
                    var metaDataBusiness = new MetaDataBusiness();
                    _queues.Add(new Queue(senderAgent, queueEvents, metaDataBusiness, queueSettings));
                }
            }
        }
Exemplo n.º 5
0
        private void Elapsed(object sender, ElapsedEventArgs e)
        {
            var metaPoints = new List <Point>();

            foreach (var dataSender in _dataSenders)
            {
                var previousQueueCount = dataSender.QueueCount;
                var success            = dataSender.Send();
                var postQueueCount     = dataSender.QueueCount;

                if (_metadata)
                {
                    metaPoints.Add(MetaDataBusiness.GetQueueCountPoints("Send", dataSender.TargetServer, dataSender.TargetDatabase, previousQueueCount, postQueueCount - previousQueueCount + _dataSenders.Count, success));
                }
            }

            if (_metadata)
            {
                foreach (var dataSender in _dataSenders)
                {
                    dataSender.Enqueue(metaPoints.ToArray());
                }
            }
        }