internal static ElasticsearchResponse <T> WatcherAckWatchDispatch <T>(this IElasticsearchClient client, ElasticsearchPathInfo <AcknowledgeWatchRequestParameters> elasticsearchPathInfo, string watchId = null, string actionId = null, Metric metric = Metric.All)
        {
            var pathInfo = elasticsearchPathInfo.ToWatcherPathInfo(watchId, actionId, metric);

            switch (pathInfo.HttpMethod)
            {
            case PathInfoHttpMethod.PUT:
                //PUT /_watcher/watch/{watch_id}/{action_id}/_ack
                if (!pathInfo.WatchId.IsNullOrEmpty() && !pathInfo.ActionId.IsNullOrEmpty())
                {
                    return(client.WatcherAckWatch <T>(pathInfo.WatchId, pathInfo.ActionId, u => pathInfo.RequestParameters));
                }
                //PUT /_watcher/watch/{watch_id}/_ack
                if (!pathInfo.WatchId.IsNullOrEmpty())
                {
                    return(client.WatcherAckWatch <T>(pathInfo.WatchId, u => pathInfo.RequestParameters));
                }
                break;

            case PathInfoHttpMethod.POST:
                //POST /_watcher/watch/{watch_id}/{action_id}/_ack
                if (!pathInfo.WatchId.IsNullOrEmpty() && !pathInfo.ActionId.IsNullOrEmpty())
                {
                    return(client.WatcherAckWatchPost <T>(pathInfo.WatchId, pathInfo.ActionId, u => pathInfo.RequestParameters));
                }
                //POST /_watcher/watch/{watch_id}/_ack
                if (!pathInfo.WatchId.IsNullOrEmpty())
                {
                    return(client.WatcherAckWatchPost <T>(pathInfo.WatchId, u => pathInfo.RequestParameters));
                }
                break;
            }
            throw new DispatchException("Could not dispatch IElasticClient.WatcherAckWatch() into any of the following paths: \r\n - /_watcher/watch/{watch_id}/_ack\r\n - /_watcher/watch/{watch_id}/{action_id}/_ack");
        }
コード例 #2
0
 public void PrepareConfiguration(IElasticsearchClient client)
 {
     _jsonFilter = new JsonFilter {
         FlattenJson = FlattenXml, SourceKey = SourceKey, Separator = Separator
     };
     _jsonFilter.PrepareConfiguration(client);
 }
コード例 #3
0
        public static Task <ElasticsearchResponse <T> > IndicesExistsTypeAsync <T>(
            this IElasticsearchClient client, string index, string type, IndicesExistsTypeSelector requestParameters)
        {
            var selector = Obsolete.UpCastSelector <IndicesExistsTypeRequestParameters, TypeExistsRequestParameters>(requestParameters);

            return(client.IndicesExistsTypeAsync <T>(index, type, selector));
        }
コード例 #4
0
            public void SetUp()
            {
                _client = new ElasticsearchClient();
                _calls  = new List <ElasticsearchProjectionHandlerCall>();
                var handler1 = new ElasticsearchProjectionHandler(
                    typeof(MatchMessage1),
                    (client, msg, token) =>
                {
                    _calls.Add(new ElasticsearchProjectionHandlerCall(client, msg, token));
                    return(Task.FromResult(false));
                });
                var handler2 = new ElasticsearchProjectionHandler(
                    typeof(MatchMessage2),
                    (client, msg, token) =>
                {
                    _calls.Add(new ElasticsearchProjectionHandlerCall(client, msg, token));
                    return(Task.FromResult(false));
                });
                var handler3 = new ElasticsearchProjectionHandler(
                    typeof(MatchMessage1),
                    (client, msg, token) =>
                {
                    _calls.Add(new ElasticsearchProjectionHandlerCall(client, msg, token));
                    return(Task.FromResult(false));
                });
                var handler4 = new ElasticsearchProjectionHandler(
                    typeof(MatchMessage2),
                    (client, msg, token) =>
                {
                    _calls.Add(new ElasticsearchProjectionHandlerCall(client, msg, token));
                    return(Task.FromResult(false));
                });

                _sut = SutFactory(new[] { handler1, handler2, handler3, handler4 });
            }
