Class: ElastomerClient::Client::Nodes
- Inherits:
-
Object
- Object
- ElastomerClient::Client::Nodes
- Defined in:
- lib/elastomer_client/client/nodes.rb
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
-
#node_id ⇒ Object
readonly
Returns the value of attribute node_id.
Instance Method Summary collapse
-
#hot_threads(params = {}) ⇒ Object
Get the current hot threads on each node in the cluster.
-
#info(params = {}) ⇒ Object
Retrieve one or more (or all) of the cluster nodes information.
-
#initialize(client, node_id) ⇒ Nodes
constructor
Create a new nodes client for making API requests that pertain to the health and management individual nodes.
-
#stats(params = {}) ⇒ Object
Retrieve one or more (or all) of the cluster nodes statistics.
-
#update_params(params, overrides = nil) ⇒ Object
Internal: Add default parameters to the ‘params` Hash and then apply `overrides` to the params if any are given.
Constructor Details
#initialize(client, node_id) ⇒ Nodes
Create a new nodes client for making API requests that pertain to the health and management individual nodes.
client - ElastomerClient::Client used for HTTP requests to the server node_id - The node ID as a String or an Array of node IDs
26 27 28 29 |
# File 'lib/elastomer_client/client/nodes.rb', line 26 def initialize(client, node_id) @client = client @node_id = node_id end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
31 32 33 |
# File 'lib/elastomer_client/client/nodes.rb', line 31 def client @client end |
#node_id ⇒ Object (readonly)
Returns the value of attribute node_id.
31 32 33 |
# File 'lib/elastomer_client/client/nodes.rb', line 31 def node_id @node_id end |
Instance Method Details
#hot_threads(params = {}) ⇒ Object
Get the current hot threads on each node in the cluster. The return value is a human formatted String - i.e. a String with newlines and other formatting characters suitable for display in a terminal window.
params - Parameters Hash
:node_id - a single node ID or Array of node IDs
:threads - number of hot threads to provide
:interval - sampling interval [default is 500ms]
:type - the type to sample: "cpu", "wait", or "block"
See www.elastic.co/guide/en/elasticsearch/reference/current/cluster-nodes-hot-threads.html
Returns the response as a String
90 91 92 93 |
# File 'lib/elastomer_client/client/nodes.rb', line 90 def hot_threads(params = {}) response = client.get "/_nodes{/node_id}/hot_threads", update_params(params, action: "nodes.hot_threads", rest_api: "nodes.hot_threads") response.body end |
#info(params = {}) ⇒ Object
Retrieve one or more (or all) of the cluster nodes information. By default all information is returned from all nodes. You can select the information to be returned by passing in the ‘:info` from the list of “settings”, “os”, “process”, “jvm”, “thread_pool”, “network”, “transport”, “http” and “plugins”.
params - Parameters Hash
:node_id - a single node ID or Array of node IDs
:info - a single information attribute or an Array
Examples
info(info: "_all")
info(info: "os")
info(info: %w[os jvm process])
See www.elastic.co/guide/en/elasticsearch/reference/current/cluster-nodes-info.html
Returns the response as a Hash
52 53 54 55 |
# File 'lib/elastomer_client/client/nodes.rb', line 52 def info(params = {}) response = client.get "/_nodes{/node_id}{/info}", update_params(params, action: "nodes.info", rest_api: "nodes.info") response.body end |
#stats(params = {}) ⇒ Object
Retrieve one or more (or all) of the cluster nodes statistics. For 1.x stats filtering, use the :stats parameter key.
params - Parameters Hash
:node_id - a single node ID or Array of node IDs
:stats - a single stats value or an Array of stats values
Examples
stats(stats: "thread_pool")
stats(stats: %w[os process])
See www.elastic.co/guide/en/elasticsearch/reference/current/cluster-nodes-stats.html
Returns the response as a Hash
72 73 74 75 |
# File 'lib/elastomer_client/client/nodes.rb', line 72 def stats(params = {}) response = client.get "/_nodes{/node_id}/stats{/stats}", update_params(params, action: "nodes.stats", rest_api: "nodes.stats") response.body end |
#update_params(params, overrides = nil) ⇒ Object
Internal: Add default parameters to the ‘params` Hash and then apply `overrides` to the params if any are given.
params - Parameters Hash overrides - Optional parameter overrides as a Hash
Returns a new params Hash.
102 103 104 105 106 |
# File 'lib/elastomer_client/client/nodes.rb', line 102 def update_params(params, overrides = nil) h = { node_id: }.update params h.update overrides unless overrides.nil? h end |