public ElasticSearchAppender()
        {
            FixedFields      = FixFlags.Partial;
            SerializeObjects = true;

            BulkSize                = 2000;
            BulkIdleTimeout         = 5000;
            DropEventsOverBulkLimit = false;
            TimeoutToWaitForTimer   = 5000;

            _tolerateCalls = new TolerateCallsBase();

            Servers = new ServerDataCollection();
            ElasticSearchTimeout = 10000;
            //DatePostfixFormat = "yyyy.MM.dd";
            IndexName       = $"LogEvent-{DatePostfixFormat}";
            IndexType       = "LogEvent";
            IndexAsync      = true;
            Template        = null;
            LogEventFactory = new BasicLogEventFactory();

            _timer         = new Timer(TimerElapsed, null, Timeout.Infinite, Timeout.Infinite);
            ElasticFilters = new ElasticAppenderFilters();

            AllowSelfSignedServerCert = false;
            Ssl = false;
            AuthenticationMethod = new AuthenticationMethodChooser();
            IndexOperationParams = new IndexOperationParamsDictionary();
        }
Esempio n. 2
0
        public ElasticSearchAppender(IElasticClientFactory clientFactory, LogEventSmartFormatter indexName,
                                     LogEventSmartFormatter indexType, IIndexingTimer timer, ITolerateCallsFactory tolerateCallsFactory,
                                     ILogBulkSet bulk, ILogEventConverterFactory logEventConverterFactory, ElasticAppenderFilters elasticFilters,
                                     IFileAccessor fileAccessor, IExternalEventWriter eventWriter)
        {
            _logEventConverterFactory = logEventConverterFactory;
            _elasticClientFactory     = clientFactory;
            IndexName             = indexName;
            IndexType             = indexType;
            _timer                = timer;
            _timer.Elapsed       += (o, e) => DoIndexNow();
            _tolerateCallsFactory = tolerateCallsFactory;
            _bulk         = bulk;
            _fileAccessor = fileAccessor;
            _eventWriter  = eventWriter;

            FixedFields               = FixFlags.Partial;
            SerializeObjects          = true;
            BulkSize                  = 2000;
            BulkIdleTimeout           = 5000;
            DropEventsOverBulkLimit   = false;
            TotalDropEventLimit       = null;
            TimeoutToWaitForTimer     = 5000;
            ElasticSearchTimeout      = 10000;
            IndexAsync                = true;
            Template                  = null;
            AllowSelfSignedServerCert = false;
            Ssl                  = false;
            _tolerateCalls       = _tolerateCallsFactory.Create(0);
            Servers              = new ServerDataCollection();
            ElasticFilters       = elasticFilters;
            AuthenticationMethod = new AuthenticationMethodChooser();
            IndexOperationParams = new IndexOperationParamsDictionary();
        }
Esempio n. 3
0
        private void Checker(TolerateCallsBase tolerator, bool shouldTolerate)
        {
            var t    = GetType();
            var mock = new FuncMock();

            Parallel.For(0, 100, i => tolerator.Call(mock.Inc, t, 0));
            Assert.AreEqual(shouldTolerate ? 1 : 100, mock.Times);

            Parallel.For(0, 100, i => tolerator.Call(mock.Inc, t, 1));
            Assert.AreEqual(shouldTolerate ? 2 : 200, mock.Times);

            Thread.Sleep(TimeSpan.FromSeconds(TimeSec));

            Parallel.For(0, 100, i => tolerator.Call(mock.Inc, t, 0));
            Parallel.For(0, 100, i => tolerator.Call(mock.Inc, t, 1));

            Assert.AreEqual(shouldTolerate ? 4 : 400, mock.Times);
        }