コード例 #5
0
        public static ElasticsearchResponse <T> IndicesExistsAlias <T>(
            this IElasticsearchClient client, string index, IndicesExistsAliasSelector requestParameters)
        {
            var selector = Obsolete.UpCastSelector <IndicesExistsAliasRequestParameters, AliasExistsRequestParameters>(requestParameters);

            return(client.IndicesExistsAlias <T>(index, selector));
        }
コード例 #6
0
        public ElasticSearchClientTests()
        {
            var elasticSettingsOptionsMock = new Mock <IOptions <ElasticsearchSettings> >();

            elasticSettingsOptionsMock
            .SetupGet(m => m.Value)
            .Returns(() => new ElasticsearchSettings()
            {
                Url = "http://localhost:9200"
            });


            _elasticClientWrapperMock = new Mock <IElasticClientWrapper>();
            _searchResponseMock       = new Mock <ISearchResponse <SearchableQuestion> >();

            _searchResponseMock.Setup(x => x.Documents)
            .Returns(new List <SearchableQuestion>
            {
                new SearchableQuestion {
                    Text = Text, Id = Guid.NewGuid().ToString()
                }
            });
            _searchResponseMock.SetupGet(x => x.ApiCall.HttpStatusCode)
            .Returns((int)HttpStatusCode.OK);

            _elasticClientWrapperMock.Setup(x =>
                                            x.SearchAsync(
                                                It.IsAny <Func <SearchDescriptor <SearchableQuestion>, ISearchRequest> >()))
            .ReturnsAsync(_searchResponseMock.Object);

            _client = new ElasticsearchClient(_elasticClientWrapperMock.Object);
        }
コード例 #7
0
        public static Task <ElasticsearchResponse <DynamicDictionary> > IndicesExistsAliasAsync(
            this IElasticsearchClient client, string index, IndicesExistsAliasSelector requestParameters)
        {
            var selector = Obsolete.UpCastSelector <IndicesExistsAliasRequestParameters, AliasExistsRequestParameters>(requestParameters);

            return(client.IndicesExistsAliasAsync(index, selector));
        }
コード例 #8
0
        public static ElasticsearchResponse <DynamicDictionary> IndicesExistsType(
            this IElasticsearchClient client, string index, string type, IndicesExistsTypeSelector requestParameters)
        {
            var selector = Obsolete.UpCastSelector <IndicesExistsTypeRequestParameters, TypeExistsRequestParameters>(requestParameters);

            return(client.IndicesExistsType(index, type, selector));
        }
コード例 #9
0
        /// <summary>
        /// Projects the specified messages asynchronously.
        /// </summary>
        /// <param name="client">The Elasticsearch client used during projection.</param>
        /// <param name="messages">The messages to project.</param>
        /// <param name="cancellationToken">The cancellation token.</param>
        /// <returns>
        ///     A <see cref="Task" />.
        /// </returns>
        /// <exception cref="System.ArgumentNullException">Thrown when <paramref name="client"/> or <paramref name="messages"/> are <c>null</c>.</exception>
        public async Task ProjectAsync(IElasticsearchClient client, IEnumerable <object> messages, CancellationToken cancellationToken)
        {
            if (client == null)
            {
                throw new ArgumentNullException("client");
            }
            if (messages == null)
            {
                throw new ArgumentNullException("messages");
            }

            foreach (var message in messages)
            {
                ElasticsearchProjectionHandler[] handlers;
                if (!_handlers.TryGetValue(message.GetType(), out handlers))
                {
                    continue;
                }

                foreach (var handler in handlers)
                {
                    await handler.Handler(client, message, cancellationToken);
                }
            }
        }
        internal static ElasticsearchResponse <T> WatcherExecuteWatchDispatch <T>(this IElasticsearchClient client, ElasticsearchPathInfo <ExecuteWatchRequestParameters> elasticsearchPathInfo, object body, string watchId = null, string actionId = null, Metric metric = Metric.All)
        {
            var pathInfo = elasticsearchPathInfo.ToWatcherPathInfo(watchId, actionId, metric);

            switch (pathInfo.HttpMethod)
            {
            case PathInfoHttpMethod.PUT:
                //PUT /_watcher/watch/{id}/_execute
                if (!pathInfo.Id.IsNullOrEmpty() && body != null)
                {
                    return(client.WatcherExecuteWatch <T>(pathInfo.Id, body, u => pathInfo.RequestParameters));
                }
                //PUT /_watcher/watch/_execute
                if (body != null)
                {
                    return(client.WatcherExecuteWatch <T>(body, u => pathInfo.RequestParameters));
                }
                break;

            case PathInfoHttpMethod.POST:
                //POST /_watcher/watch/{id}/_execute
                if (!pathInfo.Id.IsNullOrEmpty() && body != null)
                {
                    return(client.WatcherExecuteWatchPost <T>(pathInfo.Id, body, u => pathInfo.RequestParameters));
                }
                //POST /_watcher/watch/_execute
                if (body != null)
                {
                    return(client.WatcherExecuteWatchPost <T>(body, u => pathInfo.RequestParameters));
                }
                break;
            }
            throw new DispatchException("Could not dispatch IElasticClient.WatcherExecuteWatch() into any of the following paths: \r\n - /_watcher/watch/{id}/_execute\r\n - /_watcher/watch/_execute");
        }
