Skip to content

Commit

Permalink
log about support for create_unless_exists in http protocol
Browse files Browse the repository at this point in the history
Closes elastic#78.
  • Loading branch information
talevy committed Apr 15, 2015
1 parent c1dcdb7 commit 4cdaee7
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
4 changes: 4 additions & 0 deletions lib/logstash/outputs/elasticsearch.rb
Expand Up @@ -257,6 +257,10 @@ def register
@protocol = LogStash::Environment.jruby? ? "node" : "http"
end

if @protocol == "http" && @action == "create_unless_exists"
raise(LogStash::ConfigurationError, "action => 'create_unless_exists' is not supported under the HTTP protocol");
end

if ["node", "transport"].include?(@protocol)
# Node or TransportClient; requires JRuby
raise(LogStash::PluginLoadingError, "This configuration requires JRuby. If you are not using JRuby, you must set 'protocol' to 'http'. For example: output { elasticsearch { protocol => \"http\" } }") unless LogStash::Environment.jruby?
Expand Down
17 changes: 13 additions & 4 deletions spec/outputs/elasticsearch_spec.rb
Expand Up @@ -6,11 +6,20 @@

describe "outputs/elasticsearch" do

it "should register" do
output = LogStash::Plugin.lookup("output", "elasticsearch").new("embedded" => "false", "protocol" => "transport", "manage_template" => "false")
context "registration" do

# register will try to load jars and raise if it cannot find jars
expect {output.register}.to_not raise_error
it "should register" do
output = LogStash::Plugin.lookup("output", "elasticsearch").new("embedded" => "false", "protocol" => "transport", "manage_template" => "false")

# register will try to load jars and raise if it cannot find jars
expect {output.register}.to_not raise_error
end

it "should fail to register when protocol => http, action => create_unless_exists" do
output = LogStash::Plugin.lookup("output", "elasticsearch").new("protocol" => "http", "action" => "create_unless_exists")

expect {output.register}.to raise_error
end
end

describe "ship lots of events w/ default index_type", :elasticsearch => true do
Expand Down

0 comments on commit 4cdaee7

Please sign in to comment.