Esempio n. 1
0
        public async Task <ResultDetails <bool> > SendWarmerCommandAsync(Warmer warmer, string index, string type)
        {
            _traceProvider.Trace(TraceEventType.Verbose,
                                 string.Format("ElasticContextWarmer: Creating Warmer {0}", warmer.Name));

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

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

            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("ElasticContextWarmer: Cound Not Execute Warmer Create  {0}", warmer.Name));
            throw new ElasticException(string.Format("ElasticContextWarmer: Cound Not Execute Warmer Create  {0}",
                                                     warmer.Name));
        }
Esempio n. 2
0
        public bool SendWarmerCommand(Warmer warmer, string index, string type)
        {
            var syncExecutor = new SyncExecute(_traceProvider);

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