コード例 #11
0
 public void PrepareConfiguration(IElasticsearchClient client)
 {
     foreach (var filter in _filters)
     {
         ValidateFilterProperties(filter);
         filter.PrepareConfiguration(client);
     }
 }
コード例 #12
0
 public WeatherForecastController(ILogger <WeatherForecastController> logger,
                                  IElasticsearchClient elasticsearchClient,
                                  IOptions <ApplicationSettings> options)
 {
     _logger = logger;
     _elasticsearchClient = elasticsearchClient;
     _appSettings         = options.Value;
 }
コード例 #13
0
 protected TestBase(ITestOutputHelper output)
 {
     Output = output;
     Client = new ElasticsearchClient(new ElasticsearchConfigProvider(new ElasticsearchConfig
     {
         Urls = "http://10.186.132.138:9200"
     }));
 }
コード例 #14
0
		public ElasticNetConnection(
			IElasticsearchClient client, 
			Uri endpoint,
			string index = null, 
			TimeSpan? timeout = null, 
			ElasticConnectionOptions options = null)
			: base(endpoint, index, timeout, options)
		{
			this.client = client;
		}
コード例 #15
0
        protected override void InitializeTarget()
        {
            base.InitializeTarget();

            var uri = GetConnectionString(ConnectionStringName) ?? Uri;
            var nodes = uri.Split(',').Select(url => new Uri(url));
            var connectionPool = new StaticConnectionPool(nodes);
            var config = new ConnectionConfiguration(connectionPool);
            _client = new ElasticsearchClient(config, serializer:ElasticsearchSerializer);
        }
コード例 #16
0
        /// <summary>
        /// Create a new ElasticNetConnection with the given parameters defining its properties.
        /// </summary>
        /// <param name="client">The ElasticsearchClient to use in order to contact elasticsearch.</param>
        /// <param name="timeout">TimeSpan to wait for network responses before failing (optional, defaults to 10 seconds).</param>
        /// <param name="index">Name of the index to use on the server (optional).</param>
        /// <param name="options">Additional options that specify how this connection should behave.</param>
        public ElasticNetConnection(
            IElasticsearchClient client,
            string index = null,
            TimeSpan? timeout = null,
            ElasticConnectionOptions options = null)
            : base(index, timeout, options)
        {
            if (client == null) throw new ArgumentNullException("client");

            this.client = client;
        }
コード例 #17
0
        public ElasticClient(ITransport <IConnectionSettingsValues> transport)
        {
            transport.ThrowIfNull(nameof(transport));
            transport.Settings.ThrowIfNull(nameof(transport.Settings));
            transport.Settings.Serializer.ThrowIfNull(nameof(transport.Settings.Serializer));
            transport.Settings.Inferrer.ThrowIfNull(nameof(transport.Settings.Inferrer));

            this.Transport        = transport;
            this.Raw              = new ElasticsearchClient(this.Transport);
            this.LowLevelDispatch = new LowLevelDispatch(this.Raw);
        }
