コード例 #1
0
        public async Task <ResultDetails <bool> > SendWarmerCommandAsync(Warmer warmer, string index, string type)
        {
            _traceProvider.Trace(TraceEventType.Verbose, string.Format("ElasticsearchContextWarmer: Creating Warmer {0}", warmer.Name));

            var resultDetails = new ResultDetails <bool> {
                Status = HttpStatusCode.InternalServerError
            };
            var elasticsearchUrl = CreateWarmerUriParameter(index, type, warmer.Name);
            var uri = new Uri(elasticsearchUrl);

            _traceProvider.Trace(TraceEventType.Verbose, "{1}: Request HTTP PUT uri: {0}", uri.AbsoluteUri, "ElasticsearchContextWarmer");

            var content  = new StringContent(warmer.ToString());
            var response = await _client.PutAsync(uri, content, _cancellationTokenSource.Token).ConfigureAwait(false);

            if (response.StatusCode == HttpStatusCode.OK)
            {
                resultDetails.PayloadResult = true;
                return(resultDetails);
            }

            _traceProvider.Trace(TraceEventType.Error, string.Format("ElasticsearchContextWarmer: Cound Not Execute Warmer Create  {0}", warmer.Name));
            throw new ElasticsearchCrudException(string.Format("ElasticsearchContextWarmer: Cound Not Execute Warmer Create  {0}", warmer.Name));
        }
コード例 #2
0
        public bool SendWarmerCommand(Warmer warmer, string index, string type)
        {
            var syncExecutor = new SyncExecute(_traceProvider);

            return(syncExecutor.Execute(() => SendWarmerCommandAsync(warmer, index, type)));
        }