Class: Elastomer::Client::Nodes

Inherits:
Object
  • Object
show all
Defined in:
lib/elastomer/client/nodes.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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 - Elastomer::Client used for HTTP requests to the server node_id - The node ID as a String or an Array of node IDs



25
26
27
28
# File 'lib/elastomer/client/nodes.rb', line 25

def initialize( client, node_id )
  @client  = client
  @node_id = node_id
end

Instance Attribute Details

#clientObject (readonly)

Returns the value of attribute client.



30
31
32
# File 'lib/elastomer/client/nodes.rb', line 30

def client
  @client
end

#node_idObject (readonly)

Returns the value of attribute node_id.



30
31
32
# File 'lib/elastomer/client/nodes.rb', line 30

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



89
90
91
92
# File 'lib/elastomer/client/nodes.rb', line 89

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 ndoes. 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



51
52
53
54
# File 'lib/elastomer/client/nodes.rb', line 51

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



71
72
73
74
# File 'lib/elastomer/client/nodes.rb', line 71

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.



101
102
103
104
105
# File 'lib/elastomer/client/nodes.rb', line 101

def update_params( params, overrides = nil )
  h = { :node_id => node_id }.update params
  h.update overrides unless overrides.nil?
  h
end