Start ES embedded server before creating a client.

This resolves a startup-delay problem where Node/Transport protocols
would attempt to find a master before continuing, having no master,
After this patch:
waits for a timeout.

Manual test:
    % time bin/logstash -e 'input { generator {  count => 1 } } output { elasticsearch { embedded => true } }'

Before this patch:
    WARN: org.elasticsearch.discovery: [logstash-ds4172-27071-2010]
    waited for 30s and no initial state was set by the discovery

    bin/logstash -e   20.50s user 0.70s system 45% cpu 46.793 total

After this patch:
    bin/logstash -e   21.53s user 0.52s system 115% cpu 19.070 total
This commit is contained in:
Jordan Sissel 2014-04-14 18:26:27 +00:00
parent 8eed4a9233
commit 67a3fc0ec4

View file

@ -234,12 +234,6 @@ class LogStash::Outputs::ElasticSearch < LogStash::Outputs::Base
LogStash::Outputs::Elasticsearch::Protocols::HTTPClient
end
@client = client_class.new(options)
@logger.info("New Elasticsearch output", :cluster => @cluster,
:host => @host, :port => @port, :embedded => @embedded,
:protocol => @protocol)
if @embedded
raise(LogStash::ConfigurationError, "The 'embedded => true' setting is only valid for the elasticsearch output under JRuby. You are running #{RUBY_DESCRIPTION}") unless LogStash::Environment.jruby?
LogStash::Environment.load_elasticsearch_jars!
@ -253,6 +247,12 @@ class LogStash::Outputs::ElasticSearch < LogStash::Outputs::Base
start_local_elasticsearch
end
@client = client_class.new(options)
@logger.info("New Elasticsearch output", :cluster => @cluster,
:host => @host, :port => @port, :embedded => @embedded,
:protocol => @protocol)
if @manage_template
@logger.info("Automatic template management enabled", :manage_template => @manage_template.to_s)