コード例 #18
0
 public MongoIndexingForElasticJob(
     ISearchableTextService searchableTextService,
     IElasticsearchClient elasticsearchClient,
     IApplicationPropertyDao applicationPropertyDao,
     ILogger <MongoIndexingForElasticJob> logger)
 {
     _searchableTextService  = searchableTextService;
     _elasticsearchClient    = elasticsearchClient;
     _applicationPropertyDao = applicationPropertyDao;
     _logger = logger;
 }
コード例 #19
0
ファイル: KvFilter.cs プロジェクト: cdzhoubin/log4stash
 public void PrepareConfiguration(IElasticsearchClient client)
 {
     var valueRxString = "(?:\"([^\"]+)\"" +
                  "|'([^']+)'" +
                  "|\\(([^\\)]+)\\)" +
                  "|\\[([^\\]]+)\\]" +
                  "|([^" + FieldSplit + "]+))";
     _kvRegex = new Regex(
         string.Format("([^{0}{1}]+)\\s*[{1}]\\s*{2}", FieldSplit, ValueSplit, valueRxString)
         , RegexOptions.Compiled | RegexOptions.Multiline);
 }
コード例 #20
0
 public MasterScheduler(IEventQueueOperator eventQueueOperator, 
     IConfigurationValueProvider configurationValueProvider,
     ISourceConfiguration sourceConfiguration,
     IElasticsearchClient elasticsearchClient,
     IServiceLocator locator)
 {
     _sourceConfiguration = sourceConfiguration;
     _locator = locator;
     _elasticsearchClient = elasticsearchClient;
     _configurationValueProvider = configurationValueProvider;
     _eventQueueOperator = eventQueueOperator;
  }
コード例 #21
0
 public MasterScheduler(IEventQueueOperator eventQueueOperator,
                        IConfigurationValueProvider configurationValueProvider,
                        ISourceConfiguration sourceConfiguration,
                        IElasticsearchClient elasticsearchClient,
                        IServiceLocator locator)
 {
     _sourceConfiguration        = sourceConfiguration;
     _locator                    = locator;
     _elasticsearchClient        = elasticsearchClient;
     _configurationValueProvider = configurationValueProvider;
     _eventQueueOperator         = eventQueueOperator;
 }
コード例 #22
0
ファイル: YamlTestsBase.cs プロジェクト: rodrigopalhares/NEST
 static YamlTestsBase()
 {
     var host = "localhost";
     if (Process.GetProcessesByName("fiddler").Any())
         host = "ipv4.fiddler";
     var uri = new Uri("http://"+host+":9200/");
     var settings = new ElasticsearchConnectionSettings(uri).UsePrettyResponses();
     _client = new ElasticsearchClient(settings);
     var infoResponse = _client.Info();
     dynamic info = infoResponse.Response;
     _versionNumber = new Version(info.version.number);
 }
コード例 #23
0
        public void PrepareConfiguration(IElasticsearchClient client)
        {
            var valueRxString = "(?:\"([^\"]+)\"" +
                                "|'([^']+)'" +
                                "|\\(([^\\)]+)\\)" +
                                "|\\[([^\\]]+)\\]" +
                                "|([^" + FieldSplit + "]+))";

            _kvRegex = new Regex(
                string.Format("([^{0}{1}]+)\\s*[{1}]\\s*{2}", FieldSplit, ValueSplit, valueRxString)
                , RegexOptions.Compiled | RegexOptions.Multiline);
        }
