Class: LogStash::Outputs::ElasticSearchJavaPlugins::Protocols::NodeClient
- Inherits:
-
Base
- Object
- Base
- LogStash::Outputs::ElasticSearchJavaPlugins::Protocols::NodeClient
- Defined in:
- lib/logstash/outputs/elasticsearch_java/protocol.rb
Direct Known Subclasses
Constant Summary collapse
- CLIENT_MUTEX =
Mutex.new
Class Method Summary collapse
Instance Method Summary collapse
- #bulk(actions) ⇒ Object
-
#initialize(options = {}) ⇒ NodeClient
constructor
A new instance of NodeClient.
Methods inherited from Base
Constructor Details
#initialize(options = {}) ⇒ NodeClient
Returns a new instance of NodeClient.
69 70 71 72 73 74 |
# File 'lib/logstash/outputs/elasticsearch_java/protocol.rb', line 69 def initialize(={}) super require "java" @options = DEFAULT_OPTIONS.merge() setup(@options) end |
Class Method Details
.clear_client ⇒ Object
57 58 59 60 61 |
# File 'lib/logstash/outputs/elasticsearch_java/protocol.rb', line 57 def self.clear_client() CLIENT_MUTEX.synchronize { @client = null } end |
.get_client(settings) ⇒ Object
46 47 48 49 50 51 52 53 54 55 |
# File 'lib/logstash/outputs/elasticsearch_java/protocol.rb', line 46 def self.get_client(settings) CLIENT_MUTEX.synchronize { if @client @client else nodebuilder = org.elasticsearch.node.NodeBuilder.nodeBuilder @client = nodebuilder.settings(settings.build).node().client() end } end |
Instance Method Details
#bulk(actions) ⇒ Object
151 152 153 154 155 156 157 158 159 160 |
# File 'lib/logstash/outputs/elasticsearch_java/protocol.rb', line 151 def bulk(actions) # Actions an array of [ action, action_metadata, source ] prep = client.prepareBulk actions.each do |action, args, source| prep.add(build_request(action, args, source)) end response = prep.execute.actionGet() self.class.normalize_bulk_response(response) end |