Merge pull request #1263 from elasticsearch/bug/fix-es-embedded-startup-delay

Start ES embedded server before creating a client.
This commit is contained in:
Jordan Sissel 2014-04-16 21:40:15 -07:00
commit 066a3b7e1c

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)
@ -303,6 +303,7 @@ class LogStash::Outputs::ElasticSearch < LogStash::Outputs::Base
#builder.local(true)
builder.settings.put("cluster.name", @cluster) if @cluster
builder.settings.put("node.name", @node_name) if @node_name
builder.settings.put("network.host", @bind_host) if @bind_host
builder.settings.put("http.port", @embedded_http_port)
@embedded_elasticsearch = builder.node