コード例 #24
0
ファイル: ConfluenceJob.cs プロジェクト: mmikirtumov/ISA
 public ConfluenceJob(IConfluenceHttpClient confluenceHttpClient,
                      IElasticsearchClient elasticsearchClient,
                      IApplicationPropertyDao applicationPropertyDao,
                      IOptions <ConfluenceSettings> settings,
                      ILogger <ConfluenceJob> logger)
 {
     _confluenceHttpClient   = confluenceHttpClient;
     _elasticsearchClient    = elasticsearchClient;
     _applicationPropertyDao = applicationPropertyDao;
     _settings = settings;
     _logger   = logger;
 }
        internal static ElasticsearchResponse <T> WatcherStopDispatch <T>(this IElasticsearchClient client, ElasticsearchPathInfo <StopWatcherRequestParameters> elasticsearchPathInfo, string watchId = null, string actionId = null, Metric metric = Metric.All)
        {
            var pathInfo = elasticsearchPathInfo.ToWatcherPathInfo(watchId, actionId, metric);

            switch (pathInfo.HttpMethod)
            {
            case PathInfoHttpMethod.PUT:
                //PUT /_watcher/_stop
                return(client.WatcherStop <T>(u => pathInfo.RequestParameters));
            }
            throw new DispatchException("Could not dispatch IElasticClient.WatcherStop() into any of the following paths: \r\n - /_watcher/_stop");
        }
コード例 #26
0
        protected override void InitializeTarget()
        {
            base.InitializeTarget();

            var uri = GetConnectionString(ConnectionStringName) ?? Uri;
            var nodes = uri.Split(',').Select(url => new Uri(url));
            var connectionPool = new StaticConnectionPool(nodes);
            var config = new ConnectionConfiguration(connectionPool);
            _client = new ElasticsearchClient(config, serializer:ElasticsearchSerializer);

            if (!String.IsNullOrEmpty(ExcludedProperties))
                _excludedProperties = new List<string>(ExcludedProperties.Split(new [] { ',' }, StringSplitOptions.RemoveEmptyEntries));
        }
コード例 #27
0
ファイル: JiraJob.cs プロジェクト: mmikirtumov/ISA
 public JiraJob(
     ILogger <JiraJob> logger,
     IElasticsearchClient elasticsearchClient,
     IApplicationPropertyDao applicationPropertyDao,
     IJiraClient jiraClient,
     IOptions <JiraSettings> settings)
 {
     _logger = logger;
     _elasticsearchClient    = elasticsearchClient;
     _applicationPropertyDao = applicationPropertyDao;
     _jiraClient             = jiraClient;
     _settings = settings;
 }
コード例 #28
0
        public override void ActivateOptions()
        {
            _client = new WebElasticClient(Server, Port);

            if (Template != null && Template.IsValid)
            {
                _client.PutTemplateRaw(Template.Name, File.ReadAllText(Template.FileName));
            }

            ElasticFilters.PrepareConfiguration(_client);

            RestartTimer();
        }
コード例 #29
0
        public override void ActivateOptions()
        {
            _client = new WebElasticClient(Server, Port, Ssl, AllowSelfSignedServerCert, BasicAuthUsername, BasicAuthPassword);

            if (Template != null && Template.IsValid)
            {
                _client.PutTemplateRaw(Template.Name, File.ReadAllText(Template.FileName));
            }

            ElasticFilters.PrepareConfiguration(_client);

            RestartTimer();
        }
コード例 #30
0
        /// <summary>
        /// Create a new ElasticNetConnection with the given parameters defining its properties.
        /// </summary>
        /// <param name="client">The ElasticsearchClient to use in order to contact elasticsearch.</param>
        /// <param name="timeout">TimeSpan to wait for network responses before failing (optional, defaults to 10 seconds).</param>
        /// <param name="index">Name of the index to use on the server (optional).</param>
        /// <param name="options">Additional options that specify how this connection should behave.</param>
        public ElasticNetConnection(
            IElasticsearchClient client,
            string index     = null,
            TimeSpan?timeout = null,
            ElasticConnectionOptions options = null)
            : base(index, timeout, options)
        {
            if (client == null)
            {
                throw new ArgumentNullException(nameof(client));
            }

            this.client = client;
        }
コード例 #31
0
        protected override void InitializeTarget()
        {
            base.InitializeTarget();

            ConnectionStringSettings connectionStringSettings = null;
            if (!string.IsNullOrEmpty(ConnectionStringName))
                connectionStringSettings = ConfigurationManager.ConnectionStrings[ConnectionStringName];

            var uri = connectionStringSettings == null ? Uri : connectionStringSettings.ConnectionString;
            var nodes = uri.Split(',').Select(url => new Uri(url));
            var connectionPool = new StaticConnectionPool(nodes);
            var config = new ConnectionConfiguration(connectionPool);
            _client = new ElasticsearchClient(config, serializer:ElasticsearchSerializer);
        }
コード例 #32
0
        /// <summary>
        /// Projects the specified message asynchronously.
        /// </summary>
        /// <param name="client">The Elasticsearch client used during projection.</param>
        /// <param name="message">The message to project.</param>
        /// <param name="cancellationToken">The cancellation token.</param>
        /// <returns>
        ///     A <see cref="Task" />.
        /// </returns>
        /// <exception cref="System.ArgumentNullException">Thrown when <paramref name="client"/> or <paramref name="message"/> is <c>null</c>.</exception>
        public async Task ProjectAsync(IElasticsearchClient client, object message, CancellationToken cancellationToken)
        {
            if (client == null) throw new ArgumentNullException("client");
            if (message == null) throw new ArgumentNullException("message");

            ElasticsearchProjectionHandler[] handlers;
            if (_handlers.TryGetValue(message.GetType(), out handlers) && handlers.Length > 0)
            {
                foreach (var handler in handlers)
                {
                    await handler.Handler(client, message, cancellationToken);
                }
            }
        }
コード例 #33
0
 public void Setup()
 {
     _elasticClientFactory = Substitute.For <IElasticClientFactory>();
     _elasticClient        = Substitute.For <IElasticsearchClient>();
     _timer = Substitute.For <IIndexingTimer>();
     _tolerateCallsFactory = Substitute.For <ITolerateCallsFactory>();
     _bulk = Substitute.For <ILogBulkSet>();
     _logEventConverterFactory = Substitute.For <ILogEventConverterFactory>();
     _logEventConverter        = Substitute.For <ILogEventConverter>();
     _elasticFilters           = new ElasticAppenderFilters();
     _fileAccessor             = Substitute.For <IFileAccessor>();
     _eventWriter = Substitute.For <IExternalEventWriter>();
     _elasticClientFactory.CreateClient(null, 0, false, false, null).ReturnsForAnyArgs(_elasticClient);
     _logEventConverterFactory.Create(FixFlags.All, false).ReturnsForAnyArgs(_logEventConverter);
 }
コード例 #34
0
        public override void ActivateOptions()
        {
            _client = new WebElasticClient(Server, Port, Ssl, AllowSelfSignedServerCert, BasicAuthUsername, BasicAuthPassword);

            LogEventFactory.Configure(this);

            if (Template != null && Template.IsValid)
            {
                _client.PutTemplateRaw(Template.Name, File.ReadAllText(Template.FileName));
            }

            ElasticFilters.PrepareConfiguration(_client);

            RestartTimer();
        }
コード例 #35
0
        protected override void InitializeTarget()
        {
            base.InitializeTarget();

            var uri            = GetConnectionString(ConnectionStringName) ?? Uri;
            var nodes          = uri.Split(',').Select(url => new Uri(url));
            var connectionPool = new StaticConnectionPool(nodes);
            var config         = new ConnectionConfiguration(connectionPool);

            _client = new ElasticsearchClient(config, serializer: ElasticsearchSerializer);

            if (!String.IsNullOrEmpty(ExcludedProperties))
            {
                _excludedProperties = new List <string>(ExcludedProperties.Split(new [] { ',' }, StringSplitOptions.RemoveEmptyEntries));
            }
        }
        internal static ElasticsearchResponse <T> WatcherDeleteWatchDispatch <T>(this IElasticsearchClient client, ElasticsearchPathInfo <DeleteWatchRequestParameters> elasticsearchPathInfo, string watchId = null, string actionId = null, Metric metric = Metric.All)
        {
            var pathInfo = elasticsearchPathInfo.ToWatcherPathInfo(watchId, actionId, metric);

            switch (pathInfo.HttpMethod)
            {
            case PathInfoHttpMethod.DELETE:
                //DELETE /_watcher/watch/{id}
                if (!pathInfo.Id.IsNullOrEmpty())
                {
                    return(client.WatcherDeleteWatch <T>(pathInfo.Id, u => pathInfo.RequestParameters));
                }
                break;
            }
            throw new DispatchException("Could not dispatch IElasticClient.WatcherDeleteWatch() into any of the following paths: \r\n - /_watcher/watch/{id}");
        }
コード例 #37
0
        public override void ActivateOptions()
        {
            _client = new WebElasticClient(Server, Port, Ssl, AllowSelfSignedServerCert, BasicAuthUsername, BasicAuthPassword, UseAWS4Signer,
                                           AWS4SignerRegion, AWS4SignerAccessKey, AWS4SignerSecretKey, ElasticSearchTimeout);

            LogEventFactory.Configure(this);

            if (Template != null && Template.IsValid)
            {
                _client.PutTemplateRaw(Template.Name, File.ReadAllText(Template.FileName));
            }

            ElasticFilters.PrepareConfiguration(_client);

            RestartTimer();
        }
コード例 #38
0
        public override void ActivateOptions()
        {
            AddOptionalServer();
            _client = new WebElasticClient(Servers, ElasticSearchTimeout, Ssl, AllowSelfSignedServerCert, AuthenticationMethod);

            LogEventFactory.Configure(this);

            if (Template != null && Template.IsValid)
            {
                _client.PutTemplateRaw(Template.Name, File.ReadAllText(Template.FileName));
            }

            ElasticFilters.PrepareConfiguration(_client);

            RestartTimer();
        }
        internal static ElasticsearchResponse <T> WatcherStatsDispatch <T>(this IElasticsearchClient client, ElasticsearchPathInfo <WatcherStatsRequestParameters> elasticsearchPathInfo, string watchId = null, string actionId = null, Metric metric = Metric.All)
        {
            var pathInfo = elasticsearchPathInfo.ToWatcherPathInfo(watchId, actionId, metric);

            switch (pathInfo.HttpMethod)
            {
            case PathInfoHttpMethod.GET:
                //GET /_watcher/stats/{metric}
                if (pathInfo.Metric != null)
                {
                    return(client.WatcherStats <T>(pathInfo.Metric, u => pathInfo.RequestParameters));
                }
                //GET /_watcher/stats
                return(client.WatcherStats <T>(u => pathInfo.RequestParameters));
            }
            throw new DispatchException("Could not dispatch IElasticClient.WatcherStats() into any of the following paths: \r\n - /_watcher/stats\r\n - /_watcher/stats/{metric}");
        }
コード例 #40
0
        protected override void InitializeTarget()
        {
            base.InitializeTarget();

            ConnectionStringSettings connectionStringSettings = null;

            if (!string.IsNullOrEmpty(ConnectionName))
            {
                connectionStringSettings = ConfigurationManager.ConnectionStrings[ConnectionName];
            }

            var nodes          = connectionStringSettings != null?connectionStringSettings.ConnectionString.Split(',').Select(url => new Uri(url)) : new[] { new Uri(string.Format("http://{0}:{1}", Host, Port)) };
            var connectionPool = new StaticConnectionPool(nodes);
            var config         = new ConnectionConfiguration(connectionPool);

            _client = new ElasticsearchClient(config, serializer: new NewtonsoftJsonSerializer());
        }
コード例 #41
0
 public ElasticsearchProjectionHandlerCall(IElasticsearchClient client, object message, CancellationToken token)
 {
     Client = client;
     Message = message;
     Token = token;
 }
コード例 #42
0
 public ElasticClient(IElasticsearchClient elasticsearchClient)
 {
     _elasticsearchClient = elasticsearchClient;
 }
コード例 #43
0
 /// <summary>
 /// Projects the specified message asynchronously.
 /// </summary>
 /// <param name="client">The Elasticsearch client used during projection.</param>
 /// <param name="message">The message to project.</param>
 /// <returns>
 ///     A <see cref="Task" />.
 /// </returns>
 /// <exception cref="System.ArgumentNullException">Thrown when <paramref name="client"/> or <paramref name="message"/> is <c>null</c>.</exception>
 public Task ProjectAsync(IElasticsearchClient client, object message)
 {
     return ProjectAsync(client, message, CancellationToken.None);
 }
コード例 #44
0
		public LowLevelDispatch(IElasticsearchClient rawElasticClient)
		{
			this._lowLevel = rawElasticClient;
		}
コード例 #45
0
 private void StartupElasticSearch(){
     var settings = new ConnectionSettings(hostElastic);
     //clientElastic = new ElasticsearchClient();            
     clientElasticNest = new ElasticClient(settings);
     clientElastic = clientElasticNest.Raw;
 }
コード例 #46
0
 /// <summary>
 /// Projects the specified messages asynchronously.
 /// </summary>
 /// <param name="client">The Elasticsearch client used during projection.</param>
 /// <param name="messages">The messages to project.</param>
 /// <returns>
 ///     A <see cref="Task" />.
 /// </returns>
 /// <exception cref="System.ArgumentNullException">Thrown when <paramref name="client"/> or <paramref name="messages"/> are <c>null</c>.</exception>
 public Task ProjectAsync(IElasticsearchClient client, IEnumerable<object> messages)
 {
     return ProjectAsync(client, messages, CancellationToken.None);
 }
コード例 #47
0
 public void SetUp()
 {
     _client = new ElasticsearchClient();
     _calls = new List<ElasticsearchProjectionHandlerCall>();
     var handler1 = new ElasticsearchProjectionHandler(
         typeof(MatchMessage1),
         (client, msg, token) =>
         {
             _calls.Add(new ElasticsearchProjectionHandlerCall(client, msg, token));
             return Task.FromResult(false);
         });
     var handler2 = new ElasticsearchProjectionHandler(
         typeof(MatchMessage2),
         (client, msg, token) =>
         {
             _calls.Add(new ElasticsearchProjectionHandlerCall(client, msg, token));
             return Task.FromResult(false);
         });
     var handler3 = new ElasticsearchProjectionHandler(
         typeof(MatchMessage1),
         (client, msg, token) =>
         {
             _calls.Add(new ElasticsearchProjectionHandlerCall(client, msg, token));
             return Task.FromResult(false);
         });
     var handler4 = new ElasticsearchProjectionHandler(
         typeof(MatchMessage2),
         (client, msg, token) =>
         {
             _calls.Add(new ElasticsearchProjectionHandlerCall(client, msg, token));
             return Task.FromResult(false);
         });
     _sut = SutFactory(new[] { handler1, handler2, handler3, handler4 });
 }
コード例 #48
0
ファイル: GrokFilter.cs プロジェクト: cdzhoubin/log4stash
 public void PrepareConfiguration(IElasticsearchClient client)
 {
 }
コード例 #49
0
        /// <summary>
        /// Projects the specified messages asynchronously.
        /// </summary>
        /// <param name="client">The Elasticsearch client used during projection.</param>
        /// <param name="messages">The messages to project.</param>
        /// <param name="cancellationToken">The cancellation token.</param>
        /// <returns>
        ///     A <see cref="Task" />.
        /// </returns>
        /// <exception cref="System.ArgumentNullException">Thrown when <paramref name="client"/> or <paramref name="messages"/> are <c>null</c>.</exception>
        public async Task ProjectAsync(IElasticsearchClient client, IEnumerable<object> messages, CancellationToken cancellationToken)
        {
            if (client == null) throw new ArgumentNullException("client");
            if (messages == null) throw new ArgumentNullException("messages");

            foreach (var message in messages)
            {
                ElasticsearchProjectionHandler[] handlers;
                if (!_handlers.TryGetValue(message.GetType(), out handlers)) 
                    continue;

                foreach (var handler in handlers)
                {
                    await handler.Handler(client, message, cancellationToken);
                }
            }
        }
コード例 #50
0
		public RawDispatch(IElasticsearchClient rawElasticClient)
		{
			this.Raw = rawElasticClient;
		}
コード例 #51
0
 public void SetUp()
 {
     _client = new ElasticsearchClient();
 }